Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel > Class Template Reference

#include <Singleton.h>

Static Public Member Functions

static T & instance ()
 Provide access to the singleton instance. More...
 

Private Member Functions

Singletonoperator= (const Singleton &)
 Forbid assignment. More...
 
 Singleton ()
 Forbid creation. More...
 
 Singleton (const Singleton &)
 Forbid copy-construction. More...
 
 ~Singleton ()
 Forbid deletion. More...
 

Static Private Member Functions

static void destroySingleton ()
 Helper for destroying the instance. More...
 

Static Private Attributes

static bool m_destroyed = false
 Indicates whether the instance has been destroyed. More...
 
static T * m_instance = NULL
 The singleton instance. More...
 
static TThreadingModel< T >::Lock m_lock
 The lock for synchronizing instantiation. Must be default-constructable. More...
 

Detailed Description

template<class T, template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
class icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >

A generic, policy-based singleton.

Parameters
TThe class for which to maintain a singleton instance.
TCreationPolicyA policy for creating the instance, to allow for different allocators.
See also
SingletonCreationPolicies.h
Parameters
TLifetimePolicyA policy for managing the instance's lifetime, to control whether, when and how to destroy the instance.
See also
SingletonLifetimePolicies.h
Parameters
TThreadingModelA policy for managing thread safety. The standard model provided in icl_core is for single-threaded use only. Thread-safe implementations can be found in icl_core_logging and icl_core_thread.
See also
SingletonThreadingModels.h

Definition at line 55 of file Singleton.h.

Constructor & Destructor Documentation

template<class T , template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::Singleton ( )
private

Forbid creation.

template<class T , template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::~Singleton ( )
private

Forbid deletion.

template<class T , template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::Singleton ( const Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel > &  )
private

Forbid copy-construction.

Member Function Documentation

template<class T , template< class > class TCreationPolicy, template< class > class TLifetimePolicy, template< class > class TThreadingModel>
void icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::destroySingleton ( )
staticprivate

Helper for destroying the instance.

Definition at line 64 of file Singleton.hpp.

template<class T , template< class > class TCreationPolicy, template< class > class TLifetimePolicy, template< class > class TThreadingModel>
T & icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::instance ( )
static

Provide access to the singleton instance.

Definition at line 37 of file Singleton.hpp.

template<class T , template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
Singleton& icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::operator= ( const Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel > &  )
private

Forbid assignment.

Member Data Documentation

template<class T , template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
bool icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::m_destroyed = false
staticprivate

Indicates whether the instance has been destroyed.

Definition at line 76 of file Singleton.h.

template<class T , template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
T * icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::m_instance = NULL
staticprivate

The singleton instance.

Definition at line 74 of file Singleton.h.

template<class T , template< class > class TCreationPolicy = SCPCreateUsingNew, template< class > class TLifetimePolicy = SLPDefaultLifetime, template< class > class TThreadingModel = STMSingleThreaded>
TThreadingModel< T >::Lock icl_core::Singleton< T, TCreationPolicy, TLifetimePolicy, TThreadingModel >::m_lock
staticprivate

The lock for synchronizing instantiation. Must be default-constructable.

Definition at line 78 of file Singleton.h.


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


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:59