Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_INSTANCE_H__
00024 #define __MYGUI_INSTANCE_H__
00025
00026 #define MYGUI_INSTANCE_HEADER(type) \
00027 private: \
00028 static type* msInstance; \
00029 bool mIsInitialise; \
00030 public: \
00031 type();\
00032 ~type();\
00033 static type& getInstance(); \
00034 static type* getInstancePtr();
00035
00036
00037 #define MYGUI_INSTANCE_IMPLEMENT(type) \
00038 const std::string INSTANCE_TYPE_NAME(#type); \
00039 type* type::msInstance = nullptr; \
00040 type* type::getInstancePtr() { return msInstance; } \
00041 type& type::getInstance() { MYGUI_ASSERT(0 != msInstance, "instance " << INSTANCE_TYPE_NAME << " was not created"); return (*msInstance); } \
00042 type::type() : mIsInitialise(false) { MYGUI_ASSERT(0 == msInstance, "instance " << INSTANCE_TYPE_NAME << " is exsist"); msInstance = this; } \
00043 type::~type() { msInstance = nullptr; }
00044
00045 #endif // __MYGUI_INSTANCE_H__