SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
sutil::CSingleton< SDataStruct > Class Template Reference

#include <CSingleton.hpp>

Collaboration diagram for sutil::CSingleton< SDataStruct >:
Collaboration graph

Public Member Functions

virtual ~CSingleton ()

Static Public Member Functions

static SDataStruct * getData ()
static bool resetData ()

Protected Attributes

SDataStruct data_

Static Protected Attributes

static CSingletonsingleton_ = 0

Private Member Functions

 CSingleton ()
 CSingleton (const CSingleton &)
CSingletonoperator= (const CSingleton &)

Detailed Description

template<typename SDataStruct>
class sutil::CSingleton< SDataStruct >

Use this to create a singleton with any given data type

Works quite well to implement the 'Singleton', a shared data structure that allows different threads in a program to communicate efficiently.

Constructor & Destructor Documentation

template<typename SDataStruct >
sutil::CSingleton< SDataStruct >::~CSingleton ( )

Default destructor : Deletes the singleton instance if it exists

template<typename SDataStruct>
sutil::CSingleton< SDataStruct >::CSingleton ( )

Private constructor : for the singleton

template<typename SDataStruct>
sutil::CSingleton< SDataStruct >::CSingleton ( const CSingleton< SDataStruct > &  )

Private constructor : for the singleton

Member Function Documentation

template<typename SDataStruct >
SDataStruct * sutil::CSingleton< SDataStruct >::getData ( )

Creates a singleton if necessary and returns it.

Returns a pointer instead of a reference to support a 0 return when there is an error

template<typename SDataStruct>
CSingleton& sutil::CSingleton< SDataStruct >::operator= ( const CSingleton< SDataStruct > &  )

Private operator : for the singleton

template<typename SDataStruct >
bool sutil::CSingleton< SDataStruct >::resetData ( )

Deletes the singleton instance and creates a new one.

Member Data Documentation

template<typename SDataStruct>
SDataStruct sutil::CSingleton< SDataStruct >::data_

Shared Memory: The publicly available data that will be shared across the different subsystems

template<typename SDataStruct>
CSingleton< SDataStruct > * sutil::CSingleton< SDataStruct >::singleton_ = 0

The singleton instance

This initializes the pointer to null

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