DART  6.6.2
dart::common::Singleton< T > Class Template Reference

Singleton template class. More...

#include <Singleton.hpp>

Static Public Member Functions

template<typename... Args>
static T & getSingleton (Args... _args)
 Returns reference of the singleton. More...
 
template<typename ... Args>
static T * getSingletonPtr (Args... _args)
 Returns pointer of the singleton. More...
 

Protected Member Functions

 Singleton ()=default
 Constructor. More...
 
virtual ~Singleton ()=default
 Destructor. More...
 

Private Member Functions

 Singleton (const T &)=delete
 Don't implement copy constructor. More...
 
const T & operator= (const T &)=delete
 Don't assignment operator. More...
 

Static Private Attributes

static T * mInstance = nullptr
 Singleton instance. More...
 

Detailed Description

template<typename T>
class dart::common::Singleton< T >

Singleton template class.

Note
This singleton is not thread safe. For use of thread safe singleton, use static initialization as:

// Singletone class Engine class Engine : public Singleton<Engine> {};

// Call before main() and use theT only instead of calling getSingleton() static T& theT = T::getSingleton();

Constructor & Destructor Documentation

◆ Singleton() [1/2]

template<typename T >
dart::common::Singleton< T >::Singleton ( )
protecteddefault

Constructor.

◆ ~Singleton()

template<typename T >
virtual dart::common::Singleton< T >::~Singleton ( )
protectedvirtualdefault

Destructor.

◆ Singleton() [2/2]

template<typename T >
dart::common::Singleton< T >::Singleton ( const T &  )
privatedelete

Don't implement copy constructor.

Member Function Documentation

◆ getSingleton()

template<typename T >
template<typename... Args>
T & dart::common::Singleton< T >::getSingleton ( Args...  _args)
static

Returns reference of the singleton.

◆ getSingletonPtr()

template<typename T >
template<typename ... Args>
T * dart::common::Singleton< T >::getSingletonPtr ( Args...  _args)
static

Returns pointer of the singleton.

◆ operator=()

template<typename T >
const T& dart::common::Singleton< T >::operator= ( const T &  )
privatedelete

Don't assignment operator.

Member Data Documentation

◆ mInstance

template<typename T >
T * dart::common::Singleton< T >::mInstance = nullptr
staticprivate

Singleton instance.