Fixed per-class thread safety

This commit is contained in:
Lynix 2012-05-08 08:20:57 +02:00
parent 45f3fc4e28
commit e91cde657b
44 changed files with 90 additions and 145 deletions

View File

@ -7,10 +7,10 @@
#ifndef NAZARA_BYTEARRAY_HPP #ifndef NAZARA_BYTEARRAY_HPP
#define NAZARA_BYTEARRAY_HPP #define NAZARA_BYTEARRAY_HPP
#define NAZARA_BYTEARRAY
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Hashable.hpp> #include <Nazara/Core/Hashable.hpp>
#define NAZARA_CLASS_BYTEARRAY
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
class NzAbstractHash; class NzAbstractHash;
@ -119,6 +119,6 @@ namespace std
NAZARA_API void swap(NzByteArray& lhs, NzByteArray& rhs); NAZARA_API void swap(NzByteArray& lhs, NzByteArray& rhs);
} }
#undef NAZARA_BYTEARRAY #undef NAZARA_CLASS_BYTEARRAY
#endif // NAZARA_BYTEARRAY_HPP #endif // NAZARA_BYTEARRAY_HPP

View File

@ -7,9 +7,9 @@
#ifndef NAZARA_CLOCK_HPP #ifndef NAZARA_CLOCK_HPP
#define NAZARA_CLOCK_HPP #define NAZARA_CLOCK_HPP
#define NAZARA_CLOCK
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#define NAZARA_CLASS_CLOCK
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
class NAZARA_API NzClock class NAZARA_API NzClock
@ -40,6 +40,6 @@ typedef nzUInt64 (*NzClockFunction)();
extern NAZARA_API NzClockFunction NzGetMicroseconds; extern NAZARA_API NzClockFunction NzGetMicroseconds;
extern NAZARA_API NzClockFunction NzGetMilliseconds; extern NAZARA_API NzClockFunction NzGetMilliseconds;
#undef NAZARA_CLOCK #undef NAZARA_CLASS_CLOCK
#endif // NAZARA_CLOCK_HPP #endif // NAZARA_CLOCK_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP #ifndef NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
#define NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP #define NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
#define NAZARA_DEBUG_MEMORYLEAKTRACKER
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
@ -34,6 +32,4 @@ NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int
NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) throw(); NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) throw();
NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) throw(); NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) throw();
#undef NAZARA_DEBUG_MEMORYLEAKTRACKER
#endif // NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP #endif // NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP

View File

@ -7,11 +7,8 @@
#ifndef NAZARA_DIRECTORY_HPP #ifndef NAZARA_DIRECTORY_HPP
#define NAZARA_DIRECTORY_HPP #define NAZARA_DIRECTORY_HPP
#define NAZARA_DIRECTORY
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS) #if defined(NAZARA_PLATFORM_WINDOWS)
#define NAZARA_DIRECTORY_SEPARATOR '\\' #define NAZARA_DIRECTORY_SEPARATOR '\\'
@ -22,6 +19,9 @@
#define NAZARA_DIRECTORY_SEPARATOR '/' #define NAZARA_DIRECTORY_SEPARATOR '/'
#endif #endif
#define NAZARA_CLASS_DIRECTORY
#include <Nazara/Core/ThreadSafety.hpp>
class NzDirectoryImpl; class NzDirectoryImpl;
class NAZARA_API NzDirectory class NAZARA_API NzDirectory
@ -59,6 +59,6 @@ class NAZARA_API NzDirectory
NzDirectoryImpl* m_impl; NzDirectoryImpl* m_impl;
}; };
#undef NAZARA_DIRECTORY #undef NAZARA_CLASS_DIRECTORY
#endif // NAZARA_DIRECTORY_HPP #endif // NAZARA_DIRECTORY_HPP

View File

@ -7,13 +7,13 @@
#ifndef NAZARA_DYNLIB_HPP #ifndef NAZARA_DYNLIB_HPP
#define NAZARA_DYNLIB_HPP #define NAZARA_DYNLIB_HPP
#define NAZARA_DYNLIB
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Utility/NonCopyable.hpp> #include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_DYNLIB
#include <Nazara/Core/ThreadSafety.hpp>
class NzDynLibImpl; class NzDynLibImpl;
typedef int (*NzDynLibFunc)(); // Type "générique" de pointeur sur fonction typedef int (*NzDynLibFunc)(); // Type "générique" de pointeur sur fonction

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_ENDIANNESS_HPP #ifndef NAZARA_ENDIANNESS_HPP
#define NAZARA_ENDIANNESS_HPP #define NAZARA_ENDIANNESS_HPP
#define NAZARA_ENDIANNESS
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#if defined(NAZARA_ENDIANNESS_BIGENDIAN) #if defined(NAZARA_ENDIANNESS_BIGENDIAN)
@ -45,6 +43,4 @@ inline nzEndianness NzGetPlatformEndianness();
#include <Nazara/Core/Endianness.inl> #include <Nazara/Core/Endianness.inl>
#undef NAZARA_ENDIANNESS
#endif // NAZARA_ENDIANNESS_HPP #endif // NAZARA_ENDIANNESS_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_ERROR_HPP #ifndef NAZARA_ERROR_HPP
#define NAZARA_ERROR_HPP #define NAZARA_ERROR_HPP
#define NAZARA_ERROR
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
@ -34,6 +32,4 @@ NAZARA_API void NzError(nzErrorType type, const NzString& error, unsigned int li
NAZARA_API unsigned int NzGetLastSystemErrorCode(); NAZARA_API unsigned int NzGetLastSystemErrorCode();
NAZARA_API NzString NzGetLastSystemError(unsigned int code = NzGetLastSystemErrorCode()); NAZARA_API NzString NzGetLastSystemError(unsigned int code = NzGetLastSystemErrorCode());
#undef NAZARA_ERROR
#endif // NAZARA_ERROR_HPP #endif // NAZARA_ERROR_HPP

View File

@ -7,17 +7,17 @@
#ifndef NAZARA_FILE_HPP #ifndef NAZARA_FILE_HPP
#define NAZARA_FILE_HPP #define NAZARA_FILE_HPP
#define NAZARA_FILE
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Directory.hpp> #include <Nazara/Core/Directory.hpp>
#include <Nazara/Core/Endianness.hpp> #include <Nazara/Core/Endianness.hpp>
#include <Nazara/Core/Hashable.hpp> #include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/HashDigest.hpp> #include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Utility/NonCopyable.hpp> #include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_CLASS_FILE
#include <Nazara/Core/ThreadSafety.hpp>
class NzFileImpl; class NzFileImpl;
class NAZARA_API NzFile : public NzHashable, NzNonCopyable class NAZARA_API NzFile : public NzHashable, NzNonCopyable
@ -115,6 +115,6 @@ class NAZARA_API NzFile : public NzHashable, NzNonCopyable
unsigned int m_openMode; unsigned int m_openMode;
}; };
#undef NAZARA_FILE #undef NAZARA_CLASS_FILE
#endif // NAZARA_FILE_HPP #endif // NAZARA_FILE_HPP

View File

@ -7,12 +7,8 @@
#ifndef NAZARA_FORMAT_HPP #ifndef NAZARA_FORMAT_HPP
#define NAZARA_FORMAT_HPP #define NAZARA_FORMAT_HPP
#define NAZARA_FORMAT
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
template<typename... Args> NzString NzFormat(const NzString& str, Args... args); template<typename... Args> NzString NzFormat(const NzString& str, Args... args);
#undef NAZARA_FORMAT
#endif // NAZARA_FORMAT_HPP #endif // NAZARA_FORMAT_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_HPP #ifndef NAZARA_HASH_HPP
#define NAZARA_HASH_HPP #define NAZARA_HASH_HPP
#define NAZARA_HASH
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Hashable.hpp> #include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/HashDigest.hpp> #include <Nazara/Core/HashDigest.hpp>
@ -28,6 +26,4 @@ class NAZARA_API NzHash : NzNonCopyable
NzHashImpl* m_impl; NzHashImpl* m_impl;
}; };
#undef NAZARA_HASH
#endif // NAZARA_HASH_HPP #endif // NAZARA_HASH_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_CRC32_HPP #ifndef NAZARA_HASH_CRC32_HPP
#define NAZARA_HASH_CRC32_HPP #define NAZARA_HASH_CRC32_HPP
#define NAZARA_HASH_CRC32
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp> #include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp> #include <Nazara/Core/HashImpl.hpp>
@ -32,6 +30,4 @@ class NAZARA_API NzHashCRC32 : public NzHashImpl
NzHashCRC32_state* m_state; NzHashCRC32_state* m_state;
}; };
#undef NAZARA_HASH_CRC32
#endif // NAZARA_HASH_CRC32_HPP #endif // NAZARA_HASH_CRC32_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_FLETCHER16_HPP #ifndef NAZARA_HASH_FLETCHER16_HPP
#define NAZARA_HASH_FLETCHER16_HPP #define NAZARA_HASH_FLETCHER16_HPP
#define NAZARA_HASH_FLETCHER16
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp> #include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp> #include <Nazara/Core/HashImpl.hpp>
@ -33,6 +31,4 @@ class NAZARA_API NzHashFletcher16 : public NzHashImpl
NzHashFletcher16_state* m_state; NzHashFletcher16_state* m_state;
}; };
#undef NAZARA_HASH_FLETCHER16
#endif // NAZARA_HASH_FLETCHER16_HPP #endif // NAZARA_HASH_FLETCHER16_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_MD5_HPP #ifndef NAZARA_HASH_MD5_HPP
#define NAZARA_HASH_MD5_HPP #define NAZARA_HASH_MD5_HPP
#define NAZARA_HASH_MD5
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp> #include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp> #include <Nazara/Core/HashImpl.hpp>
@ -32,6 +30,4 @@ class NAZARA_API NzHashMD5 : public NzHashImpl
NzHashMD5_state* m_state; NzHashMD5_state* m_state;
}; };
#undef NAZARA_HASH_MD5
#endif // NAZARA_HASH_MD5_HPP #endif // NAZARA_HASH_MD5_HPP

View File

@ -5,8 +5,6 @@
#ifndef NAZARA_HASH_WHIRLPOOL_HPP #ifndef NAZARA_HASH_WHIRLPOOL_HPP
#define NAZARA_HASH_WHIRLPOOL_HPP #define NAZARA_HASH_WHIRLPOOL_HPP
#define NAZARA_HASH_WHIRLPOOL
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp> #include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp> #include <Nazara/Core/HashImpl.hpp>
@ -30,6 +28,4 @@ class NAZARA_API NzHashWhirlpool : public NzHashImpl
NzHashWhirlpool_state* m_state; NzHashWhirlpool_state* m_state;
}; };
#undef NAZARA_HASH_WHIRLPOOL
#endif // NAZARA_HASH_WHIRLPOOL_HPP #endif // NAZARA_HASH_WHIRLPOOL_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_HASHDIGEST_HPP #ifndef NAZARA_HASHDIGEST_HPP
#define NAZARA_HASHDIGEST_HPP #define NAZARA_HASHDIGEST_HPP
#define NAZARA_HASHDIGEST
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <ostream> #include <ostream>
@ -50,6 +48,4 @@ class NAZARA_API NzHashDigest
unsigned short m_digestLength; unsigned short m_digestLength;
}; };
#undef NAZARA_HASHDIGEST
#endif // NAZARA_HASHDIGEST_HPP #endif // NAZARA_HASHDIGEST_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_HASHIMPL_HPP #ifndef NAZARA_HASHIMPL_HPP
#define NAZARA_HASHIMPL_HPP #define NAZARA_HASHIMPL_HPP
#define NAZARA_HASHIMPL
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp> #include <Nazara/Utility/NonCopyable.hpp>
@ -25,6 +23,4 @@ class NAZARA_API NzHashImpl : NzNonCopyable
virtual NzHashDigest End() = 0; virtual NzHashDigest End() = 0;
}; };
#undef NAZARA_HASHIMPL
#endif // NAZARA_HASHIMPL_HPP #endif // NAZARA_HASHIMPL_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_LOCK_HPP #ifndef NAZARA_LOCK_HPP
#define NAZARA_LOCK_HPP #define NAZARA_LOCK_HPP
#define NAZARA_LOCK
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
class NzMutex; class NzMutex;
@ -23,6 +21,4 @@ class NAZARA_API NzLock
NzMutex& m_mutex; NzMutex& m_mutex;
}; };
#undef NAZARA_LOCK
#endif // NAZARA_LOCK_HPP #endif // NAZARA_LOCK_HPP

View File

@ -7,14 +7,14 @@
#ifndef NAZARA_LOG_HPP #ifndef NAZARA_LOG_HPP
#define NAZARA_LOG_HPP #define NAZARA_LOG_HPP
#define NAZARA_LOG
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Utility/NonCopyable.hpp> #include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_CLASS_LOG
#include <Nazara/Core/ThreadSafety.hpp>
#define NazaraLog NzLog::Instance() #define NazaraLog NzLog::Instance()
class NzFile; class NzFile;
@ -50,6 +50,6 @@ class NAZARA_API NzLog : NzNonCopyable
bool m_writeTime; bool m_writeTime;
}; };
#undef NAZARA_LOGGER #undef NAZARA_CLASS_LOG
#endif // NAZARA_LOGGER_HPP #endif // NAZARA_LOGGER_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_MUTEX_HPP #ifndef NAZARA_MUTEX_HPP
#define NAZARA_MUTEX_HPP #define NAZARA_MUTEX_HPP
#define NAZARA_MUTEX
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp> #include <Nazara/Utility/NonCopyable.hpp>
@ -31,6 +29,4 @@ class NAZARA_API NzMutex : NzNonCopyable
NzMutexImpl* m_impl; NzMutexImpl* m_impl;
}; };
#undef NAZARA_MUTEX
#endif // NAZARA_MUTEX_HPP #endif // NAZARA_MUTEX_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_SEMAPHORE_HPP #ifndef NAZARA_SEMAPHORE_HPP
#define NAZARA_SEMAPHORE_HPP #define NAZARA_SEMAPHORE_HPP
#define NAZARA_SEMAPHORE
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp> #include <Nazara/Utility/NonCopyable.hpp>
@ -29,6 +27,4 @@ class NAZARA_API NzSemaphore : NzNonCopyable
NzSemaphoreImpl* m_impl; NzSemaphoreImpl* m_impl;
}; };
#undef NAZARA_SEMAPHORE
#endif // NAZARA_SEMAPHORE_HPP #endif // NAZARA_SEMAPHORE_HPP

View File

@ -7,16 +7,16 @@
#ifndef NAZARA_STRING_HPP #ifndef NAZARA_STRING_HPP
#define NAZARA_STRING_HPP #define NAZARA_STRING_HPP
#define NAZARA_STRING
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Hashable.hpp> #include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <istream> #include <istream>
#include <ostream> #include <ostream>
#include <string> #include <string>
#include <vector> #include <vector>
#define NAZARA_CLASS_STRING
#include <Nazara/Core/ThreadSafety.hpp>
class NzAbstractHash; class NzAbstractHash;
class NzHashDigest; class NzHashDigest;
@ -317,7 +317,6 @@ namespace std
NAZARA_API void swap(NzString& lhs, NzString& rhs); NAZARA_API void swap(NzString& lhs, NzString& rhs);
} }
#undef NAZARA_STRING #undef NAZARA_CLASS_STRING
#endif // NAZARA_STRING_HPP #endif // NAZARA_STRING_HPP

View File

@ -7,14 +7,14 @@
#ifndef NAZARA_STRINGSTREAM_HPP #ifndef NAZARA_STRINGSTREAM_HPP
#define NAZARA_STRINGSTREAM_HPP #define NAZARA_STRINGSTREAM_HPP
#define NAZARA_STRINGSTREAM
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
#define NAZARA_CLASS_STRINGSTREAM
#include <Nazara/Core/ThreadSafety.hpp>
class NAZARA_API NzStringStream class NAZARA_API NzStringStream
{ {
public: public:
@ -51,6 +51,6 @@ class NAZARA_API NzStringStream
unsigned int m_bufferSize; unsigned int m_bufferSize;
}; };
#undef NAZARA_STRINGSTREAM #undef NAZARA_CLASS_STRINGSTREAM
#endif // NAZARA_STRINGSTREAM_HPP #endif // NAZARA_STRINGSTREAM_HPP

View File

@ -9,8 +9,6 @@
#ifndef NAZARA_THREAD_HPP #ifndef NAZARA_THREAD_HPP
#define NAZARA_THREAD_HPP #define NAZARA_THREAD_HPP
#define NAZARA_THREAD
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Functor.hpp> #include <Nazara/Utility/Functor.hpp>
#include <Nazara/Utility/NonCopyable.hpp> #include <Nazara/Utility/NonCopyable.hpp>
@ -64,6 +62,4 @@ class NAZARA_API NzThread : NzNonCopyable
#include <Nazara/Core/Thread.inl> #include <Nazara/Core/Thread.inl>
#undef NAZARA_THREAD
#endif // NAZARA_THREAD_HPP #endif // NAZARA_THREAD_HPP

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_THREADCONDITION_HPP #ifndef NAZARA_THREADCONDITION_HPP
#define NAZARA_THREADCONDITION_HPP #define NAZARA_THREADCONDITION_HPP
#define NAZARA_THREADCONDITION
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
class NzMutex; class NzMutex;
@ -30,6 +28,4 @@ class NAZARA_API NzThreadCondition
NzThreadConditionImpl* m_impl; NzThreadConditionImpl* m_impl;
}; };
#undef NAZARA_THREADCONDITION
#endif // NAZARA_THREADCONDITION_HPP #endif // NAZARA_THREADCONDITION_HPP

View File

@ -15,15 +15,14 @@
#undef NazaraNamedLock #undef NazaraNamedLock
#if NAZARA_CORE_THREADSAFE && (\ #if NAZARA_CORE_THREADSAFE && (\
(NAZARA_THREADSAFETY_BYTEARRAY && (defined(NAZARA_BYTEARRAY) || defined(NAZARA_BYTEARRAY_CPP))) || \ (NAZARA_THREADSAFETY_BYTEARRAY && defined(NAZARA_CLASS_BYTEARRAY)) || \
(NAZARA_THREADSAFETY_CLOCK && (defined(NAZARA_CLOCK) || defined(NAZARA_CLOCK_CPP))) || \ (NAZARA_THREADSAFETY_CLOCK && defined(NAZARA_CLASS_CLOCK)) || \
(NAZARA_THREADSAFETY_DIRECTORY && (defined(NAZARA_DIRECTORY) || defined(NAZARA_DIRECTORY_CPP))) || \ (NAZARA_THREADSAFETY_DIRECTORY && defined(NAZARA_CLASS_DIRECTORY)) || \
(NAZARA_THREADSAFETY_DYNLIB && (defined(NAZARA_DYNLIB) || defined(NAZARA_DYNLIB_CPP))) || \ (NAZARA_THREADSAFETY_DYNLIB && defined(NAZARA_CLASS_DYNLIB)) || \
(NAZARA_THREADSAFETY_FILE && (defined(NAZARA_FILE) || defined(NAZARA_FILE_CPP))) || \ (NAZARA_THREADSAFETY_FILE && defined(NAZARA_CLASS_FILE)) || \
(NAZARA_THREADSAFETY_HASHDIGEST && (defined(NAZARA_HASHDIGEST) || defined(NAZARA_HASHDIGEST_CPP))) || \ (NAZARA_THREADSAFETY_LOG && defined(NAZARA_CLASS_LOG)) || \
(NAZARA_THREADSAFETY_LOG && (defined(NAZARA_LOG) || defined(NAZARA_LOG_CPP))) || \ (NAZARA_THREADSAFETY_STRING && defined(NAZARA_CLASS_STRING)) || \
(NAZARA_THREADSAFETY_STRING && (defined(NAZARA_STRING) || defined(NAZARA_STRING_CPP))) || \ (NAZARA_THREADSAFETY_STRINGSTREAM && defined(NAZARA_CLASS_STRINGSTREAM)))
(NAZARA_THREADSAFETY_STRINGSTREAM && (defined(NAZARA_STRINGSTREAM) || defined(NAZARA_STRINGSTREAM_CPP))))
#include <Nazara/Core/Lock.hpp> #include <Nazara/Core/Lock.hpp>
#include <Nazara/Core/Mutex.hpp> #include <Nazara/Core/Mutex.hpp>

View File

@ -7,8 +7,6 @@
#ifndef NAZARA_UNICODE_HPP #ifndef NAZARA_UNICODE_HPP
#define NAZARA_UNICODE_HPP #define NAZARA_UNICODE_HPP
#define NAZARA_UNICODE
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
namespace NzUnicode namespace NzUnicode
@ -105,6 +103,4 @@ namespace NzUnicode
char32_t GetUppercase(char32_t character); char32_t GetUppercase(char32_t character);
} }
#undef NAZARA_UNICODE
#endif // NAZARA_UNICODE_HPP #endif // NAZARA_UNICODE_HPP

View File

@ -9,6 +9,9 @@
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#define NAZARA_CLASS_MATRIX4
#include <Nazara/Math/ThreadSafety.hpp>
template<typename T> class NzEulerAngles; template<typename T> class NzEulerAngles;
template<typename T> class NzQuaternion; template<typename T> class NzQuaternion;
template<typename T> class NzVector2; template<typename T> class NzVector2;
@ -51,6 +54,7 @@ template<typename T> class NzMatrix4
template<typename U> void Set(const NzMatrix4<U>& matrix); template<typename U> void Set(const NzMatrix4<U>& matrix);
void SetIdentity(); void SetIdentity();
void SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up); void SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up);
void SetOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
void SetPerspective(T angle, T ratio, T zNear, T zFar); void SetPerspective(T angle, T ratio, T zNear, T zFar);
void SetRotation(const NzQuaternion<T>& rotation); void SetRotation(const NzQuaternion<T>& rotation);
void SetScale(const NzVector3<T>& scale); void SetScale(const NzVector3<T>& scale);
@ -84,6 +88,7 @@ template<typename T> class NzMatrix4
NzMatrix4& operator*=(T scalar); NzMatrix4& operator*=(T scalar);
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up); static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up);
static NzMatrix4 Ortho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar); static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar);
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation); static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
static NzMatrix4 Scale(const NzVector3<T>& scale); static NzMatrix4 Scale(const NzVector3<T>& scale);
@ -96,10 +101,10 @@ template<typename T> class NzMatrix4
{ {
} }
T m11, m12, m13, m14, T m11, m12, m13, m14;
m21, m22, m23, m24, T m21, m22, m23, m24;
m31, m32, m33, m34, T m31, m32, m33, m34;
m41, m42, m43, m44; T m41, m42, m43, m44;
unsigned int refCount; unsigned int refCount;
@ -118,6 +123,8 @@ template<typename T> std::ostream& operator<<(std::ostream& out, const NzMatrix4
typedef NzMatrix4<double> NzMatrix4d; typedef NzMatrix4<double> NzMatrix4d;
typedef NzMatrix4<float> NzMatrix4f; typedef NzMatrix4<float> NzMatrix4f;
#undef NAZARA_CLASS_MATRIX4
#include <Nazara/Math/Matrix4.inl> #include <Nazara/Math/Matrix4.inl>
#endif // NAZARA_MATRIX4_HPP #endif // NAZARA_MATRIX4_HPP

View File

@ -14,6 +14,9 @@
#include <cstring> #include <cstring>
#include <limits> #include <limits>
#include <stdexcept> #include <stdexcept>
#define NAZARA_CLASS_MATRIX4
#include <Nazara/Math/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>
template<typename T> template<typename T>
@ -289,6 +292,22 @@ void NzMatrix4<T>::SetIdentity()
0.0, 0.0, 0.0, 1.0); 0.0, 0.0, 0.0, 1.0);
} }
template<typename T>
void NzMatrix4<T>::SetOrtho(T left, T top, T width, T height, T zNear, T zFar)
{
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
Set(2.0/(width-left), 0.0, 0.0, -(width+left)/(width-left),
0.0, 2.0/(top-height), 0.0, -(top+height)/(top-height),
0.0, 0.0, -2.0/(zFar-zNear), -(zFar+zNear)/(zFar-zNear),
0.0, 0.0, 0.0, 1.0);
#else
Set(2.0/(width-left), 0.0, 0.0, 0.0,
0.0, 2.0/(top-height), 0.0, 0.0,
0.0, 0.0, -2.0/(zFar-zNear), 0.0,
-(width+left)/(width-left), -(top+height)/(top-height), -(zFar+zNear)/(zFar-zNear), 1.0);
#endif
}
template<typename T> template<typename T>
void NzMatrix4<T>::SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up) void NzMatrix4<T>::SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up)
{ {
@ -320,7 +339,7 @@ void NzMatrix4<T>::SetPerspective(T angle, T ratio, T zNear, T zFar)
angle = NzDegreeToRadian(angle/2); angle = NzDegreeToRadian(angle/2);
#endif #endif
T f = 1 / std::tan(angle); auto f = 1 / std::tan(angle);
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR #if NAZARA_MATH_MATRIX_COLUMN_MAJOR
Set(f / ratio, 0.0, 0.0, 0.0, Set(f / ratio, 0.0, 0.0, 0.0,
@ -713,6 +732,15 @@ NzMatrix4<T> NzMatrix4<T>::LookAt(const NzVector3<T>& eye, const NzVector3<T>& c
return matrix; return matrix;
} }
template<typename T>
NzMatrix4<T> NzMatrix4<T>::Ortho(T left, T top, T width, T height, T zNear, T zFar)
{
NzMatrix4 matrix;
matrix.SetOrtho(left, top, width, height, zNear, zFar);
return matrix;
}
template<typename T> template<typename T>
NzMatrix4<T> NzMatrix4<T>::Perspective(T angle, T ratio, T zNear, T zFar) NzMatrix4<T> NzMatrix4<T>::Perspective(T angle, T ratio, T zNear, T zFar)
{ {
@ -789,5 +817,6 @@ void NzMatrix4<T>::ReleaseMatrix()
m_sharedMatrix = nullptr; m_sharedMatrix = nullptr;
} }
#undef NAZARA_MATRIX4_INL
#include <Nazara/Core/DebugOff.hpp> #include <Nazara/Core/DebugOff.hpp>

View File

@ -15,8 +15,8 @@
#undef NazaraNamedLock #undef NazaraNamedLock
#if NAZARA_MATH_THREADSAFE && (\ #if NAZARA_MATH_THREADSAFE && (\
(NAZARA_THREADSAFETY_MATRIX3 && (defined(NAZARA_MATRIX3) || defined(NAZARA_MATRIX3_CPP))) || \ (NAZARA_THREADSAFETY_MATRIX3 && (defined(NAZARA_MATRIX3) || defined(NAZARA_MATRIX3_INL))) || \
(NAZARA_THREADSAFETY_MATRIX4 && (defined(NAZARA_MATRIX4) || defined(NAZARA_MATRIX4_CPP)))) (NAZARA_THREADSAFETY_MATRIX4 && (defined(NAZARA_MATRIX4) || defined(NAZARA_MATRIX4_INL))))
#include <Nazara/Core/Lock.hpp> #include <Nazara/Core/Lock.hpp>
#include <Nazara/Core/Mutex.hpp> #include <Nazara/Core/Mutex.hpp>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_CLOCK_CPP
#include <Nazara/Core/Clock.hpp> #include <Nazara/Core/Clock.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
@ -15,6 +13,7 @@
#error OS not handled #error OS not handled
#endif #endif
#define NAZARA_CLASS_CLOCK
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_DIRECTORY_CPP
#include <Nazara/Core/Directory.hpp> #include <Nazara/Core/Directory.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <Nazara/Core/File.hpp> #include <Nazara/Core/File.hpp>
@ -17,6 +15,7 @@
#error OS not handled #error OS not handled
#endif #endif
#define NAZARA_CLASS_DIRECTORY
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_DYNLIB_CPP
#include <Nazara/Core/DynLib.hpp> #include <Nazara/Core/DynLib.hpp>
#include <Nazara/Core/Config.hpp> #include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
@ -19,6 +17,8 @@
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>
#define NAZARA_DYNLIB_CPP
NzDynLib::NzDynLib(const NzString& libraryPath) : NzDynLib::NzDynLib(const NzString& libraryPath) :
m_path(libraryPath), m_path(libraryPath),
m_impl(nullptr) m_impl(nullptr)

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_ERROR_CPP
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <Nazara/Core/Log.hpp> #include <Nazara/Core/Log.hpp>
#include <cstdlib> #include <cstdlib>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_FILE_CPP
#include <Nazara/Core/File.hpp> #include <Nazara/Core/File.hpp>
#include <Nazara/Core/Config.hpp> #include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
@ -21,6 +19,7 @@
#error OS not handled #error OS not handled
#endif #endif
#define NAZARA_CLASS_FILE
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>

View File

@ -2,14 +2,11 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_HASHDIGEST_CPP
#include <Nazara/Core/HashDigest.hpp> #include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <utility> #include <utility>
#include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>
NzHashDigest::NzHashDigest() : NzHashDigest::NzHashDigest() :

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_LOCK_CPP
#include <Nazara/Core/Lock.hpp> #include <Nazara/Core/Lock.hpp>
#include <Nazara/Core/Mutex.hpp> #include <Nazara/Core/Mutex.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_LOG_CPP
#include <Nazara/Core/Log.hpp> #include <Nazara/Core/Log.hpp>
#include <Nazara/Core/File.hpp> #include <Nazara/Core/File.hpp>
#include <Nazara/Core/StringStream.hpp> #include <Nazara/Core/StringStream.hpp>
@ -14,6 +12,7 @@
#include <cstdio> #include <cstdio>
#endif #endif
#define NAZARA_CLASS_LOG
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_MUTEX_CPP
#include <Nazara/Core/Mutex.hpp> #include <Nazara/Core/Mutex.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS) #if defined(NAZARA_PLATFORM_WINDOWS)

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_SEMAPHORE_CPP
#include <Nazara/Core/Semaphore.hpp> #include <Nazara/Core/Semaphore.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS) #if defined(NAZARA_PLATFORM_WINDOWS)

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_STRING_CPP
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Core/Config.hpp> #include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
@ -15,6 +13,8 @@
#include <cstring> #include <cstring>
#include <sstream> #include <sstream>
#include <Utfcpp/utf8.h> #include <Utfcpp/utf8.h>
#define NAZARA_CLASS_STRING
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>

View File

@ -2,11 +2,11 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_STRINGSTREAM_CPP
#include <Nazara/Core/StringStream.hpp> #include <Nazara/Core/StringStream.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>
#define NAZARA_STRINGSTREAM_CPP
NzStringStream::NzStringStream() : NzStringStream::NzStringStream() :
m_bufferSize(0) m_bufferSize(0)
{ {

View File

@ -4,8 +4,6 @@
// Inspiré du code de la SFML par Laurent Gomila // Inspiré du code de la SFML par Laurent Gomila
#define NAZARA_THREAD_CPP
#include <Nazara/Core/Thread.hpp> #include <Nazara/Core/Thread.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_THREADCONDITION_CPP
#include <Nazara/Core/ThreadCondition.hpp> #include <Nazara/Core/ThreadCondition.hpp>
#include <Nazara/Core/Mutex.hpp> #include <Nazara/Core/Mutex.hpp>

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine". // This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#define NAZARA_UNICODE_CPP
#include <Nazara/Core/Unicode.hpp> #include <Nazara/Core/Unicode.hpp>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>