Currenton< C > Class Template Reference

A 'Currenton' allows access to the currently active instance of a class via the static current() function. More...

#include <currenton.hpp>

List of all members.

Static Public Member Functions

static C * current ()

Protected Member Functions

 Currenton ()
virtual ~Currenton ()

Static Private Attributes

static C * s_current


Detailed Description

template<class C>
class Currenton< C >

A 'Currenton' allows access to the currently active instance of a class via the static current() function.

It is kind of like a singleton, but without handling the object construction itself or in other words its a glorified global variable that points to the current instance of a class.

Definition at line 32 of file currenton.hpp.


Constructor & Destructor Documentation

template<class C>
Currenton< C >::Currenton (  )  [inline, protected]

Definition at line 38 of file currenton.hpp.

00039   { 
00040     // FIXME: temporarly disabled, as Sector() for the main menu,
00041     // doesn't get cleaned up before a real Sector() starts
00042     // assert(!s_current); 
00043     s_current = static_cast<C*>(this); 
00044   }

template<class C>
virtual Currenton< C >::~Currenton (  )  [inline, protected, virtual]

Definition at line 46 of file currenton.hpp.

00047   {
00048     s_current = 0; 
00049   }


Member Function Documentation

template<class C>
static C* Currenton< C >::current (  )  [inline, static]

Reimplemented in Sector.

Definition at line 52 of file currenton.hpp.

00052 { return s_current; }


Member Data Documentation

template<class C>
C * Currenton< C >::s_current [static, private]

Definition at line 35 of file currenton.hpp.

Referenced by Currenton< GameSession >::current(), Currenton< GameSession >::Currenton(), and Currenton< GameSession >::~Currenton().


The documentation for this class was generated from the following file:
Generated on Mon Jun 9 03:38:29 2014 for SuperTux by  doxygen 1.5.1