32 #ifndef __SINGLETON_H__ 33 #define __SINGLETON_H__ 35 #include "../lib/common.h" 45 static DERIVATED_CLASS* instance;
74 assert(!Singleton<DERIVATED_CLASS>::instance);
75 #if defined(_MSC_VER) && _MSC_VER < 1200 76 int offset = (int)(DERIVATED_CLASS*)1 - (int)(Singleton <DERIVATED_CLASS>*)(DERIVATED_CLASS*)1;
77 Singleton<DERIVATED_CLASS>::instance = (DERIVATED_CLASS*)((
int)
this + offset);
79 Singleton<DERIVATED_CLASS>::instance =
static_cast<DERIVATED_CLASS*
>(
this);
85 assert(Singleton<DERIVATED_CLASS>::instance);
86 Singleton<DERIVATED_CLASS>::instance = 0;
91 assert(Singleton<DERIVATED_CLASS>::instance);
92 return (*Singleton<DERIVATED_CLASS>::instance);
97 return Singleton<DERIVATED_CLASS>::instance;
static DERIVATED_CLASS * GetSingletonPtr()
static DERIVATED_CLASS & GetSingleton()