From 45f18379b489107da0de5a7eb720d9840a737b5b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 8 Dec 2008 03:01:02 +0100 Subject: [PATCH] provide the missing parts for actually bringing up a (dummy) subsystem "GUI" --- src/backend/enginefacade.cpp | 9 ++++- src/backend/netnodefacade.cpp | 9 ++++- src/backend/scriptrunnerfacade.cpp | 9 ++++- src/lumiera/appstate.cpp | 23 +++++++------ src/lumiera/appstate.hpp | 1 + src/lumiera/guifacade.cpp | 54 +++++++++++++++++++++++++++--- src/lumiera/main.cpp | 4 +-- src/lumiera/subsys.cpp | 4 +-- src/lumiera/subsys.hpp | 20 ++++++----- src/proc/control/stypemanager.cpp | 4 +-- src/proc/facade.cpp | 18 ++++++++-- 11 files changed, 120 insertions(+), 35 deletions(-) diff --git a/src/backend/enginefacade.cpp b/src/backend/enginefacade.cpp index 5c2ff789c..e081b116e 100644 --- a/src/backend/enginefacade.cpp +++ b/src/backend/enginefacade.cpp @@ -40,7 +40,7 @@ namespace backend { bool shouldStart (lumiera::Option&) { - UNIMPLEMENTED ("determine, if renderengine should be started"); + TODO ("determine, if renderengine should be started"); return false; } @@ -57,6 +57,13 @@ namespace backend { UNIMPLEMENTED ("initiate halting the engine"); } + bool + checkRunningState () throw() + { + //Lock guard (*this); + TODO ("implement detecting running state"); + return false; + } }; namespace { diff --git a/src/backend/netnodefacade.cpp b/src/backend/netnodefacade.cpp index 6f9a5098b..df019fbaa 100644 --- a/src/backend/netnodefacade.cpp +++ b/src/backend/netnodefacade.cpp @@ -39,7 +39,7 @@ namespace backend { bool shouldStart (lumiera::Option&) { - UNIMPLEMENTED ("determine, if render node service should be provided"); + TODO ("determine, if render node service should be provided"); return false; } @@ -56,6 +56,13 @@ namespace backend { UNIMPLEMENTED ("initiate shutting down the render node"); } + bool + checkRunningState () throw() + { + //Lock guard (*this); + TODO ("implement detecting running state"); + return false; + } }; namespace { diff --git a/src/backend/scriptrunnerfacade.cpp b/src/backend/scriptrunnerfacade.cpp index 3a329a905..533ea3481 100644 --- a/src/backend/scriptrunnerfacade.cpp +++ b/src/backend/scriptrunnerfacade.cpp @@ -40,7 +40,7 @@ namespace backend { bool shouldStart (lumiera::Option&) { - UNIMPLEMENTED ("determine, if a script should be executed"); + TODO ("determine, if a script should be executed"); return false; } @@ -57,6 +57,13 @@ namespace backend { UNIMPLEMENTED ("halt any running script"); } + bool + checkRunningState () throw() + { + //Lock guard (*this); + TODO ("implement detecting running state"); + return false; + } }; namespace { diff --git a/src/lumiera/appstate.cpp b/src/lumiera/appstate.cpp index e7d940282..a654f223e 100644 --- a/src/lumiera/appstate.cpp +++ b/src/lumiera/appstate.cpp @@ -67,9 +67,10 @@ namespace lumiera { * client codes POV it just behaves like intended). */ AppState::AppState() - : lifecycleHooks_(new LifecycleRegistry), - subsystems_(0), - emergency_(false) + : lifecycleHooks_(new LifecycleRegistry) + , subsystems_(0) + , emergency_(false) + , core_up_ (false) { lifecycleHooks_->execute (ON_BASIC_INIT); // note in most cases a NOP } @@ -122,6 +123,7 @@ namespace lumiera { lumiera_config_interface_init (); _THROW_IF + core_up_= true; AppState::lifecycle (ON_GLOBAL_INIT); _THROW_IF @@ -237,12 +239,13 @@ namespace lumiera { */ AppState::~AppState() { - try - { - TRACE (lumiera, "shutting down basic application layer..."); - lumiera_config_interface_destroy (); - lumiera_interfaceregistry_destroy (); - } + if (core_up_) + try + { + TRACE (lumiera, "shutting down basic application layer..."); + lumiera_config_interface_destroy (); + lumiera_interfaceregistry_destroy (); + } catch (...) { log_and_clear_unexpected_errorstate(); @@ -277,7 +280,7 @@ namespace lumiera { void - trigger (Symbol eventLabel) + LifecycleHook::trigger (Symbol eventLabel) { AppState::lifecycle (eventLabel); } diff --git a/src/lumiera/appstate.hpp b/src/lumiera/appstate.hpp index 3a9300583..5833b9fcc 100644 --- a/src/lumiera/appstate.hpp +++ b/src/lumiera/appstate.hpp @@ -130,6 +130,7 @@ namespace lumiera { PSub subsystems_; bool emergency_; + bool core_up_; friend class LifecycleHook; diff --git a/src/lumiera/guifacade.cpp b/src/lumiera/guifacade.cpp index d4ef02da1..d6a012643 100644 --- a/src/lumiera/guifacade.cpp +++ b/src/lumiera/guifacade.cpp @@ -25,9 +25,11 @@ #include "include/guinotificationfacade.h" #include "include/error.hpp" #include "common/singleton.hpp" +#include "lib/functorutil.hpp" #include "lumiera/instancehandle.hpp" #include +#include #include @@ -35,9 +37,12 @@ namespace gui { using std::string; using boost::scoped_ptr; + using std::tr1::bind; + using std::tr1::placeholders::_1; using lumiera::Subsys; using lumiera::InstanceHandle; - + using util::dispatchSequenced; + @@ -80,16 +85,27 @@ namespace gui { operator string () const { return "Lumiera GTK GUI"; } bool - shouldStart (lumiera::Option&) + shouldStart (lumiera::Option& opts) { - UNIMPLEMENTED ("determine, if a GUI is needed"); - return false; + if (opts.isHeadless() || 0 < opts.getPort()) + { + INFO (lumiera, "*not* starting the GUI..."); + return false; + } + else + return true; } bool start (lumiera::Option&, Subsys::SigTerm termination) { - facade.reset (new GuiRunner (termination)); /////////////////////TODO: actually decorate the termSignal, in order to delete the facade + //Lock guard (*this); + if (facade) return false; // already started + + facade.reset ( + new GuiRunner ( // trigger loading load the GuiStarterPlugin... + dispatchSequenced( closeOnTermination_ // on termination call this->closeGuiModule(*) first + , termination))); //...followed by invoking the given termSignal return true; } @@ -101,6 +117,34 @@ namespace gui { catch (...){} } + bool + checkRunningState () throw() + { + //Lock guard (*this); + return (facade); + } + + void + closeGuiModule (lumiera::Error *) + { + //Lock guard (*this); + if (!facade) + { + TRACE (operate, "duplicate? call of the termination signal, " + "GUI is currently closed."); + } + else + facade.reset (0); + } + + + Subsys::SigTerm closeOnTermination_; + + public: + GuiSubsysDescriptor() + : closeOnTermination_ (bind (&GuiSubsysDescriptor::closeGuiModule, this, _1)) + { } + }; lumiera::Singleton theDescriptor; diff --git a/src/lumiera/main.cpp b/src/lumiera/main.cpp index f3450fa2b..03e266686 100644 --- a/src/lumiera/main.cpp +++ b/src/lumiera/main.cpp @@ -64,8 +64,8 @@ main (int argc, const char* argv[]) session.depends (builder); netNode.depends (session); netNode.depends (engine); - lumigui.depends (session); - lumigui.depends (engine); +// lumigui.depends (session); //////TODO commented out in order to be able to start up a dummy GuiStarterPlugin +// lumigui.depends (engine); script.depends (session); script.depends (engine); diff --git a/src/lumiera/subsys.cpp b/src/lumiera/subsys.cpp index d0456ade6..823b838e4 100644 --- a/src/lumiera/subsys.cpp +++ b/src/lumiera/subsys.cpp @@ -53,8 +53,8 @@ namespace lumiera { bool Subsys::isRunning() { - TODO ("maintain isRunning flag in a threadsafe manner"); - return true; + //Lock guard (*this); + return checkRunningState(); } diff --git a/src/lumiera/subsys.hpp b/src/lumiera/subsys.hpp index 6af22f8ef..ccb3bfbcd 100644 --- a/src/lumiera/subsys.hpp +++ b/src/lumiera/subsys.hpp @@ -43,14 +43,12 @@ #ifndef LUMIERA_SUBSYS_H #define LUMIERA_SUBSYS_H -//#include "include/symbol.hpp" #include "include/error.hpp" #include "lumiera/option.hpp" #include #include -//#include -//#include +#include #include @@ -85,6 +83,9 @@ namespace lumiera { * required for running this subsystem */ Subsys& depends (Subsys& prereq); + /** @return true if Up */ + bool isRunning(); + /** query application option state to determine * if this subsystem should be activated. */ @@ -107,17 +108,18 @@ namespace lumiera { virtual void triggerShutdown () throw() =0; - /** weather this subsystem is currently operational. - * When returning \c false here, the application may - * terminate at any point without further notice*/ - bool isRunning(); - const std::vector getPrerequisites () { return prereq_; } - private: + /** weather this subsystem is actually operational. + * When returning \c false here, the application may + * terminate at any point without further notice + * Note further, that a subsystem must not be in + * running state when signalling termination. */ + virtual bool checkRunningState() throw() =0; + std::vector prereq_; }; diff --git a/src/proc/control/stypemanager.cpp b/src/proc/control/stypemanager.cpp index 33f1fc00d..d2f798a8b 100644 --- a/src/proc/control/stypemanager.cpp +++ b/src/proc/control/stypemanager.cpp @@ -24,7 +24,7 @@ #include "proc/common.hpp" #include "proc/control/stypemanager.hpp" #include "proc/control/styperegistry.hpp" -#include "lumiera/appstate.hpp" +#include "include/lifecycle.h" namespace control { @@ -53,7 +53,7 @@ namespace control { STypeManager::reset() { reg_.reset(new Registry); - lumiera::AppState::lifecycle(ON_STREAMTYPES_RESET); + lumiera::LifecycleHook::trigger (ON_STREAMTYPES_RESET); } /** \par diff --git a/src/proc/facade.cpp b/src/proc/facade.cpp index 1d7d68b80..f1fbdd239 100644 --- a/src/proc/facade.cpp +++ b/src/proc/facade.cpp @@ -41,7 +41,7 @@ namespace proc { bool shouldStart (lumiera::Option&) { - UNIMPLEMENTED ("determine, if we need a Builder Thread"); + TODO ("determine, if we need a Builder Thread"); return false; } @@ -58,6 +58,13 @@ namespace proc { UNIMPLEMENTED ("halt the Builder and cancel any build process"); /////TODO really cancel?? } + bool + checkRunningState () throw() + { + //Lock guard (*this); + TODO ("implement detecting running state"); + return false; + } }; @@ -70,7 +77,7 @@ namespace proc { bool shouldStart (lumiera::Option&) { - UNIMPLEMENTED ("determine, if an existing Session schould be loaded"); + TODO ("determine, if an existing Session schould be loaded"); return false; } @@ -87,6 +94,13 @@ namespace proc { UNIMPLEMENTED ("initiate closing this Session"); } + bool + checkRunningState () throw() + { + //Lock guard (*this); + TODO ("implement detecting running state"); + return false; + } }; namespace {