Subsystem descriptor skeleton
This commit is contained in:
parent
010b0d99ff
commit
2dd90e4fad
4 changed files with 147 additions and 4 deletions
|
|
@ -36,6 +36,8 @@
|
|||
#define LUMIERA_APPSTATE_H
|
||||
|
||||
#include "include/symbol.hpp"
|
||||
#include "lumiera/option.hpp"
|
||||
#include "lumiera/subsys.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
|
|
|||
135
src/lumiera/subsys.hpp
Normal file
135
src/lumiera/subsys.hpp
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
SUBSYS.hpp - 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.
|
||||
|
||||
*/
|
||||
|
||||
/** @file subsys.hpp
|
||||
** Describing dependencies and lifecycle of the application's primary parts.
|
||||
** Within Lumiera's main(), a small number of well-known application subsystems
|
||||
** need to be started and maintained, while observing some interrelations.
|
||||
** While the activation of the key components is controlled by options, maybe
|
||||
** some prerequisite subsystems need to be pulled up, and in case of an regular
|
||||
** or irregular exit of a given subsystem, the whole dependency graph needs
|
||||
** to be brought down in a clean manner. The purpose of lumiera::Subsys is
|
||||
** to maintain these in a self-explanatory script-like fashion within main(),
|
||||
** without forcing the individual subsystems into a fixed implementation scheme.
|
||||
** The only requirement is that for each subsystem there is sort-of an entry
|
||||
** point or facade object, providing a Subsys descriptor instance to be
|
||||
** used within main.
|
||||
**
|
||||
** @see lumiera::AppState
|
||||
** @see lumiera::Option
|
||||
** @see main.cpp
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LUMIERA_SUBSYS_H
|
||||
#define LUMIERA_SUBSYS_H
|
||||
|
||||
//#include "include/symbol.hpp"
|
||||
#include "include/error.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
//#include <boost/scoped_ptr.hpp>
|
||||
//#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
namespace lumiera {
|
||||
|
||||
using std::string;
|
||||
// using boost::scoped_ptr;
|
||||
using boost::noncopyable;
|
||||
|
||||
typedef void (SigTerm)(Error*); ///////////////////TODO better use Glib-- Signal type?
|
||||
|
||||
|
||||
/**
|
||||
* Dependencies and lifecycle of a partially independent Subsystem of the Application.
|
||||
* Using such descriptors, AppState as activated from main() is able to pull up,
|
||||
* maintain and shut down the primary parts of the Application.
|
||||
*/
|
||||
class Subsys
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
// Subsys ();
|
||||
|
||||
virtual ~Subsys () {};
|
||||
|
||||
|
||||
/** define a dependency to another Subsys
|
||||
* required for running this subsystem */
|
||||
Subsys& depends (Subsys& prereq);
|
||||
|
||||
|
||||
/** a query to run on the application option state
|
||||
* to determine if this subsystem should be activated. */
|
||||
virtual bool shouldStart (lumiera::Option&) =0;
|
||||
|
||||
|
||||
/** how to start up this subsystem. Failure to start up
|
||||
* usually terminates the whole application. When this subsystem
|
||||
* ceases to work, it must assure to activate the given signal.
|
||||
* @param termination to be signalled by the subsystem.
|
||||
* @return \c true if actually started. */
|
||||
virtual bool start (lumiera::Option&, SigTerm termination) =0;
|
||||
|
||||
|
||||
/** initiate termination of this subsystem.
|
||||
* @warning must not block nor throw. */
|
||||
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();
|
||||
|
||||
|
||||
private:
|
||||
std::vector<Subsys*> prereq_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------ implementation skeleton ----------
|
||||
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
|
||||
|
||||
#endif
|
||||
|
|
@ -45,13 +45,13 @@
|
|||
#include "common/p.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "common/lumitime.hpp"
|
||||
#include "include/symbol.hpp"
|
||||
#include "include/error.hpp" ///< pulls in NoBug via nobugcfg.h
|
||||
#include "lumiera/appstate.hpp"
|
||||
|
||||
|
||||
/**
|
||||
* Namespace for globals.
|
||||
* A small number of definitions and facilities of application wide relevance.
|
||||
* Lumiera public interface.
|
||||
* Global interfaces and facilities accessible from plugins and scripts.
|
||||
* It's probably a good idea to pull it in explicitly and to avoid nesting
|
||||
* implementation namespaces within \c lumiera::
|
||||
*/
|
||||
|
|
@ -64,7 +64,7 @@ namespace lumiera {
|
|||
|
||||
|
||||
/**
|
||||
* Namespace for support and library code.
|
||||
* Implementation namespace for support and library code.
|
||||
*/
|
||||
namespace lib {
|
||||
|
||||
|
|
@ -73,12 +73,14 @@ namespace lib {
|
|||
|
||||
/**
|
||||
* The asset subsystem of the Proc-Layer.
|
||||
* @todo refactor proc namespaces
|
||||
*/
|
||||
namespace asset { }
|
||||
|
||||
|
||||
/**
|
||||
* Proc-Layer dispatcher, controller and administrative facilities.
|
||||
* @todo refactor proc namespaces
|
||||
*/
|
||||
namespace control { }
|
||||
|
||||
|
|
@ -88,6 +90,7 @@ namespace control { }
|
|||
* Backbone of the engine, render nodes base and cooperation.
|
||||
* A good deal of the active engine code is outside the scope of the
|
||||
* Proc-Layer, e.g. code located in backend services and plugins.
|
||||
* @todo refactor proc namespaces
|
||||
*/
|
||||
namespace engine { }
|
||||
|
||||
|
|
@ -95,6 +98,8 @@ namespace engine { }
|
|||
|
||||
/**
|
||||
* Media-Objects, edit operations and high-level session.
|
||||
* @todo is this interface or implementation ??
|
||||
* @todo refactor proc namespaces
|
||||
*/
|
||||
namespace mobject {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "proc/common.hpp"
|
||||
#include "proc/control/stypemanager.hpp"
|
||||
#include "proc/control/styperegistry.hpp"
|
||||
#include "lumiera/appstate.hpp"
|
||||
|
||||
|
||||
namespace control {
|
||||
|
|
|
|||
Loading…
Reference in a new issue