From 7cc68fadea60cb995129ee9ecbb1dd4e4635f92f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 9 Nov 2018 22:55:08 +0100 Subject: [PATCH] GenNode / Timeline: allow to mutate attribute objects with explicitly given ID so this seems to be the better approach for dealing with this insidious problem. In some cases -- as here most prominently with the root track within the timeline -- we have to care within the domain model to prepare unique ids even for sub objects treated as attributes. In the actual case, without that special attention, all timelines would hold onto an attribute "fork" with the same ID, based on the type of the nested object plus the string "fork". Thus all root track representations in the GUI would end up listening to the same ID on the UI-Bus... --- src/gui/timeline/timeline-controller.cpp | 7 ++++--- src/lib/diff/tree-mutator-attribute-binding.hpp | 9 +++++++++ src/lib/diff/tree-mutator.hpp | 7 ++++++- wiki/thinkPad.ichthyo.mm | 6 +++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/gui/timeline/timeline-controller.cpp b/src/gui/timeline/timeline-controller.cpp index 5403f6b6c..8a55e588e 100644 --- a/src/gui/timeline/timeline-controller.cpp +++ b/src/gui/timeline/timeline-controller.cpp @@ -138,6 +138,7 @@ namespace timeline { TimelineController::buildMutator (TreeMutator::Handle buffer) { using PMarker = unique_ptr; + auto rootForkID = ID{*fork_}; buffer.create ( TreeMutator::build() @@ -160,13 +161,13 @@ namespace timeline { target->buildMutator (buff); // - delegate to child to build nested TreeMutator return true; })) - .mutateAttrib(ATTR_fork, [&](TreeMutator::Handle buff) - { // »Attribute Mutator« : how to enter an object field as nested scope + .mutateAttrib(rootForkID, [&](TreeMutator::Handle buff) + { // »Attribute Mutator« : how to enter the track-fork-object field as nested scope REQUIRE (fork_); fork_->buildMutator(buff); }) .change(ATTR_name, [&](string val) - { // »Attribute Setter« : how to assign a new value to some object field + { // »Attribute Setter« : how to assign a new value to the name field (object member) name_ = val; })); } diff --git a/src/lib/diff/tree-mutator-attribute-binding.hpp b/src/lib/diff/tree-mutator-attribute-binding.hpp index 69221a1d2..398aa5963 100644 --- a/src/lib/diff/tree-mutator-attribute-binding.hpp +++ b/src/lib/diff/tree-mutator-attribute-binding.hpp @@ -359,6 +359,15 @@ namespace diff{ return chainedBuilder> (key, mutatorBuilderClosure); } + /** Entry point for DSL builder; variation to handle an attribute-object with given ID */ + template + template + inline auto + Builder::mutateAttrib (idi::BareEntryID const& rawID, CLO mutatorBuilderClosure) + { + return chainedBuilder> (rawID, mutatorBuilderClosure); + } + }//(END)Mutator-Builder decorator components... diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index 4e11d98c2..07a12fc57 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -373,7 +373,12 @@ namespace diff{ template auto mutateAttrib (Symbol attributeID, CLO mutatorBuilderClosure); - ///////////////////////////////////////TODO define variant taking a GenNode::ID ?? + /** + * @param rawID the explicitly given ID of an attribute object, + * used literally to match the attribute in question + */ + template + auto mutateAttrib (idi::BareEntryID const& rawID, CLO mutatorBuilderClosure); /** set up a binding to a structure of "child objects", diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index d2f2ca438..3f7be1a3c 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -21049,7 +21049,7 @@ - + @@ -21212,7 +21212,7 @@ - + @@ -21224,7 +21224,7 @@ - +