#include <singleton.h>
Inherited by UniversalManager< Font, FontManager >, and UniversalManager< Texture, TextureManager >.
Inheritance diagram for Singleton< T >:


Public Member Functions | |
| virtual | ~Singleton (void) |
Static Public Member Functions | |
| static T * | getInstance (void) |
| returns instance pointer | |
| static T * | getPtr (void) |
| returns instance pointer | |
| static T & | getRef (void) |
| returns instance reference | |
Protected Member Functions | |
| Singleton (void) | |
| protected ctor due to singleton DP | |
| Singleton (const Singleton &) | |
| protected ctor due to singleton DP | |
| Singleton & | operator= (const Singleton &) |
| protected operator= due to singleton DP | |
Static Private Member Functions | |
| static void | createInstance (void) |
| creates a new instance of singleton class T | |
| static void | destroyInstance (void) |
| destroys the instance of singleton class T | |
Static Private Attributes | |
| static T * | m_InstancePtr = 0 |
| static pointer to the instance of the singleton class T | |
| static Singleton< T >::InstanceDestruction | m_InstanceDestruction |
| static class that destroys singleton instance at the program exit. | |
Classes | |
| class | InstanceDestruction |
| class that will destroy the singleton instance at the program exit. More... | |
// Singleton<T> usage example: class OneClass: public ClassA, ClassB, Singleton<OneClass> { // I. Singleton stuffs // only the Singleton<OneClass> can call OneClass::OneClass() friend class Singleton<OneClass>; protected: OneClass(); // protected ctor (singleton) ~OneClass(); // protected dtor (singleton) // II. OneClass definition - methods, attributes public: some_OneClass_method() }; ... // Equivalent usage of the OneClass singleton: OneClass::getInstance()->some_OneClass_method(); OneClass::getPtr()->some_OneClass_method(); OneClass::getRef().some_OneClass_method();
Singleton classes are destroyed at the program exit (at static variables destruction). Therefore, using other classes and global or static variables (other singletons as well) inside the destructor-body of some singleton class could be unsafe (the variables that we are attempting to use might be already destroyed)!
Sometimes, it can be possible to destroy the singleton directly by using delete SomeSingleton::getPtr(). It isn't recommended, however it shouldn't cause any program's crash...
Definition at line 75 of file singleton.h.
|
||||||||||
|
Definition at line 81 of file singleton.h. |
|
||||||||||
|
protected ctor due to singleton DP
Definition at line 121 of file singleton.h. |
|
||||||||||
|
protected ctor due to singleton DP
Definition at line 124 of file singleton.h. |
|
||||||||||
|
creates a new instance of singleton class T
Definition at line 133 of file singleton.h. Referenced by Singleton< T >::getInstance(). |
|
||||||||||
|
destroys the instance of singleton class T
Definition at line 141 of file singleton.h. Referenced by Singleton< T >::InstanceDestruction::~InstanceDestruction(). |
|
||||||||||
|
returns instance pointer The instance of T is created at the first getInstance() call.
Definition at line 165 of file singleton.h. References Singleton< T >::createInstance(), and Singleton< T >::m_InstancePtr. Referenced by SurfaceFactory::create(), Singleton< FontManager >::getPtr(), Singleton< FontManager >::getRef(), TerrainClient::loadGlobalTexture(), and TerrainClient::loadLightmap(). Here is the call graph for this function: ![]() |
|
||||||||||
|
returns instance pointer The instance of T is created at the first getInstance() call.
Definition at line 105 of file singleton.h. Referenced by GFX::clean(). |
|
||||||||||
|
returns instance reference The instance of T is created at the first getInstance() call.
Definition at line 116 of file singleton.h. Referenced by Messages::init(), Console::init(), and ApplicationClient::init(). |
|
||||||||||
|
protected operator= due to singleton DP
Definition at line 127 of file singleton.h. |
|
|||||
|
static class that destroys singleton instance at the program exit.
Definition at line 161 of file singleton.h. |
|
|||||
|
static pointer to the instance of the singleton class T
Definition at line 130 of file singleton.h. Referenced by Singleton< FontManager >::createInstance(), Singleton< FontManager >::destroyInstance(), Singleton< T >::getInstance(), and Singleton< FontManager >::~Singleton(). |
1.4.5