Static Public Member Functions | |
static TYPE * | Instance (void) |
Singleton dynamic creation using the default builder. | |
static bool | IsAlreadyExisting (void) |
returns True if the singleton is already existing | |
static int | Destruction (void) |
destroys the Singleton before the end of the application process |
Definition
A singleton is a data which is created and deleted only once in the application. The C++ compiler allow the user to create static data before the first executable statement. They are deleted after the last statement.statement.
The SINGLETON_ template class deals with dynamic singleton. It is useful for functor objects. For example, an object which, when created, connects the application to a system and disconnects the application at deletion.
Usage
To create a single instance a POINT_ object :
# include "Utils_SINGLETON.hxx" ... ptrPoint = SINGLETON_<POINT_>::Instance() ;
Design description
TYPE * SINGLETON_< TYPE >::Instance | ( | void | ) | [inline, static] |
Singleton dynamic creation using the default builder.
The class method Instance :
Note that the two created objects are deleted at the end of the process in the function Nettoyage().
bool SINGLETON_< TYPE >::IsAlreadyExisting | ( | void | ) | [inline, static] |
returns True if the singleton is already existing
int SINGLETON_< TYPE >::Destruction | ( | void | ) | [inline, static] |
destroys the Singleton before the end of the application process
The method SINGLETON_<TYPE>::Destruction can be called by the user. If it is not the function nettoyage() calls it atexit.
N.B. : the singleton objects are destroyed in the reverse order of there creation.