Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Singleton< T > Class Template Reference

#include <Singleton.hh>

List of all members.


Detailed Description

template<class T>
class Singleton< T >

base class for all singleton classes

This is a base class for all classes that use the singleton pattern.


Static Public Member Functions

void destroy (void)
 Destroy the singleton class instance.

T * instance (void)
 Return a pointer to the singleton class instance.


Protected Member Functions

 Singleton (void)

Related Functions

(Note that these are not member functions.)

 SINGLETON_IMPL(T)
 Macro for implementing a singleton class.

 SINGLETON_DECL(T)
 Macro for defining a singleton class.

 SINGLETON_DECL2(T, S)
 Macro for defining a singleton class which has a single superclass.


Constructor & Destructor Documentation

template<class T>
Singleton< T >::Singleton void   )  [inline, protected]
 

This constructor is defined protected to prevent explicit creation of the class instance by others.


Member Function Documentation

template<class T>
void Singleton< T >::destroy void   )  [inline, static]
 

Destroy the singleton class instance.

This method destroys the single instance of the derived class. This method is important for proper destruction of the singleton instance. It must be called externally somewhere to ensure that the instance is destroyed before program exit.

template<class T>
T* Singleton< T >::instance void   )  [inline, static]
 

Return a pointer to the singleton class instance.

This method returns a pointer to the single instance of the singleton class. If it had not been [previously created, it creates the instance.


Friends And Related Function Documentation

template<class T>
SINGLETON_DECL  )  [related]
 

Macro for defining a singleton class.

Does the C++ template magic to declare a class T as a singleton class.

Parameters:
T The singleton class being declared

template<class T>
SINGLETON_DECL2 T,
 )  [related]
 

Macro for defining a singleton class which has a single superclass.

Does the C++ template magic to declare a class T, which is a subclass of class S, as a singleton class.

Parameters:
T The singleton class being declared
S Its superclass

template<class T>
SINGLETON_IMPL  )  [related]
 

Macro for implementing a singleton class.

Does the C++ magic necessary to implement class T as a singleton class. This must be in exactly one source file for each singleton class in order to implement the various static member variables of the interface.

Parameters:
T The singleton class being implemented


SimLib Reference Documentation