Singleton Class Template Reference

#include <Singleton.h>

List of all members.


Detailed Description

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

Template class Singleton is the base for classes that follow the singleton pattern.

It is used as follows.

 class TheRulbusDeviceList : public Singleton<TheRulbusDeviceList>
 {
    friend class Singleton<TheRulbusDeviceList>;

    // implementation
 };

If the instance cannot be created via the default constructor, static function instance() must be overridden to create the (single) instance, for example:

 inline TheRulbusInterfaceRef TheRulbusInterface::instance()
 {
    if ( 0 == theInstance )
    {
       theInstance = RulbusInterfaceFactory::createInterface();
    }

    return *theInstance;
 }


Static Public Member Functions

T & instance ()
 return the instance, creating it if necessary.


Static Protected Attributes

T * theInstance = 0
 the single instance.


The documentation for this class was generated from the following file:
Generated on Tue Oct 12 14:12:06 2004 for Rulbus Device Class Library for Microsoft Windows by doxygen 1.3.4