From b582c35c9f44a7e2cb648e623a3ed91b07157160 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 2 May 2023 04:16:39 +0200 Subject: [PATCH] Segmentation: structure analysis for splitSplice operation There are 12 distinct cases regarding the orientation of two intervals; The Segmentation::splitSplice() operation shall insert a new Segment and adjust / truncate / expand / split / delete existing segments such as to retain the *Invariant* (seamless segmentation covering the complete time axis) --- src/lib/diff/gen-node.hpp | 13 +- src/steam/fixture/segmentation.cpp | 32 +++-- src/steam/fixture/segmentation.hpp | 7 ++ tests/51-gui-model.tests | 2 +- tests/core/steam/engine/mock-dispatcher.hpp | 10 +- tests/library/diff/gen-node-test.cpp | 7 ++ wiki/renderengine.html | 80 +++++++++++- wiki/thinkPad.ichthyo.mm | 127 ++++++++++++++++++++ 8 files changed, 262 insertions(+), 16 deletions(-) diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index fd07d35eb..da48b6cd4 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -115,14 +115,11 @@ #include #include - namespace lib { namespace diff{ namespace error = lumiera::error; - using std::string; - struct GenNode; struct Ref; @@ -474,6 +471,7 @@ namespace diff{ bool hasAttribute (string key) const; bool isNested() const; + bool hasChildren() const; protected: @@ -590,7 +588,7 @@ namespace diff{ /** * Building block for monad-like depth-first expansion of a GenNode. * When used within lib::IterStateWrapper, the result is an Iterator - * to visit the contents of a GenNodet tree recursively depth-fist. + * to visit the contents of a GenNode tree recursively depth-fist. */ class GenNode::ScopeExplorer { @@ -814,6 +812,13 @@ namespace diff{ return data.isNested(); } + inline bool + GenNode::hasChildren() const + { + return not isnil (data.childIter()); + } + + diff --git a/src/steam/fixture/segmentation.cpp b/src/steam/fixture/segmentation.cpp index 1258e0674..ba4b094fd 100644 --- a/src/steam/fixture/segmentation.cpp +++ b/src/steam/fixture/segmentation.cpp @@ -64,13 +64,31 @@ namespace fixture { - /** */ -// bool -// ModelPortRegistry::contains (ID key) const -// { -// return bool(key) -// && util::contains (transaction_, key); -// } + /** + * @param start (optional) definition of the new Segment's start point (inclusive) + * @param after (optional) definition of the end point (exclusive) + * @param jobTicket specification of provided render functionality for the new Segment + * @remarks missing definitions will be derived or interpolated according to context + * - if start point is omitted, the new Segment will start seamlessly after + * any preceding Segment's end, in case this preceding Segment ends earlier + * - otherwise the preceding Segment's start point will be used, thereby effectively + * replacing and expanding or trimming or inserting into the preceding Segment + * - similar for the end point: if the definition is omitted, the new Segment + * will cover the time range until the next Segmen's start + * - if upper/lower boundaries can not be established, the covered range will be + * expanded from Time::ANYTIME up to Time::ANYTIME in as fitting current context + * - after start and end point have been established by the above rules, the actual + * splicing operation will be determined; either an existing Segment is replaced + * altogether, or it is trimmed to fit, or the new Segment is inserted, thereby + * creating a second (copied) part of the encompassing old Segment. + * - in case the JobTicket is omitted, the new Segment will be marked as _passive_ + * and any job created from such a Segment will then be a »NOP-job« + */ + Segment const& + Segmentation::splitSplice (OptTime start, OptTime after, const engine::JobTicket* jobTicket) + { + UNIMPLEMENTED ("determine predecessor, successor and orientation and perform del/trunc/split/swap/insert"); + } diff --git a/src/steam/fixture/segmentation.hpp b/src/steam/fixture/segmentation.hpp index be83575e0..de6e08fbc 100644 --- a/src/steam/fixture/segmentation.hpp +++ b/src/steam/fixture/segmentation.hpp @@ -53,6 +53,7 @@ #include "lib/nocopy.hpp" #include +#include namespace steam { @@ -64,6 +65,8 @@ namespace fixture { using lib::time::TimeValue; using util::_Fmt; + using OptTime = std::optional; + /** * For the purpose of building and rendering, the fixture (for each timeline) * is partitioned such that each segment is _structurally constant._ @@ -108,6 +111,10 @@ namespace fixture { return seg; throw error::State (_Fmt{"Fixture datastructure corrupted: Time %s not covered"} % time); } + + /** rework the existing Segmentation to include a new Segment as specified */ + Segment const& + splitSplice (OptTime start, OptTime after, const engine::JobTicket* =nullptr); }; diff --git a/tests/51-gui-model.tests b/tests/51-gui-model.tests index fde36a170..be8d30527 100644 --- a/tests/51-gui-model.tests +++ b/tests/51-gui-model.tests @@ -2,7 +2,7 @@ TESTING "Component Test Suite: GUI Model Parts" ./test-suite --group=stage -TEST "Self-check: testing GUI backbone parts" TestGui_test <("mark"); + JobTicket* newTicket = nullptr; + auto seed = spec.retrieveAttribute ("mark"); tickets_.emplace_back (seed? *seed : HashVal(rand() % 1000)); + newTicket = & tickets_.back(); + + auto start = spec.retrieveAttribute