Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
configfacade.cpp
Go to the documentation of this file.
1/*
2 ConfigFacade - C++ convenience wrapper and startup of the config system
3
4 Copyright (C)
5 2008, 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
33#include "include/logging.h"
34#include "include/lifecycle.h"
36#include "common/appstate.hpp"
37#include "lib/searchpath.hpp"
38#include "lib/iter-explorer.hpp"
39#include "lib/format-util.hpp"
40#include "lib/util.hpp"
41
42extern "C" {
43 #include "common/config.h"
44}
45
46
52#define KEY_CONFIG_PATH "Lumiera.configpath"
53
59#define KEY_PLUGIN_PATH "Lumiera.modulepath"
60
61
62
63
64namespace lumiera {
65
66 using util::isnil;
67 using lib::Literal;
68
69
72
73
74 namespace {
75
76 void
78 {
79 TRACE (common, "booting up config system");
81 }
82
83 LifecycleHook trigger__ (ON_BASIC_INIT, &pull_up_ConfigSystem);
84 }
85
86
87
88
90 {
91 string extendedConfigSearchPath = AppState::instance().fetchSetupValue (KEY_CONFIG_PATH);
92 lumiera_config_init (cStr(extendedConfigSearchPath));
93 TRACE (config, "Config system ready.");
94 }
95
96
98 {
100 TRACE (config, "config system closed.");
101 }
102
103
104
108 string
110 {
111 string value = AppState::instance().fetchSetupValue (key);
112 if (isnil (value))
113 throw error::Config ("Configuration value for key=\""+key+"\" is missing");
114
115 return value;
116 }
117
118
119
120} // namespace lumiera
121
122
123extern "C" { /* ==== implementation C interface for accessing setup.ini ======= */
124
125
126 using std::string;
127 using lumiera::Config;
129 using util::isnil;
130
131
132
133 const char*
135 { // Meyer's Singleton...
136 static string pathSpec = []{ string pluginPath = Config::get (KEY_PLUGIN_PATH);
137 return "plugin.path=" // syntax expected by lumiera_config_setdefault
138 + util::join (SearchPathSplitter{pluginPath}, ":");
139 }();
140 return cStr(pathSpec);
141 }
142}
Registering and managing primary application-global services.
Access point to singletons and other kinds of dependencies designated by type.
Definition depend.hpp:281
Inline string literal.
Definition symbol.hpp:78
Helper: Access a path Specification as a sequence of filesystem Paths.
static lib::Depend< AppState > instance
get the (single) AppState instance.
Definition appstate.hpp:74
C++ wrapper for convenient access to the Lumiera config system.
static string get(lib::Literal key)
static lib::Depend< Config > instance
storage and setup for the single system-wide config facade instance
define and register a callback for a specific lifecycle event.
Definition lifecycle.h:69
The lumiera::Config wrapper class addresses two issues.
int lumiera_config_init(const char *path)
Initialise the configuration subsystem.
Definition config.c:77
void lumiera_config_destroy()
Destroys the configuration subsystem.
Definition config.c:105
Interface for a lumiera configuration system (draft).
#define KEY_PLUGIN_PATH
Similarly, this key is used to fetch the configured default plugin/module search path from the basic ...
const char * lumiera_get_plugin_path_default()
#define KEY_CONFIG_PATH
key to fetch the search path for extended configuration.
Collection of small helpers and convenience shortcuts for diagnostics & formatting.
Building tree expanding and backtracking evaluations within hierarchical scopes.
Installing and invoking of application lifecycle event callbacks.
This header is for including and configuring NoBug.
LifecycleHook trigger__(ON_BASIC_INIT, &pull_up_ConfigSystem)
LumieraError< LERR_(CONFIG), Invalid > Config
Definition error.hpp:212
Lumiera public interface.
Definition advice.hpp:102
CStr ON_BASIC_INIT
automatic static init. treated specially to run as soon as possible
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
bool isnil(lib::time::Duration const &dur)
Helpers to handle directory search paths.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
Definition symbol.hpp:60
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...