experiment: now bind a Proc-Layer command to these fabricated functions

yeah! it works.

some problems though.
- problem-A : reference arguments
  * we're storing the parameters as-is
  * for not-yet-bound commands we need to store default constructed values
  * together this means we can not handle reference arguments
- problem-B : noncopyable arguments
  * especially our Time values are noncopyable.
  * this is going to become a huge problem for sure!
This commit is contained in:
Fischlurch 2016-01-15 23:55:44 +01:00
parent 9c346ca914
commit c4adc234b4
2 changed files with 24 additions and 7 deletions

View file

@ -13,7 +13,7 @@ envR.Append(CPPPATH='research')
# envR.Append(CCFLAGS=' -O3 ')
# build additional test and administrative tools....
experiments = [ envR.Program('try', ['try.cpp'] + support_lib) #### to try out some feature...
experiments = [ envR.Program('try', ['try.cpp'] + core) #### to try out some feature...
, envR.Program('clang-static-init', ['clang-static-init-1.cpp', 'clang-static-init-2.cpp'])
]

View file

@ -60,6 +60,8 @@ using lib::meta::Types;
using lib::meta::NullType;
using proc::control::CommandSignature;
using proc::control::CommandDef;
using proc::control::Command;
using lib::time::TimeVar;
using lib::time::Time;
using util::stringify;
using util::join;
@ -91,24 +93,24 @@ template<typename...ARGS>
struct Funny
{
static void
operate (ARGS const& ...args)
operate (ARGS ...args)
{
VecS strs = stringify<VecS> (args...);
cout << join (strs);
cout << join (strs) <<endl;
}
static string
capture (ARGS const& ...args)
capture (ARGS ...args)
{
VecS strs = stringify<VecS> (args...);
return join (strs);
}
static void
undo (ARGS const& ...args, string plonk)
undo (ARGS ...args, string plonk)
{
VecS strs = stringify<VecS> (args...);
cout << "UNDO..." << plonk << "args=" << join (strs);
cout << "UNDO..." << plonk << "| args=" << join (strs) <<endl;
}
};
@ -132,7 +134,7 @@ main (int, char**)
cout << Funny<const char*, string, int, long, double>::capture ("lalü", string("lala"), 12, 34L, 56.78) <<endl;
auto ops = Funny<double,Time>::operate;
auto ops = Funny<double,TimeVar>::operate;
using FunnySIG = lib::meta::_Fun<typeof(ops)>::Sig;
@ -160,6 +162,21 @@ main (int, char**)
cout << capy (98.7654321987654321987654321, Time(1,2,3,4)) <<endl;
CommandDef("lalü")
.operation(Funny<ArgS>::operate)
.captureUndo(Funny<ArgS>::capture)
.undoOperation(Funny<ArgS>::undo);
cout << Command("lalü") << endl;
Command com = Command("lalü");
com.bind(12.33445566778899, TimeVar(Time(4,3,2,1)));
com();
com.undo();
cout << "\n.gulp.\n";
return 0;