From 9490192ef8f822613fb4ac08dfdfc9b5587caebc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 11 Oct 2024 02:45:51 +0200 Subject: [PATCH] Invocation: integrate WeavingBuilder into PortBuilder ...seems that the former is well suited to serve as detail builder used internally by the latter to provide a simplified standard adaptation for a given processing function. The integration can be achieved to layer a specialised detail builder class on top, which can be entered only by specifying the concrete function or lambda to wrap for the processing; the further builder-API-functions to control the wiring in detail become thus only accessible after the function type is known; this allows to place the detail builder as member into the enclosing port builder and thus to allocate everything within the current stack frame invoking the builder chain. --- src/steam/engine/node-builder.hpp | 101 ++++++++++++----- src/steam/engine/turnout.hpp | 25 +++- src/steam/engine/weaving-pattern-builder.hpp | 8 +- wiki/thinkPad.ichthyo.mm | 113 +++++++------------ 4 files changed, 141 insertions(+), 106 deletions(-) diff --git a/src/steam/engine/node-builder.hpp b/src/steam/engine/node-builder.hpp index 7b5e7988e..14b49ec77 100644 --- a/src/steam/engine/node-builder.hpp +++ b/src/steam/engine/node-builder.hpp @@ -129,7 +129,7 @@ namespace engine { template - class PortBuilder; + class PortBuilderRoot; template class NodeBuilder @@ -159,7 +159,7 @@ namespace engine { /** recursively enter detailed setup of a single processing port */ - PortBuilder preparePort (); + PortBuilderRoot preparePort(); /** @@ -198,28 +198,63 @@ namespace engine { } }; + + template - class PortBuilder + class PortBuilderRoot : protected NodeBuilder , util::MoveOnly { - public: + NodeBuilder + completePort() + { + static_assert(not sizeof(POL), + "can not build a port without specifying a processing function"); + } + /** setup standard wiring to adapt the given processing function. + * @return a PortBuilder specialised to wrap the given \a FUN */ template - PortBuilder - invoke (FUN&& fun) - { - UNIMPLEMENTED ("setup standard wiring to adapt the given processing function"); - return move(*this); - } + auto invoke (FUN&& fun); + /** specify an `InvocationAdapter` to use explicitly. */ template - PortBuilder - adaptInvocation(ARGS&& ...args) - { - UNIMPLEMENTED ("specify an `InvocationAdapter` to use explicitly"); - return move(*this); - } + auto adaptInvocation(ARGS&& ...args); + + + private: + PortBuilderRoot(NodeBuilder&& anchor) + : NodeBuilder{move(anchor)} + { } + + friend PortBuilderRoot NodeBuilder::preparePort(); + }; + + /** + * @remark while _logically_ this builder-function _descends_ into the + * definition of a port, for the implementation we _wrap_ the existing + * NodeBuilder and layer a PortBuilder subclass „on top“ — thereby shadowing + * the enclosed original builder temporarily; the terminal builder operation + * PortBuilder::completePort() will unwrap and return the original NodeBuilder. + */ + template + inline PortBuilderRoot + NodeBuilder::preparePort () + { + return PortBuilderRoot{move(*this)}; + } + + + + template + class PortBuilder + : public PortBuilderRoot + { + using _Par = PortBuilderRoot; + + WAB weavingBuilder_; + + public: template PortBuilder @@ -283,27 +318,31 @@ namespace engine { } // slice away the subclass private: - PortBuilder(NodeBuilder&& anchor) + PortBuilder(_Par&& base) + : _Par{move(base)} { } - friend PortBuilder NodeBuilder::preparePort(); + friend class PortBuilderRoot; }; - /** - * @remark while _logically_ this builder-function _descends_ into the - * definition of a port, for the implementation we _wrap_ the existing - * NodeBuilder and layer a PortBuilder subclass „on top“ — thereby shadowing - * the enclosed original builder temporarily; the terminal builder operation - * PortBuilder::completePort() will unwrap and return the original NodeBuilder. - */ template - inline PortBuilder - NodeBuilder::preparePort () - { - return PortBuilder{move(*this)}; - } - + template + auto + PortBuilderRoot::invoke (FUN&& fun) + { + using WeavingBuilder_FUN = WeavingBuilder(), FUN>; + return PortBuilder{move(*this)}; + } +/* + template + template + auto + PortBuilderRoot::adaptInvocation(ARGS&& ...args) + { + return move(*this); + } + */ /** * Entrance point for building actual Render Node Connectivity (Level-2) diff --git a/src/steam/engine/turnout.hpp b/src/steam/engine/turnout.hpp index 4fe0bbe8d..ea0cd9991 100644 --- a/src/steam/engine/turnout.hpp +++ b/src/steam/engine/turnout.hpp @@ -75,7 +75,7 @@ //#include "lib/iter-adapter.hpp" #include "lib/meta/function.hpp" //#include "lib/itertools.hpp" -//#include "lib/util.hpp" +//#include "lib/util.hpp" ////////OOO wegen manifoldSiz() #include #include @@ -328,6 +328,29 @@ namespace engine { , FAN_O = MatchBuffArray::SIZ }; }; + + + /** + * Pick a suitable size for the FeedManifold to accommodate the given function. + * @remark only returning one of a small selection of sizes, to avoid + * excessive generation of template instances. + * @todo 10/24 this is a premature safety guard; + * need to assess if there is actually a problem + * (chances are that the optimiser absorbs most of the combinatoric complexity, + * or that, to the contrary, other proliferation mechanisms cause more harm) + */ + template + inline constexpr uint + manifoldSiz() + { + using _F = _ProcFun; + auto bound = std::max (_F::FAN_I, _F::FAN_O); + static_assert (bound <= 10, + "Limitation of template instances exceeded"); + return bound < 3? bound + : bound < 6? 5 + : 10; + } }//(End)Introspection helpers. diff --git a/src/steam/engine/weaving-pattern-builder.hpp b/src/steam/engine/weaving-pattern-builder.hpp index b8a30df1a..0b480a914 100644 --- a/src/steam/engine/weaving-pattern-builder.hpp +++ b/src/steam/engine/weaving-pattern-builder.hpp @@ -70,7 +70,7 @@ namespace engine { using SimpleDirectInvoke = SimpleWeavingPattern>; template - struct SimpleWeavingBuilder + struct WeavingBuilder : util::MoveOnly { DataBuilder leadPort; @@ -92,7 +92,7 @@ namespace engine { }; ServiceCtx ctx; //////////////////////////////////////////OOO need to wire that top-down through all builders! - SimpleWeavingBuilder + WeavingBuilder attachToLeadPort(ProcNode& lead, uint portNr) { PortRef portRef; /////////////////////////////////////OOO TODO need Accessor on ProcNode!!!!! @@ -102,7 +102,7 @@ namespace engine { } template - SimpleWeavingBuilder + WeavingBuilder appendBufferTypes(uint cnt) { while (cnt--) @@ -112,7 +112,7 @@ namespace engine { return move(*this); } - SimpleWeavingBuilder + WeavingBuilder selectResultSlot(uint idx) { this->resultSlot = idx; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index bde4f6033..459f9450a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -6887,9 +6887,7 @@ - - - +

...das können wir erst dann sinnvoll angehen, wenn die Application-Core weiter ausgereift ist @@ -6944,9 +6942,7 @@ - - - +

das verschiebt das Problem nur @@ -7061,9 +7057,7 @@ - - - +

UI-Koordinaten (UICoord) @@ -7134,9 +7128,7 @@ - - - +

...need to be extended to allow anchoring @@ -7172,9 +7164,7 @@ - - - +

we may construct the covered part of a given spec, including automatic anchoring. @@ -7751,9 +7741,7 @@ - - - +

welche Operationen @@ -7803,9 +7791,7 @@ - - - +

...denn wir verlangen, daß wir nach dem Interpolieren über eine Lücke @@ -8297,9 +8283,7 @@ - - - +

Puffer ab Tiefe @@ -9553,9 +9537,7 @@ - - - +

....und dann könnten diese Transformer in der Kette @@ -11492,9 +11474,7 @@ - - - +

das Nav-Interface könnte daraus entstehen @@ -14515,9 +14495,7 @@ - - - +

klassischer Fall von »premature optimisation« @@ -19172,9 +19150,7 @@ - - - +

  • @@ -26189,9 +26165,7 @@ - - - +

    ...was bisher nur nicht aufgefallen war, weil die Display-Evaluation nur einmal lief;
    Nachdem ich das ZoomWindow integriert hatte, zeigten sich diverse Defekte / run-away-Effekte, die erst beoben waren, nachdem ich die Layout-Berechnung im TrackHeadWidget komplett überarbeitet und systematisch ausgestaltet hatte @@ -39491,9 +39465,7 @@ - - - +

    BUTT true flag=«GdkEventType» @@ -51152,9 +51124,7 @@ - - - +

    hat überhaupt nichts mit dem Zugang zu Commands zu tun, @@ -51167,9 +51137,7 @@ - - - +

    es geht um Service-Dependencies @@ -51221,9 +51189,7 @@ - - - +

    nur eine Art remote procedure call @@ -51264,9 +51230,7 @@ - - - +

    ...nicht klar, ob das notwendig (und gut) ist @@ -51280,9 +51244,7 @@ - - - +

    denn InteractionStateManager ist ein Interface! @@ -89326,8 +89288,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
    - - + + @@ -89341,16 +89303,26 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
    - - + + - - + + + + + - - + + + + + + + + + @@ -89365,15 +89337,15 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
    - + - +

    - jetzt habe ich einen SimpleWeavingBuilder geschrieben, dem man das alles explizit sagen muß + jetzt habe ich einen WeavingBuilder geschrieben, dem man das alles explizit sagen muß

    @@ -89381,7 +89353,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
    - + @@ -89574,7 +89546,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
    - + +