Shadowrun: Awakened 29 September 2011 - Build 871
Singleton.h
Go to the documentation of this file.
00001 #ifndef __SINGLETON_H
00002 #define __SINGLETON_H
00003 
00013 template<class T>
00014 class Singleton
00015 {
00016 protected:
00017     static T* _Singleton;
00018 
00022     static void SetSingleton(T* value)
00023     {
00024         _Singleton = value;
00025     }
00026 
00027 public:
00031     static T& GetSingleton()
00032     {
00033         return *_Singleton;
00034     }
00035 
00039     Singleton() { }
00040 
00045     static void CreateSingletonInstance()
00046     {
00047         _Singleton = new T();
00048     }
00049 
00053     static void DeleteSingletonInstance()
00054     {
00055         delete _Singleton;
00056         _Singleton = NULL;
00057     }
00058 
00063     Singleton(T* value)
00064     {
00065         SetSingleton(value);
00066     }
00067 };
00068 
00072 template <class T> T* Singleton<T>::_Singleton;
00073 
00074 #endif

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net