From d8fe9bce9455cad063266a6b7e71abf31d2e0397 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 3 Mar 2016 23:11:36 +0100 Subject: [PATCH] baseline of test-dummy implementation or a mutation target binding - we're using the source / target buffer paradigm to implement the mutation - we're using Record to account for "the current content" --- src/lib/diff/test-mutation-target.hpp | 52 +++++++++++++++---- src/lib/diff/tree-mutator.hpp | 5 +- .../diff/tree-manipulation-binding-test.cpp | 3 +- wiki/thinkPad.ichthyo.mm | 5 +- 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/lib/diff/test-mutation-target.hpp b/src/lib/diff/test-mutation-target.hpp index 0c2aa32b4..cd2747635 100644 --- a/src/lib/diff/test-mutation-target.hpp +++ b/src/lib/diff/test-mutation-target.hpp @@ -51,9 +51,10 @@ #include "lib/diff/tree-mutator.hpp" #include "lib/idi/genfunc.hpp" #include "lib/test/event-log.hpp" -//#include "lib/util.hpp" +#include "lib/util.hpp" //#include "lib/format-string.hpp" +#include //#include #include //#include @@ -72,7 +73,16 @@ namespace diff{ // using std::function; using std::string; + using RecS = lib::diff::Record; + namespace { + template + string + identify (const T* const entity) + { + return lib::idi::instanceTypeID(entity); + } + } @@ -82,24 +92,40 @@ namespace diff{ * @todo WIP 2/2016 */ class TestMutationTarget + : boost::noncopyable { - EventLog log_{this->identify()}; + EventLog log_{identify (this)}; + + RecS::Mutator content_{}; + RecS prev_content_{}; public: + /* === Operation / Mutation API === */ + + void + initMutation (string mutatorID) + { + content_.swap (prev_content_); + log_.event ("attachMutator "+mutatorID); + } + + /* === Diagnostic / Verification === */ bool empty() const { - UNIMPLEMENTED ("NIL check"); + return content_.empty(); } + /** check for recorded element */ bool contains (string spec) const { - UNIMPLEMENTED ("check for recorded element"); + RecS const& currentValidContent{content_}; + return util::contains (currentValidContent, spec); } EventMatch @@ -146,11 +172,6 @@ namespace diff{ private: - string - identify() const - { - return lib::idi::instanceTypeID(this); - } }; @@ -163,10 +184,21 @@ namespace diff{ { TestMutationTarget& target_; + /* ==== re-Implementation of the operation API ==== */ + + virtual void + injectNew (GenNode const& n) override + { + UNIMPLEMENTED("establish new child node at current position"); + } + + TestWireTap(TestMutationTarget& dummy, PAR const& chain) : PAR(chain) , target_(dummy) - { } + { + target_.initMutation (identify(this)); + } }; template diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index f218b27e7..91f59d94b 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -105,8 +105,8 @@ namespace diff{ /** - * Customisable intermediary to abstract - * mutating operations on arbitrary, hierarchical object-like data. + * Customisable intermediary to abstract mutating operations + * on arbitrary, hierarchical object-like data. * The TreeMutator exposes two distinct interfaces * - the \em operation API -- similar to what a container exposes -- * is the entirety of abstract operations that can be done to the @@ -155,6 +155,7 @@ namespace diff{ static Builder build(); }; + namespace { // Mutator-Builder decorator components... /** diff --git a/tests/library/diff/tree-manipulation-binding-test.cpp b/tests/library/diff/tree-manipulation-binding-test.cpp index 566b57975..0458c7996 100644 --- a/tests/library/diff/tree-manipulation-binding-test.cpp +++ b/tests/library/diff/tree-manipulation-binding-test.cpp @@ -103,6 +103,7 @@ namespace test{ } + /** @test diagnostic binding: how to monitor and verify the mutations applied */ void mutateDummy() { @@ -131,7 +132,7 @@ namespace test{ void mutateCollection() { - TODO ("define how to map the mutation primitives on a generic collection"); + TODO ("define how to map the mutation primitives onto a generic collection"); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 0139d12b5..112f6a166 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1504,7 +1504,7 @@ - + @@ -1656,9 +1656,10 @@ + - +