Darc Library  2012.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
darc::Singleton< T > Class Template Reference

Template singleton class wrapper. More...

#include <dc_aux.h>

List of all members.

Static Public Member Functions

static T * getInstance ()
 Returns the singleton instance of T.
static void release ()

Detailed Description

template<typename T>
class darc::Singleton< T >

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().


Member Function Documentation

template<typename T >
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().

template<typename T >
static void darc::Singleton< T >::release ( ) [inline, static]

The documentation for this class was generated from the following files: