From 6ae8ad5d0bf8731a3c7424f4a10aee65bbdd73c9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 15 Jan 2016 22:51:17 +0100 Subject: [PATCH] experiment: bind function to fabricated signature ...and this is cool, since our command framework already provides a nice type constructor / rebinding template, so it's easy to pick up just some arbitrary function signature and fabricate the corresponding "capture" and "undo" signatures. Starting from there, we can construct std::function objects with those specifically tailored signatures, and then bind the actual variadic functions to these. Bottom line is: it seems feasible to create a variadic handler function, and then to emulate command invocations through this function. For one this allows us to build a debugging facility, and besides that it shows a path how to solve the other binding problem GenNode -> command --- research/try.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index b35d87891..077bd3e1a 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -47,6 +47,7 @@ typedef unsigned int uint; //#include "lib/diff/gen-node.hpp" #include "lib/time/timevalue.hpp" +#include "proc/control/command-def.hpp" #include "lib/format-cout.hpp" #include "lib/format-util.hpp" @@ -55,6 +56,8 @@ typedef unsigned int uint; #include //using lib::diff::GenNode; +using proc::control::CommandSignature; +using proc::control::CommandDef; using lib::time::Time; using util::stringify; using util::join; @@ -67,27 +70,67 @@ using VecS = vector; template -string +void operate (ARGS const& ...args) + { + VecS strs = stringify (args...); + cout << join (strs); + } + +template +string +capture (ARGS const& ...args) { VecS strs = stringify (args...); return join (strs); } +template +void +undo (ARGS const& ...args) + { + VecS strs = stringify (args...); + cout << "UNDO..." << join (strs); + } + + + + + +#define SHOW_TYPE(_TY_) \ + cout << "typeof( " << STRINGIFY(_TY_) << " )= " << lib::meta::typeStr<_TY_>() <; + + using FunnySIG = lib::meta::_Fun::Sig; + + using SIG_Opr = CommandSignature::OperateSig; + using SIG_Cap = CommandSignature::CaptureSig; + using SIG_Udo = CommandSignature::UndoOp_Sig; + + SHOW_TYPE (SIG_Opr); + SHOW_TYPE (SIG_Cap); + SHOW_TYPE (SIG_Udo); + + function funny; + function capy; + function undy; - function funny; cout << "funny? " << bool(funny) <; + capy = capture; + undy = undo; cout << "funny? " << bool(funny) <