xoreos  0.0.5
Static Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
Common::Singleton< T > Class Template Reference

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

#include <singleton.h>

Inheritance diagram for Common::Singleton< T >:
Inheritance graph
[legend]
Collaboration diagram for Common::Singleton< T >:
Collaboration graph
[legend]

Static Public Member Functions

static T & instance ()
 
static void destroy ()
 

Protected Types

typedef T SingletonBaseType
 

Protected Member Functions

 Singleton ()
 
virtual ~Singleton ()
 

Private Member Functions

 Singleton (const Singleton< T > &)
 
Singleton< T > & operator= (const Singleton< T > &)
 
template<>
Aurora::TwoDARegistry_singleton
 

Static Private Member Functions

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

Static Private Attributes

static T * _singleton
 

Detailed Description

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

Generic template base class for implementing the singleton design pattern.

Definition at line 61 of file singleton.h.

Member Typedef Documentation

◆ SingletonBaseType

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

Definition at line 111 of file singleton.h.

Constructor & Destructor Documentation

◆ Singleton() [1/2]

template<class T>
Common::Singleton< T >::Singleton ( const Singleton< T > &  )
private

◆ Singleton() [2/2]

template<class T>
Common::Singleton< T >::Singleton ( )
inlineprotected

Definition at line 108 of file singleton.h.

◆ ~Singleton()

template<class T>
virtual Common::Singleton< T >::~Singleton ( )
inlineprotectedvirtual

Definition at line 109 of file singleton.h.

Member Function Documentation

◆ _singleton()

template<>
Aurora::TwoDARegistry * Common::Singleton< Aurora::TwoDARegistry >::_singleton ( )
private

Definition at line 35 of file 2dareg.cpp.

Referenced by Common::Singleton< TimerManager >::destroyInstance(), and Common::Singleton< TimerManager >::instance().

Here is the caller graph for this function:

◆ destroy()

template<class T>
static void Common::Singleton< T >::destroy ( )
inlinestatic

Definition at line 104 of file singleton.h.

Referenced by Events::RequestManager::destroy().

Here is the caller graph for this function:

◆ destroyInstance()

template<class T>
static void Common::Singleton< T >::destroyInstance ( )
inlinestaticprivate

Definition at line 84 of file singleton.h.

◆ instance()

template<class T>
static T& Common::Singleton< T >::instance ( )
inlinestatic

Definition at line 91 of file singleton.h.

◆ makeInstance()

template<class T>
static T* Common::Singleton< T >::makeInstance ( )
inlinestaticprivate

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 80 of file singleton.h.

◆ operator=()

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

Member Data Documentation

◆ _singleton

template<class T>
T* Common::Singleton< T >::_singleton
staticprivate

Definition at line 66 of file singleton.h.


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