00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SINGLETON_HPP_INCLUDED
00020 #define SINGLETON_HPP_INCLUDED
00021
00022 #include "start_code.hpp"
00023
00024 namespace SPACE
00025 {
00026 namespace Core
00027 {
00032 template <class T>
00033 class TSingleton
00034 {
00035 protected:
00036 static T* m_pSingleton;
00037
00038 public:
00039 virtual ~TSingleton () {}
00040
00045 inline static T* Get()
00046 {
00047 if(!m_pSingleton)
00048 m_pSingleton = new T;
00049
00050 return m_pSingleton;
00051 }
00052
00054 static void Del()
00055 {
00056 if(m_pSingleton)
00057 {
00058 delete(m_pSingleton);
00059 m_pSingleton = NULL;
00060 }
00061 }
00062
00063 };
00064
00065 template <class T>
00066 T* TSingleton<T>::m_pSingleton = 0;
00067 }
00068 }
00069
00070 #endif // SINGLETON_HPP_INCLUDED