move init plugin/interface system and global init to AppState::init()
This commit is contained in:
parent
3518235b57
commit
fa9b23115c
9 changed files with 130 additions and 46 deletions
|
|
@ -21,17 +21,26 @@
|
|||
* *****************************************************/
|
||||
|
||||
|
||||
#include "include/error.hpp"
|
||||
#include "include/lifecycle.h"
|
||||
#include "lumiera/appstate.hpp"
|
||||
#include "lib/lifecycleregistry.hpp"
|
||||
|
||||
#include "include/error.hpp"
|
||||
extern "C" {
|
||||
#include "lumiera/config_interface.h"
|
||||
|
||||
#include "lumiera/interface.h"
|
||||
#include "lumiera/interfaceregistry.h"
|
||||
#include "lumiera/plugin.h"
|
||||
}
|
||||
|
||||
#include "common/util.hpp"
|
||||
|
||||
|
||||
using util::isnil;
|
||||
using util::cStr;
|
||||
|
||||
|
||||
namespace lumiera {
|
||||
|
||||
|
||||
|
|
@ -52,7 +61,8 @@ namespace lumiera {
|
|||
* client codes POV it just behaves like intended).
|
||||
*/
|
||||
AppState::AppState()
|
||||
: lifecycleHooks_(new LifecycleRegistry)
|
||||
: lifecycleHooks_(new LifecycleRegistry),
|
||||
parts_(0)
|
||||
{
|
||||
lifecycleHooks_->execute (ON_BASIC_INIT); // note in most cases a NOP
|
||||
}
|
||||
|
|
@ -80,10 +90,48 @@ namespace lumiera {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
// ==== implementation startup sequence for main() =======
|
||||
|
||||
struct SubsystemRunner
|
||||
{
|
||||
Option& opts_;
|
||||
|
||||
SubsystemRunner (Option& opts)
|
||||
: opts_(opts)
|
||||
{ }
|
||||
|
||||
};
|
||||
|
||||
|
||||
#define _THROW_IF \
|
||||
if (lumiera_error_peek()) \
|
||||
throw error::Fatal (lumiera_error());
|
||||
|
||||
|
||||
|
||||
void
|
||||
AppState::evaluate (lumiera::Option& options)
|
||||
AppState::init (Option& options)
|
||||
{
|
||||
UNIMPLEMENTED ("evaluate the options and set global application state");
|
||||
TRACE (lumiera, "initialising application core...");
|
||||
|
||||
lumiera_interfaceregistry_init ();
|
||||
_THROW_IF
|
||||
|
||||
TODO ("use a plugindb instead of loading all plugins at once");
|
||||
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
|
||||
_THROW_IF
|
||||
|
||||
lumiera_config_interface_init ();
|
||||
_THROW_IF
|
||||
|
||||
AppState::lifecycle (ON_GLOBAL_INIT);
|
||||
_THROW_IF
|
||||
|
||||
|
||||
parts_.reset (new SubsystemRunner (options));
|
||||
TRACE (lumiera, "Lumiera core started successfully.");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ namespace lumiera {
|
|||
using boost::noncopyable;
|
||||
|
||||
class LifecycleRegistry;
|
||||
class SubsystemRunner;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -82,10 +83,11 @@ namespace lumiera {
|
|||
static void lifecycle (Symbol eventLabel);
|
||||
|
||||
|
||||
/** evaluate the command line options and maybe additional configuration
|
||||
/** evaluate the result of option parsing and maybe additional configuration
|
||||
* such as to be able to determine the further behaviour of the application.
|
||||
* Set the internal state within this object accordingly */
|
||||
void evaluate (lumiera::Option& options);
|
||||
* Set the internal state within this object accordingly.
|
||||
* @return the AppState singleton instance */
|
||||
void init (lumiera::Option& options);
|
||||
|
||||
|
||||
/** building on the state determined by #evaluate, decide if the given Subsys
|
||||
|
|
@ -123,8 +125,10 @@ namespace lumiera {
|
|||
|
||||
private:
|
||||
typedef scoped_ptr<LifecycleRegistry> PLife;
|
||||
typedef scoped_ptr<SubsystemRunner> PSub;
|
||||
|
||||
PLife lifecycleHooks_;
|
||||
PSub parts_;
|
||||
|
||||
friend class LifecycleHook;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
/**
|
||||
* @file
|
||||
* Interface instances are published and activated by registering them
|
||||
* into a gloabl registry, which is defined here. This instances are identified
|
||||
* into a global registry, which is defined here. This instances are identified
|
||||
* by their name and major version.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,6 @@ start (int argc, char** argv)
|
|||
TODO ("commandline parser");
|
||||
lumiera_config_init (LUMIERA_CONFIG_PATH);
|
||||
|
||||
lumiera_interfaceregistry_init ();
|
||||
TODO ("plugindb support instead loading all plugins at once");
|
||||
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
|
||||
|
||||
lumiera_init ();
|
||||
TRACE (lumiera, "Lumiera is alive");
|
||||
|
||||
TODO ("video editing");
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@ lumiera_preinit (void)
|
|||
void
|
||||
lumiera_init (void)
|
||||
{
|
||||
TRACE (lumiera, "initializing");
|
||||
|
||||
lumiera_config_interface_init ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "include/nobugcfg.h"
|
||||
#include "include/error.hpp"
|
||||
#include "include/lifecycle.h"
|
||||
#include "lumiera/appstate.hpp"
|
||||
#include "lumiera/option.hpp"
|
||||
|
||||
|
|
@ -57,14 +56,12 @@ main (int argc, const char* argv[])
|
|||
{
|
||||
NOTICE (lumiera, "*** Lumiera NLE for Linux ***");
|
||||
|
||||
Cmdline args (argc,argv);
|
||||
AppState& application = AppState::instance();
|
||||
lumiera::Option options (args);
|
||||
application.evaluate (options);
|
||||
|
||||
try
|
||||
{
|
||||
AppState::lifecycle (ON_GLOBAL_INIT);
|
||||
Cmdline args (argc,argv);
|
||||
lumiera::Option options (args);
|
||||
application.init (options);
|
||||
|
||||
session.depends (builder);
|
||||
netNode.depends (session);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ NOBUG_DECLARE_FLAG (plugin);
|
|||
struct lumiera_plugin_struct;
|
||||
typedef struct lumiera_plugin_struct lumiera_plugin;
|
||||
typedef lumiera_plugin* LumieraPlugin;
|
||||
enum lumiera_plugin_type;
|
||||
|
||||
|
||||
/**
|
||||
* Allocates an preinitializes a plugin structure
|
||||
|
|
@ -89,7 +89,7 @@ lumiera_plugin_new (const char* name);
|
|||
* Stores any pending error (from loading) in self which clears out the LUMIERA_ERROR_PLUGIN_INIT error state
|
||||
* which was initialized by lumiera_plugin_new(), stores the handle and plugin pointers in the plugin struct.
|
||||
* @param self pointer to the plugin struct
|
||||
* @param handle opaque handle refering to some plugin type specific data
|
||||
* @param handle opaque handle referring to some plugin type specific data
|
||||
* @param plugin a lumieraorg__plugin interface which will be used to initialize this plugin
|
||||
*/
|
||||
LumieraPlugin
|
||||
|
|
|
|||
64
src/lumiera/subsys.cpp
Normal file
64
src/lumiera/subsys.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Subsys - interface for describing an application part to be handled by main()
|
||||
|
||||
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 "lumiera/subsys.hpp"
|
||||
|
||||
#include "include/error.hpp"
|
||||
//#include "common/util.hpp"
|
||||
|
||||
|
||||
//using util::isnil;
|
||||
//using util::cStr;
|
||||
|
||||
namespace lumiera {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Subsys::~Subsys() { }
|
||||
|
||||
|
||||
|
||||
Subsys&
|
||||
Subsys::depends (Subsys& prereq)
|
||||
{
|
||||
TODO ("anything else to care when defining a dependency on the prerequisite subsystem??");/////////////////////TODO
|
||||
prereq_.push_back(&prereq);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
Subsys::isRunning()
|
||||
{
|
||||
UNIMPLEMENTED ("maintain isRunning flag in a threadsafe manner");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace lumiera
|
||||
|
|
@ -73,8 +73,7 @@ namespace lumiera {
|
|||
public:
|
||||
typedef void (SigTerm)(Error*); ///////////////////TODO better use Glib-- Signal type?
|
||||
|
||||
|
||||
virtual ~Subsys () {};
|
||||
virtual ~Subsys();
|
||||
|
||||
|
||||
/** define a dependency to another Subsys
|
||||
|
|
@ -112,25 +111,6 @@ namespace lumiera {
|
|||
|
||||
|
||||
|
||||
//------ implementation skeleton ----------
|
||||
inline Subsys&
|
||||
Subsys::depends (Subsys& prereq)
|
||||
{
|
||||
TODO ("anything else to care when defining a dependency on the prerequisite subsystem??");/////////////////////TODO
|
||||
prereq_.push_back(&prereq);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline bool
|
||||
Subsys::isRunning()
|
||||
{
|
||||
UNIMPLEMENTED ("maintain isRunning flag in a threadsafe manner");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace lumiera
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue