Commit in lcdd/include on MAIN
Singleton.hh+49added 1.1
JM: Moving from slic to lcdd.

lcdd/include
Singleton.hh added at 1.1
diff -N Singleton.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Singleton.hh	5 Mar 2007 22:59:41 -0000	1.1
@@ -0,0 +1,49 @@
+// $Id: Singleton.hh,v 1.1 2007/03/05 22:59:41 jeremy Exp $
+
+#ifndef LCDD_SINGLETON_HH
+#define LCDD_SINGLETON_HH 1
+
+template<class T>
+class Singleton
+{
+public:
+  static T* instance();
+  void release();
+  
+  Singleton();
+  ~Singleton();
+  
+private:
+  static T* m_singleton;
+};
+
+template<class T> T* Singleton<T>::m_singleton = 0;
+
+template<class T>
+Singleton<T>::Singleton()
+{}
+
+template<class T>
+Singleton<T>::~Singleton()
+{}
+
+template<class T>
+T* Singleton<T>::instance()
+{
+  if (m_singleton == 0) {
+    m_singleton = new T;
+  }
+  return m_singleton;
+}
+
+template<class T>
+void Singleton<T>::release ()
+{
+  if (m_singleton == 0)
+    return;
+  delete m_singleton;
+  m_singleton = 0;
+}
+
+#endif
+
CVSspam 0.2.8