Lumiera  0.pre.03
»edit your freedom«
basic-setup.hpp
Go to the documentation of this file.
1 /*
2  BASIC-SETUP.hpp - elementary self-configuration of the application
3 
4  Copyright (C)
5  2011, 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 
14 
44 #ifndef COMMON_BASIC_SETUP_H
45 #define COMMON_BASIC_SETUP_H
46 
47 #include "lib/error.hpp"
48 #include "lib/symbol.hpp"
49 #include "lib/nocopy.hpp"
50 #include "lib/util.hpp"
51 
52 #include <boost/program_options.hpp>
53 #include <string>
54 
55 
57 #define LUMIERA_LOCATION_OF_BOOTSTRAP_INI "$ORIGIN/setup.ini"
58 
59 
60 
61 namespace lumiera {
62 
63  using std::string;
64 
65  namespace opt = boost::program_options;
66 
67 
88  class BasicSetup
90  {
91  opt::options_description syntax;
92  opt::variables_map settings;
93 
94  public:
95  BasicSetup (string bootstrapIni);
96 
97  string
98  operator[] (lib::Literal key) const
99  {
100  return get (key).as<string>();
101  }
102 
103  opt::variable_value const&
104  get (lib::Literal key) const
105  {
106  string keyID (key);
107  __ensure_hasKey(keyID);
108  return settings[keyID];
109  }
110 
111 
112  private:
113  void
114  __ensure_hasKey (string const& key) const
115  {
116  if (!util::contains (settings, key))
117  throw error::Logic ("Key \""+key+"\" not found in setup.ini");
118  }
119  };
120 
121 
122 } // namespace lumiera
123 #endif
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
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
BasicSetup(string bootstrapIni)
Creating the BasicSetup object performs the initial self-configuration of the Lumiera Application...
Definition: basic-setup.cpp:73
Lumiera error handling (C++ interface).
Lumiera public interface.
Definition: advice.cpp:104
Represents the elementary self-configuration of a running Lumiera application instance.
Definition: basic-setup.hpp:88