libassa  3.5.1
Static Public Member Functions | Protected Member Functions | Static Private Attributes | Friends | List of all members
ASSA::Singleton< T > Class Template Reference

#include <Singleton.h>

Static Public Member Functions

static T * get_instance ()
 Return an instance of templated class T. More...
 

Protected Member Functions

 Singleton ()
 Protected Constructor. More...
 
virtual ~Singleton ()
 Virtual Destructor. More...
 

Static Private Attributes

static T * m_instance
 Pointer to the object T instance. More...
 
static Destroyer< T > m_destroyer
 Destroyer that owns object T. More...
 

Friends

class Destroyer< T >
 

Detailed Description

template<class T>
class ASSA::Singleton< T >

Definition at line 42 of file Singleton.h.

Constructor & Destructor Documentation

◆ Singleton()

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

Protected Constructor.

Definition at line 57 of file Singleton.h.

57 {}

◆ ~Singleton()

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

Virtual Destructor.

Definition at line 62 of file Singleton.h.

62 {}

Member Function Documentation

◆ get_instance()

template<class T >
static T* ASSA::Singleton< T >::get_instance ( )
inlinestatic

Return an instance of templated class T.

Definition at line 47 of file Singleton.h.

47  {
48  if (m_instance == 0) {
49  m_instance = new T;
50  m_destroyer.setGuard (m_instance);
51  }
52  return m_instance;
53  }
static Destroyer< T > m_destroyer
Destroyer that owns object T.
Definition: Singleton.h:69
static T * m_instance
Pointer to the object T instance.
Definition: Singleton.h:66

References ASSA::Singleton< T >::m_destroyer, and ASSA::Singleton< T >::m_instance.

Friends And Related Function Documentation

◆ Destroyer< T >

template<class T >
friend class Destroyer< T >
friend

Definition at line 57 of file Singleton.h.

Member Data Documentation

◆ m_destroyer

template<class T >
Destroyer<T> ASSA::Singleton< T >::m_destroyer
staticprivate

Destroyer that owns object T.

Definition at line 69 of file Singleton.h.

Referenced by ASSA::Singleton< T >::get_instance().

◆ m_instance

template<class T >
T* ASSA::Singleton< T >::m_instance
staticprivate

Pointer to the object T instance.

Definition at line 66 of file Singleton.h.

Referenced by ASSA::Singleton< T >::get_instance().


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