slic/include
diff -N Singleton.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Singleton.hh 5 Sep 2006 23:21:11 -0000 1.1
@@ -0,0 +1,52 @@
+// $Id: Singleton.hh,v 1.1 2006/09/05 23:21:11 jeremy Exp $
+
+#ifndef SLIC_SINGLETON_HH
+#define SLIC_SINGLETON_HH 1
+
+namespace slic
+{
+
+ 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