OGRE: Ogre::Singleton< T > Class Template Reference

| OGRE 14.5 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Ogre::Singleton< T > Class Template Reference
Core » General

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.
static T * | getSingletonPtr (void)
| Get the singleton instance.

## Detailed Description

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

Template class for creating single-instance global classes.

This implementation [bilas2000automatic] 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 parameters 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

References OgreAssert.

## ◆ ~Singleton()

template<typename T>

Ogre::Singleton< T >::~Singleton | ( | void |  | ) |
| inline

## Member Function Documentation

## ◆ getSingleton()

template<typename T>

T & Ogre::Singleton< T >::getSingleton | ( | void |  | ) |
| inlinestatic

Get the singleton instance.

## ◆ getSingletonPtr()

template<typename T>

T * Ogre::Singleton< T >::getSingletonPtr | ( | void |  | ) |
| inlinestatic

Get the singleton instance.

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

- OgreSingleton.h