diff --git a/src/include/configfacade.hpp b/src/include/configfacade.hpp new file mode 100644 index 000000000..db30b9937 --- /dev/null +++ b/src/include/configfacade.hpp @@ -0,0 +1,73 @@ +/* + CONFIGFACADE - C++ convenience wrapper and startup of the config system + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +/** @file configfacade.hpp + ** The lumiera::Config wrapper class addresses two issues. + ** First, it registers startup and shutdown hooks to bring up the config system + ** as early as possible. Later, on application main initialisation, the global + ** config interface is opened and wrapped for convenient access from C++ code. + ** + ** @see config.h + ** @see lumiera::AppState + ** @see main.cpp + */ + + +#ifndef INTERFACE_CONFIGFACADE_H +#define INTERFACE_CONFIGFACADE_H + + +#include "common/singleton.hpp" + +#include + + +namespace lumiera { + + using std::string; + + + /********************************************************************* + * C++ wrapper for convenient access to the Lumiera config system. + */ + struct Config + { + + static const string get (string const& key); + + + static lumiera::Singleton instance; + + private: + Config(); + ~Config(); + + friend class lumiera::singleton::StaticCreate; + + //////////////////TODO: define startup/shutdown and loading of the config interface + + }; + + + +} // namespace lumiera +#endif diff --git a/src/include/nobugcfg.h b/src/include/nobugcfg.h index 57df1fe29..cfcedd6b7 100644 --- a/src/include/nobugcfg.h +++ b/src/include/nobugcfg.h @@ -73,7 +73,7 @@ namespace lumiera { void initialise_NoBug (); namespace { - LifecycleHook schedule_ (ON_BASIC_INIT, &initialise_NoBug); + LifecycleHook trigger_it_ (ON_BASIC_INIT, &initialise_NoBug); } } #endif /* =====================(End) C++ ================ */ @@ -105,9 +105,9 @@ namespace lumiera { NOBUG_CPP_DEFINE_FLAG (all); NOBUG_CPP_DEFINE_FLAG_PARENT (lumiera_all, all); NOBUG_CPP_DEFINE_FLAG_PARENT (lumiera, lumiera_all); - NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (operate, lumiera, LOG_INFO); + NOBUG_CPP_DEFINE_FLAG_PARENT (config, lumiera); + NOBUG_CPP_DEFINE_FLAG_PARENT (operate, lumiera); NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (render, lumiera, LOG_WARNING); - NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (config, lumiera, LOG_WARNING); NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (memory, lumiera, LOG_WARNING); NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (test, all, LOG_ERR); diff --git a/src/lumiera/appstate.cpp b/src/lumiera/appstate.cpp index 05b28ee2e..79fbeb56f 100644 --- a/src/lumiera/appstate.cpp +++ b/src/lumiera/appstate.cpp @@ -35,6 +35,7 @@ extern "C" { } #include "common/util.hpp" +#include "include/configfacade.hpp" //////////TODO: temp hack to force configfacade.o to be linked in using util::isnil; @@ -158,6 +159,9 @@ namespace lumiera { ExitCode AppState::abort (lumiera::Error& problem) { + + INFO (operate, "Address of Config Facade = %x", &lumiera::Config::instance()); //////////TODO: a temp hack to force configfacade.cpp to be linked into lumiera.exe + UNIMPLEMENTED ("clean error shutdown"); } diff --git a/src/lumiera/configfacade.cpp b/src/lumiera/configfacade.cpp new file mode 100644 index 000000000..27e953acf --- /dev/null +++ b/src/lumiera/configfacade.cpp @@ -0,0 +1,97 @@ +/* + ConfigFacade - C++ convenience wrapper and startup of the config system + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "include/nobugcfg.h" +#include "include/lifecycle.h" +#include "include/configfacade.hpp" + +extern "C" { // TODO: can't include "lumiera/config.h" from C++ code, because it uses an identifier "new" + + /** Initialise the configuration subsystem. + * Must be called exactly once prior to any use + * @param path search path for config files. + */ + int lumiera_config_init (const char* path); + + /** Destroys the configuration subsystem. + * Subsequent calls are no-op. */ + void + lumiera_config_destroy (); + +} + +#ifndef LUMIERA_CONFIG_PATH +#error LUMIERA_CONFIG_PATH not defined +#endif + + + +namespace lumiera { + + + namespace { + + void + pull_up_ConfigSystem () + { + TRACE (lumiera, "booting up config system"); + Config::instance(); + } + + LifecycleHook trigger__ (ON_BASIC_INIT, &pull_up_ConfigSystem); + } + + + + + /** storage for the single system-wide config facade instance */ + Singleton Config::instance; + + + Config::Config () + { + lumiera_config_init (LUMIERA_CONFIG_PATH); + INFO (config, "Config system ready."); + + TODO ("wire Config facade to config interface"); + } + + + Config::~Config() + { + lumiera_config_destroy(); + TRACE (lumiera, "config system closed."); + } + + + + const string + Config::get (string const& key) + { + UNIMPLEMENTED ("config facade access to config value"); + return string("warwohlnix"); + } + + + +} // namespace lumiera diff --git a/src/lumiera/lumiera.c b/src/lumiera/lumiera.c index db4a260b0..1e3c57597 100644 --- a/src/lumiera/lumiera.c +++ b/src/lumiera/lumiera.c @@ -28,7 +28,6 @@ #include "lumiera/interface.h" #include "lumiera/interfaceregistry.h" #include "lumiera/plugin.h" -#include "lumiera/config.h" //TODO: internal/static forward declarations// @@ -36,9 +35,6 @@ //TODO: System includes// #include -#ifndef LUMIERA_CONFIG_PATH -#error LUMIERA_CONFIG_PATH not defined -#endif /** @@ -53,18 +49,11 @@ start (int argc, char** argv) { (void) argc; (void) argv; - lumiera_preinit (); - TODO ("commandline parser"); - lumiera_config_init (LUMIERA_CONFIG_PATH); - - - TODO ("video editing"); TRACE (lumiera, "initiating shutdown sequence"); lumiera_shutdown (); lumiera_interfaceregistry_destroy (); - lumiera_config_destroy (); } diff --git a/src/lumiera/lumiera.h b/src/lumiera/lumiera.h index 78b2310e1..ecc4cd489 100644 --- a/src/lumiera/lumiera.h +++ b/src/lumiera/lumiera.h @@ -42,11 +42,6 @@ */ //TODO: declarations go here// -void -lumiera_preinit (void); - -void -lumiera_init (void); void lumiera_shutdown (void); diff --git a/src/lumiera/lumiera_init.c b/src/lumiera/lumiera_init.c index 78e1a13ed..bb6310855 100644 --- a/src/lumiera/lumiera_init.c +++ b/src/lumiera/lumiera_init.c @@ -41,29 +41,6 @@ //code goes here// -/** - * Early initialization - * Sets up some important basic stuff, this is run as *very* first before anything - * else got initialized. Used for NoBug and other kinds of hooks. There is no matching - * shutdown function for this, consider moving as much as possible to lumiera_init() - */ -void -lumiera_preinit (void) -{ - TRACE (lumiera, "booting up"); -} - - -/** - * Standard initialization procedure - * Boots all builtin subsystems up as described in DesignProcess/GlobalInitilaization. - * The configuration and interfaces/plugin subsystems are already started at this point and - * commandline arguments are parsed. - */ -void -lumiera_init (void) -{ -} /** diff --git a/src/lumiera/main.cpp b/src/lumiera/main.cpp index 4004a6119..abd245442 100644 --- a/src/lumiera/main.cpp +++ b/src/lumiera/main.cpp @@ -22,8 +22,6 @@ */ -#include - #include "include/nobugcfg.h" #include "include/error.hpp" #include "lumiera/appstate.hpp" diff --git a/src/lumiera/option.cpp b/src/lumiera/option.cpp index cdd9162a1..65e3675a5 100644 --- a/src/lumiera/option.cpp +++ b/src/lumiera/option.cpp @@ -41,28 +41,32 @@ namespace lumiera { * Recognises the following options * \code * --help + * [--session] FILENAME + * --script FILENAME + * --headless + * --port # * \endcode * @todo describe the actual options */ Option::Option (util::Cmdline& cmdline) - : syntax("Run a collection of test cases. Supported parameters"), + : syntax("Lumiera, the non linear video editor. Supported parameters"), parameters() { - UNIMPLEMENTED ("parse main Lumiera application parameters"); - syntax.add_options() ("help,h", "produce help message") - ("group,g", op::value()->default_value("blablubb"), - "the group (selection) of testcases to execute") - ("describe", op::bool_switch(), - "enumerate all testcases in this Suite in a format usable with ./test.sh.") - ("id", op::value(), - "an individual testcase to be called.\nIf not specified, run all.") + ("session,f", op::value(), + "session file to load") + ("script,s", op::value(), + "execute the given LUA script") + ("headless", op::bool_switch(), + "start without GUI") + ("port,p", op::value(), + "open renderfarm node at given port") ; // the testcase-ID is really an positional parameter op::positional_options_description posopt; - posopt.add("id", -1); + posopt.add("session", -1); op::parsed_options parsed = op::command_line_parser (cmdline) @@ -78,7 +82,10 @@ namespace lumiera { cmdline = op::collect_unrecognized(parsed.options, op::include_positional); if (parameters.count("help")) - std::cerr << *this; + { + std::cerr << *this; + exit(-1); + } } @@ -121,11 +128,9 @@ namespace lumiera { ostream& - operator<< (ostream& os, const Option& to) + operator<< (ostream& os, const Option& ops) { - NOTREACHED; ////////////////////////////TODO: define real query help messg - - return os << to.syntax; + return os << ops.syntax; } diff --git a/tests/common/lifecycletest.cpp b/tests/common/lifecycletest.cpp index 529eda9bf..113c1c162 100644 --- a/tests/common/lifecycletest.cpp +++ b/tests/common/lifecycletest.cpp @@ -44,7 +44,7 @@ namespace lumiera Symbol MY_MAGIC_MEGA_EVENT = "dial M for murder"; - namespace // register them to be invoced by lifecycle event id + namespace // register them to be invoked by lifecycle event id { LifecycleHook _schedule1 (ON_BASIC_INIT, &basicInitHook); LifecycleHook _schedule2 (MY_MAGIC_MEGA_EVENT, &myCallback);