OregonCore  revision 3611e8a-git
Your Favourite TBC server
Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy > Class Template Reference

#include <Singleton.h>

Static Public Member Functions

static T & Instance ()
 

Protected Member Functions

 Singleton ()
 

Private Types

typedef ThreadingModel::Lock Guard
 

Private Member Functions

 Singleton (const Singleton &)
 
Singletonoperator= (const Singleton &)
 

Static Private Member Functions

static void DestroySingleton ()
 

Static Private Attributes

static T * si_instance = NULL
 
static bool si_destroyed = false
 

Detailed Description

template<typename T, class ThreadingModel = Oregon::SingleThreaded<T>, class CreatePolicy = Oregon::OperatorNew<T>, class LifeTimePolicy = Oregon::ObjectLifeTime<T>>
class Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >

Definition at line 34 of file Singleton.h.

Member Typedef Documentation

template<typename T, class ThreadingModel = Oregon::SingleThreaded<T>, class CreatePolicy = Oregon::OperatorNew<T>, class LifeTimePolicy = Oregon::ObjectLifeTime<T>>
typedef ThreadingModel::Lock Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::Guard
private

Definition at line 52 of file Singleton.h.

Constructor & Destructor Documentation

template<typename T, class ThreadingModel = Oregon::SingleThreaded<T>, class CreatePolicy = Oregon::OperatorNew<T>, class LifeTimePolicy = Oregon::ObjectLifeTime<T>>
Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::Singleton ( )
inlineprotected
template<typename T, class ThreadingModel = Oregon::SingleThreaded<T>, class CreatePolicy = Oregon::OperatorNew<T>, class LifeTimePolicy = Oregon::ObjectLifeTime<T>>
Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::Singleton ( const Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy > &  )
private

Member Function Documentation

template<typename T , class ThreadingModel , class CreatePolicy , class LifeTimePolicy >
void Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::DestroySingleton ( )
staticprivate
template<typename T , class ThreadingModel , class CreatePolicy , class LifeTimePolicy >
T & Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::Instance ( )
static

Definition at line 71 of file Singleton.h.

References Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::DestroySingleton(), Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::si_destroyed, and Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::si_instance.

Referenced by channelMgr(), FactoryHolder< MovementGenerator, MovementGeneratorType >::DeregisterSelf(), and FactoryHolder< MovementGenerator, MovementGeneratorType >::RegisterSelf().

72 {
73  if (!si_instance)
74  {
75  // double-checked Locking pattern
76  Guard();
77  if (!si_instance)
78  {
79  if (si_destroyed)
80  {
81  si_destroyed = false;
82  LifeTimePolicy::OnDeadReference();
83  }
84  si_instance = CreatePolicy::Create();
85  LifeTimePolicy::ScheduleCall(&DestroySingleton);
86  }
87  }
88 
89  return *si_instance;
90 }
static void DestroySingleton()
Definition: Singleton.h:100
ThreadingModel::Lock Guard
Definition: Singleton.h:52
static T * si_instance
Definition: Singleton.h:53
static bool si_destroyed
Definition: Singleton.h:54
template<typename T, class ThreadingModel = Oregon::SingleThreaded<T>, class CreatePolicy = Oregon::OperatorNew<T>, class LifeTimePolicy = Oregon::ObjectLifeTime<T>>
Singleton& Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::operator= ( const Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy > &  )
private

Member Data Documentation

template<typename T, class ThreadingModel = Oregon::SingleThreaded<T>, class CreatePolicy = Oregon::OperatorNew<T>, class LifeTimePolicy = Oregon::ObjectLifeTime<T>>
bool Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::si_destroyed = false
staticprivate
template<typename T, class ThreadingModel = Oregon::SingleThreaded<T>, class CreatePolicy = Oregon::OperatorNew<T>, class LifeTimePolicy = Oregon::ObjectLifeTime<T>>
T * Oregon::Singleton< T, ThreadingModel, CreatePolicy, LifeTimePolicy >::si_instance = NULL
staticprivate

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