Go to the documentation of this file.
23 #ifndef __MYGUI_INSTANCE_H__
24 #define __MYGUI_INSTANCE_H__
26 #define MYGUI_INSTANCE_HEADER(type) \
28 static type* msInstance; \
33 static type& getInstance(); \
34 static type* getInstancePtr();
37 #define MYGUI_INSTANCE_IMPLEMENT(type) \
38 const std::string INSTANCE_TYPE_NAME(#type); \
39 type* type::msInstance = nullptr; \
40 type* type::getInstancePtr() { return msInstance; } \
41 type& type::getInstance() { MYGUI_ASSERT(0 != msInstance, "instance " << INSTANCE_TYPE_NAME << " was not created"); return (*msInstance); } \
42 type::type() : mIsInitialise(false) { MYGUI_ASSERT(0 == msInstance, "instance " << INSTANCE_TYPE_NAME << " is exsist"); msInstance = this; } \
43 type::~type() { msInstance = nullptr; }
45 #endif // __MYGUI_INSTANCE_H__