Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
LifecycleRegistry Class Reference

#include "lib/lifecycleregistry.hpp"

Description

Registry of callback functions accessible by a label (ID) provided at registration.

Registered functions will be added to a list, which can be triggered via label. Used by AppState to implement the lumiera lifecycle (init, shutdown) hooks.

Definition at line 56 of file lifecycleregistry.hpp.

Public Types

typedef void(* Hook) (void)
 
typedef std::set< HookCallbacks
 
typedef Callbacks::iterator Iter
 

Static Public Member Functions

static LifecycleRegistryinstance ()
 get the (single) LifecycleRegistry instance.
 

Public Member Functions

bool enrol (Symbol label, Hook toCall)
 
void execute (Symbol label)
 

Private Member Functions

 LifecycleRegistry ()
 
 ~LifecycleRegistry ()
 
- Private Member Functions inherited from NonCopyable
 ~NonCopyable ()=default
 
 NonCopyable ()=default
 
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

std::map< Symbol, Callbackstable_
 

Constructor & Destructor Documentation

◆ LifecycleRegistry()

LifecycleRegistry ( )
inlineprivate

Definition at line 91 of file lifecycleregistry.hpp.

References LifecycleRegistry::execute(), and lumiera::ON_BASIC_INIT.

+ Here is the call graph for this function:

◆ ~LifecycleRegistry()

~LifecycleRegistry ( )
inlineprivate

Definition at line 95 of file lifecycleregistry.hpp.

Member Typedef Documentation

◆ Hook

typedef void(* Hook) (void)

Definition at line 60 of file lifecycleregistry.hpp.

◆ Callbacks

typedef std::set<Hook> Callbacks

Definition at line 61 of file lifecycleregistry.hpp.

◆ Iter

typedef Callbacks::iterator Iter

Definition at line 62 of file lifecycleregistry.hpp.

Member Function Documentation

◆ enrol()

bool enrol ( Symbol  label,
Hook  toCall 
)
inline
Note
only one copy of each distinct callback remembered

Definition at line 66 of file lifecycleregistry.hpp.

References LifecycleRegistry::table_.

Referenced by LifecycleHook::add().

+ Here is the caller graph for this function:

◆ execute()

void execute ( Symbol  label)
inline

Definition at line 73 of file lifecycleregistry.hpp.

References LifecycleRegistry::table_.

Referenced by LifecycleRegistry::LifecycleRegistry(), lumiera_Lifecycle_trigger(), and LifecycleHook::trigger().

+ Here is the caller graph for this function:

◆ instance()

LifecycleRegistry & instance ( )
static

get the (single) LifecycleRegistry instance.

Warning
don't use it after the end of main()!
Remarks
since the LifecycleRegistry is used to implement the most basic initialisation, we need to ensure it is fully initialised as early as possible. Especially we can not use lib::Depend for that purpose, since the latter needs the LifecycleRegistry to pull up the NoBug-Library. More specifically, if we #include "lib/depend.hpp", on static initialisation the handle planted within that include would invoke DependencyFactory<LifecycleRegistry>, which is defined later in the same header and thus not yet initialised.

Definition at line 41 of file lifecycle.cpp.

Referenced by LifecycleHook::add(), lumiera_Lifecycle_trigger(), and LifecycleHook::trigger().

+ Here is the caller graph for this function:

Member Data Documentation

◆ table_

std::map<Symbol, Callbacks> table_
private

Definition at line 89 of file lifecycleregistry.hpp.

Referenced by LifecycleRegistry::enrol(), and LifecycleRegistry::execute().

+ Inheritance diagram for LifecycleRegistry:
+ Collaboration diagram for LifecycleRegistry:

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