1 #include "hmbdc/Copyright.hpp" 4 #include "hmbdc/Exception.hpp" 9 namespace hmbdc {
namespace pattern {
11 template <
typename Singleton>
13 template <
typename...Args>
18 template<
typename Singleton>
21 static Singleton& instance() {
return *pInstance_s;}
22 static bool initialized() {
return pInstance_s;}
25 static Singleton* pInstance_s;
28 template <
typename Singleton> Singleton*
31 template <
typename Singleton>
32 template <
typename...Args>
35 if (GuardedSingleton<Singleton>::pInstance_s) {
36 HMBDC_THROW(std::runtime_error
37 ,
"Cannot reinitialize typeid=" <<
typeid(Singleton).name());
39 GuardedSingleton<Singleton>::pInstance_s
40 =
new Singleton(std::forward<Args>(args)...);
43 template <
typename Singleton>
46 delete GuardedSingleton<Singleton>::pInstance_s;
47 GuardedSingleton<Singleton>::pInstance_s = 0;
Definition: GuardedSingleton.hpp:19
Definition: GuardedSingleton.hpp:12
Definition: Client.hpp:11