diff --git a/pub/CHANGELOG b/pub/CHANGELOG index c7c037b52b1037bd98e38d31ef005cd4cd5cf7c5..a2c1a13b093b75b361a78a6a020139bd7506767e 100644 --- a/pub/CHANGELOG +++ b/pub/CHANGELOG @@ -3,6 +3,7 @@ Release: - New functionality: - functions kwwmc, kwwms, kwwmp take argument <tau> instead of tau - Code cleanup: + - modernize and simplify singleton base class - got rid of global instances of singletons Release 2.3.2f of 17nov15: diff --git a/pub/lib/toplevel.cpp b/pub/lib/toplevel.cpp index a9cdc4c520ab0b61909b780baf223977461e7ed4..3a1c260cf91e2146bc595fea8f433d670fc3e985 100644 --- a/pub/lib/toplevel.cpp +++ b/pub/lib/toplevel.cpp @@ -53,15 +53,10 @@ void my_gsl_error_handler ( const char * reason, const char * file, int line, in } -//! At exit, tear down globals. +//! At exit, currently nothing to do. void atexit_handler() { - SFuncRegistry::reset_instance(); - SGeniRegistry::reset_instance(); - SCvinRegistry::reset_instance(); - SVariRegistry::reset_instance(); - SPloWin::reset_instance(); } diff --git a/pub/trivia/singleton.hpp b/pub/trivia/singleton.hpp index a176692070b3de44839875ac21c942b712f934b8..7fc1cbff28a166a1c3e9c5aa1fab212092384a15 100644 --- a/pub/trivia/singleton.hpp +++ b/pub/trivia/singleton.hpp @@ -19,26 +19,14 @@ class ISingleton { private: ISingleton(ISingleton const&) = delete; //! To prevent copying void operator=(ISingleton const&) = delete; //! To prevent copying - static T* instance; protected: ~ISingleton() {}; ISingleton() {} typedef T* T_Pointer; public: - static T* get_instance() - { if ( instance==nullptr ) - instance = new T(); - return instance; } - static void reset_instance() { - delete instance; - instance = nullptr; - } + static T* get_instance() { static T* instance = new T(); return instance; } }; -// Instantiate static member: -template<class T> -typename ISingleton<T>::T_Pointer ISingleton<T>::instance = nullptr; - -} +} // namespace triv #endif // ISINGLETON_H