From b26de14dcf472ed70e689152220bf1eb06d01190 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 20 Jun 2009 09:22:33 +0200 Subject: [PATCH] WIP how to apply the param tuple? --- src/proc/control/command-closure.hpp | 39 +++++++++++++++++++++++++++ src/proc/control/command-mutation.hpp | 10 ------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/proc/control/command-closure.hpp b/src/proc/control/command-closure.hpp index 80ef6f095..a01079ee8 100644 --- a/src/proc/control/command-closure.hpp +++ b/src/proc/control/command-closure.hpp @@ -39,6 +39,7 @@ #include "lib/meta/typelist.hpp" #include "lib/meta/function.hpp" #include "lib/meta/function-closure.hpp" +#include "lib/meta/function-erasure.hpp" #include "lib/meta/tuple.hpp" #include @@ -64,8 +65,19 @@ namespace control { using lumiera::typelist::FunctionSignature; using lumiera::typelist::Tuple; using lumiera::typelist::BuildTupleAccessor; + using lumiera::typelist::TupleApplicator; + using lumiera::typelist::FunErasure; + using lumiera::typelist::StoreFunction; using lumiera::typelist::NullType; + + + /** + * A neutral container internally holding + * the functor used to implement the Command + */ + typedef FunErasure CmdFunctor; + class CmdClosure; typedef std::tr1::shared_ptr PClo; ///< smart-ptr type used for handling concrete closures @@ -81,6 +93,7 @@ namespace control { virtual operator string() const =0; + virtual CmdFunctor bindArguments (CmdFunctor&) =0; }; @@ -158,6 +171,32 @@ namespace control { { } + /** Core operation: use the embedded argument tuple + * to close a given functor over its arguments. + * @param unboundFunctor an function object, whose + * function arguments are required to match + * the types of the embedded ParamStorageTuple + * @return new functor object containing the function, + * which is created by binding all arguments of the + * input functor. + * @note ASSERTION failure if the function signature + * doesn't match the argument types tuple. + * @note when finally invoked, the functor, which is + * bound here to the argument tuple, might actually + * \em modify the param values. Thus this function + * can't be const. + */ + CmdFunctor + bindArguments (CmdFunctor& unboundFunctor) + { + function unboundF (unboundFunctor.getFun()); + TupleApplicator appli (params_); + + function boundFunctor = appli.bind (unboundF); + return CmdFunctor (boundFunctor); + } + + /** create a clone copy of this concrete closure, * hidden behind the generic CmdClosure interface * and owned by a shared_ptr PClo. diff --git a/src/proc/control/command-mutation.hpp b/src/proc/control/command-mutation.hpp index d7711079a..a17f7973e 100644 --- a/src/proc/control/command-mutation.hpp +++ b/src/proc/control/command-mutation.hpp @@ -38,7 +38,6 @@ //#include "pre.hpp" #include "lib/error.hpp" #include "proc/control/command-closure.hpp" -#include "lib/meta/function-erasure.hpp" //#include #include @@ -50,8 +49,6 @@ namespace control { - using lumiera::typelist::FunErasure; - using lumiera::typelist::StoreFunction; // using lumiera::Symbol; // using std::tr1::shared_ptr; using boost::scoped_ptr; @@ -60,13 +57,6 @@ namespace control { using std::string; - /** - * A neutral container internally holding - * the functor used to implement the Command - */ - typedef FunErasure CmdFunctor; - - /** * @todo Type-comment */