From 61c685fa9fb2561b2b5f153f589810a0e86d2ace Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 11 Feb 2025 01:10:25 +0100 Subject: [PATCH] Invocation: draft missing feature for integration test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seemed that the integration test will end up as a dull repetition of already coded stuff, just with more ports and thus more boilerplate; and so I reconsidered what an actually relevant integration test might encompass - getting parameters from the invocation - translating and wiring parameters - which entails to adapt / partially close a processing function! Thus — surprise — there is a new feature not yet supported by the `NodeBuilder`, which would be very likely to be used in many real-world use cases: which is to adapt the parameter tuple expected by the binding from the library. Obviously we want this, since many »raw« processing functions will expose a mix of technical and artistic parameters; and we'd like to ''close'' the technical ones. Such a feature ''should be implementable,'' based on the already developed technique with the »cross builder«, which implies to switch the template arguments from within a builder expression. We already do this very thing for adapting parameter functor, and thus the main difficulty would be to compose an adaptor functor to the correct argument of the processing functor... Which is... (well, it is nasty and technical, yet feasible). --- src/steam/engine/feed-manifold.hpp | 13 +- src/steam/engine/node-builder.hpp | 12 + src/steam/engine/weaving-pattern-builder.hpp | 25 +- tests/core/steam/engine/node-base-test.cpp | 4 +- tests/core/steam/engine/node-builder-test.cpp | 24 ++ tests/core/steam/engine/node-devel-test.cpp | 9 +- tests/core/steam/engine/node-link-test.cpp | 67 +++++ wiki/thinkPad.ichthyo.mm | 238 +++++++++++++----- 8 files changed, 324 insertions(+), 68 deletions(-) diff --git a/src/steam/engine/feed-manifold.hpp b/src/steam/engine/feed-manifold.hpp index 5e0751caa..4f69f3897 100644 --- a/src/steam/engine/feed-manifold.hpp +++ b/src/steam/engine/feed-manifold.hpp @@ -605,6 +605,9 @@ namespace engine { template using Adapted = FeedPrototype; + template + using Decorated = FeedPrototype; + /** is the given functor suitable as parameter functor for this Feed? */ template static constexpr bool isSuitable() @@ -623,12 +626,20 @@ namespace engine { */ template auto - moveAdapted (PFX otherParamFun =PFX{}) + moveAdaptedParam (PFX otherParamFun =PFX{}) { using OtherParamFun = std::decay_t; return Adapted{move(procFun_), move(otherParamFun)}; } + template + auto + moveDecoratedProc (DEC procFunDecorator) + { + using AugmentedProcFun = std::decay_t; + return Decorated{procFunDecorator (move(procFun_)), move(paramFun_)}; + } + /** build a clone-copy of this prototype, holding the same functors * @note possible only if both proc-functor and param-functor are copyable diff --git a/src/steam/engine/node-builder.hpp b/src/steam/engine/node-builder.hpp index df24d6906..d1f255553 100644 --- a/src/steam/engine/node-builder.hpp +++ b/src/steam/engine/node-builder.hpp @@ -477,6 +477,18 @@ namespace engine { }); } + template + auto + adaptParam (ADA&& paramAdaptor) + { + using DecoratedPrototype = typename WAB::template Decorated; + using AdaptedPortBuilder = PortBuilder; + // + return AdaptedPortBuilder{move(*this) + ,weavingBuilder_.adaptProcFunParam (move (paramAdaptor)) + }; + } + /*************************************************************//** diff --git a/src/steam/engine/weaving-pattern-builder.hpp b/src/steam/engine/weaving-pattern-builder.hpp index 8cbeb2fb0..d43744d23 100644 --- a/src/steam/engine/weaving-pattern-builder.hpp +++ b/src/steam/engine/weaving-pattern-builder.hpp @@ -294,7 +294,12 @@ namespace engine { using AdaptedPrototype = typename PROT::template Adapted; template using Adapted = WeavingBuilder>; - + + template + using DecoratedPrototype = typename PROT::template Decorated; + template + using Decorated = WeavingBuilder>; + /** Adapt a parameter-functor into the _Feed Prototype,_ * so that it is invoked whenever a new `FeedManifold` is built. * @return adapted WeavingBuilder marked with changed `FeedManifold` type. @@ -309,7 +314,23 @@ namespace engine { using AdaptedWeavingBuilder = Adapted; // return AdaptedWeavingBuilder{move(*this) - ,prototype_.moveAdapted (move (paramFunctor)) + ,prototype_.moveAdaptedParam (move (paramFunctor)) + }; + } + + /** @todo */ + template + auto + adaptProcFunParam (DEC decorator) + { +// static_assert (PROT::template isSuitable() +// ,"suitable as param-functor for given processing-functor"); //////////////////////////TODO + // + using AdaptedWeavingBuilder = Decorated; + // + return AdaptedWeavingBuilder{move(*this) + ,prototype_.moveDecoratedProc (move (decorator)) + //////////////////////////////////////////////////////////////////////OOO need to do the actual adaptation here }; } diff --git a/tests/core/steam/engine/node-base-test.cpp b/tests/core/steam/engine/node-base-test.cpp index 1319232bf..824d008ca 100644 --- a/tests/core/steam/engine/node-base-test.cpp +++ b/tests/core/steam/engine/node-base-test.cpp @@ -370,7 +370,7 @@ namespace test { CHECK ( P1x::hasParamFun()); CHECK (not P1x::canActivate()); - P1x p1x = p1.moveAdapted (move(fun_paramSimple)); + P1x p1x = p1.moveAdaptedParam (move(fun_paramSimple)); M1 m1x = p1x.buildFeed(turSys); // ◁————————— param-functor invoked here CHECK (rr == m1x.param); // ...as indicated by the side-effect short r1 = m1x.param; @@ -413,7 +413,7 @@ namespace test { CHECK ( P1F::canActivate()); P1F p1f = p1x.clone() // if (and only if) the embedded functors allow clone-copy - .moveAdapted(); // then we can fork-off and then adapt a cloned prototype + .moveAdaptedParam(); // then we can fork-off and then adapt a cloned prototype // Need to distinguish between static capability and runtime state... CHECK (not p1 .canActivate()); // Case-1 had no param functor installed... diff --git a/tests/core/steam/engine/node-builder-test.cpp b/tests/core/steam/engine/node-builder-test.cpp index 66e9b5101..ee98a3384 100644 --- a/tests/core/steam/engine/node-builder-test.cpp +++ b/tests/core/steam/engine/node-builder-test.cpp @@ -26,6 +26,7 @@ #include "lib/symbol.hpp" #include +#include using lib::Symbol; using std::string; @@ -60,6 +61,7 @@ namespace test { build_simpleNode(); build_Node_fixedParam(); build_Node_dynamicParam(); + build_Node_adaptedParam(); build_connectedNodes(); build_ParamNode(); } @@ -164,6 +166,28 @@ namespace test { } + /** @test build a node and _adapt the parameters_ for invocation. + * - again use a processing function which takes a parameter + * - but then _decorate_ this functor, so that it takes different arguments + * - attach parameter handling to supply these adapted arguments + * @todo 2/25 ✔ define ⟶ 🔁 implement + */ + void + build_Node_adaptedParam() + { + auto procFun = [](ulong param, int* buff){ *buff = int(param); }; + auto adaptor = [](string const& spec){ return boost::lexical_cast(spec); }; + + ProcNode node{prepareNode("Test") + .preparePort() + .invoke ("fun()", procFun) +// .adaptParam (adaptor) /////////////////////OOO engage here! +// .setParam ("55") + .completePort() + .build()}; + } + + /** @test build a chain with three connected Nodes * - have two source nodes, which accept a parameter * - but configure them differently: one gets a constant, diff --git a/tests/core/steam/engine/node-devel-test.cpp b/tests/core/steam/engine/node-devel-test.cpp index 00f642520..f6c30d5e0 100644 --- a/tests/core/steam/engine/node-devel-test.cpp +++ b/tests/core/steam/engine/node-devel-test.cpp @@ -22,10 +22,8 @@ #include "steam/engine/node-builder.hpp" #include "steam/engine/test-rand-ontology.hpp" #include "steam/engine/diagnostic-buffer-provider.hpp" -#include "lib/test/diagnostic-output.hpp"/////////////////TODO #include "lib/iter-zip.hpp" #include "lib/random.hpp" -//#include "lib/util.hpp" #include @@ -40,7 +38,6 @@ namespace steam { namespace engine{ namespace test { - namespace { /** uninitialised local storage that can be passed * as working buffer and accessed as TestFrame */ @@ -66,6 +63,12 @@ namespace test { /***************************************************************//** * @test verify support for developing Render Node functionality. + * - raw processing functions to generate and manipulate + * \ref TestFrame data, including hash chaining. + * - a »TestRand-Ontology«, which is a test helper framework, + * and mimics a real _Domain Ontology_ (as would be accessible + * through the adapter plug-in of a specific media handling library. + * - some convenience shortcuts to build test-nodes */ class NodeDevel_test : public Test { diff --git a/tests/core/steam/engine/node-link-test.cpp b/tests/core/steam/engine/node-link-test.cpp index 4626c21f9..152bd3ffa 100644 --- a/tests/core/steam/engine/node-link-test.cpp +++ b/tests/core/steam/engine/node-link-test.cpp @@ -319,6 +319,73 @@ namespace test { void trigger_node_port_invocation() { + auto testGen = testRand().setupGenerator(); + auto testMan = testRand().setupManipulator(); + auto testMix = testRand().setupCombinator(); + +/* + // A Node with two (source) ports + ProcNode n1s{prepareNode("srcA") + .preparePort() + .invoke("a(int)", src_op) + .setParam(5) + .completePort() + .preparePort() + .invoke("b(int)", src_op) + .setParam(23) + .completePort() + .build()}; + + // A node to add some "processing" to each data chain + auto add1_op = [](int* src, int* res){ *res = 1 + *src; }; + ProcNode n1f{prepareNode("filterA") + .preparePort() + .invoke("a+1(int)(int)", add1_op) + .connectLead(n1s) + .completePort() + .preparePort() + .invoke("b+1(int)(int)", add1_op) + .connectLead(n1s) + .completePort() + .build()}; + + // Need a secondary source, this time with three ports + ProcNode n2s{prepareNode("srcB") + .preparePort() + .invoke("a(int)", src_op) + .setParam(7) + .completePort() + .preparePort() + .invoke("b(int)", src_op) + .setParam(13) + .completePort() + .preparePort() + .invoke("c(int)", src_op) + .setParam(17) + .completePort() + .build()}; + + // Wiring for the Mix, building up three ports + // Since the first source-chain has only two ports, + // for the third result port we'll re-use the second source + ProcNode mix{prepareNode("mix") + .preparePort() + .invoke("a-mix(int/2)(int)", mix_op) + .connectLead(n1f) + .connectLead(n2s) + .completePort() + .preparePort() + .invoke("b-mix(int/2)(int)", mix_op) + .connectLead(n1f) + .connectLead(n2s) + .completePort() + .preparePort() + .invoke("c-mix(int/2)(int)", mix_op) + .connectLeadPort(n1f,1) + .connectLead(n2s) + .completePort() + .build()}; +*/ UNIMPLEMENTED ("operate some render nodes as linked together"); } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3e5522278..f770a383e 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -93948,7 +93948,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -94446,13 +94446,13 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + - - + + @@ -94461,19 +94461,26 @@ Date:   Thu Apr 20 18:53:17 2023 +0200

+ + + + + +
- + - + + - + @@ -94546,7 +94553,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -94562,6 +94569,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ @@ -94577,6 +94585,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + @@ -97878,7 +97889,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -97916,24 +97927,24 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + - + - - - + + + - - - + + + @@ -97945,10 +97956,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + @@ -98016,7 +98027,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -98061,8 +98072,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -98146,8 +98157,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -98155,6 +98166,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + @@ -99191,8 +99206,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -99206,7 +99221,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -99382,8 +99397,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
umbenannt in MediaWeavingPattern

- -
+
@@ -99392,11 +99406,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + @@ -99466,7 +99480,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -99504,7 +99518,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -99513,6 +99527,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200

+ + @@ -99537,9 +99553,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + @@ -99549,7 +99565,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -99590,9 +99606,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + @@ -99610,7 +99626,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -100886,7 +100902,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -102538,7 +102554,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -103191,7 +103207,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -104452,8 +104468,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) ergibt hier keinen Sinn — berechnet wird eine einfache lineare Interpolation, zwar ohne Beschränkung des Wertebereichs, jedoch sind aus Sicht des Aufrufers nur Werte [0.0 ... 1.0] plausibel

- - +
@@ -105406,8 +105421,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) ...da war doch irgendwas mit der Sequenz-Nr und Channel-Nr, die habe ich entweder mit anderen Aufrufen harmonisiert oder die Anordnung im Cache verändert; wenn ich mich bloß an die Details erinnern könnte

- - +
@@ -105451,6 +105465,110 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
+ + + + + + + + + + + + + + + + + + + +

+ ...was auch immer das heißt — es gibt nämlich dafür noch kein Konzept; nur die Vorstellung, daß dafür irgendwo ein Schieberegler existiert +

+ + +
+
+
+ + + + + + + + + + + + + +

+ demnach sollte auch die Param-Node zum Einsatz kommen +

+ + +
+
+
+
+ + + + + + + + + + +

+ definitiv nicht des Parameter-Funktors, denn letzterer empfängt immer das Turnout-System, kann also sowiso beliebige Anpassungen vornehmen; was aber gebraucht wird ist eine Processing-function, die andere (angepaßte) Parameter nimmt +

+ +
+
+ + + + +

+ das sollte über die bestehenden cross-Builder-Techniken lösbar sein (seufz) +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -105589,7 +105707,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
- + @@ -107552,8 +107670,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - + + @@ -107566,16 +107684,16 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - - + + + - + @@ -107778,11 +107896,11 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - + + - - + + @@ -107795,7 +107913,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -107955,8 +108073,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - +