From c8dc5a24a8a2fdd7bc580d043d9964fe11a2e3c9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 10 Nov 2018 02:39:17 +0100 Subject: [PATCH] DummySessionConnection: extend population diff to send distinct root-track This change demonstrates how to deal properly with possible duplicate entities with similar symbolic ID: define a RandomID (to guarantee a distinct hash on each instance). In the actual implementation, this should happen already within the domain model, not when constructing the diff (obviously of course...) This change also adds a mutation sequence to inject the actual track name --- src/gui/model/tangible.hpp | 2 +- src/lib/diff/tree-diff-application.hpp | 2 +- src/lib/diff/tree-diff.cpp | 2 +- src/lib/diff/tree-mutator.hpp | 1 + .../session/dummy-session-connection.cpp | 25 ++++++++++++++----- wiki/thinkPad.ichthyo.mm | 4 +-- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/gui/model/tangible.hpp b/src/gui/model/tangible.hpp index c20601116..f8e06fe99 100644 --- a/src/gui/model/tangible.hpp +++ b/src/gui/model/tangible.hpp @@ -235,7 +235,7 @@ namespace model { friend constexpr size_t treeMutatorSize (const Tangible*) { - return 256; + return 512; } }; diff --git a/src/lib/diff/tree-diff-application.hpp b/src/lib/diff/tree-diff-application.hpp index e5e275495..336df1888 100644 --- a/src/lib/diff/tree-diff-application.hpp +++ b/src/lib/diff/tree-diff-application.hpp @@ -158,7 +158,7 @@ namespace diff{ public: virtual ~ScopeManager(); ///< this is an interface - virtual TreeMutator::Handle openScope() =0; + virtual TreeMutator::Handle openScope() =0; ///< @remark picks up `treeMutatorSize(...)` virtual TreeMutator& closeScope() =0; virtual void clear() =0; diff --git a/src/lib/diff/tree-diff.cpp b/src/lib/diff/tree-diff.cpp index 301767708..8c61b297f 100644 --- a/src/lib/diff/tree-diff.cpp +++ b/src/lib/diff/tree-diff.cpp @@ -205,7 +205,7 @@ namespace diff{ void TreeDiffMutatorBinding::mut (GenNode const& n) { - TreeMutator::Handle buffHandle = scopeManger_->openScope(); + TreeMutator::Handle buffHandle = scopeManger_->openScope(); // hint: treeMutatorSize(...) if (not treeMutator_->mutateChild(n, buffHandle)) __failMismatch("enter nested scope", n); diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index 07a12fc57..17ce59b5d 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -83,6 +83,7 @@ ** ** @see tree-mutator-test.cpp ** @see tree-mutator-binding-test.cpp + ** @see [usage for tree diff application](\ref tree-diff-application.hpp) ** @see diff-language.hpp ** @see DiffDetector ** diff --git a/src/proc/mobject/session/dummy-session-connection.cpp b/src/proc/mobject/session/dummy-session-connection.cpp index e9c677785..5913ea8cd 100644 --- a/src/proc/mobject/session/dummy-session-connection.cpp +++ b/src/proc/mobject/session/dummy-session-connection.cpp @@ -55,9 +55,11 @@ #include //#include +using lib::diff::MutationMessage; using lib::diff::GenNode; using lib::diff::MakeRec; -using lib::diff::MutationMessage; +using lib::diff::Ref; +using lib::idi::RandID; //using util::cStr; using util::_Fmt; using std::string; @@ -77,12 +79,12 @@ namespace session { namespace { //Implementation details.... GenNode - emptyTimeline (string baseID) + emptyTimeline (string baseID, RandID const& forkRootID) { return MakeRec() - .set(string{gui::ATTR_fork} - ,MakeRec() - .type(string{gui::TYPE_Fork}) + .set(MakeRec() + .type (string{gui::TYPE_Fork}) + .genNode(forkRootID) ) .genNode(baseID); } @@ -106,7 +108,18 @@ namespace session { MutationMessage DummySessionConnection::fabricateSeq1 (string baseID) { - return MutationMessage{ ins (emptyTimeline (baseID)) + const RandID forkRootID{gui::ATTR_fork}; + const GenNode timeline = emptyTimeline (baseID, forkRootID); + const GenNode rootTrackName{string{gui::ATTR_name}, "Track-"+baseID} + , FORK_ROOT = MakeRec().genNode(forkRootID) + ; + + return MutationMessage{ ins (timeline) + , mut (timeline) + , mut (FORK_ROOT) + , set (rootTrackName) + , emu (FORK_ROOT) + , emu (timeline) }; } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 11713b164..4e321b39e 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -31117,7 +31117,7 @@ - + @@ -32179,7 +32179,7 @@ - +