Lumiera  0.pre.03
»edityourfreedom«
appstate.hpp
Go to the documentation of this file.
1 /*
2  APPSTATE.hpp - application initialisation and behaviour
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
40 #ifndef LUMIERA_APPSTATE_H
41 #define LUMIERA_APPSTATE_H
42 
43 #include "lib/symbol.hpp"
44 #include "lib/nocopy.hpp"
45 #include "lib/depend.hpp"
46 #include "common/option.hpp"
47 #include "common/subsys.hpp"
48 #include "common/basic-setup.hpp"
49 
50 #include <memory>
51 #include <string>
52 #include <map>
53 
54 
55 
56 namespace lumiera {
57 
58  using std::string;
59 
60  class SubsystemRunner;
61 
62 
70  class AppState
72  {
73  private:
74  AppState ();
75 
76  ~AppState ();
78 
79 
80  public:
84 
85 
89  void init (lumiera::Option& options);
90 
91 
93  string fetchSetupValue (lib::Literal key);
94 
95 
100  void maybeStart (lumiera::Subsys&);
101 
102 
103  enum ExitCode {
108  };
109 
119 
120 
123  ExitCode abort (lumiera::Error& problem);
124 
125 
128  ExitCode abort () noexcept;
129 
130 
131 
132  private:
133  using PSub = std::unique_ptr<SubsystemRunner>;
134 
136 
138 
140  bool core_up_;
141 
142  };
143 
144 
145 } // namespace lumiera
146 
147 #endif
ExitCode abort() noexcept
initiate an fatal emergency shutdown, caused by an unforeseen error condition
Definition: appstate.cpp:213
Dependencies and lifecycle of a partially independent Subsystem of the Application.
Definition: subsys.hpp:70
AppState()
perform initialisation triggered on first access.
Definition: appstate.cpp:81
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:237
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:75
STL namespace.
Frontend for handling the Lumiera application commandline arguments.
Definition: option.hpp:76
The Lumiera Application state and basic initialisation.
Definition: appstate.hpp:70
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
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:137
Mix-Ins to allow or prohibit various degrees of copying and cloning.
std::unique_ptr< SubsystemRunner > PSub
Definition: appstate.hpp:133
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:112
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:162
string fetchSetupValue(lib::Literal key)
access basic application setup values (from setup.ini)
Definition: appstate.cpp:93
BasicSetup setup_
Definition: appstate.hpp:135
Lumiera public interface.
Helper to abstract creation and lifecycle of a dependency.
Definition: depend.hpp:134
Represents the elementary self-configuration of a running Lumiera application instance.
Definition: basic-setup.hpp:97
static lib::Depend< AppState > instance
get the (single) AppState instance.
Definition: appstate.hpp:83
Interface and Base definition for all Lumiera Exceptions.
Definition: error.hpp:69