Geant4  10.07
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Singleton< Type, PointerT > Class Template Reference

Singleton object that allows a deleter class to be specified. More...

Classes

struct  persistent_data
 

Public Types

using this_type = Singleton< Type, PointerT >
 
using thread_id_t = std::thread::id
 
using mutex_t = std::recursive_mutex
 
using auto_lock_t = std::unique_lock< mutex_t >
 
using pointer = Type *
 
using list_t = std::set< pointer >
 
using smart_pointer = PointerT
 
using deleter_t = std::function< void(PointerT &)>
 
template<bool B, typename T = int>
using enable_if_t = typename std::enable_if< B, T >::type
 

Public Member Functions

 Singleton ()
 
 Singleton (pointer)
 
 ~Singleton ()
 
 Singleton (const Singleton &)=delete
 
 Singleton (Singleton &&)=delete
 
Singletonoperator= (const Singleton &)=delete
 
Singletonoperator= (Singleton &&)=delete
 
void Initialize ()
 
void Initialize (pointer)
 
void Destroy ()
 
void Reset (pointer)
 
void Reset ()
 
voidoperator new (size_t)
 
void operator delete (void *ptr)
 

Static Public Member Functions

static pointer GetInstance ()
 
static pointer GetMasterInstance ()
 
static thread_id_t GetMasterThreadID ()
 
static list_t Children ()
 
static bool IsMaster (pointer ptr)
 
static bool IsMasterThread ()
 
static void Insert (pointer)
 
static void Remove (pointer)
 
static mutex_tGetMutex ()
 

Protected Member Functions

smart_pointerGetSmartInstance ()
 
pointer GetRawInstance ()
 

Static Protected Member Functions

static smart_pointerGetSmartMasterInstance ()
 
static pointer GetRawMasterInstance ()
 

Private Member Functions

voidoperator new[] (std::size_t) noexcept
 
void operator delete[] (void *) noexcept
 
template<typename Tp = Type, typename PtrT = PointerT>
deleter_tGetDeleter ()
 
template<typename Tp = Type, typename PtrT = PointerT>
deleter_tGetDeleter ()
 

Static Private Member Functions

static smart_pointer_local_instance ()
 
static smart_pointer_master_instance ()
 
static thread_id_tf_master_thread ()
 
static mutex_tf_mutex ()
 
static pointerf_master_instance ()
 
static list_tf_children ()
 
static persistent_dataf_persistent_data ()
 

Private Attributes

bool m_IsMaster = false
 

Friends

class Type
 

Detailed Description

template<typename Type, typename PointerT = std::unique_ptr<Type, std::default_delete<Type>>>
class PTL::Singleton< Type, PointerT >

Singleton object that allows a deleter class to be specified.

Member Typedef Documentation

using this_type = Singleton<Type, PointerT>
using thread_id_t = std::thread::id
using mutex_t = std::recursive_mutex
using auto_lock_t = std::unique_lock<mutex_t>
using pointer = Type*
using list_t = std::set<pointer>
using smart_pointer = PointerT
using deleter_t = std::function<void(PointerT&)>
using enable_if_t = typename std::enable_if<B, T>::type

Constructor & Destructor Documentation

Singleton ( )
Singleton ( pointer  ptr)
~Singleton ( )
Singleton ( const Singleton< Type, PointerT > &  )
delete
Singleton ( Singleton< Type, PointerT > &&  )
delete

Member Function Documentation

Singleton& operator= ( const Singleton< Type, PointerT > &  )
delete
Singleton& operator= ( Singleton< Type, PointerT > &&  )
delete
Singleton< Type, PointerT >::pointer GetInstance ( )
static

References JA::Insert().

Singleton< Type, PointerT >::pointer GetMasterInstance ( )
static
static thread_id_t GetMasterThreadID ( )
static
static list_t Children ( )
static
static bool IsMaster ( pointer  ptr)
static
bool IsMasterThread ( )
static
void Insert ( pointer  itr)
static
void Remove ( pointer  itr)
static
static mutex_t& GetMutex ( )
static
void Initialize ( )
void Initialize ( pointer  ptr)
void Destroy ( )
void Reset ( pointer  ptr)
void Reset ( )
void* operator new ( size_t  )
smart_pointer& GetSmartInstance ( )
protected
static smart_pointer& GetSmartMasterInstance ( )
staticprotected
static pointer GetRawMasterInstance ( )
staticprotected
static smart_pointer& _master_instance ( )
staticprivate
void* operator new[] ( std::size_t  )
privatenoexcept
void operator delete[] ( void )
privatenoexcept
deleter_t& GetDeleter ( )
private
deleter_t& GetDeleter ( )
private
Singleton< Type, PointerT >::mutex_t & f_mutex ( )
staticprivate
Singleton< Type, PointerT >::list_t & f_children ( )
staticprivate
static persistent_data& f_persistent_data ( )
staticprivate

Friends And Related Function Documentation

friend class Type
friend

Member Data Documentation

bool m_IsMaster = false
private