provide the missing parts for actually bringing up a (dummy) subsystem "GUI"

This commit is contained in:
Fischlurch 2008-12-08 03:01:02 +01:00 committed by Christian Thaeter
parent 4ec74a4dc3
commit 45f18379b4
11 changed files with 120 additions and 35 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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);
}

View file

@ -130,6 +130,7 @@ namespace lumiera {
PSub subsystems_;
bool emergency_;
bool core_up_;
friend class LifecycleHook;

View file

@ -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 <boost/scoped_ptr.hpp>
#include <tr1/functional>
#include <string>
@ -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<GuiSubsysDescriptor> theDescriptor;

View file

@ -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);

View file

@ -53,8 +53,8 @@ namespace lumiera {
bool
Subsys::isRunning()
{
TODO ("maintain isRunning flag in a threadsafe manner");
return true;
//Lock guard (*this);
return checkRunningState();
}

View file

@ -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 <boost/noncopyable.hpp>
#include <tr1/functional>
//#include <boost/scoped_ptr.hpp>
//#include <string>
#include <string>
#include <vector>
@ -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<Subsys*>
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<Subsys*> prereq_;
};

View file

@ -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

View file

@ -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 {