diff options
author | chai <chaifix@163.com> | 2019-03-19 23:06:27 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-19 23:06:27 +0800 |
commit | 1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 (patch) | |
tree | f8d1bff50da13e126d08c7345653e002e293202d /Source/Samples/LuaxTest/header.h | |
parent | 5e2a973516e0729b225da9de0b03015dc5854ac4 (diff) |
*rename
Diffstat (limited to 'Source/Samples/LuaxTest/header.h')
-rw-r--r-- | Source/Samples/LuaxTest/header.h | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/Source/Samples/LuaxTest/header.h b/Source/Samples/LuaxTest/header.h deleted file mode 100644 index 386ae71..0000000 --- a/Source/Samples/LuaxTest/header.h +++ /dev/null @@ -1,60 +0,0 @@ - -#ifndef ASSERT -#ifdef NDEBUG -#define ASSERT(x) { false ? (void)(x) : (void)0; } -#else -#ifdef _WIN32 -#define ASURA_DEBUG_BREAK() __debugbreak() -#else -#define ASURA_DEBUG_BREAK() raise(SIGTRAP) -#endif -#define ASSERT(x) do { const volatile bool asura_assert_b____ = !(x); if(asura_assert_b____) ASURA_DEBUG_BREAK(); } while (false) -#endif -#endif - -/// -/// ̳Singletonڵһʵʱʵ֮ٴʵᱨ -/// -template<class T> -class Singleton -{ -public: - - static T* Get() - { - // ֮ǰûдһ - if (!instance) instance = new T; - // ʵ - return instance; - } - - static void Destroy() - { - delete instance; - instance = nullptr; - } - -protected: - - Singleton() - { - // instanceζִһʵǴġ - ASSERT(!instance); - // ʵΪʵ - instance = static_cast<T*>(this); - }; - - virtual ~Singleton() {}; - - static T* instance; - -private: - - Singleton(const Singleton& singleton); - - Singleton& operator = (const Singleton& singleton); - -}; - -template<class T> -T* Singleton<T>::instance = nullptr; |