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

#include "include/lifecycle.h"

Description

define and register a callback for a specific lifecycle event.

The purpose of this class is to be defined as a static variable in the implementation of some subsystem (i.e. in the cpp file), providing the ctor with the pointer to a callback function. Thus the specified callback gets enrolled when the corresponding object file is loaded. The event ON_BASIC_INIT is handled specifically, firing off the referred callback function as soon as possible. All other labels are just arbitrary (string) constants and it is necessary that "someone" cares to fire off the lifecycle events at the right place. For example, lumiera-main (and the test runner) calls LifecycleHook::trigger(ON_GLOBAL_INIT) (and..SHUTDOWN)

Note
duplicate or repeated calls with the same callback are NOP

Definition at line 67 of file lifecycle.h.

Public Types

typedef void(* Hook) (void)
 

Static Public Member Functions

static void add (Symbol eventLabel, Hook callbackFun)
 alternative, static interface for registering a callback
 
static void trigger (Symbol eventLabel)
 trigger lifecycle callbacks registered under the given label
 

Public Member Functions

 LifecycleHook (Symbol eventLabel, Hook callbackFun)
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ LifecycleHook()

LifecycleHook ( Symbol  eventLabel,
Hook  callbackFun 
)

Definition at line 54 of file lifecycle.cpp.

References LifecycleHook::add().

+ Here is the call graph for this function:

Member Typedef Documentation

◆ Hook

typedef void(* Hook) (void)

Definition at line 71 of file lifecycle.h.

Member Function Documentation

◆ add()

void add ( Symbol  eventLabel,
Hook  callbackFun 
)
static

alternative, static interface for registering a callback

Definition at line 60 of file lifecycle.cpp.

References LifecycleRegistry::enrol(), LifecycleRegistry::instance(), and lumiera::ON_BASIC_INIT.

Referenced by LifecycleHook::LifecycleHook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trigger()

void trigger ( Symbol  eventLabel)
static

trigger lifecycle callbacks registered under the given label

Definition at line 72 of file lifecycle.cpp.

References LifecycleRegistry::execute(), and LifecycleRegistry::instance().

Referenced by AppState::abort(), LifecycleAdvisor::emitEvent(), AppState::init(), main(), AppState::maybeWait(), STypeManager::reset(), and LifeCycle_test::run().

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

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