Lumiera  0.pre.03
»edit your freedom«
basic-setup.cpp
Go to the documentation of this file.
1 /*
2  BasicSetup - 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 
27 #include "common/basic-setup.hpp"
28 #include "lib/searchpath.hpp"
29 #include "lib/error.hpp"
30 #include "lib/util.hpp"
31 
32 extern "C" {
33 #include <unistd.h>
34 }
35 #include <boost/filesystem.hpp>
36 #include <fstream>
37 
38 
39 namespace lumiera {
40 
41  using std::string;
42  using std::ifstream;
43 
44  namespace fsys = boost::filesystem;
45  namespace opt = boost::program_options;
46 
47  namespace { // details of the bootstrap process...
48 
49 
50  // Helper to locate a module using a search path spec
52 
55  string
56  resolve (fsys::path iniSpec)
57  {
58  string searchpath = iniSpec.parent_path().string();
59  return resolveModulePath (iniSpec.filename(), searchpath);
60  }
61 
62  }//(End) implementation details
63 
64 
65 
73  BasicSetup::BasicSetup (string bootstrapIni)
74  : syntax("Lumiera installation and platform configuration")
75  , settings()
76  {
77  syntax.add_options()
78  ("Lumiera.gui", opt::value<string>(),
79  "name of the Lumiera GUI plugin to load")
80  ("Lumiera.modulepath", opt::value<string>(),
81  "search path for loadable modules. "
82  "May use $ORIGIN to refer to the EXE location")
83  ("Lumiera.configpath", opt::value<string>(),
84  "search path for extended configuration. "
85  "Extended Config system not yet implemented "
86  "Ignored as of 2/2011")
87  ("Lumiera.title", opt::value<string>(),
88  "title of the Lumiera Application, e.g. for windows")
89  ("Lumiera.version", opt::value<string>(),
90  "Application version string")
91  ("Lumiera.website", opt::value<string>(),
92  "URL of the Lumiera website")
93  ("Lumiera.authors", opt::value<string>(),
94  "names of Lumiera authors, for 'about' dialog. Separated by '|'")
95  ("Lumiera.copyright", opt::value<string>(),
96  "year(s) for the author's copyright claim")
97 
98  ("Gui.stylesheet", opt::value<string>(),
99  "name of the GTK stylesheet to use. Will be searched in resource path")
100  ("Gui.iconpath", opt::value<string>(),
101  "search path for icons")
102  ("Gui.resourcepath", opt::value<string>(),
103  "general search path for UI resources")
104  ;
105 
106  ifstream configIn (resolve(bootstrapIni).c_str());
107 
108 
109  opt::parsed_options parsed = opt::parse_config_file (configIn, syntax);
110 
111  opt::store (parsed, settings);
112  opt::notify(settings);
113  }
114 
115 
116 
117 } // namespace lumiera
Bootstrap and self-configuration of the application at startup.
Helpers to handle directory search paths.
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
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:79
string resolve(fsys::path iniSpec)
use the general mechanism for resolving a search path to get the absolute path of the setup...
Definition: basic-setup.cpp:56