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) Lumiera.org
5  2011, 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 
23 
53 #ifndef COMMON_BASIC_SETUP_H
54 #define COMMON_BASIC_SETUP_H
55 
56 #include "lib/error.hpp"
57 #include "lib/symbol.hpp"
58 #include "lib/nocopy.hpp"
59 #include "lib/util.hpp"
60 
61 #include <boost/program_options.hpp>
62 #include <string>
63 
64 
66 #define LUMIERA_LOCATION_OF_BOOTSTRAP_INI "$ORIGIN/setup.ini"
67 
68 
69 
70 namespace lumiera {
71 
72  using std::string;
73 
74  namespace opt = boost::program_options;
75 
76 
97  class BasicSetup
99  {
100  opt::options_description syntax;
101  opt::variables_map settings;
102 
103  public:
104  BasicSetup (string bootstrapIni);
105 
106  string
107  operator[] (lib::Literal key) const
108  {
109  return get (key).as<string>();
110  }
111 
112  opt::variable_value const&
113  get (lib::Literal key) const
114  {
115  string keyID (key);
116  __ensure_hasKey(keyID);
117  return settings[keyID];
118  }
119 
120 
121  private:
122  void
123  __ensure_hasKey (string const& key) const
124  {
125  if (!util::contains (settings, key))
126  throw error::Logic ("Key \""+key+"\" not found in setup.ini");
127  }
128  };
129 
130 
131 } // namespace lumiera
132 #endif
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:85
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
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:82
Lumiera error handling (C++ interface).
Lumiera public interface.
Definition: advice.cpp:113
Represents the elementary self-configuration of a running Lumiera application instance.
Definition: basic-setup.hpp:97