SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Static Public Member Functions | Protected Member Functions | Static Protected Attributes | Private Member Functions | List of all members
ThreadSafeSingleton< S > Class Template Reference

Template class used to make from a class a singleton. More...

#include <threadsafesingleton.h>

Static Public Member Functions

static S & instance ()
 

Protected Member Functions

 ThreadSafeSingleton ()
 
 ~ThreadSafeSingleton ()
 

Static Protected Attributes

static S * _pInstance = new S
 

Private Member Functions

 ThreadSafeSingleton (const ThreadSafeSingleton &)
 
ThreadSafeSingletonoperator= (const ThreadSafeSingleton &)
 

Detailed Description

template<class S>
class ThreadSafeSingleton< S >

Template class used to make from a class a singleton.

S is the type of the singleton object to instantiate.
This class permits to gather all singleton code in the same place and not to pollute object interface with singleton methods.
Accessing to the instance of S is made through ThreadSafeSingleton<S>::instance()
Note : The class using this adapter should have constructor and destructor protected and copy constructor and operator= private.
Besides it should declare the class ThreadSafeSingleton<S> friend in order this class can make the construction.

Definition at line 22 of file threadsafesingleton.h.

Constructor & Destructor Documentation

◆ ThreadSafeSingleton() [1/2]

template<class S >
ThreadSafeSingleton< S >::ThreadSafeSingleton ( )
inlineprotected

Definition at line 28 of file threadsafesingleton.h.

28 {}

◆ ~ThreadSafeSingleton()

template<class S >
ThreadSafeSingleton< S >::~ThreadSafeSingleton ( )
inlineprotected

Definition at line 29 of file threadsafesingleton.h.

References ThreadSafeSingleton< S >::_pInstance.

29 { delete _pInstance; }

◆ ThreadSafeSingleton() [2/2]

template<class S >
ThreadSafeSingleton< S >::ThreadSafeSingleton ( const ThreadSafeSingleton< S > &  )
inlineprivate

Definition at line 33 of file threadsafesingleton.h.

33 {}

Member Function Documentation

◆ instance()

template<class S >
static S& ThreadSafeSingleton< S >::instance ( )
inlinestatic

Definition at line 25 of file threadsafesingleton.h.

References ThreadSafeSingleton< S >::_pInstance.

25 { return *_pInstance; }

◆ operator=()

template<class S >
ThreadSafeSingleton& ThreadSafeSingleton< S >::operator= ( const ThreadSafeSingleton< S > &  )
inlineprivate

Definition at line 34 of file threadsafesingleton.h.

34 {return *this;}

Member Data Documentation

◆ _pInstance

template<class S >
S * ThreadSafeSingleton< S >::_pInstance = new S
staticprotected

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