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
This commit is contained in:
Fischlurch 2018-11-10 02:39:17 +01:00
parent a4c37ed99c
commit c8dc5a24a8
6 changed files with 25 additions and 11 deletions

View file

@ -235,7 +235,7 @@ namespace model {
friend constexpr size_t
treeMutatorSize (const Tangible*)
{
return 256;
return 512;
}
};

View file

@ -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;

View file

@ -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);

View file

@ -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
**

View file

@ -55,9 +55,11 @@
#include <string>
//#include <map>
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)
};
}

View file

@ -31117,7 +31117,7 @@
</node>
</node>
</node>
<node CREATED="1434128074725" FOLDED="true" HGAP="28" ID="ID_933994138" MODIFIED="1538870799628" TEXT="Diff-System" VSHIFT="1">
<node CREATED="1434128074725" FOLDED="true" HGAP="28" ID="ID_933994138" MODIFIED="1541811331872" TEXT="Diff-System" VSHIFT="1">
<font NAME="SansSerif" SIZE="14"/>
<icon BUILTIN="go"/>
<node CREATED="1434128278990" ID="ID_106354755" MODIFIED="1518487921094" TEXT="Diff-Darstellung"/>
@ -32179,7 +32179,7 @@
</node>
</node>
</node>
<node CREATED="1443733567706" FOLDED="true" HGAP="325" ID="ID_143203937" MODIFIED="1538870668723" TEXT="Diff-Language" VSHIFT="41">
<node CREATED="1443733567706" FOLDED="true" HGAP="325" ID="ID_143203937" MODIFIED="1541811328497" TEXT="Diff-Language" VSHIFT="41">
<cloud COLOR="#cfba9d"/>
<linktarget COLOR="#a9acc1" DESTINATION="ID_143203937" ENDARROW="Default" ENDINCLINATION="115;-2033;" ID="Arrow_ID_136706418" SOURCE="ID_1091994004" STARTARROW="None" STARTINCLINATION="1656;0;"/>
<font NAME="SansSerif" SIZE="14"/>