00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00039 #ifndef LUMIERA_APPCONFIG_H
00040 #define LUMIERA_APPCONFIG_H
00041
00042 #include <map>
00043 #include <string>
00044 #include <boost/scoped_ptr.hpp>
00045 #include <boost/noncopyable.hpp>
00046 #include "lib/lifecycleregistry.hpp"
00047
00048
00049
00050 namespace lumiera
00051 {
00052 using std::string;
00053 using boost::scoped_ptr;
00054 using boost::noncopyable;
00055
00056
00064 class Appconfig
00065 : private noncopyable
00066 {
00067 private:
00071 Appconfig ();
00072
00073 ~Appconfig () throw() {};
00074 friend void boost::checked_delete<Appconfig>(Appconfig*);
00075
00076
00077 public:
00082 static Appconfig& instance()
00083 {
00084 static scoped_ptr<Appconfig> theApp_ (0);
00085 if (!theApp_) theApp_.reset (new Appconfig ());
00086 return *theApp_;
00087 }
00088
00089
00092 static const string & get (const string& key);
00093
00096 static void lifecycle (Symbol eventLabel);
00097
00098
00099
00100
00101 private:
00102 typedef std::map<string,string> Configmap;
00103 typedef scoped_ptr<Configmap> PConfig;
00104 typedef scoped_ptr<LifecycleRegistry> PLife;
00105
00106 PConfig configParam_;
00107 PLife lifecycleHooks_;
00108
00109 friend class LifecycleHook;
00110
00111 };
00112
00113
00114 extern Symbol ON_BASIC_INIT;
00115 extern Symbol ON_GLOBAL_INIT;
00116 extern Symbol ON_GLOBAL_SHUTDOWN;
00117
00118
00119
00120
00135 class LifecycleHook
00136 : private noncopyable
00137 {
00138 public:
00139 LifecycleHook (Symbol eventLabel, LifecycleRegistry::Hook callbackFun);
00140
00141 LifecycleHook& add (Symbol eventLabel, LifecycleRegistry::Hook callbackFun);
00142 };
00143
00144
00145
00146 }
00147
00148
00149 extern "C" {
00150
00151 void lumiera_LifecycleHook_add (const char* eventLabel, void callbackFun(void));
00152 void lumiera_Lifecycle_execute (const char* eventLabel);
00153 const char* lumiera_Appconfig_get (const char* key);
00154
00155 }
00156
00157
00158 #endif