25 #ifndef __I6ENGINE_UTILS_SINGLETON_H__
26 #define __I6ENGINE_UTILS_SINGLETON_H__
28 #include "boost/interprocess/sync/scoped_lock.hpp"
29 #include "boost/make_shared.hpp"
30 #include "boost/thread/mutex.hpp"
43 template<
typename T,
typename... Dependencies>
71 template<
typename... B>
72 struct InitDependencies {
82 template<
typename A,
typename... B>
83 struct InitDependencies<A, B...> {
91 InitDependencies<B...>::Init();
98 static boost::shared_ptr<T> & Init() {
99 static const InitDependencies<Dependencies...> id;
100 static boost::shared_ptr<T> _ptrSingleton = boost::shared_ptr<T>(
new T());
101 return _ptrSingleton;
Derive from this templated class to make a class a singleton. Refer to the Singleton Design Pattern i...
static T * GetSingletonPtr()
Returns a pointer to the Singleton class.
static T & GetSingleton()
Returns a reference to the Singleton class.