1 #ifndef SIMGEAR_SINGLETON_HXX
2 #define SIMGEAR_SINGLETON_HXX 1
4 #include <boost/pool/detail/singleton.hpp>
6 #include <osg/Referenced>
12 * Class that supplies the address of a singleton instance. This class
13 * can be inherited by its Class argument in order to support the
14 * instance() method in that class.
16 template <typename Class>
22 static Class* instance()
25 = boost::details::pool::singleton_default<Class>::instance();
30 template <typename RefClass>
38 static RefClass* instance()
40 SingletonRefPtr& singleton
41 = boost::details::pool::singleton_default<SingletonRefPtr>::instance();
42 return singleton.ptr.get();
45 osg::ref_ptr<RefClass> ptr;
48 template <typename RefClass>
49 class ReferencedSingleton : public virtual osg::Referenced
52 static RefClass* instance()
54 return SingletonRefPtr<RefClass>::instance();