ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Generic template base class for implementing the singleton design pattern. More...

#include <singleton.h>

Inheritance diagram for Common::Singleton< T >:
Collaboration diagram for Common::Singleton< T >:

List of all members.

Static Public Member Functions

static bool hasInstance ()
static T & instance ()
static void destroy ()

Protected Types

typedef T SingletonBaseType

Protected Member Functions

 Singleton ()
virtual ~Singleton ()

Static Protected Attributes

static T * _singleton

Private Member Functions

 Singleton (const Singleton< T > &)
Singleton< T > & operator= (const Singleton< T > &)

Static Private Member Functions

static T * makeInstance ()
 The default object factory used by the template class Singleton.
static void destroyInstance ()

Detailed Description

template<class T>
class Common::Singleton< T >

Generic template base class for implementing the singleton design pattern.

Definition at line 34 of file singleton.h.


Member Typedef Documentation

template<class T>
typedef T Common::Singleton< T >::SingletonBaseType [protected]

Definition at line 90 of file singleton.h.


Constructor & Destructor Documentation

template<class T>
Common::Singleton< T >::Singleton ( const Singleton< T > &   )  [private]
template<class T>
Common::Singleton< T >::Singleton (  )  [inline, protected]
template<class T>
virtual Common::Singleton< T >::~Singleton (  )  [inline, protected, virtual]

Member Function Documentation

template<class T>
static void Common::Singleton< T >::destroy (  )  [inline, static]

Definition at line 79 of file singleton.h.

template<class T>
static void Common::Singleton< T >::destroyInstance (  )  [inline, static, private]

Definition at line 55 of file singleton.h.

template<class T>
static bool Common::Singleton< T >::hasInstance (  )  [inline, static]

Definition at line 62 of file singleton.h.

template<class T>
static T& Common::Singleton< T >::instance (  )  [inline, static]

Definition at line 66 of file singleton.h.

template<class T>
static T* Common::Singleton< T >::makeInstance (  )  [inline, static, private]

The default object factory used by the template class Singleton.

By specialising this template function, one can make a singleton use a custom object factory. For example, to support encapsulation, your singleton class might be pure virtual (or "abstract" in Java terminology), and you specialise makeInstance to return an instance of a subclass.

Definition at line 51 of file singleton.h.

template<class T>
Singleton<T>& Common::Singleton< T >::operator= ( const Singleton< T > &   )  [private]

Member Data Documentation

template<class T>
T* Common::Singleton< T >::_singleton [static, protected]

Definition at line 92 of file singleton.h.


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


Generated on Sat Mar 16 2019 05:05:43 for ResidualVM by doxygen 1.7.1
curved edge   curved edge