Lumiera  0.pre.03
»edit your freedom«
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 
39 namespace lumiera {
40 
41  using lib::Symbol;
42 
43  //defined in liblumiera.so
44  extern const char * ON_BASIC_INIT;
45  extern const char * ON_GLOBAL_INIT;
46  extern const char * ON_GLOBAL_SHUTDOWN;
47 
48  extern const char * 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
92 extern const char * lumiera_ON_BASIC_INIT;
93 extern const char * lumiera_ON_GLOBAL_INIT;
94 extern const char * lumiera_ON_GLOBAL_SHUTDOWN;
95 
96 
97 void lumiera_LifecycleHook_add (const char* eventLabel, void callbackFun(void));
98 void lumiera_Lifecycle_trigger (const char* eventLabel);
99 
100 #endif
101 #endif
const char * ON_BASIC_INIT
automatic static init. treated specially to run as soon as possible
const char * ON_GLOBAL_SHUTDOWN
to be triggered at the end of main()
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
static void add(Symbol eventLabel, Hook callbackFun)
alternative, static interface for registering a callback
Definition: lifecycle.cpp:60
static void trigger(Symbol eventLabel)
trigger lifecycle callbacks registered under the given label
Definition: lifecycle.cpp:72
Token or Atom with distinct identity.
Definition: symbol.hpp:117
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
const char * ON_GLOBAL_INIT
to be triggered in main()
define and register a callback for a specific lifecycle event.
Definition: lifecycle.h:67
Lumiera public interface.
Definition: advice.cpp:104
const char * ON_EMERGENCY
activated on shutdown after premature failure of a subsystem