SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
Singleton.hh
Go to the documentation of this file.
1 #ifndef SLIC_SINGLETON_HH_
2 #define SLIC_SINGLETON_HH_ 1
3 
8 template<class T>
9 
10 class Singleton {
11 
12  public:
13 
17  static T* instance();
18 
22  void release();
23 
28 
33 
34  private:
35  static T* m_singleton;
36 };
37 
38 template<class T> T* Singleton<T>::m_singleton = 0;
39 
40 template<class T>
42 }
43 
44 template<class T>
46 }
47 
48 template<class T>
50  if (m_singleton == 0) {
51  m_singleton = new T;
52  }
53  return m_singleton;
54 }
55 
56 template<class T>
57 void Singleton<T>::release() {
58  if (m_singleton == 0)
59  return;
60  delete m_singleton;
61  m_singleton = 0;
62 }
63 
64 #endif
65 
void release()
static T * m_singleton
Definition: Singleton.hh:35
static T * instance()