hey... now storing the operation is almost effortless!
This commit is contained in:
parent
12bcc127a6
commit
bc94f299e2
5 changed files with 27 additions and 14 deletions
|
|
@ -82,12 +82,12 @@ namespace control {
|
|||
virtual operator string() const =0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline ostream& operator<< (ostream& os, const CmdClosure& clo) { return os << string(clo); }
|
||||
|
||||
|
||||
|
||||
template
|
||||
< typename TY
|
||||
, class BASE
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
//#include "pre.hpp"
|
||||
#include "lib/error.hpp"
|
||||
#include "proc/control/command-closure.hpp"
|
||||
#include "lib/meta/function-erasure.hpp"
|
||||
|
||||
//#include <tr1/memory>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
|
@ -49,6 +50,8 @@
|
|||
|
||||
namespace control {
|
||||
|
||||
using lumiera::typelist::FunErasure;
|
||||
using lumiera::typelist::StoreFunction;
|
||||
// using lumiera::Symbol;
|
||||
// using std::tr1::shared_ptr;
|
||||
using boost::scoped_ptr;
|
||||
|
|
@ -57,19 +60,26 @@ namespace control {
|
|||
using std::string;
|
||||
|
||||
|
||||
/**
|
||||
* A neutral container internally holding
|
||||
* the functor used to implement the Command
|
||||
*/
|
||||
typedef FunErasure<StoreFunction> CmdFunctor;
|
||||
|
||||
|
||||
/**
|
||||
* @todo Type-comment
|
||||
*/
|
||||
class Mutation
|
||||
{
|
||||
CmdFunctor func_;
|
||||
PClo clo_;
|
||||
|
||||
public:
|
||||
template<typename SIG>
|
||||
Mutation (function<SIG> const& func)
|
||||
{
|
||||
UNIMPLEMENTED ("build a Mutation functor object, thereby erasing the concrete function signature type");
|
||||
}
|
||||
: func_(func)
|
||||
{ }
|
||||
|
||||
virtual ~Mutation() {}
|
||||
|
||||
|
|
@ -121,25 +131,28 @@ namespace control {
|
|||
class UndoMutation
|
||||
: public Mutation
|
||||
{
|
||||
CmdFunctor captureFunc_;
|
||||
scoped_ptr<CmdClosure> memento_;
|
||||
|
||||
public:
|
||||
template<typename SIG_undo, typename SIG_cap>
|
||||
UndoMutation (function<SIG_undo> const& undoFunc, function<SIG_cap> const& captureFunc)
|
||||
: Mutation(undoFunc)
|
||||
{
|
||||
UNIMPLEMENTED ("build a undo Mutation functor object");
|
||||
}
|
||||
UndoMutation (function<SIG_undo> const& undoFunc,
|
||||
function<SIG_cap> const& captureFunc)
|
||||
: Mutation (undoFunc)
|
||||
, captureFunc_(captureFunc)
|
||||
{ }
|
||||
|
||||
UndoMutation (UndoMutation const& o)
|
||||
: Mutation(*this),
|
||||
memento_(o.memento_->clone().get())
|
||||
: Mutation (*this)
|
||||
, captureFunc_(o.captureFunc_)
|
||||
, memento_(o.memento_->clone().get())
|
||||
{ }
|
||||
|
||||
UndoMutation&
|
||||
operator= (UndoMutation const& o)
|
||||
{
|
||||
Mutation::operator= (o);
|
||||
captureFunc_ = o.captureFunc_;
|
||||
memento_.reset(o.memento_->clone().get());
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace test {
|
|||
|
||||
namespace {
|
||||
|
||||
int testVal; ///< used to verify the effect of testFunc
|
||||
int testVal=0; ///< used to verify the effect of testFunc
|
||||
|
||||
void
|
||||
testFunc (int val)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
FunctionClosure(Test) - appending, mixing and filtering typelists
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Hermann Vosseler <Ichthyostega@web.de>
|
||||
2009, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
TestHelper(Test) - validate the unittest support functions
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Hermann Vosseler <Ichthyostega@web.de>
|
||||
2009, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
|
|
|
|||
Loading…
Reference in a new issue