Basic Image AlgorithmS Library
2.8.0
|
Simple singleton implementation for multithreaded applications. More...
#include <Base/Common/Singleton.hh>
Static Public Member Functions | |
static T * | GetInstance () |
Protected Member Functions | |
Singleton< T > & | operator= (const Singleton &t) |
Singleton () | |
Singleton (const Singleton< T > &t) | |
~Singleton () | |
Static Protected Member Functions | |
static void | DeleteInstance_ () |
static pthread_mutex_t * | Mutex_ () |
Static Protected Attributes | |
static T * | Instance_ = NULL |
static members More... | |
Simple singleton implementation for multithreaded applications.
To use this template to create a singleton of class MyClass do the following: /code #include <Base/Common/Singleton.hh> class MyClass :public Singleton<MyClass> { public:
some functionality of class MyClass void foo();
....
constructor must be protected to let parent class access, but not ordinary users protected: make sure that class MyClass cannot be used as non-singleton by declaring constructors and copy operator private MyClass(); MyClass(const &MyClass); MyClass& operator=(const &MyClass); };
/ exemplary usage MyClassSingleton::GetInstance()->foo();
/endcode
The code wraps a previous defined class MyClass as a singleton. The Singleton class exposes a single function GetInstance() returning a pointer to MyClass. This function creates the single instance of MyClass if it is not already present and registers the DeleteInstance_() function with the atexit() function from the stdlib resulting in automatic destruction of the singleton when the application terminates.
Definition at line 86 of file Singleton.hh.
|
protected |
Definition at line 120 of file Singleton.hh.
|
protected |
Definition at line 125 of file Singleton.hh.
|
protected |
Definition at line 130 of file Singleton.hh.
|
staticprotected |
Definition at line 188 of file Singleton.hh.
References BIAS::SingletonDebugOutput_.
|
static |
Definition at line 152 of file Singleton.hh.
References BIAS::SingletonDebugOutput_.
|
staticprotected |
Definition at line 143 of file Singleton.hh.
|
protected |
Definition at line 135 of file Singleton.hh.
|
staticprotected |
static members
Definition at line 98 of file Singleton.hh.