32 #ifndef _CommonLibs_Util_Singleton_HPP_
33 #define _CommonLibs_Util_Singleton_HPP_
35 #include <type_traits>
50 # define GRANOO_SINGLETON_CLASS(CLASS) \
52 friend class GranOO3::Core::Singleton<CLASS>; \
54 static CLASS & get() \
56 return GranOO3::Core::Singleton<CLASS>::get(); \
58 static const CLASS & get_const() \
60 return GranOO3::Core::Singleton<CLASS>::get(); \
62 static void instanciate() \
64 return GranOO3::Core::Singleton<CLASS>::instanciate(); \
91 template <
typename T,
class Base>
99 template<
class T,
class Base>
103 "T must be a descendant of Base");
108 template<
class T,
class Base>
116 AssertMsg(_me==0,
"The singleton was already instanciate");
117 _me =
static_cast<T*
>(
this);
128 static_assert(std::is_base_of<
Singleton<T>,T>::
value,
"T must inherit from Singleton");
137 static_assert(std::is_base_of<
Singleton<T>,T>::
value,
"T must inherit from Singleton");
145 static_assert(std::is_base_of<
Singleton<T>,T>::
value,
"T must inherit from Singleton");
154 return (_me !=
nullptr);
#define AssertMsg(condition, message)
Definition: Macro.hpp:67
Definition: Singleton.hpp:93
virtual ~SingletonB()
Definition: Singleton.hpp:109
SingletonB()
Definition: Singleton.hpp:100
Definition: Singleton.hpp:75
Singleton()
Definition: Singleton.hpp:115
static T * _me
Definition: Singleton.hpp:87
static T & get()
Definition: Singleton.hpp:127
virtual ~Singleton()
Definition: Singleton.hpp:121
static bool exist()
Definition: Singleton.hpp:153
static void delete_me()
Definition: Singleton.hpp:144
static void instanciate()
Definition: Singleton.hpp:136
Definition: Common.hpp:198
T value(details::expression_node< T > *n)
Definition: Exprtk.hpp:15070