OpenBarnyard
 
Loading...
Searching...
No Matches
TSingleton< T > Class Template Reference

#include <TSingleton.h>

Public Member Functions

 TSingleton (const TSingleton &)=delete
 
 TSingleton (const TSingleton &&)=delete
 
TSingletonoperator= (const TSingleton &)=delete
 
TSingletonoperator= (const TSingleton &&)=delete
 

Static Public Member Functions

template<typename... Args>
static TFORCEINLINE T * CreateSingleton (Args &&... args)
 
template<typename D, typename... Args>
static TFORCEINLINE D * CreateSingleton (Args &&... args)
 
static TFORCEINLINE void DestroySingleton ()
 
static TFORCEINLINE T * GetSingletonSafe ()
 
static TFORCEINLINE TBOOL IsSingletonCreated ()
 
static TFORCEINLINE T * GetSingleton ()
 

Protected Member Functions

TFORCEINLINE TSingleton ()
 
TFORCEINLINE ~TSingleton ()
 

Static Protected Attributes

static T * ms_pSingleton
 

Detailed Description

template<typename T>
class TSingleton< T >

Definition at line 7 of file TSingleton.h.

Constructor & Destructor Documentation

◆ TSingleton() [1/3]

template<typename T>
TSingleton< T >::TSingleton ( const TSingleton< T > & )
delete

◆ TSingleton() [2/3]

template<typename T>
TSingleton< T >::TSingleton ( const TSingleton< T > && )
delete

◆ TSingleton() [3/3]

template<typename T>
TFORCEINLINE TSingleton< T >::TSingleton ( )
inlineprotected

Definition at line 63 of file TSingleton.h.

64 {
65 TASSERT( ms_pSingleton == TNULL, "Singleton instance is already created" );
66 ms_pSingleton = static_cast<T*>( this );
67 }
#define TASSERT(X,...)
Definition Defines.h:138
static T * ms_pSingleton
Definition TSingleton.h:71

◆ ~TSingleton()

template<typename T>
TFORCEINLINE TSingleton< T >::~TSingleton ( )
inlineprotected

Definition at line 69 of file TSingleton.h.

Member Function Documentation

◆ CreateSingleton() [1/2]

template<typename T>
template<typename... Args>
static TFORCEINLINE T * TSingleton< T >::CreateSingleton ( Args &&... args)
inlinestatic

Definition at line 17 of file TSingleton.h.

18 {
19 return new T( std::forward<Args>( args )... );
20 }

◆ CreateSingleton() [2/2]

template<typename T>
template<typename D, typename... Args>
static TFORCEINLINE D * TSingleton< T >::CreateSingleton ( Args &&... args)
inlinestatic

Definition at line 24 of file TSingleton.h.

25 {
27 return new D( std::forward<Args>( args )... );
28 }
#define TSTATICASSERT(...)
Definition Defines.h:67

◆ DestroySingleton()

template<typename T>
static TFORCEINLINE void TSingleton< T >::DestroySingleton ( )
inlinestatic

Definition at line 30 of file TSingleton.h.

31 {
32 delete GetSingletonSafe();
34 }
static TFORCEINLINE T * GetSingletonSafe()
Definition TSingleton.h:37

◆ GetSingleton()

template<typename T>
static TFORCEINLINE T * TSingleton< T >::GetSingleton ( )
inlinestatic

Definition at line 49 of file TSingleton.h.

50 {
51 return ms_pSingleton;
52 }

◆ GetSingletonSafe()

template<typename T>
static TFORCEINLINE T * TSingleton< T >::GetSingletonSafe ( )
inlinestatic

Definition at line 37 of file TSingleton.h.

38 {
39 TASSERT( ms_pSingleton != TNULL, "Singleton instance is not created" );
40 return ms_pSingleton;
41 }

◆ IsSingletonCreated()

template<typename T>
static TFORCEINLINE TBOOL TSingleton< T >::IsSingletonCreated ( )
inlinestatic

Definition at line 43 of file TSingleton.h.

44 {
45 return ms_pSingleton != TNULL;
46 }

◆ operator=() [1/2]

template<typename T>
TSingleton & TSingleton< T >::operator= ( const TSingleton< T > && )
delete

◆ operator=() [2/2]

template<typename T>
TSingleton & TSingleton< T >::operator= ( const TSingleton< T > & )
delete

Member Data Documentation

◆ ms_pSingleton

template<typename T>
T* TSingleton< T >::ms_pSingleton
staticprotected

Definition at line 71 of file TSingleton.h.


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