DUECA/DUSIME
|
"Smart" pointer class for singletons. More...
#include <SingletonPointer.hxx>
"Smart" pointer class for singletons.
Each of the singleton references will point to one and the same object. This object should have a private default constructor, and a private destructor, and list SingletonPointer<MyClass> as its friend. This class is useful for controlling access to hardware devices.
In your code body, add the static objects needed for this construction by using the following macro:
Of course, replace "MyClass" by the name of your class.
Note that this is not multi-thread proof. However, since any sane person will create and delete the singleton pointers in single thread mode (DUECA Module constructors and destructors), this should be no problem.
You should not use the SingletonPointer constructor and destructor in functions, as this might lead to repeated construction and destruction of the singleton class.