#include <utils.h>
Inheritance diagram for hoa_utils::Singleton< T >:


Public Member Functions | |
| virtual bool | SingletonInitialize ()=0 |
| A method for the inheriting class to implement, which initializes the class. | |
Static Public Member Functions | |
| static T * | SingletonCreate () |
| Creates and returns an instance of the singleton class. | |
| static void | SingletonDestroy () |
| Destroys the singleton class instance. | |
| static const T * | SingletonGetReference () |
| Returns a pointer to the singleton class instance (or NULL if the class is not instantiated). | |
Protected Member Functions | |
| Singleton () | |
| virtual | ~Singleton () |
Static Protected Attributes | |
| static T * | _singleton_reference |
| A reference to the singleton class instance itself. | |
Private Member Functions | |
| Singleton & | operator= (const Singleton &s) |
| Singleton (const Singleton &s) | |
****************************************************************************
This is a templated abstract class which classes may derive from to become singleton classes. To create a new singleton type class, follow the steps below. It is assumed that the desired class is called "ClassName".
With this done, your new class should be ready to go. To create and use a singleton class, do the following:
Sometimes singleton classes need to refer to each other to initialize themselves, particularly with game engine components. That is the purpose of the SingletonInitialize() method, so that all the singleton objects can be created and then reference each other when this method is invoked. It can be viewed as a helper function to the class constructor.
For engine singleton classes, SingletonCreate(), SingletonDestroy(), and SingletonInitialize() should only be called in main.cpp before the main game loop. There may be qualified exceptions to this practice, however.
Most of our singleton classes also define a pointer to their singleton object inside the source file of the class. For example, the GameAudio singleton contains the AudioManager class object name inside the hoa_audio namespace. Therefore you do not need to call the SingletonGetReference() function when this object is made available.
Definition at line 280 of file utils.h.
| hoa_utils::Singleton< T >::Singleton | ( | ) | [inline, protected] |
| virtual hoa_utils::Singleton< T >::~Singleton | ( | ) | [inline, protected, virtual] |
| hoa_utils::Singleton< T >::Singleton | ( | const Singleton< T > & | s | ) | [private] |
| Singleton& hoa_utils::Singleton< T >::operator= | ( | const Singleton< T > & | s | ) | [private] |
| static T* hoa_utils::Singleton< T >::SingletonCreate | ( | ) | [inline, static] |
Creates and returns an instance of the singleton class.
Definition at line 293 of file utils.h.
Referenced by main(), and hoa_main::PrintSystemInformation().
| static void hoa_utils::Singleton< T >::SingletonDestroy | ( | ) | [inline, static] |
Destroys the singleton class instance.
Definition at line 305 of file utils.h.
Referenced by hoa_main::PrintSystemInformation(), and hoa_video::GameVideo::~GameVideo().
| static const T* hoa_utils::Singleton< T >::SingletonGetReference | ( | ) | [inline, static] |
| virtual bool hoa_utils::Singleton< T >::SingletonInitialize | ( | ) | [pure virtual] |
A method for the inheriting class to implement, which initializes the class.
Implemented in hoa_audio::GameAudio, hoa_input::GameInput, hoa_mode_manager::GameModeManager, hoa_script::GameScript, hoa_system::GameSystem, hoa_video::private_video::GUISupervisor, hoa_video::GameVideo, and hoa_global::GameGlobal.
T* hoa_utils::Singleton< T >::_singleton_reference [static, protected] |
A reference to the singleton class instance itself.
Definition at line 283 of file utils.h.
Referenced by hoa_utils::Singleton< hoa_mode_manager::GameModeManager >::SingletonCreate(), hoa_utils::Singleton< hoa_mode_manager::GameModeManager >::SingletonDestroy(), and hoa_utils::Singleton< hoa_mode_manager::GameModeManager >::SingletonGetReference().
1.5.1