Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

csingletonmanager.h

Go to the documentation of this file.
00001 #ifndef CSINGLETONMANAGER_H
00002 #define CSINGLETONMANAGER_H
00003 
00104 #include <assert.h>
00105 
00106 template<class T> class CSingletonFactory;
00107 
00112 template<class T> class CSingletonManager {
00113 private:
00115   static T *unique_instance;
00116 
00119   CSingletonManager<T>();
00120 
00121 public:
00124   static void init(CSingletonFactory<T> *f) { unique_instance = f->make_singleton(); delete f; }
00125 
00128   static void deinit() { delete unique_instance; unique_instance = 0; }
00129 
00131   static T &get_instance() { assert(unique_instance != 0); return *unique_instance; }
00132 };
00133 
00138 template<class T> class CSingletonFactory {
00139  private:
00142   friend class CSingletonManager<T>;
00143 
00147   virtual T *make_singleton() = 0;
00148 };
00149 
00150 #endif

Generated on Wed Aug 27 11:58:41 2003 for GFW by doxygen 1.3.3