summaryrefslogtreecommitdiff
path: root/project2/common/environment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/common/environment.cpp')
-rw-r--r--project2/common/environment.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/project2/common/environment.cpp b/project2/common/environment.cpp
index 891f1d9..2047813 100644
--- a/project2/common/environment.cpp
+++ b/project2/common/environment.cpp
@@ -44,30 +44,40 @@ optionsHelper(AllOptions * ao, const Options * options)
}
}
-static
-void
-consumeIntoAll(const AllOptions * ao, const Glib::ustring & n, const Glib::ustring & p, const Glib::ustring & v)
-{
- BOOST_FOREACH(const Options * o, *ao) {
- o->consume(n, p, v);
- }
-}
+class DefaultConfigConsumer : public ConfigConsumer {
+ public:
+ void operator()(const Glib::ustring & n, const Glib::ustring & p, const Glib::ustring & v) const {
+ BOOST_FOREACH(const Options * o, allOptions) {
+ o->consume(n, p, v);
+ }
+ }
+ const Options::Option * get(const Glib::ustring & n) const {
+ BOOST_FOREACH(const Options * os, allOptions) {
+ const Options::Option * o = os->find(n);
+ if (o) {
+ return o;
+ }
+ }
+ return NULL;
+ }
+ AllOptions allOptions;
+};
void
Environment::init()
{
- AllOptions allOptions;
- allOptions.push_back(&commonOptions);
- allOptions.push_back(&engineOptions());
- LoaderBase::onAllComponents(boost::bind(optionsHelper, &allOptions, boost::bind(&ComponentLoader::options, _1)));
+ DefaultConfigConsumer dcc;
+ dcc.allOptions.push_back(&commonOptions);
+ dcc.allOptions.push_back(&engineOptions());
+ LoaderBase::onAllComponents(boost::bind(optionsHelper, &dcc.allOptions, boost::bind(&ComponentLoader::options, _1)));
- BOOST_FOREACH(const AllOptions::value_type & v, allOptions) {
+ BOOST_FOREACH(const AllOptions::value_type & v, dcc.allOptions) {
v->reset();
}
typedef std::map<std::string, boost::shared_ptr<OptionsSourceLoader> > ConfigParsersMap;
BOOST_FOREACH(const ConfigParsersMap::value_type & cp, *LoaderBase::objLoaders<OptionsSourceLoader>()) {
- cp.second->create()->loadInto(boost::bind(&consumeIntoAll, &allOptions, _1, _2, _3));
+ cp.second->create()->loadInto(dcc);
}
Logger()->clear();