00001
00031 #ifndef _CSINGLETON_H_
00032 #define _CSINGLETON_H_
00033
00034 #include "main.h"
00035
00036 template <class T>
00037 class CSingleton{
00038
00039 public:
00040
00041 static T* getInstance(){
00042
00043 if( m_instance == NULL ){
00044 m_instance = new T;
00045 }
00046
00047 return m_instance;
00048 };
00049
00050 static void deleteInstance(){
00051 if( m_instance != NULL ){
00052 delete m_instance;
00053 m_instance = NULL;
00054 }
00055 }
00056
00057 protected:
00058 static T* m_instance;
00059
00060 };
00061
00062 template<class T>
00063 T* CSingleton<T>::m_instance = NULL ;
00064
00065 #endif
00066