- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FUtils/FUSingleton.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    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_