Lumiera  0.pre.03
»edit your freedom«
appstate.hpp
Go to the documentation of this file.
1 /*
2  APPSTATE.hpp - application initialisation and behaviour
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 
31 #ifndef LUMIERA_APPSTATE_H
32 #define LUMIERA_APPSTATE_H
33 
34 #include "lib/symbol.hpp"
35 #include "lib/nocopy.hpp"
36 #include "lib/depend.hpp"
37 #include "common/option.hpp"
38 #include "common/subsys.hpp"
39 #include "common/basic-setup.hpp"
40 
41 #include <memory>
42 #include <string>
43 #include <map>
44 
45 
46 
47 namespace lumiera {
48 
49  using std::string;
50 
51  class SubsystemRunner;
52 
53 
61  class AppState
63  {
64  private:
65  AppState ();
66 
67  ~AppState ();
68  friend class lib::DependencyFactory<AppState>;
69 
70 
71  public:
75 
76 
80  void init (lumiera::Option& options);
81 
82 
84  string fetchSetupValue (lib::Literal key);
85 
86 
92 
93 
94  enum ExitCode {
95  NORMAL_EXIT,
96  CLEAN_EXIT_AFTER_ERROR,
97  CLEAN_EMERGENCY_EXIT,
98  FAILED_EMERGENCY_EXIT
99  };
100 
109  ExitCode maybeWait();
110 
111 
114  ExitCode abort (lumiera::Error& problem);
115 
116 
119  ExitCode abort () noexcept;
120 
121 
122 
123  private:
124  using PSub = std::unique_ptr<SubsystemRunner>;
125 
126  BasicSetup setup_;
127 
128  PSub subsystems_;
129 
130  bool emergency_;
131  bool core_up_;
132 
133  };
134 
135 
136 } // namespace lumiera
137 
138 #endif
ExitCode abort() noexcept
initiate an fatal emergency shutdown, caused by an unforeseen error condition
Definition: appstate.cpp:203
Dependencies and lifecycle of a partially independent Subsystem of the Application.
Definition: subsys.hpp:61
AppState()
perform initialisation triggered on first access.
Definition: appstate.cpp:71
Bootstrap and self-configuration of the application at startup.
~AppState()
anything which should be closed as late as possible and after the normal shutdown sequence can be pla...
Definition: appstate.cpp:227
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:76
STL namespace.
Frontend for handling the Lumiera application commandline arguments.
Definition: option.hpp:68
The Lumiera Application state and basic initialisation.
Definition: appstate.hpp:61
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:280
void maybeStart(lumiera::Subsys &)
building on the state determined by init, decide if the given Subsys needs to be pulled up and...
Definition: appstate.cpp:127
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Implementation helper for managing execution of a collection of subsystems, which may depend on one a...
Describing dependencies and lifecycle of the application&#39;s primary parts.
front-end for handling the commandline arguments.
void init(lumiera::Option &options)
evaluate the result of option parsing and maybe additional configuration such as to be able to determ...
Definition: appstate.cpp:102
Singleton services and Dependency Injection.
ExitCode maybeWait()
put the main thread of the application into a wait state, as long as some subsystem(s) registered wit...
Definition: appstate.cpp:152
string fetchSetupValue(lib::Literal key)
access basic application setup values (from setup.ini)
Definition: appstate.cpp:83
Lumiera public interface.
Definition: advice.cpp:104
Helper to abstract creation and lifecycle of a dependency.
Definition: depend.hpp:125
Represents the elementary self-configuration of a running Lumiera application instance.
Definition: basic-setup.hpp:88
static lib::Depend< AppState > instance
get the (single) AppState instance.
Definition: appstate.hpp:74
Interface and Base definition for all Lumiera Exceptions.
Definition: error.hpp:62