#ifndef SINGLETON_HPP #define SINGLETON_HPP #include "Common.hpp" template class Singleton { protected: Singleton() { TRACE("Simgleton::Singleton()"); } virtual ~Singleton() { TRACE("Simgleton::~Singleton()"); } private: Singleton( const Singleton& ); Singleton& operator=( const Singleton& ); public: static void createInstance() { TRACE("Simgleton::createInstance()"); if ( not m_instance ) { m_instance = new T(); } } static T* getInstance() { TRACE("Simgleton::getInstance()"); return m_instance; } static void destroy() { TRACE("Simgleton::destroy()"); if ( m_instance ) { delete m_instance; } m_instance = 0; } private: static T* m_instance; }; template T* Singleton::m_instance = 0; #endif // SINGLETON_HPP