helper for accepting arguments passes unit test
This commit is contained in:
parent
30db042b16
commit
fa3d596a59
4 changed files with 40 additions and 41 deletions
|
|
@ -22,11 +22,11 @@
|
||||||
|
|
||||||
|
|
||||||
/** @file argument-tuple-accept.hpp
|
/** @file argument-tuple-accept.hpp
|
||||||
** This template allows to mix in a \c bind(...) function.
|
** The ArgumentTupleAccept template allows to mix in a \c bind(...) function.
|
||||||
** Thereby, the correct number and types of arguments is derived
|
** Thereby, the correct number and types of arguments is derived according to
|
||||||
** according to the function signature given as template parameter.
|
** the function signature given as template parameter. This helper template is
|
||||||
** This helper template is used for the ArgumentHolder and generally
|
** used for the ArgumentHolder and generally for binding the arguments when
|
||||||
** for binding arguments for Proc-Layer commands.
|
** defining Proc-Layer commands.
|
||||||
**
|
**
|
||||||
** @see CommandDef
|
** @see CommandDef
|
||||||
** @see ArgumentHolder
|
** @see ArgumentHolder
|
||||||
|
|
@ -39,34 +39,22 @@
|
||||||
#ifndef CONTROL_ARGUMENT_TUPLE_ACCEPT_H
|
#ifndef CONTROL_ARGUMENT_TUPLE_ACCEPT_H
|
||||||
#define CONTROL_ARGUMENT_TUPLE_ACCEPT_H
|
#define CONTROL_ARGUMENT_TUPLE_ACCEPT_H
|
||||||
|
|
||||||
//#include "pre.hpp"
|
|
||||||
//#include "lib/error.hpp"
|
|
||||||
#include "lib/meta/typelist.hpp"
|
#include "lib/meta/typelist.hpp"
|
||||||
#include "lib/meta/typelist-util.hpp"
|
|
||||||
#include "lib/meta/function.hpp"
|
#include "lib/meta/function.hpp"
|
||||||
#include "lib/meta/tuple.hpp"
|
#include "lib/meta/tuple.hpp"
|
||||||
|
|
||||||
//#include <tr1/memory>
|
|
||||||
//#include <boost/scoped_ptr.hpp>
|
|
||||||
//#include <tr1/functional>
|
|
||||||
//#include <iostream>
|
|
||||||
//#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace control {
|
namespace control {
|
||||||
|
|
||||||
// using lumiera::Symbol;
|
|
||||||
// using std::tr1::shared_ptr;
|
|
||||||
// using boost::scoped_ptr;
|
|
||||||
// using std::tr1::function;
|
|
||||||
// using std::ostream;
|
|
||||||
// using std::string;
|
|
||||||
|
|
||||||
namespace bind_arg {
|
namespace bind_arg { // internals....
|
||||||
|
|
||||||
using namespace lumiera::typelist;
|
using namespace lumiera::typelist;
|
||||||
|
|
||||||
|
|
||||||
|
/** @internal mix in a \c bind() function
|
||||||
|
*/
|
||||||
template< class TAR, class BA
|
template< class TAR, class BA
|
||||||
, typename TYPES
|
, typename TYPES
|
||||||
>
|
>
|
||||||
|
|
@ -83,7 +71,7 @@ namespace control {
|
||||||
void
|
void
|
||||||
bind ()
|
bind ()
|
||||||
{
|
{
|
||||||
static_cast<TAR*> (this) -> bind (tuple::makeNullTuple() );
|
static_cast<TAR*> (this) -> bindArg (tuple::makeNullTuple() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -97,7 +85,7 @@ namespace control {
|
||||||
void
|
void
|
||||||
bind (T1 a1)
|
bind (T1 a1)
|
||||||
{
|
{
|
||||||
static_cast<TAR*> (this) -> bind (tuple::make (a1));
|
static_cast<TAR*> (this) -> bindArg (tuple::make (a1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -112,7 +100,7 @@ namespace control {
|
||||||
void
|
void
|
||||||
bind (T1 a1, T2 a2)
|
bind (T1 a1, T2 a2)
|
||||||
{
|
{
|
||||||
static_cast<TAR*> (this) -> bind (tuple::make (a1,a2));
|
static_cast<TAR*> (this) -> bindArg (tuple::make (a1,a2));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -128,7 +116,7 @@ namespace control {
|
||||||
void
|
void
|
||||||
bind (T1 a1, T2 a2, T3 a3)
|
bind (T1 a1, T2 a2, T3 a3)
|
||||||
{
|
{
|
||||||
static_cast<TAR*> (this) -> bind (tuple::make (a1,a2,a3));
|
static_cast<TAR*> (this) -> bindArg (tuple::make (a1,a2,a3));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -145,7 +133,7 @@ namespace control {
|
||||||
void
|
void
|
||||||
bind (T1 a1, T2 a2, T3 a3, T4 a4)
|
bind (T1 a1, T2 a2, T3 a3, T4 a4)
|
||||||
{
|
{
|
||||||
static_cast<TAR*> (this) -> bind (tuple::make (a1,a2,a3,a4));
|
static_cast<TAR*> (this) -> bindArg (tuple::make (a1,a2,a3,a4));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -155,7 +143,6 @@ namespace control {
|
||||||
struct _Type
|
struct _Type
|
||||||
{
|
{
|
||||||
typedef typename FunctionSignature< function<SIG> >::Args Args;
|
typedef typename FunctionSignature< function<SIG> >::Args Args;
|
||||||
enum { ARG_CNT = count<typename Args::List>::value };
|
|
||||||
typedef Tuple<Args> ArgTuple;
|
typedef Tuple<Args> ArgTuple;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -164,18 +151,18 @@ namespace control {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Helper: mix in a \c bind(...) function
|
/** Helper Template for Proc-Layer control::Command : mix in a \c bind(...) function
|
||||||
* @param SIG function signature to mimic (regarding the arguments; return type will be void)
|
* @param SIG function signature to mimic (regarding the arguments; return type will be void)
|
||||||
* @param TAR the target class providing a function \c bind(Tuple<Types<T1...> >)
|
* @param TAR the target class providing a function \c bindArg(Tuple<Types<T1...> >)
|
||||||
* @param BASE the base class for inheritance chaining
|
* @param BASE the base class for inheritance chaining
|
||||||
*/
|
*/
|
||||||
template<typename SIG, class TAR, class BASE>
|
template<typename SIG, class TAR, class BASE>
|
||||||
class ArgumentTupleAccept
|
class ArgumentTupleAccept
|
||||||
: bind_arg::AcceptArgs<TAR,BASE, typename _Type<SIG>::Args>
|
: public bind_arg::AcceptArgs<TAR,BASE, typename bind_arg::_Type<SIG>::Args>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace control
|
} // namespace control
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
//#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 "proc/control/memento-tie.hpp"
|
||||||
|
|
||||||
//#include <tr1/memory>
|
//#include <tr1/memory>
|
||||||
//#include <boost/scoped_ptr.hpp>
|
//#include <boost/scoped_ptr.hpp>
|
||||||
|
|
@ -89,7 +90,7 @@ namespace control {
|
||||||
typedef typename CommandSignature<SIG,MEM>::UndoOp_Sig SIG_undo;
|
typedef typename CommandSignature<SIG,MEM>::UndoOp_Sig SIG_undo;
|
||||||
|
|
||||||
UntiedMemento()
|
UntiedMemento()
|
||||||
: MementoTie<SIG,MEM> (function<SIG_undo>, function<SIG_cap>)
|
: MementoTie<SIG,MEM> (function<SIG_undo>(), function<SIG_cap>() )
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -99,9 +100,14 @@ namespace control {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
/* Specifically typed CmdClosure, which serves for
|
* Specifically typed CmdClosure, which serves for
|
||||||
* actually allocating storage to hold the command arguments
|
* actually allocating storage to hold the command arguments
|
||||||
* and the undo state (memento) for Proc-Layer commands.
|
* and the undo state (memento) for Proc-Layer commands.
|
||||||
|
* Both the contained components within ArgumentHolder
|
||||||
|
* can be in \em empty state; there is no distinct
|
||||||
|
* lifecycle limitations. ArgumentHolder is part
|
||||||
|
* of Proc-Layer command's implementation
|
||||||
|
* and should not be used standalone.
|
||||||
*/
|
*/
|
||||||
template<typename SIG, typename MEM>
|
template<typename SIG, typename MEM>
|
||||||
class ArgumentHolder
|
class ArgumentHolder
|
||||||
|
|
@ -148,16 +154,13 @@ namespace control {
|
||||||
* whereas the undo functions will be wired by #tie
|
* whereas the undo functions will be wired by #tie
|
||||||
*/
|
*/
|
||||||
ArgumentHolder ()
|
ArgumentHolder ()
|
||||||
: arguments_(MissingArguments<SIG>)
|
: arguments_(MissingArguments<SIG>() )
|
||||||
, memento_(UntiedMemento<SIG,MEM>)
|
, memento_(UntiedMemento<SIG,MEM>() )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/** has undo state capturing been invoked? */
|
/** has undo state capturing been invoked? */
|
||||||
bool
|
bool canUndo () { return bool(memento_); }
|
||||||
canUndo ()
|
bool empty () { return !arguments_; }
|
||||||
{
|
|
||||||
return bool(memento_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** store a new argument tuple within this ArgumentHolder,
|
/** store a new argument tuple within this ArgumentHolder,
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,14 @@ out: saved state: 11
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
TEST "build argument accepting function" ArgumentTupleAccept_test <<END
|
||||||
|
out: sizeof\( .+control.+TestClass.+ \) = 1
|
||||||
|
out: sizeof\( .+control.+TestClass.+lumiera.Time.+ \) = ( 8)|(16)
|
||||||
|
out: 00:..:..\.000
|
||||||
|
return: 0
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
TEST "Memento binding" MementoTie_test <<END
|
TEST "Memento binding" MementoTie_test <<END
|
||||||
return: 0
|
return: 0
|
||||||
END
|
END
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ test_components_SOURCES = \
|
||||||
$(testcomponents_srcdir)/proc/control/command-basic-test.cpp \
|
$(testcomponents_srcdir)/proc/control/command-basic-test.cpp \
|
||||||
$(testcomponents_srcdir)/proc/control/command-argument-test.cpp \
|
$(testcomponents_srcdir)/proc/control/command-argument-test.cpp \
|
||||||
$(testcomponents_srcdir)/proc/control/command-mutation-test.cpp \
|
$(testcomponents_srcdir)/proc/control/command-mutation-test.cpp \
|
||||||
|
$(testcomponents_srcdir)/proc/control/argument-tuple-accept-test.cpp \
|
||||||
$(testcomponents_srcdir)/proc/control/memento-tie-test.cpp \
|
$(testcomponents_srcdir)/proc/control/memento-tie-test.cpp \
|
||||||
$(testcomponents_srcdir)/proc/engine/bufftabletest.cpp \
|
$(testcomponents_srcdir)/proc/engine/bufftabletest.cpp \
|
||||||
$(testcomponents_srcdir)/proc/engine/sourcenodetest.cpp \
|
$(testcomponents_srcdir)/proc/engine/sourcenodetest.cpp \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue