Commands: add new slot into SessionCommand facade

for the operation to start a new command cycle and open a new instance
This commit is contained in:
Fischlurch 2017-04-09 02:59:16 +02:00
parent a53032cfc5
commit 0dad15209d
7 changed files with 41 additions and 19 deletions

View file

@ -53,6 +53,7 @@
#include "include/interfaceproxy.hpp"
#include "lib/diff/gen-node.hpp"
#include "lib/symbol.hpp"
#include <string>
@ -60,6 +61,7 @@
namespace proc {
namespace control {
using lib::Symbol;
using std::string;
@ -82,11 +84,14 @@ namespace control {
public:
static lumiera::facade::Accessor<SessionCommand> facade;
/** start next command cycle and "open" a new anonymous command instance */
virtual Symbol cycle (Symbol cmdID, string const& invocationID) =0;
/** prepare command invocation: bind the command's arguments */
virtual void bindArg (string const& cmdID, lib::diff::Rec const& args) =0;
virtual void bindArg (Symbol cmdID, lib::diff::Rec const& args) =0;
/** trigger invocation of a prepared command */
virtual void invoke (string const& cmdID) =0;
virtual void invoke (Symbol cmdID) =0;
protected:
@ -105,8 +110,9 @@ extern "C" {
#include "common/interface.h"
LUMIERA_INTERFACE_DECLARE (lumieraorg_SessionCommand, 0,
LUMIERA_INTERFACE_SLOT (void, bindArg, (const char*, const void*)),
LUMIERA_INTERFACE_SLOT (void, invoke, (const char*)),
LUMIERA_INTERFACE_SLOT (const char*, cycle, (const char*, const char*)),
LUMIERA_INTERFACE_SLOT (void, bindArg, (const char*, const void*)),
LUMIERA_INTERFACE_SLOT (void, invoke, (const char*)),
);

View file

@ -107,7 +107,7 @@ namespace lib {
: Symbol{std::string(str)}
{ }
Symbol (Literal const& base, std::string ext)
Symbol (Literal const& base, std::string const& ext)
: Symbol{std::string(base)+"."+ext}
{ }

View file

@ -102,7 +102,7 @@ namespace control {
CommandInstanceManager (CommandDispatch&);
~CommandInstanceManager();
Symbol newInstance (Symbol prototypeID, string invocationID);
Symbol newInstance (Symbol prototypeID, string const& invocationID);
Command& getInstance(Symbol instanceID);
void dispatch (Symbol instanceID);

View file

@ -173,7 +173,7 @@ namespace control {
* @throws error::Logic in case an instance is for this ID combination is already "open"
*/
Symbol
CommandInstanceManager::newInstance (Symbol prototypeID, string invocationID)
CommandInstanceManager::newInstance (Symbol prototypeID, string const& invocationID)
{
Symbol instanceID{prototypeID, invocationID};
Command& instance = table_[instanceID];

View file

@ -65,8 +65,9 @@ namespace facade {
{
//----Proxy-Implementation-of-SessionCommand--------
void bindArg (string const& cmdID, lib::diff::Rec const& args) override { _i_.bindArg (cStr(cmdID), &args); }
void invoke (string const& cmdID) override { _i_.invoke (cStr(cmdID)); }
Symbol cycle (Symbol cmdID, string const& invocID) override { return _i_.cycle (cmdID, cStr(invocID));}
void bindArg (Symbol cmdID, lib::diff::Rec const& args) override { _i_.bindArg (cmdID, &args); }
void invoke (Symbol cmdID) override { _i_.invoke (cmdID); }
public:

View file

@ -56,28 +56,32 @@ namespace control {
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
*/
/** @throw error::Invalid when no suitable command definition exists */
Command
retrieveCommand (string const& cmdID)
retrieveCommand (Symbol cmdID)
{
Symbol cmdSym {cmdID.c_str()};
return Command::get (cmdSym);
return Command::get (cmdID);
}
}
Symbol
SessionCommandService::cycle (Symbol cmdID, string const& invocationID)
{
UNIMPLEMENTED ("Command instance management");
}
void
SessionCommandService::bindArg (string const& cmdID, Rec const& argSeq)
SessionCommandService::bindArg (Symbol cmdID, Rec const& argSeq)
{
retrieveCommand(cmdID).bindArg(argSeq);
}
void
SessionCommandService::invoke (string const& cmdID)
SessionCommandService::invoke (Symbol cmdID)
{
dispatcher_.enqueue (retrieveCommand(cmdID));
}
@ -170,6 +174,15 @@ namespace control {
, LUMIERA_INTERFACE_REF(lumieraorg_interfacedescriptor, 0, lumieraorg_SessionCommandFacade_descriptor)
, NULL /* on open */
, NULL /* on close */
, LUMIERA_INTERFACE_INLINE (cycle,
const char*, (const char* cmdID, const char* invocationID),
{
if (!_instance)
return lumiera_error_set(LUMIERA_ERROR_FACADE_LIFECYCLE, cmdID);
else
return _instance->cycle(cmdID, invocationID);
}
)
, LUMIERA_INTERFACE_INLINE (bindArg,
void, (const char* cmdID, const void* args),
{

View file

@ -46,6 +46,7 @@
#include "common/instancehandle.hpp"
#include "lib/singleton-ref.hpp"
#include "lib/diff/gen-node.hpp"
#include "lib/symbol.hpp"
#include <boost/noncopyable.hpp>
@ -78,8 +79,9 @@ namespace control {
/* === Implementation of the Facade Interface === */
void bindArg (string const& cmdID, Rec const& args) override;
void invoke (string const& cmdID) override;
Symbol cycle (Symbol cmdID, string const& invocationID) override;
void bindArg (Symbol cmdID, Rec const& args) override;
void invoke (Symbol cmdID) override;
/* === Interface Lifecycle === */