diff --git a/src/include/session-command-facade.h b/src/include/session-command-facade.h index 6bf0efd9f..7abdc856a 100644 --- a/src/include/session-command-facade.h +++ b/src/include/session-command-facade.h @@ -36,7 +36,8 @@ ** facade indeed retrieves the corresponding proc::control::Command ** handles to perform the binding operation and hands them over ** to the ProcDispatcher for invocation. - ** + ** + ** @see command.hpp ** @see session-command-service.hpp implementation ** @see proc::control::ProcDispatcher ** @see gui::ctrl::CoreService @@ -62,15 +63,19 @@ namespace control { using std::string; - /*****************************************************************//** - * Global access point to push state update and notification of events - * from the lower layers into the Lumiera GUI. Typically, this happens - * asynchronously and triggered by events within the lower layers. + /**********************************************************************//** + * Global access point to invoke commands and cause edit operations within + * the Session. Any changes to the session are effected by prepared functors + * 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 * the embedded #facade factory, which yields a proxy to route any * calls through the lumieraorg_SessionCommand interface * @throws lumiera::error::State when interface is not opened + * @see [Command system](command.hpp) */ class SessionCommand { diff --git a/src/proc/control/command-dispatch.hpp b/src/proc/control/command-dispatch.hpp index a36e639a4..1a1858ac9 100644 --- a/src/proc/control/command-dispatch.hpp +++ b/src/proc/control/command-dispatch.hpp @@ -23,10 +23,7 @@ /** @file command-dispatch.hpp ** Interface to abstract the DispatcherLoop's ability to handle command messages. - ** //TODO ** - ** @todo WIP-WIP as of 12/2016 - ** ** @see proc-dispatcher.hpp ** @see session-command-service.hpp ** @see DispatcherLoop @@ -38,25 +35,21 @@ #ifndef PROC_CONTROL_COMMAND_DISPATCH_H #define PROC_CONTROL_COMMAND_DISPATCH_H -#include "lib/error.hpp" ////////TODO needed? -//#include "common/subsys.hpp" -//#include "lib/depend.hpp" - -//#include -//#include +#include "proc/control/command.hpp" namespace proc { 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 { @@ -64,16 +57,9 @@ namespace control { public: virtual ~CommandDispatch() { } ///< this is an interface - virtual void clear() =0; /////TODO placeholder code - - - /* == diagnostics == */ - -// size_t size() const ; -// bool empty() const ; - + virtual void clear() =0; /////TODO do we actually need that operation? + virtual void enqueue (Command) =0; }; - ////////////////TODO currently just fleshing out the API.... diff --git a/src/proc/control/command.hpp b/src/proc/control/command.hpp index feec53ff1..caaf63f8f 100644 --- a/src/proc/control/command.hpp +++ b/src/proc/control/command.hpp @@ -23,9 +23,9 @@ /** @file command.hpp ** 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 - ** 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 ** 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 diff --git a/src/proc/control/proc-dispatcher.cpp b/src/proc/control/proc-dispatcher.cpp index 2822e04ae..62b1110ac 100644 --- a/src/proc/control/proc-dispatcher.cpp +++ b/src/proc/control/proc-dispatcher.cpp @@ -92,10 +92,12 @@ #include "proc/control/session-command-service.hpp" #include "proc/mobject/session.hpp" #include "backend/thread-wrapper.hpp" +#include "lib/format-string.hpp" #include using backend::ThreadJoinable; +using util::_Fmt; using lib::Sync; using lib::RecursiveLock_Waitable; using std::unique_ptr; @@ -183,6 +185,17 @@ namespace control { //////////////////////////////////////////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() const { diff --git a/src/proc/control/session-command-service.cpp b/src/proc/control/session-command-service.cpp index 3a9fad38a..7699b5865 100644 --- a/src/proc/control/session-command-service.cpp +++ b/src/proc/control/session-command-service.cpp @@ -23,14 +23,19 @@ /** @file session-command-service.cpp ** Implementation of command invocation on the Session interface. ** This is the actual service implementation and runs within Session subsystem. - ** - ** @todo implement a minimal version of a "Session subsystem" and instantiate SessionCommandService there ///////////TICKET #318 + ** It is managed by the DispatcherLoop, which also starts the Session Loop Thread. + ** 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/command.hpp" #include "include/logging.h" #include "lib/depend.hpp" +#include "lib/symbol.hpp" #include "lib/util.hpp" extern "C" { @@ -45,21 +50,36 @@ extern "C" { namespace proc { namespace control { + using lib::Symbol; using std::string; 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 - SessionCommandService::bindArg (string const& cmdID, Rec const& args) + SessionCommandService::bindArg (string const& cmdID, Rec const& argSeq) { - UNIMPLEMENTED ("bind command with arguments from Record"); ////////////////////////TODO actually do something + retrieveCommand(cmdID).bindArg(argSeq); } void SessionCommandService::invoke (string const& cmdID) { - UNIMPLEMENTED ("enqueue command with ProcDispatcher"); ////////////////////////TODO actually do something + dispatcher_.enqueue (retrieveCommand(cmdID)); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7bd7c27f7..b03a660a8 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -410,7 +410,18 @@ - + + + + + + +

+ Session-Subsystem implementieren (#318) +

+ + +
@@ -526,13 +537,13 @@
- - + + - - + + @@ -625,10 +636,10 @@ - - + + - + @@ -640,6 +651,7 @@ + @@ -10905,8 +10917,8 @@ - - + + @@ -11097,6 +11109,12 @@ + + + + + +