Darc Library
2012.11
|
Template singleton class wrapper. More...
#include <dc_aux.h>
Static Public Member Functions | |
static T * | getInstance () |
Returns the singleton instance of T. | |
static void | release () |
Template singleton class wrapper.
This class wraps any type to create a new singleton class. An instance of the wrapped type becomes its static member. The type must be defined as
T* Singleton<T>::m_pInstance = NULL;
for lazy creation or
T* Singleton<T>::m_pInstance = Singleton<T>::getInstance();
for eager creation. After that the singleton can be accessed using getInstance().
static T* darc::Singleton< T >::getInstance | ( | ) | [inline, static] |
Returns the singleton instance of T.
The function checks if the instance is NULL and creates the object if necessary. Unused instances should be freed using release().
static void darc::Singleton< T >::release | ( | ) | [inline, static] |