1 #ifndef Protium_Singleton_h_
2 #define Protium_Singleton_h_
23 template <
class>
class CreationPolicy = CreateNew,
24 template <
class>
class DeletionPolicy = DeleteNever,
48 typedef typename ThreadingPolicy<ObjectType*,MutexPolicy>::VolatileType
PtrInstanceType;
60 template <
class>
class CreationPolicy,
61 template <
class>
class DeletionPolicy,
62 template <
class,
class>
class ThreadingPolicy,
68 template <
class>
class CreationPolicy,
69 template <
class>
class DeletionPolicy,
70 template <
class,
class>
class ThreadingPolicy,
79 template <
class>
class CreationPolicy,
80 template <
class>
class DeletionPolicy,
81 template <
class,
class>
class ThreadingPolicy,
94 template <
class>
class CreationPolicy,
95 template <
class>
class DeletionPolicy,
96 template <
class,
class>
class ThreadingPolicy,
100 typename ThreadingPolicy<Singleton,MutexPolicy>::Lock lock;
107 DeletionPolicy<Host>::OnDeadReference();
109 fInstance = CreationPolicy<Host>::Create();
110 DeletionPolicy<Host>::ScheduleDestruction(fInstance, &DestroySingleton);
114 template<
class Host,
115 template <
class>
class CreationPolicy,
116 template <
class>
class DeletionPolicy,
117 template <
class,
class>
class ThreadingPolicy,
121 CreationPolicy<Host>::Destroy(fInstance);
129 #endif //File Guardian
static Host & Instance()
Use to get instance.
static PtrInstanceType fInstance
Pointer to the interior data.
Use to specify instance-locked items.
static void MakeInstance()
Helper Function to make instance (Uses CreationPolicy)
Singleton(const Singleton &)
Declared Private so can not be used.
Wrapper class for pthreads-style mutexes.
static void DestroySingleton()
Helper Function to destroy instance (Uses Destruction policy)
Singleton & operator=(const Singleton &)
Declared Private so can not be used.
Defines mutexes and policies to be used by threaded objects.
Singleton()
Declared Private so can not be used.
static bool fDestroyed
Flag for whether or not the instance has been killed (yet)
ThreadingPolicy< ObjectType *, MutexPolicy >::VolatileType PtrInstanceType
Declaration of data interior to class.
Host ObjectType
Declaration of the host interior to the class.