Lumiera  0.pre.03
»edit your freedom«
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 std::set< Hook > Callbacks
 
typedef void(* Hook) (void)
 
typedef Callbacks::iterator Iter
 

Public Member Functions

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

Static Public Member Functions

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

Private Attributes

std::map< Symbol, Callbacks > table_
 

Additional Inherited Members

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

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::instance(), and lumiera::ON_BASIC_INIT.

Referenced by LifecycleHook::add().

+ Here is the call graph for this function:
+ 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(), LifecycleRegistry::enrol(), and LifecycleHook::trigger().

+ Here is the caller graph for this function:
+ Inheritance diagram for LifecycleRegistry:
+ Collaboration diagram for LifecycleRegistry:

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