Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
basic-setup.cpp
Go to the documentation of this file.
1 /*
2  BasicSetup - 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 
36 #include "common/basic-setup.hpp"
37 #include "lib/searchpath.hpp"
38 #include "lib/error.hpp"
39 #include "lib/util.hpp"
40 
41 extern "C" {
42 #include <unistd.h>
43 }
44 #include <boost/filesystem.hpp>
45 #include <fstream>
46 
47 
48 namespace lumiera {
49 
50  using std::string;
51  using std::ifstream;
52 
53  namespace fsys = boost::filesystem;
54  namespace opt = boost::program_options;
55 
56  namespace { // details of the bootstrap process...
57 
58 
59  // Helper to locate a module using a search path spec
61 
64  string
65  resolve (fsys::path iniSpec)
66  {
67  string searchpath = iniSpec.parent_path().string();
68  return resolveModulePath (iniSpec.filename(), searchpath);
69  }
70 
71  }//(End) implementation details
72 
73 
74 
82  BasicSetup::BasicSetup (string bootstrapIni)
83  : syntax("Lumiera installation and platform configuration")
84  , settings()
85  {
86  syntax.add_options()
87  ("Lumiera.gui", opt::value<string>(),
88  "name of the Lumiera GUI plugin to load")
89  ("Lumiera.modulepath", opt::value<string>(),
90  "search path for loadable modules. "
91  "May use $ORIGIN to refer to the EXE location")
92  ("Lumiera.configpath", opt::value<string>(),
93  "search path for extended configuration. "
94  "Extended Config system not yet implemented "
95  "Ignored as of 2/2011")
96  ("Lumiera.title", opt::value<string>(),
97  "title of the Lumiera Application, e.g. for windows")
98  ("Lumiera.version", opt::value<string>(),
99  "Application version string")
100  ("Lumiera.website", opt::value<string>(),
101  "URL of the Lumiera website")
102  ("Lumiera.authors", opt::value<string>(),
103  "names of Lumiera authors, for 'about' dialog. Separated by '|'")
104  ("Lumiera.copyright", opt::value<string>(),
105  "year(s) for the author's copyright claim")
106 
107  ("Gui.stylesheet", opt::value<string>(),
108  "name of the GTK stylesheet to use. Will be searched in resource path")
109  ("Gui.iconpath", opt::value<string>(),
110  "search path for icons")
111  ("Gui.resourcepath", opt::value<string>(),
112  "general search path for UI resources")
113  ;
114 
115  ifstream configIn (resolve(bootstrapIni).c_str());
116 
117 
118  opt::parsed_options parsed = opt::parse_config_file (configIn, syntax);
119 
120  opt::store (parsed, settings);
121  opt::notify(settings);
122  }
123 
124 
125 
126 } // namespace lumiera
Bootstrap and self-configuration of the application at startup.
opt::variables_map settings
Helpers to handle directory search paths.
opt::options_description syntax
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.
string resolveModulePath(fsys::path moduleName, string searchPath)
helper to establish the location to search for loadable modules, configuration files, icons and further resources.
Definition: searchpath.cpp:89