Commands: integrate inline command definition by lambda

...this was the problematic part of the whole design attempted here,
and seemingly it works like a charm!
This commit is contained in:
Fischlurch 2017-03-18 17:56:41 +01:00
parent 180b1224e7
commit e9948084fc
2 changed files with 34 additions and 4 deletions

View file

@ -168,13 +168,13 @@ namespace control {
void
setArguments (Arguments& args)
{
{ //////////////////////////////////////TICKET #1095 : explicit argument arity check here
pClo_->bindArguments (args);
}
void
setArguments (lib::diff::Rec const& paramData)
{
{ //////////////////////////////////////TICKET #1095 : explicit argument arity check here
pClo_->bindArguments (paramData);
}

View file

@ -34,6 +34,8 @@
//#include <cstdlib>
#include <string>
#include <regex>
//using std::rand;
@ -48,6 +50,8 @@ namespace test {
//using lib::time::Offset;
using lib::Literal;
using std::string;
using std::regex;
using std::regex_replace;
@ -66,6 +70,25 @@ namespace test {
testString = "Ichthyostega wuz here";
cout << "after--->" << testString << endl;
}
void
operate (string search, string replace)
{
testString = regex_replace (testString, regex(search), replace);
}
string
capture (string, string)
{
return testString;
}
void
undoIt (string, string, string oldVal)
{
testString = oldVal;
}
}
@ -122,7 +145,14 @@ namespace test {
CHECK (CommandSetup::pendingCnt() == 1);
CommandSetup def_1{"test.CommandSetup.def_1"};
CommandSetup def_1 = CommandSetup{"test.CommandSetup.def_1"}
= [](CommandDef def)
{
def.operation (operate)
.captureUndo (capture)
.undoOperation (undoIt);
};
CommandSetup def_2{"test.CommandSetup.def_2"};
//////////// does not compile -- copy assignment prohibited...
@ -136,7 +166,7 @@ namespace test {
{
size_t cnt = CommandSetup::invokeDefinitionClosures();
CHECK (CommandSetup::pendingCnt() == 0);
CHECK (cnt == 1);
CHECK (cnt == 2);
CHECK (testString == "Ichthyostega wuz here");
TODO ("verify the command definitions happened");
}