From bc94f299e28a4f012b95409f89327fc3224ed55f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 20 Jun 2009 07:13:20 +0200 Subject: [PATCH] hey... now storing the operation is almost effortless! --- src/proc/control/command-closure.hpp | 2 +- src/proc/control/command-mutation.hpp | 33 +++++++++++++------ .../proc/control/command-mutation-test.cpp | 2 +- tests/lib/meta/function-closure-test.cpp | 2 +- tests/lib/test/test-helper-test.cpp | 2 +- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/proc/control/command-closure.hpp b/src/proc/control/command-closure.hpp index 5c5923f09..80ef6f095 100644 --- a/src/proc/control/command-closure.hpp +++ b/src/proc/control/command-closure.hpp @@ -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 diff --git a/src/proc/control/command-mutation.hpp b/src/proc/control/command-mutation.hpp index 02a68794f..d7711079a 100644 --- a/src/proc/control/command-mutation.hpp +++ b/src/proc/control/command-mutation.hpp @@ -38,6 +38,7 @@ //#include "pre.hpp" #include "lib/error.hpp" #include "proc/control/command-closure.hpp" +#include "lib/meta/function-erasure.hpp" //#include #include @@ -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 CmdFunctor; + + /** * @todo Type-comment */ class Mutation { + CmdFunctor func_; PClo clo_; public: template Mutation (function 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 memento_; public: template - UndoMutation (function const& undoFunc, function const& captureFunc) - : Mutation(undoFunc) - { - UNIMPLEMENTED ("build a undo Mutation functor object"); - } + UndoMutation (function const& undoFunc, + function 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; } diff --git a/tests/components/proc/control/command-mutation-test.cpp b/tests/components/proc/control/command-mutation-test.cpp index 5d9547a32..79b54d723 100644 --- a/tests/components/proc/control/command-mutation-test.cpp +++ b/tests/components/proc/control/command-mutation-test.cpp @@ -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) diff --git a/tests/lib/meta/function-closure-test.cpp b/tests/lib/meta/function-closure-test.cpp index 6218061a6..b0be3edb5 100644 --- a/tests/lib/meta/function-closure-test.cpp +++ b/tests/lib/meta/function-closure-test.cpp @@ -2,7 +2,7 @@ FunctionClosure(Test) - appending, mixing and filtering typelists Copyright (C) Lumiera.org - 2008, Hermann Vosseler + 2009, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/tests/lib/test/test-helper-test.cpp b/tests/lib/test/test-helper-test.cpp index f4d44a0a5..40258c44a 100644 --- a/tests/lib/test/test-helper-test.cpp +++ b/tests/lib/test/test-helper-test.cpp @@ -2,7 +2,7 @@ TestHelper(Test) - validate the unittest support functions Copyright (C) Lumiera.org - 2008, Hermann Vosseler + 2009, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as