1 #ifndef SIMGEAR_SINGLETON_HXX
2 #define SIMGEAR_SINGLETON_HXX 1
4 #include "singleton.hpp"
6 #include "SGReferenced.hxx"
7 #include "SGSharedPtr.hxx"
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 SGSharedPtr<RefClass> ptr;
48 template <typename RefClass>
49 class ReferencedSingleton : public virtual SGReferenced
52 static RefClass* instance()
54 return SingletonRefPtr<RefClass>::instance();