cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Static Public Member Functions
Singleton< T > Class Template Reference

#include <cddefines.h>

Inheritance diagram for Singleton< T >:
Inheritance graph
[legend]

Static Public Member Functions

static T & Inst ()
 

Detailed Description

template<typename T>
class Singleton< T >

Singleton: template to construct classes where a single instance can be accessed across the entire program. Construct your class as follows:

class t_myclass : public Singleton<t_myclass> { friend class Singleton<t_myclass>; protected: t_myclass(); // make sure the contructor is protected! public: long myfunc() const { return 43; } };

and use as follows throughout the code:

long l = t_myclass::Inst().myfunc();

NB NB - This implementation is not threadsafe !!

Definition at line 206 of file cddefines.h.

Member Function Documentation

template<typename T>
static T& Singleton< T >::Inst ( )
inlinestatic

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