#include <CeylanSingleton.h>
Static Public Member Functions | |
static Singleton & | GetSingleton () |
Returns the one and only one Singleton instance available. | |
static void | DeleteSingleton () |
Removes the shared Singleton. | |
Protected Member Functions | |
Singleton () | |
Basic constructor. | |
virtual | ~Singleton () throw () |
Basic virtual destructor. | |
Private Member Functions | |
Singleton (const Singleton &source) | |
Copy constructor made private to ensure that it will never be called. | |
Singleton & | operator= (const Singleton &source) |
Assignment operator made private to ensure that it will never be called. | |
Static Private Attributes | |
static Singleton * | _InternalSingleton = 0 |
The internal single instance. |
This class should be templated so that it can be used with any class that has to have only one instance at any time.
Another possible implementation would be:
static AClass::singleton() { static AClass singleton ; return singleton ; }
Definition at line 74 of file CeylanSingleton.h.
Singleton::Singleton | ( | ) | [protected] |
Basic constructor.
Definition at line 109 of file CeylanSingleton.cc.
References Ceylan::toString().
Referenced by GetSingleton().
Singleton::~Singleton | ( | ) | throw () [protected, virtual] |
Basic virtual destructor.
Definition at line 119 of file CeylanSingleton.cc.
References Ceylan::toString().
Ceylan::Singleton::Singleton | ( | const Singleton & | source | ) | [private] |
Copy constructor made private to ensure that it will never be called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
void Singleton::DeleteSingleton | ( | ) | [static] |
Singleton & Singleton::GetSingleton | ( | ) | [static] |
Returns the one and only one Singleton instance available.
The returned value is a reference and not a pointer, to avoid any abnormal deallocation by its users, that should never deallocate the Singleton.
Definition at line 60 of file CeylanSingleton.cc.
References Singleton(), and Ceylan::toString().
Assignment operator made private to ensure that it will never be called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
Singleton * Singleton::_InternalSingleton = 0 [static, private] |