ODIN
Public Member Functions | List of all members
SingletonHandler< T, thread_safe > Class Template Reference

#include <tjhandler.h>

Inheritance diagram for SingletonHandler< T, thread_safe >:
Inheritance graph
[legend]

Public Member Functions

void init (const char *unique_label)
 
void destroy ()
 
void copy (T &destination) const
 
T * unlocked_ptr ()
 
LockProxy< T > operator-> ()
 
const T * operator-> () const
 
 operator bool () const
 

Detailed Description

template<class T, bool thread_safe>
class SingletonHandler< T, thread_safe >

Template class to manage singleton objects of type T, i.e. those objects which are exist only once in the program. The instantiation must be a static field of of a certain class. The init/destroy member functions are used to create/destroy the singleton. If 'thread_safe' is set to 'true', use a mutex to manage multi-threaded access to the singleton object.

Its main purpose is to share singletons across DLL boundaries on Windows and/or thread-safe access to global resources. This class has an pointer-to-T-like interface.

Definition at line 166 of file tjhandler.h.

Member Function Documentation

◆ copy()

template<class T , bool thread_safe>
void SingletonHandler< T, thread_safe >::copy ( T &  destination) const

Copies this to 'destination'

Definition at line 127 of file tjhandler_code.h.

◆ destroy()

template<class T , bool thread_safe>
void SingletonHandler< T, thread_safe >::destroy

Deletes the singleton

Definition at line 120 of file tjhandler_code.h.

◆ init()

template<class T , bool thread_safe>
void SingletonHandler< T, thread_safe >::init ( const char *  unique_label)

Initialize the singleton with the unique identifier 'unique_label'. The singleton object will be allocated if it does not already exist somewhere in the program.

Definition at line 104 of file tjhandler_code.h.

◆ operator bool()

template<class T , bool thread_safe>
SingletonHandler< T, thread_safe >::operator bool ( ) const
inline

Returns whether singleton is already initialized

Definition at line 214 of file tjhandler.h.

◆ operator->() [1/2]

template<class T , bool thread_safe>
LockProxy<T> SingletonHandler< T, thread_safe >::operator-> ( )
inline

Returns mutex-locked pointer to handled singleton

Definition at line 204 of file tjhandler.h.

◆ operator->() [2/2]

template<class T , bool thread_safe>
const T* SingletonHandler< T, thread_safe >::operator-> ( ) const
inline

Returns read-only pointer to handled singleton

Definition at line 209 of file tjhandler.h.

◆ unlocked_ptr()

template<class T , bool thread_safe>
T* SingletonHandler< T, thread_safe >::unlocked_ptr ( )
inline

Returns unlocked ptr to object (know what you are doing)

Definition at line 196 of file tjhandler.h.


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