From 1b24453f5b0719d3c112bf11fb62d643b8f9cf3e Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 18 Mar 2016 19:35:48 +0100 Subject: [PATCH] set up the full builder definition chain --- src/lib/diff/tree-mutator.hpp | 154 ++++++++++++++++++++++++++++++++++ wiki/thinkPad.ichthyo.mm | 29 ++++++- 2 files changed, 182 insertions(+), 1 deletion(-) diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index ef82e7de4..736586ad6 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -555,6 +555,150 @@ namespace diff{ }; + /** + * Nested DSL to define the specifics of a collection binding. + */ + template + struct CollectionBindingBuilder + : CollectionBinding + { + + template + CollectionBindingBuilder + matchElement(FUN matcher) + { + return { this->collection + , matcher + , this->construct + , this->isApplicable + , this->assign + , this->openSub + }; + } + + template + CollectionBindingBuilder + constructFrom(FUN constructor) + { + return { this->collection + , this->matches + , constructor + , this->isApplicable + , this->assign + , this->openSub + }; + } + + template + CollectionBindingBuilder + isApplicableIf(FUN selector) + { + return { this->collection + , this->matches + , this->construct + , selector + , this->assign + , this->openSub + }; + } + + template + CollectionBindingBuilder + assignElement(FUN setter) + { + return { this->collection + , this->matches + , this->construct + , this->isApplicable + , setter + , this->openSub + }; + } + + template + CollectionBindingBuilder + buildChildMutator(FUN childMutationBuilder) + { + return { this->collection + , this->matches + , this->construct + , this->isApplicable + , this->assign + , childMutationBuilder + }; + } + }; + + template + struct _DefaultBinding + { + using Coll = typename Strip::TypeReferred; + using Elm = typename Coll::value_type; + + static bool + disable_selector (GenNode const& spec) + { + UNIMPLEMENTED ("dont discriminate by default"); + } + + static bool + default_contantMatch (Elm const& elm) + { + UNIMPLEMENTED ("fallback matcher"); + } + + static Elm + default_construct_from_payload (GenNode const& spec) + { + UNIMPLEMENTED ("default construct from spec payload"); + } + + static bool + disable_assignment (GenNode const& spec) + { + UNIMPLEMENTED ("disabled assignment"); + } + + static bool + disable_childMutation (GenNode const& spec, TreeMutator::MutatorBuffer targetBuff) + { + UNIMPLEMENTED ("inactive mutator builder"); + } + + + using FallbackBindingConfiguration + = CollectionBindingBuilder; + + static FallbackBindingConfiguration + attachTo (Coll& coll) + { + return { coll + , disable_selector + , default_contantMatch + , default_construct_from_payload + , disable_assignment + , disable_childMutation + }; + } + }; + + + template + auto + collection (COLL& coll) -> decltype(_DefaultBinding::attachTo(coll)) + { + return _DefaultBinding::attachTo(coll); + } + + + + template struct TestWireTap; @@ -570,6 +714,9 @@ namespace diff{ template using Change = ChangeOperation; + template + using Collection = ChildCollectionMutator; + using WireTap = TestWireTap; @@ -582,6 +729,13 @@ namespace diff{ return Change (attributeID, closure, *this); } + template + Builder> + attach (BIN&& collectionBindingSetup) + { + return Collection (std::forward(collectionBindingSetup)); + } + Builder attachDummy (TestMutationTarget& dummy); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index c95758602..11274738b 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -2339,7 +2339,34 @@ - + + + + + + + + + + + +

+ ...will sagen, +

+

+ da sind mehrere Layer an praktisch ungebundenem Template-Code dazwischen, +

+

+ so daß zu befürchten steht, daß ein unpassendes Lambda erst weit entfernt +

+

+ eine womöglich irreführende Meldung generiert +

+ + +
+
+