Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
lifecycle.h
Go to the documentation of this file.
1/*
2 LIFECYCLE.h - interface for registering and triggering lifecycle callbacks
3
4 Copyright (C)
5 2008, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
28#ifndef LUMIERA_LIFECYCLE_H
29#define LUMIERA_LIFECYCLE_H
30
31
32#ifdef __cplusplus
33
34#include "lib/symbol.hpp"
35#include "lib/nocopy.hpp"
36
37
38
39namespace lumiera {
40
41 using lib::Symbol;
42
43 //defined in liblumiera.so
44 extern CStr ON_BASIC_INIT;
45 extern CStr ON_GLOBAL_INIT;
47
48 extern CStr ON_EMERGENCY;
49
50
51 // client code is free to register and use additional lifecycle events
52
53
54
69 {
70 public:
71 typedef void (*Hook)(void);
72
73 LifecycleHook (Symbol eventLabel, Hook callbackFun);
74
76 static void add (Symbol eventLabel, Hook callbackFun);
77
79 static void trigger (Symbol eventLabel);
80 };
81
82
83
84} // namespace lumiera
85
86
87
88#else /* =========== C interface ====================== */
89
90
91//defined in liblumiera.so
92extern const char * lumiera_ON_BASIC_INIT;
93extern const char * lumiera_ON_GLOBAL_INIT;
94extern const char * lumiera_ON_GLOBAL_SHUTDOWN;
95
96
97void lumiera_LifecycleHook_add (const char* eventLabel, void callbackFun(void));
98void lumiera_Lifecycle_trigger (const char* eventLabel);
99
100#endif
101#endif
Token or Atom with distinct identity.
Definition symbol.hpp:120
define and register a callback for a specific lifecycle event.
Definition lifecycle.h:69
static void add(Symbol eventLabel, Hook callbackFun)
alternative, static interface for registering a callback
Definition lifecycle.cpp:60
void(* Hook)(void)
Definition lifecycle.h:71
static void trigger(Symbol eventLabel)
trigger lifecycle callbacks registered under the given label
Definition lifecycle.cpp:72
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
const char * CStr
Definition error.hpp:42
void lumiera_LifecycleHook_add(const char *eventLabel, void callbackFun(void))
const char * lumiera_ON_GLOBAL_SHUTDOWN
Definition lifecycle.cpp:94
void lumiera_Lifecycle_trigger(const char *eventLabel)
const char * lumiera_ON_BASIC_INIT
Definition lifecycle.cpp:92
const char * lumiera_ON_GLOBAL_INIT
Definition lifecycle.cpp:93
Lumiera public interface.
Definition advice.hpp:102
CStr ON_GLOBAL_INIT
to be triggered in main()
CStr ON_GLOBAL_SHUTDOWN
to be triggered at the end of main()
CStr ON_EMERGENCY
activated on shutdown after premature failure of a subsystem
CStr ON_BASIC_INIT
automatic static init. treated specially to run as soon as possible
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.