diff --git a/src/proc/control/command-argument-holder.hpp b/src/proc/control/command-argument-holder.hpp index e196e4698..11480695c 100644 --- a/src/proc/control/command-argument-holder.hpp +++ b/src/proc/control/command-argument-holder.hpp @@ -45,6 +45,7 @@ //#include "pre.hpp" //#include "lib/error.hpp" +#include "proc/control/argument-tuple-accept.hpp" #include "proc/control/command-closure.hpp" #include "proc/control/memento-tie.hpp" @@ -104,14 +105,17 @@ namespace control { * actually allocating storage to hold the command arguments * and the undo state (memento) for Proc-Layer commands. * Both the contained components within ArgumentHolder - * can be in \em empty state; there is no distinct + * can be in \em empty state; there are no distinct * lifecycle limitations. ArgumentHolder is part * of Proc-Layer command's implementation * and should not be used standalone. */ template class ArgumentHolder - : public CmdClosure + : public ArgumentTupleAccept< SIG // to derive the desired bind(..) signature + , ArgumentHolder // target class providing the implementation + , CmdClosure // base class to inherit from + > { Closure arguments_; MementoTie memento_; @@ -141,8 +145,8 @@ namespace control { virtual operator string() const { return "Command-State{ arguments=" - + arguments_? arguments_ : "unbound" - + memento_ ? ", }" : " }" + + (arguments_? string(arguments_) : "unbound") + + (memento_ ? ", }" : " }") ; } @@ -159,14 +163,14 @@ namespace control { { } /** has undo state capturing been invoked? */ - bool canUndo () { return bool(memento_); } - bool empty () { return !arguments_; } + bool canUndo () const { return bool(memento_); } + bool empty () const { return !arguments_; } /** store a new argument tuple within this ArgumentHolder, * discarding and previously stored arguments */ void - bind (ArgTuple argTup) + bindArg (ArgTuple argTup) { this->arguments_ = Closure (argTup); } @@ -185,6 +189,15 @@ namespace control { return this->memento_ = MementoTie (undoFunc,captureFunc); } + + /** direct "backdoor" access to stored memento value. + * @note you might access a placeholder when called prior to \c tie(..) */ + MEM& + memento () + { + return memento_.getState(); + } + }; diff --git a/src/proc/control/command-closure.hpp b/src/proc/control/command-closure.hpp index 34498fe18..71dbe7384 100644 --- a/src/proc/control/command-closure.hpp +++ b/src/proc/control/command-closure.hpp @@ -97,7 +97,7 @@ namespace control { virtual operator string() const =0; - virtual bool isValid () const { return true; } + virtual bool isValid () const =0; virtual CmdFunctor bindArguments (CmdFunctor&) =0; }; @@ -212,6 +212,9 @@ namespace control { else return dumped+")"; } + + + bool isValid () const { return true; } }; diff --git a/tests/components/proc/control/command-argument-test.cpp b/tests/components/proc/control/command-argument-test.cpp index 3ff10cc23..e796d9646 100644 --- a/tests/components/proc/control/command-argument-test.cpp +++ b/tests/components/proc/control/command-argument-test.cpp @@ -51,7 +51,8 @@ //using std::tr1::placeholders::_2; //using std::tr1::function; using util::isnil; -using util::and_all; +//using util::and_all; +using util::for_each; using boost::format; using lumiera::Time; //using util::contains; @@ -178,46 +179,60 @@ namespace test { virtual void run (Arg) { -#if false ////////////////////////////////////////////////////////////////////////////TODO..... ArgTuples testTuples; Tracker