WIP how to apply the param tuple?
This commit is contained in:
parent
bc94f299e2
commit
b26de14dcf
2 changed files with 39 additions and 10 deletions
|
|
@ -39,6 +39,7 @@
|
||||||
#include "lib/meta/typelist.hpp"
|
#include "lib/meta/typelist.hpp"
|
||||||
#include "lib/meta/function.hpp"
|
#include "lib/meta/function.hpp"
|
||||||
#include "lib/meta/function-closure.hpp"
|
#include "lib/meta/function-closure.hpp"
|
||||||
|
#include "lib/meta/function-erasure.hpp"
|
||||||
#include "lib/meta/tuple.hpp"
|
#include "lib/meta/tuple.hpp"
|
||||||
|
|
||||||
#include <tr1/memory>
|
#include <tr1/memory>
|
||||||
|
|
@ -64,9 +65,20 @@ namespace control {
|
||||||
using lumiera::typelist::FunctionSignature;
|
using lumiera::typelist::FunctionSignature;
|
||||||
using lumiera::typelist::Tuple;
|
using lumiera::typelist::Tuple;
|
||||||
using lumiera::typelist::BuildTupleAccessor;
|
using lumiera::typelist::BuildTupleAccessor;
|
||||||
|
using lumiera::typelist::TupleApplicator;
|
||||||
|
using lumiera::typelist::FunErasure;
|
||||||
|
using lumiera::typelist::StoreFunction;
|
||||||
|
|
||||||
using lumiera::typelist::NullType;
|
using lumiera::typelist::NullType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A neutral container internally holding
|
||||||
|
* the functor used to implement the Command
|
||||||
|
*/
|
||||||
|
typedef FunErasure<StoreFunction> CmdFunctor;
|
||||||
|
|
||||||
|
|
||||||
class CmdClosure;
|
class CmdClosure;
|
||||||
typedef std::tr1::shared_ptr<CmdClosure> PClo; ///< smart-ptr type used for handling concrete closures
|
typedef std::tr1::shared_ptr<CmdClosure> PClo; ///< smart-ptr type used for handling concrete closures
|
||||||
|
|
||||||
|
|
@ -81,6 +93,7 @@ namespace control {
|
||||||
|
|
||||||
virtual operator string() const =0;
|
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<void()>,
|
||||||
|
* 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<SIG> unboundF (unboundFunctor.getFun<SIG>());
|
||||||
|
TupleApplicator<SIG> appli (params_);
|
||||||
|
|
||||||
|
function<void()> boundFunctor = appli.bind (unboundF);
|
||||||
|
return CmdFunctor (boundFunctor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** create a clone copy of this concrete closure,
|
/** create a clone copy of this concrete closure,
|
||||||
* hidden behind the generic CmdClosure interface
|
* hidden behind the generic CmdClosure interface
|
||||||
* and owned by a shared_ptr PClo.
|
* and owned by a shared_ptr PClo.
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
//#include "pre.hpp"
|
//#include "pre.hpp"
|
||||||
#include "lib/error.hpp"
|
#include "lib/error.hpp"
|
||||||
#include "proc/control/command-closure.hpp"
|
#include "proc/control/command-closure.hpp"
|
||||||
#include "lib/meta/function-erasure.hpp"
|
|
||||||
|
|
||||||
//#include <tr1/memory>
|
//#include <tr1/memory>
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
@ -50,8 +49,6 @@
|
||||||
|
|
||||||
namespace control {
|
namespace control {
|
||||||
|
|
||||||
using lumiera::typelist::FunErasure;
|
|
||||||
using lumiera::typelist::StoreFunction;
|
|
||||||
// using lumiera::Symbol;
|
// using lumiera::Symbol;
|
||||||
// using std::tr1::shared_ptr;
|
// using std::tr1::shared_ptr;
|
||||||
using boost::scoped_ptr;
|
using boost::scoped_ptr;
|
||||||
|
|
@ -60,13 +57,6 @@ namespace control {
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A neutral container internally holding
|
|
||||||
* the functor used to implement the Command
|
|
||||||
*/
|
|
||||||
typedef FunErasure<StoreFunction> CmdFunctor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Type-comment
|
* @todo Type-comment
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue