#ifndef SINGLETON_H
#define SINGLETON_H
#include <boost/smart_ptr.hpp>
template< class T >
class singleton
{
public:
typedef boost::shared_ptr< T > T_sptr;
static T_sptr instance()
{
static T_sptr _instance;
if (_instance.get() == 0)
{
_instance.reset(new T);
}
return _instance;
}
protected:
singleton()
{
}
};
#endif // SINGLETON_H