profiler  0.0
molpro::profiler::WeakSingleton< Object > Struct Template Reference

Implements the mechanism for the weak singleton pattern. More...

#include <WeakSingleton.h>

Public Types

using key_t = std::tuple< std::string, std::weak_ptr< Object >, Object * >
 

Public Member Functions

std::list< WeakSingleton< Profiler >::key_tm_register
 

Static Public Member Functions

template<typename... T>
static std::shared_ptr< Object > single (const std::string &key, T &&... constructor_args)
 Creates an instance of Object or returns an already registered instance. More...
 
static std::shared_ptr< Object > single ()
 Access the last registered object. More...
 
static void erase (Object *obj)
 Remove object from the register. This should be called in the destructor of class that exposes this pattern. More...
 
static void erase (const std::string &key)
 Remove object registered under the name key. More...
 
static void clear ()
 Remove all registered objects. More...
 

Static Public Attributes

static std::list< key_tm_register
 stores all objects created by a call to single More...
 

Detailed Description

template<class Object>
struct molpro::profiler::WeakSingleton< Object >

Implements the mechanism for the weak singleton pattern.

Member Typedef Documentation

◆ key_t

template<class Object >
using molpro::profiler::WeakSingleton< Object >::key_t = std::tuple<std::string, std::weak_ptr<Object>, Object*>

Member Function Documentation

◆ clear()

template<class Object >
static void molpro::profiler::WeakSingleton< Object >::clear ( )
inlinestatic

Remove all registered objects.

◆ erase() [1/2]

template<class Object >
static void molpro::profiler::WeakSingleton< Object >::erase ( const std::string &  key)
inlinestatic

Remove object registered under the name key.

◆ erase() [2/2]

template<class Object >
static void molpro::profiler::WeakSingleton< Object >::erase ( Object *  obj)
inlinestatic

Remove object from the register. This should be called in the destructor of class that exposes this pattern.

◆ m_register()

◆ single() [1/2]

template<class Object >
static std::shared_ptr<Object> molpro::profiler::WeakSingleton< Object >::single ( )
inlinestatic

Access the last registered object.

◆ single() [2/2]

template<class Object >
template<typename... T>
static std::shared_ptr<Object> molpro::profiler::WeakSingleton< Object >::single ( const std::string &  key,
T &&...  constructor_args 
)
inlinestatic

Creates an instance of Object or returns an already registered instance.

Parameters
constructor_argsarguments that should be passed to the constructor

Member Data Documentation

◆ m_register

template<class Object >
std::list<key_t> molpro::profiler::WeakSingleton< Object >::m_register
static

stores all objects created by a call to single