From 16597fcd99a054c8de1db26baf04d584e7b1a567 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 22 Jan 2016 20:29:45 +0100 Subject: [PATCH] extend command API to also accept a lib::diff::Rec for arguments WIP: have to decide how the arguments can be unpacked and how to generate proper runtime type mismatch errors. --- src/proc/control/command.hpp | 12 ++++++++++-- tests/gui/test/test-nexus.cpp | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/proc/control/command.hpp b/src/proc/control/command.hpp index 04a718633..639ccb52f 100644 --- a/src/proc/control/command.hpp +++ b/src/proc/control/command.hpp @@ -60,6 +60,7 @@ #include "proc/control/handling-pattern.hpp" #include "lib/meta/tuple-helper.hpp" #include "lib/bool-checkable.hpp" +#include "lib/diff/gen-node.hpp" #include "lib/handle.hpp" #include @@ -134,8 +135,7 @@ namespace control { template Command& bindArg (std::tuple const&); - /////////////////////////////////////////////////////////////TICKET #798 : we need a second overload to take the arguments as lib::diff::Record. - ///////////////////////////////////////////////////////////// : this needs to be built into the ParamAccessor within Closure (command-closure.hpp) + Command& bindArg (lib::diff::Rec const&); ExecResult operator() () ; @@ -231,6 +231,14 @@ namespace control { } + inline Command& + Command::bindArg (lib::diff::Rec const& paramData) + { + UNIMPLEMENTED ("how to accept a GenNode-Rec and unpack it into our argument holder..."); + } + + + /* == state predicate shortcuts == */ diff --git a/tests/gui/test/test-nexus.cpp b/tests/gui/test/test-nexus.cpp index 2bc55fce6..7391a05bd 100644 --- a/tests/gui/test/test-nexus.cpp +++ b/tests/gui/test/test-nexus.cpp @@ -466,12 +466,16 @@ namespace test{ /* ==== CommandHandler ==== */ + /** Case-1: the message provides parameter data to bind to the command */ bool - handle (Rec const& argBinding) override + handle (Rec const& argData) override { - log_.event("TestNexus", "bound command arguments "+string(argBinding)); + command_.bindArg (argData); + log_.event("TestNexus", "bound command arguments "+string(argData)); + return true; } + /** Case-2: the message triggers execution of a prepared command */ bool handle (int const&) override {