Skip to content
Snippets Groups Projects
Commit 4a8c9e40 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

modernize and simplify singleton base class

parent 5fbe3a9f
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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();
}
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment