pull up the config system in pre-init phase
This commit is contained in:
parent
fa9b23115c
commit
df85f2a5d9
10 changed files with 198 additions and 60 deletions
73
src/include/configfacade.hpp
Normal file
73
src/include/configfacade.hpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
CONFIGFACADE - C++ convenience wrapper and startup of the config system
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
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 <string>
|
||||
|
||||
|
||||
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<Config> instance;
|
||||
|
||||
private:
|
||||
Config();
|
||||
~Config();
|
||||
|
||||
friend class lumiera::singleton::StaticCreate<Config>;
|
||||
|
||||
//////////////////TODO: define startup/shutdown and loading of the config interface
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace lumiera
|
||||
#endif
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
97
src/lumiera/configfacade.cpp
Normal file
97
src/lumiera/configfacade.cpp
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
ConfigFacade - C++ convenience wrapper and startup of the config system
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
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> 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
|
||||
|
|
@ -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 <stdio.h>
|
||||
|
||||
#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 ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@
|
|||
*/
|
||||
|
||||
//TODO: declarations go here//
|
||||
void
|
||||
lumiera_preinit (void);
|
||||
|
||||
void
|
||||
lumiera_init (void);
|
||||
|
||||
void
|
||||
lumiera_shutdown (void);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "include/nobugcfg.h"
|
||||
#include "include/error.hpp"
|
||||
#include "lumiera/appstate.hpp"
|
||||
|
|
|
|||
|
|
@ -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<string>()->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<VectS>(),
|
||||
"an individual testcase to be called.\nIf not specified, run all.")
|
||||
("session,f", op::value<string>(),
|
||||
"session file to load")
|
||||
("script,s", op::value<string>(),
|
||||
"execute the given LUA script")
|
||||
("headless", op::bool_switch(),
|
||||
"start without GUI")
|
||||
("port,p", op::value<int>(),
|
||||
"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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue