diff --git a/src/lib/diff/tree-mutator-collection-binding.hpp b/src/lib/diff/tree-mutator-collection-binding.hpp index a0476eade..1afe7d873 100644 --- a/src/lib/diff/tree-mutator-collection-binding.hpp +++ b/src/lib/diff/tree-mutator-collection-binding.hpp @@ -138,15 +138,15 @@ collection.emplace_back (forward(elm)); } -#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 - static iterator - search (GenNode::ID const& targetID, iterator pos) + iterator + search (GenNode const& targetSpec, iterator pos) { - while (pos and not pos->matches(targetID)) + while (pos and not matches(targetSpec, *pos)) ++pos; return pos; } +#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 iterator locate (GenNode::ID const& targetID) { @@ -174,7 +174,6 @@ using Iter = typename BIN::iterator; BIN binding_; - public: ///////////////TODO: diagnostics Iter pos_; @@ -190,13 +189,6 @@ ChildCollectionMutator& operator= (ChildCollectionMutator const&) =delete; - /////////////////TODO : diagnostics - typename BIN::const_iterator - exposeSrcBuffer() const - { - return eachElm (binding_.contentBuffer); - } - /////////////////TODO : diagnostics /* ==== re-Implementation of the operation API ==== */ @@ -227,14 +219,12 @@ return !pos_; } -#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 /** ensure the next recorded source element * matches on a formal level with given spec */ virtual bool - matchSrc (GenNode const& n) override + matchSrc (GenNode const& spec) override { - return PAR::matchSrc(n) - or pos_? n.matches(*pos_) + return pos_? binding_.matches (spec, *pos_) : false; } @@ -242,29 +232,28 @@ virtual bool acceptSrc (GenNode const& n) override { - bool isSrcMatch = TestWireTap::matchSrc(n); - if (isSrcMatch) // NOTE: important to call our own method here, not the virtual function + bool isSrcMatch = ChildCollectionMutator::matchSrc(n); + if (isSrcMatch) // NOTE: crucial to call our own method here, not the virtual function { - target_.inject (move(*pos_), "acceptSrc"); + binding_.inject (move(*pos_)); ++pos_; } - return PAR::acceptSrc(n) - or isSrcMatch; + return isSrcMatch; } /** locate designated element and accept it at current position */ virtual bool - findSrc (GenNode const& ref) override + findSrc (GenNode const& refSpec) override { - Iter found = TestMutationTarget::search (ref.idi, pos_); + Iter found = binding_.search (refSpec, pos_); if (found) { - target_.inject (move(*found), "findSrc"); + binding_.inject (move(*found)); } - return PAR::findSrc(ref) - or found; + return found; } +#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 /** repeatedly accept, until after the designated location */ virtual bool accept_until (GenNode const& spec) diff --git a/tests/library/diff/tree-manipulation-binding-test.cpp b/tests/library/diff/tree-manipulation-binding-test.cpp index 09d045eb2..281a95b23 100644 --- a/tests/library/diff/tree-manipulation-binding-test.cpp +++ b/tests/library/diff/tree-manipulation-binding-test.cpp @@ -277,13 +277,28 @@ namespace test{ } - /** @test map mutation primitives onto a STL collection managed locally. */ + + + + /** @test map mutation primitives onto a STL collection managed locally. + * - we perform _literally_ the same diff steps as in mutateDummy() + * - but now we have a completely opaque implementation data structure, + * where even the data type is unknown beyond this functions's scope. + * - thus we build a custom mutator, installing lambdas to tie into this + * local data structure, without disclosing any details. In fact we even + * install different lambdas on each usage cycle, according to the specific + * mutation operations to perform. Of course, it would be pointless to do so + * in real world usage, yet nicely demonstrates the point that the implementation + * really remains in control about anything regarding its private data structure. + * - and still, by exposing such a custom configured mutator, this private structure + * can be populated, reordered and even altered recursively, by generic instructions. + */ void mutateCollection() { MARK_TEST_FUN; - // some private data structures + // private data structures to be mutated struct Data { string key; @@ -307,20 +322,14 @@ namespace test{ { cout << "constructor invoked on "<