DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SingletonPointer< T > Class Template Reference

"Smart" pointer class for singletons. More...

#include <SingletonPointer.hxx>

Public Member Functions

 SingletonPointer ()
 Constructor.
 
 ~SingletonPointer ()
 Destructor.
 
T * operator-> ()
 Obtaining a normal pointer.
 
const T * operator-> () const
 Obtaining a normal pointer for a const object.
 

Detailed Description

template<class T>
class SingletonPointer< T >

"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:

SINGLETON_POINTER_STATIC(MyClass);

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.


The documentation for this class was generated from the following file: