From c4b2902dd474e2e5c6ab68ef633b355fb7d18063 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 27 Dec 2024 03:55:06 +0100 Subject: [PATCH] Invocation: provide simplified API to inject fixed parameter values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ...by defining a parameter-functor to »drop off« a given value * ...also add a static sanity check to reject unsuitable parameter-functor \\ (e.g. for a processing-functor with different or even no parameters) --- src/steam/engine/feed-manifold.hpp | 7 +++ src/steam/engine/node-builder.hpp | 23 ++++++++ src/steam/engine/weaving-pattern-builder.hpp | 3 + tests/core/steam/engine/node-builder-test.cpp | 13 ++--- wiki/thinkPad.ichthyo.mm | 58 +++++++++++++------ 5 files changed, 79 insertions(+), 25 deletions(-) diff --git a/src/steam/engine/feed-manifold.hpp b/src/steam/engine/feed-manifold.hpp index 3d35492d6..a1a2904e8 100644 --- a/src/steam/engine/feed-manifold.hpp +++ b/src/steam/engine/feed-manifold.hpp @@ -605,6 +605,13 @@ namespace engine { template using Adapted = FeedPrototype; + /** is the given functor suitable as parameter functor for this Feed? */ + template + static constexpr bool isSuitable() + { + return hasParam() and _Trait::template isParamFun(); + } + /** * Cross-Builder to add configuration with a given parameter-functor. * @return new FeedPrototype instance outfitted with the current diff --git a/src/steam/engine/node-builder.hpp b/src/steam/engine/node-builder.hpp index 7ed3175ee..20e0f4eb3 100644 --- a/src/steam/engine/node-builder.hpp +++ b/src/steam/engine/node-builder.hpp @@ -369,6 +369,29 @@ namespace engine { }; } + template + auto + attachAutomation (AUTO&& aFun) + { + return attachParamFun ([automation = forward(aFun)] + (TurnoutSystem& turnoutSys) + { + Time nomTime = Time::ZERO; ////////////////////OOO need to retrieve that from turnoutSys + return automation(nomTime); + }); + } + + template + auto + setParam (PAR paramVal) + { + return attachParamFun ([=](TurnoutSystem&) -> PAR + { + return paramVal; + }); + } + + /*************************************************************//** * Terminal: complete the Port wiring and return to the node level. diff --git a/src/steam/engine/weaving-pattern-builder.hpp b/src/steam/engine/weaving-pattern-builder.hpp index b6c392871..f9d06d785 100644 --- a/src/steam/engine/weaving-pattern-builder.hpp +++ b/src/steam/engine/weaving-pattern-builder.hpp @@ -301,6 +301,9 @@ namespace engine { auto adaptParam (PFX paramFunctor) { + static_assert (PROT::template isSuitable() + ,"suitable as param-functor for given processing-functor"); + // using AdaptedWeavingBuilder = Adapted; // return AdaptedWeavingBuilder{move(*this) diff --git a/tests/core/steam/engine/node-builder-test.cpp b/tests/core/steam/engine/node-builder-test.cpp index 89cbab87c..0b133827a 100644 --- a/tests/core/steam/engine/node-builder-test.cpp +++ b/tests/core/steam/engine/node-builder-test.cpp @@ -95,30 +95,27 @@ namespace test { } - /** @test TODO build a Node with a fixed invocation parameter - * @todo WIP 12/24 🔁 define ⟶ implement + /** @test build a Node with a fixed invocation parameter + * @todo 12/24 ✔ define ⟶ ✔ implement */ void build_Node_fixedParam() { auto procFun = [](ushort param, uint* buff){ *buff = param; }; - auto paramFun = [](TurnoutSystem&){ return LIFE_AND_UNIVERSE_4EVER; }; ProcNode node{prepareNode("Test") .preparePort() - .invoke("fun()",procFun) - .attachParamFun(paramFun) + .invoke("fun()", procFun) + .setParam (LIFE_AND_UNIVERSE_4EVER) .completePort() .build()}; CHECK (LIFE_AND_UNIVERSE_4EVER == invokeRenderNode (node)); - - UNIMPLEMENTED ("build node with fixed param"); } /** @test TODO build a Node with dynamically generated parameter - * @todo WIP 12/24 define ⟶ implement + * @todo WIP 12/24 🔁 define ⟶ implement */ void build_Node_dynamicParam() diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index e882650e4..948e6fbdc 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -82346,8 +82346,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
»dropper-Funktion« verwenden, die einen fest hinterlegten Parameter-Wert für jede Invocation in die FeedManifold setzt

- - + @@ -82377,8 +82376,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
beliebiger Parameter-Funktor, der auf dem TurnoutSystem arbeitet und einen passenden Parameter-Wert produziert; Typisierung wird zur compile-Zeit geprüft.

- -
+
@@ -88866,10 +88864,13 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + + + + @@ -91582,8 +91583,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -93710,7 +93711,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -97348,6 +97349,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + @@ -97357,13 +97361,13 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + - + @@ -97383,8 +97387,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - + + @@ -97461,8 +97465,30 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + +

+ Über das Prototyping hat eine Art Normierung stattgefunden; ich bin jetzt sicher, daß die allermeisten Aufgaben zur Medien-Berechnung in dieses Standard-Pattern abgebildet werden können, vor allem durch die stark erweiterte Flexibilität des Buffer- und Parameter-Bindings +

+ + +
+
+
+ + + + + + + + @@ -97476,8 +97502,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) erfolgt als Teil der Konfiguration eines Ports

- - +
@@ -97487,8 +97512,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) also nachdem man den Processing-Functor gegeben hat

- -
+