GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
GpgFrontend::SingletonFunctionObject< T > Class Template Reference

#include <GpgFunctionObject.h>

Inheritance diagram for GpgFrontend::SingletonFunctionObject< T >:
Inheritance graph
Collaboration diagram for GpgFrontend::SingletonFunctionObject< T >:
Collaboration graph

Public Member Functions

int GetChannel () const
 Get the Channel object. More...
 
 SingletonFunctionObject (T &&)=delete
 Construct a new Singleton Function Object object. More...
 
 SingletonFunctionObject (const T &)=delete
 Construct a new Singleton Function Object object. More...
 
void operator= (const T &)=delete
 

Static Public Member Functions

static T & GetInstance (int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
 Get the Instance object. More...
 
static T & CreateInstance (int channel, std::function< std::unique_ptr< T >(void)> factory)
 Create a Instance object. More...
 
static T & CreateInstance (int channel, std::unique_ptr< T > p_obj=nullptr)
 Create a Instance object. More...
 
static T & ReleaseChannel (int channel)
 
static int GetDefaultChannel ()
 Get the Default Channel object. More...
 

Protected Member Functions

 SingletonFunctionObject ()=default
 Construct a new Singleton Function Object object. More...
 
 SingletonFunctionObject (int channel)
 Construct a new Singleton Function Object object. More...
 
virtual ~SingletonFunctionObject ()=default
 Destroy the Singleton Function Object object. More...
 
void SetChannel (int channel)
 Set the Channel object. More...
 

Static Private Member Functions

static T * find_object_in_channel (int channel)
 
static T * set_object_in_channel (int channel, std::unique_ptr< T > p_obj)
 Set the object in channel object. More...
 

Private Attributes

int channel_ = _default_channel
 

Static Private Attributes

static int _default_channel
 
static std::mutex _instance_mutex
 
static std::shared_mutex _instances_mutex
 
static std::unique_ptr< T > _instance = nullptr
 
static std::map< int, std::unique_ptr< T > > _instances_map
 

Detailed Description

template<typename T>
class GpgFrontend::SingletonFunctionObject< T >

Template Parameters
T

Constructor & Destructor Documentation

◆ SingletonFunctionObject() [1/4]

template<typename T >
GpgFrontend::SingletonFunctionObject< T >::SingletonFunctionObject ( T &&  )
delete

Construct a new Singleton Function Object object.

◆ SingletonFunctionObject() [2/4]

template<typename T >
GpgFrontend::SingletonFunctionObject< T >::SingletonFunctionObject ( const T &  )
delete

Construct a new Singleton Function Object object.

◆ SingletonFunctionObject() [3/4]

template<typename T >
GpgFrontend::SingletonFunctionObject< T >::SingletonFunctionObject ( )
protecteddefault

Construct a new Singleton Function Object object.

◆ SingletonFunctionObject() [4/4]

template<typename T >
GpgFrontend::SingletonFunctionObject< T >::SingletonFunctionObject ( int  channel)
inlineexplicitprotected

Construct a new Singleton Function Object object.

Parameters
channel

◆ ~SingletonFunctionObject()

template<typename T >
virtual GpgFrontend::SingletonFunctionObject< T >::~SingletonFunctionObject ( )
protectedvirtualdefault

Destroy the Singleton Function Object object.

Member Function Documentation

◆ CreateInstance() [1/2]

template<typename T >
static T& GpgFrontend::SingletonFunctionObject< T >::CreateInstance ( int  channel,
std::function< std::unique_ptr< T >(void)>  factory 
)
inlinestatic

Create a Instance object.

Parameters
channel
factory
Returns
T&

◆ CreateInstance() [2/2]

template<typename T >
static T& GpgFrontend::SingletonFunctionObject< T >::CreateInstance ( int  channel,
std::unique_ptr< T >  p_obj = nullptr 
)
inlinestatic

Create a Instance object.

Parameters
channel
p_obj
Returns
T&

◆ find_object_in_channel()

template<typename T >
static T* GpgFrontend::SingletonFunctionObject< T >::find_object_in_channel ( int  channel)
inlinestaticprivate

◆ GetChannel()

template<typename T >
int GpgFrontend::SingletonFunctionObject< T >::GetChannel ( ) const
inline

Get the Channel object.

Returns
int

◆ GetDefaultChannel()

template<typename T >
static int GpgFrontend::SingletonFunctionObject< T >::GetDefaultChannel ( )
inlinestatic

Get the Default Channel object.

Returns
int

◆ GetInstance()

template<typename T >
static T& GpgFrontend::SingletonFunctionObject< T >::GetInstance ( int  channel = GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
inlinestatic

Get the Instance object.

Parameters
channel
Returns
T&

◆ ReleaseChannel()

template<typename T >
static T& GpgFrontend::SingletonFunctionObject< T >::ReleaseChannel ( int  channel)
inlinestatic
Parameters
channel
Returns
T&

◆ set_object_in_channel()

template<typename T >
static T* GpgFrontend::SingletonFunctionObject< T >::set_object_in_channel ( int  channel,
std::unique_ptr< T >  p_obj 
)
inlinestaticprivate

Set the object in channel object.

Parameters
channel
p_obj
Returns
T*

Referenced by GpgFrontend::SingletonFunctionObject< GpgContext >::CreateInstance(), and GpgFrontend::SingletonFunctionObject< GpgContext >::GetInstance().

◆ SetChannel()

template<typename T >
void GpgFrontend::SingletonFunctionObject< T >::SetChannel ( int  channel)
inlineprotected

Set the Channel object.

Parameters
channel

Member Data Documentation

◆ _default_channel

template<typename T >
int GpgFrontend::SingletonFunctionObject< T >::_default_channel
staticprivate
Initial value:
=
GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL

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