Orxonox
0.0.5 Codename: Arcturus
|
Definition of the Singleton template that is used as base class for classes that allow only one instance. More...
Go to the source code of this file.
Classes | |
class | orxonox::Singleton< T > |
Base for singleton classes. More... | |
Namespaces | |
orxonox | |
Die Wagnis Klasse hat die folgenden Aufgaben: | |
Definition of the Singleton template that is used as base class for classes that allow only one instance.
Classes that inherit from orxonox::Singleton follow the singleton pattern and thus allow only one instance of the class to exist. This istance is stored in a static variable called singletonPtr_s
. orxonox::Singleton will access this variable, but it must be implemented in the deriving class.
Example:
And don't forget to initialize the static singleton pointer in the source (*.cc) file:
If a class inherits from orxonox::Singleton, it also inherits its functions. The most important function is orxonox::Singleton::getInstance() which returns a reference to the only instance of the singleton.
Example: