OGRE  1.12.13
Object-Oriented Graphics Rendering Engine
Ogre::Singleton< T > Class Template Reference

Template class for creating single-instance global classes. More...

#include <OgreSingleton.h>

Public Member Functions

 Singleton (void)
 
 ~Singleton (void)
 

Static Public Member Functions

static T & getSingleton (void)
 Get the singleton instance. More...
 
static T * getSingletonPtr (void)
 Get the singleton instance. More...
 

Detailed Description

template<typename T>
class Ogre::Singleton< T >

Template class for creating single-instance global classes.

This implementation [1] slightly derives from the textbook pattern, by requiring manual instantiation, instead of implicitly doing it in getSingleton. This is useful for classes that want to do some involved initialization, which should be done at a well defined time-point or need some additional parmeters in their constructor.

It also allows you to manage the singleton lifetime through RAII.

Note
Be aware that getSingleton will fail before the global instance is created. (check via getSingletonPtr)

Constructor & Destructor Documentation

◆ Singleton()

template<typename T >
Ogre::Singleton< T >::Singleton ( void  )
inline

◆ ~Singleton()

template<typename T >
Ogre::Singleton< T >::~Singleton ( void  )
inline

Member Function Documentation

◆ getSingleton()

template<typename T >
static T& Ogre::Singleton< T >::getSingleton ( void  )
inlinestatic

Get the singleton instance.

◆ getSingletonPtr()

template<typename T >
static T* Ogre::Singleton< T >::getSingletonPtr ( void  )
inlinestatic

Get the singleton instance.


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