SessionCommandService implemented by delegating to the ProcDispatcher

This commit is contained in:
Fischlurch 2016-12-23 23:42:27 +01:00
parent b3f0605b9b
commit b6d5cd1c76
6 changed files with 86 additions and 44 deletions

View file

@ -37,6 +37,7 @@
** handles to perform the binding operation and hands them over ** handles to perform the binding operation and hands them over
** to the ProcDispatcher for invocation. ** to the ProcDispatcher for invocation.
** **
** @see command.hpp
** @see session-command-service.hpp implementation ** @see session-command-service.hpp implementation
** @see proc::control::ProcDispatcher ** @see proc::control::ProcDispatcher
** @see gui::ctrl::CoreService ** @see gui::ctrl::CoreService
@ -62,15 +63,19 @@ namespace control {
using std::string; using std::string;
/*****************************************************************//** /**********************************************************************//**
* Global access point to push state update and notification of events * Global access point to invoke commands and cause edit operations within
* from the lower layers into the Lumiera GUI. Typically, this happens * the Session. Any changes to the session are effected by prepared functors
* asynchronously and triggered by events within the lower layers. * bound into a proc::control::Command registration. A command instance will
* first be outfitted with suitable parameters to define the target and to
* qualify and elaborate the action, before it can be actually triggered.
* Commands then go through a queue to be invoked one by one.
* *
* This is a layer separation facade interface. Clients should use * This is a layer separation facade interface. Clients should use
* the embedded #facade factory, which yields a proxy to route any * the embedded #facade factory, which yields a proxy to route any
* calls through the lumieraorg_SessionCommand interface * calls through the lumieraorg_SessionCommand interface
* @throws lumiera::error::State when interface is not opened * @throws lumiera::error::State when interface is not opened
* @see [Command system](command.hpp)
*/ */
class SessionCommand class SessionCommand
{ {

View file

@ -23,9 +23,6 @@
/** @file command-dispatch.hpp /** @file command-dispatch.hpp
** Interface to abstract the DispatcherLoop's ability to handle command messages. ** Interface to abstract the DispatcherLoop's ability to handle command messages.
** //TODO
**
** @todo WIP-WIP as of 12/2016
** **
** @see proc-dispatcher.hpp ** @see proc-dispatcher.hpp
** @see session-command-service.hpp ** @see session-command-service.hpp
@ -38,25 +35,21 @@
#ifndef PROC_CONTROL_COMMAND_DISPATCH_H #ifndef PROC_CONTROL_COMMAND_DISPATCH_H
#define PROC_CONTROL_COMMAND_DISPATCH_H #define PROC_CONTROL_COMMAND_DISPATCH_H
#include "lib/error.hpp" ////////TODO needed? #include "proc/control/command.hpp"
//#include "common/subsys.hpp"
//#include "lib/depend.hpp"
//#include <memory>
//#include <functional>
namespace proc { namespace proc {
namespace control { namespace control {
// using lib::Symbol;
// using std::bind;
/** /**
* @todo Type-comment * Interface of a service to perform Commands on the session.
* Commands committed here need to be ready for actual performance
* on the _current session._ They will be sent through a queue
* to be performed one by one.
*/ */
class CommandDispatch class CommandDispatch
{ {
@ -64,16 +57,9 @@ namespace control {
public: public:
virtual ~CommandDispatch() { } ///< this is an interface virtual ~CommandDispatch() { } ///< this is an interface
virtual void clear() =0; /////TODO placeholder code virtual void clear() =0; /////TODO do we actually need that operation?
virtual void enqueue (Command) =0;
/* == diagnostics == */
// size_t size() const ;
// bool empty() const ;
}; };
////////////////TODO currently just fleshing out the API....

View file

@ -23,9 +23,9 @@
/** @file command.hpp /** @file command.hpp
** Proc-Layer command frontend. ** Proc-Layer command frontend.
** A \b command is a functor, which can be invoked according to a pre-defined HandlingPattern. ** A *command* is a functor, which can be invoked according to a pre-defined HandlingPattern.
** Most notably, command invocation can be scheduled and logged with the serialiser, and the effect ** Most notably, command invocation can be scheduled and logged with the serialiser, and the effect
** of any command invocation can be \em undone later on by invoking the "undo operation" defined ** of any command invocation can be _undone_ later on by invoking the "undo operation" defined
** alongside with the command's operation. The command operation is defined through a C/C++ function ** alongside with the command's operation. The command operation is defined through a C/C++ function
** and may receive an arbitrary number and type of arguments. After setting up such a CommandDef , ** and may receive an arbitrary number and type of arguments. After setting up such a CommandDef ,
** it can be referred for use through a symbolic ID. Before being able to invoke the command, concrete ** it can be referred for use through a symbolic ID. Before being able to invoke the command, concrete

View file

@ -92,10 +92,12 @@
#include "proc/control/session-command-service.hpp" #include "proc/control/session-command-service.hpp"
#include "proc/mobject/session.hpp" #include "proc/mobject/session.hpp"
#include "backend/thread-wrapper.hpp" #include "backend/thread-wrapper.hpp"
#include "lib/format-string.hpp"
#include <memory> #include <memory>
using backend::ThreadJoinable; using backend::ThreadJoinable;
using util::_Fmt;
using lib::Sync; using lib::Sync;
using lib::RecursiveLock_Waitable; using lib::RecursiveLock_Waitable;
using std::unique_ptr; using std::unique_ptr;
@ -183,6 +185,17 @@ namespace control {
//////////////////////////////////////////TODO notify!!!! //////////////////////////////////////////TODO notify!!!!
} }
void
enqueue (Command cmd) override
{
if (not cmd.canExec())
throw error::Logic(_Fmt("Reject '%s'. Not suitably prepared for invocation: %s")
% cmd.getID() % cmd
, LUMIERA_ERROR_UNBOUND_ARGUMENTS);
UNIMPLEMENTED ("enqueue command");
//////////////////////////////////////////TODO notify!!!!
}
size_t size_t
size() const size() const
{ {

View file

@ -23,14 +23,19 @@
/** @file session-command-service.cpp /** @file session-command-service.cpp
** Implementation of command invocation on the Session interface. ** Implementation of command invocation on the Session interface.
** This is the actual service implementation and runs within Session subsystem. ** This is the actual service implementation and runs within Session subsystem.
** ** It is managed by the DispatcherLoop, which also starts the Session Loop Thread.
** @todo implement a minimal version of a "Session subsystem" and instantiate SessionCommandService there ///////////TICKET #318 ** Moreover, for actually perform any command, the command operation needs to be
** defined somewhere statically, as a function operating on the _current session,_
** plus an _state capturing_ and _UNDO_ function. And the concrete arguments of
** the command functor must be suitably bound.
** **
*/ */
#include "proc/control/session-command-service.hpp" #include "proc/control/session-command-service.hpp"
#include "proc/control/command.hpp"
#include "include/logging.h" #include "include/logging.h"
#include "lib/depend.hpp" #include "lib/depend.hpp"
#include "lib/symbol.hpp"
#include "lib/util.hpp" #include "lib/util.hpp"
extern "C" { extern "C" {
@ -45,21 +50,36 @@ extern "C" {
namespace proc { namespace proc {
namespace control { namespace control {
using lib::Symbol;
using std::string; using std::string;
using util::cStr; using util::cStr;
namespace {
/** @todo workaround until we're able to retrieve a Symbol by string ////////////////////////TICKET #158 : symbol table to get a Symbol from string representation
* @throw error::Invalid when no suitable command definition exists
*/
Command
retrieveCommand (string const& cmdID)
{
Symbol cmdSym {cmdID.c_str()};
return Command::get (cmdSym);
}
}
void void
SessionCommandService::bindArg (string const& cmdID, Rec const& args) SessionCommandService::bindArg (string const& cmdID, Rec const& argSeq)
{ {
UNIMPLEMENTED ("bind command with arguments from Record<GenNode>"); ////////////////////////TODO actually do something retrieveCommand(cmdID).bindArg(argSeq);
} }
void void
SessionCommandService::invoke (string const& cmdID) SessionCommandService::invoke (string const& cmdID)
{ {
UNIMPLEMENTED ("enqueue command with ProcDispatcher"); ////////////////////////TODO actually do something dispatcher_.enqueue (retrieveCommand(cmdID));
} }

View file

@ -410,7 +410,18 @@
</node> </node>
</node> </node>
<node CREATED="1481320850779" ID="ID_1632600003" MODIFIED="1481320854143" TEXT="hochfahren"> <node CREATED="1481320850779" ID="ID_1632600003" MODIFIED="1481320854143" TEXT="hochfahren">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481509921211" ID="ID_1515469097" MODIFIED="1481599502388" TEXT="TODO: Session-Subsystem implementieren (#318)"> <node CREATED="1481509921211" ID="ID_1515469097" MODIFIED="1482532921007">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
Session-Subsystem implementieren <font color="#c60814">(#318)</font>
</p>
</body>
</html>
</richcontent>
<icon BUILTIN="pencil"/> <icon BUILTIN="pencil"/>
<node CREATED="1481599413419" ID="ID_673133356" MODIFIED="1481599420290" TEXT="Ticket #318"/> <node CREATED="1481599413419" ID="ID_673133356" MODIFIED="1481599420290" TEXT="Ticket #318"/>
<node CREATED="1482464327133" ID="ID_996095134" MODIFIED="1482464370699" TEXT="was es ist"> <node CREATED="1482464327133" ID="ID_996095134" MODIFIED="1482464370699" TEXT="was es ist">
@ -526,13 +537,13 @@
</node> </node>
</node> </node>
</node> </node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481510231986" ID="ID_45803267" MODIFIED="1481510243425" TEXT="TODO: dort SessionCommandService instantiieren"> <node COLOR="#338800" CREATED="1481510231986" ID="ID_45803267" MODIFIED="1482530111326" TEXT="dort SessionCommandService instantiieren">
<icon BUILTIN="flag-yellow"/> <icon BUILTIN="button_ok"/>
<node CREATED="1481769089234" ID="ID_1152351588" MODIFIED="1481769124140" TEXT="lebt in der DispatcherLoop"> <node CREATED="1481769089234" ID="ID_1152351588" MODIFIED="1481769124140" TEXT="lebt in der DispatcherLoop">
<arrowlink COLOR="#4aff51" DESTINATION="ID_1364443356" ENDARROW="Default" ENDINCLINATION="10;30;" ID="Arrow_ID_870320696" STARTARROW="Default" STARTINCLINATION="-221;-88;"/> <arrowlink COLOR="#4aff51" DESTINATION="ID_1364443356" ENDARROW="Default" ENDINCLINATION="10;30;" ID="Arrow_ID_870320696" STARTARROW="Default" STARTINCLINATION="-221;-88;"/>
</node> </node>
<node CREATED="1481769144226" ID="ID_1609251574" MODIFIED="1481769153389" TEXT="mu&#xdf; Service-API extrahieren"> <node CREATED="1481769144226" ID="ID_1609251574" MODIFIED="1482532883149" TEXT="mu&#xdf; Service-API extrahieren">
<icon BUILTIN="pencil"/> <icon BUILTIN="button_ok"/>
</node> </node>
<node CREATED="1481777039358" ID="ID_395609084" MODIFIED="1481777050096" TEXT="Shutdown sauber regeln"> <node CREATED="1481777039358" ID="ID_395609084" MODIFIED="1481777050096" TEXT="Shutdown sauber regeln">
<node CREATED="1481777054755" ID="ID_1551225439" MODIFIED="1481778421924"> <node CREATED="1481777054755" ID="ID_1551225439" MODIFIED="1481778421924">
@ -625,10 +636,10 @@
<node CREATED="1482466246933" ID="ID_870716233" MODIFIED="1482466256655" TEXT="h&#xe4;ngt von der Verwendung ab"/> <node CREATED="1482466246933" ID="ID_870716233" MODIFIED="1482466256655" TEXT="h&#xe4;ngt von der Verwendung ab"/>
<node CREATED="1482466257027" ID="ID_1491453181" MODIFIED="1482466260134" TEXT="von InvocationTrail"/> <node CREATED="1482466257027" ID="ID_1491453181" MODIFIED="1482466260134" TEXT="von InvocationTrail"/>
<node CREATED="1482466260627" ID="ID_1708185529" MODIFIED="1482466265989" TEXT="wie Commands im UI gebunden werden"/> <node CREATED="1482466260627" ID="ID_1708185529" MODIFIED="1482466265989" TEXT="wie Commands im UI gebunden werden"/>
<node CREATED="1482466271713" ID="ID_1519273419" MODIFIED="1482466437871" TEXT="Nur IDs gehen &#xfc;ber die Leitung"> <node CREATED="1482466271713" ID="ID_1519273419" MODIFIED="1482524336076" TEXT="Nur IDs gehen &#xfc;ber die Leitung">
<icon BUILTIN="idea"/> <icon BUILTIN="info"/>
</node> </node>
<node CREATED="1482466587807" ID="ID_135147405" MODIFIED="1482466599044"> <node CREATED="1482466587807" ID="ID_135147405" MODIFIED="1482524332833">
<richcontent TYPE="NODE"><html> <richcontent TYPE="NODE"><html>
<head> <head>
@ -640,6 +651,7 @@
</body> </body>
</html> </html>
</richcontent> </richcontent>
<icon BUILTIN="idea"/>
</node> </node>
<node CREATED="1482466285359" ID="ID_1077952925" MODIFIED="1482466316309" TEXT="Zugriff auf proc::control::Command is OK"> <node CREATED="1482466285359" ID="ID_1077952925" MODIFIED="1482466316309" TEXT="Zugriff auf proc::control::Command is OK">
<icon BUILTIN="yes"/> <icon BUILTIN="yes"/>
@ -10905,8 +10917,8 @@
</node> </node>
</node> </node>
</node> </node>
<node CREATED="1448314834155" ID="ID_1725514536" MODIFIED="1448314977228" POSITION="right" TEXT="Integrate"> <node CREATED="1448314834155" ID="ID_1725514536" MODIFIED="1482524387497" POSITION="right" TEXT="Integral">
<node CREATED="1448315011484" ID="ID_867104544" MODIFIED="1448315014471" TEXT="generic"> <node CREATED="1448315011484" ID="ID_867104544" MODIFIED="1482524639777" TEXT="generisch">
<node CREATED="1448315015107" ID="ID_1900900399" MODIFIED="1448315016511" TEXT="JSON"> <node CREATED="1448315015107" ID="ID_1900900399" MODIFIED="1448315016511" TEXT="JSON">
<node CREATED="1448315031553" ID="ID_1177387568" MODIFIED="1448321655258" TEXT="parser"> <node CREATED="1448315031553" ID="ID_1177387568" MODIFIED="1448321655258" TEXT="parser">
<icon BUILTIN="button_ok"/> <icon BUILTIN="button_ok"/>
@ -11097,6 +11109,12 @@
</node> </node>
</node> </node>
</node> </node>
<node CREATED="1482524641484" ID="ID_1651495185" MODIFIED="1482524645893" TEXT="Architektur"/>
<node CREATED="1482524498822" ID="ID_431883229" MODIFIED="1482524501904" TEXT="Datenstrom"/>
<node CREATED="1482524516371" ID="ID_396707258" MODIFIED="1482524525561" TEXT="Event-Sourcing"/>
<node CREATED="1482524530842" ID="ID_606738640" MODIFIED="1482524535059" TEXT="Dependency-Injection"/>
<node CREATED="1482524535575" ID="ID_387248900" MODIFIED="1482524540392" TEXT="Extension-System"/>
<node CREATED="1482524569705" ID="ID_1815572475" MODIFIED="1482524583394" TEXT="Parametrisierung"/>
</node> </node>
<node CREATED="1448314890907" ID="ID_411012156" MODIFIED="1448314929930" POSITION="right" TEXT="Session"> <node CREATED="1448314890907" ID="ID_411012156" MODIFIED="1448314929930" POSITION="right" TEXT="Session">
<node CREATED="1481688464060" ID="ID_53574817" MODIFIED="1481688467351" TEXT="Architektur"> <node CREATED="1481688464060" ID="ID_53574817" MODIFIED="1481688467351" TEXT="Architektur">