00001
00002
00003
00004
00005
00006
00007
00008
00014 #ifndef _FU_SINGLETON_H_
00015 #define _FU_SINGLETON_H_
00016
00041 #define DeclareSingletonClass(_SingletonClass) \
00042 private: \
00043 static _SingletonClass* singleton; \
00044 public: \
00045 static _SingletonClass* CreateSingleton(); \
00046 static void DestroySingleton(); \
00047 static inline _SingletonClass* GetSingleton() { return singleton; } \
00048 private:
00049
00052 #define ImplementSingletonClass(_SingletonClass) \
00053 _SingletonClass* _SingletonClass::CreateSingleton() { \
00054 FUAssert(singleton == NULL, return singleton); \
00055 return singleton = new _SingletonClass(); } \
00056 void _SingletonClass::DestroySingleton() { \
00057 FUAssert(singleton != NULL, return); \
00058 SAFE_DELETE(singleton); } \
00059 _SingletonClass* _SingletonClass::singleton = NULL
00060
00061 #endif // _FU_SINGLETON_H_