From 1955d28087dc044f3d1c1fc6969f633e35034bee Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 11 Jul 2024 17:34:57 +0200 Subject: [PATCH] Invocation: use introspection to setup an example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The deeper problem is that we must not engage into any premature decisions regarding the structure or layout of the actual processing function invocation. Thus attempting to create a kind of »firewall« of sorts, by connecting the building blocks strictly through template parameter and preferably figuring out any detailed knowledge locally, through ''compile-time introspection...'' --- src/steam/engine/turnout.hpp | 101 +++++++++++++++++++++++++++++++---- wiki/thinkPad.ichthyo.mm | 63 +++++++++------------- 2 files changed, 116 insertions(+), 48 deletions(-) diff --git a/src/steam/engine/turnout.hpp b/src/steam/engine/turnout.hpp index 6f036a49a..c9dabde8f 100644 --- a/src/steam/engine/turnout.hpp +++ b/src/steam/engine/turnout.hpp @@ -272,7 +272,7 @@ namespace engine { } - struct WeavingPatternBase + struct WeavingPatternBase ///////OOO seems to be obsolete...?? //////////////////////////////OOO non-copyable? move-only?? { using Feed = FeedManifold<0>; @@ -284,15 +284,84 @@ namespace engine { void fix (Feed&) { /* NOP */ } }; + namespace {// Introspection helpers.... + + using lib::meta::_Fun; + using lib::meta::is_BinaryFun; + + /** Helper to pick up the parameter dimensions from the processing function + * @remark this is the rather simple yet common case that media processing + * is done by a function, which takes an array of input and output + * buffer pointers with a common type; this simple case is used + * 7/2024 for prototyping and validate the design. + * @tparam FUN a _function-like_ object, expected to accept two arguments, + * which both are arrays of buffer pointers (input, output). + */ + template + struct _ProcFun + { + static_assert(_Fun() , "something funktion-like required"); + static_assert(is_BinaryFun() , "function with two arguments expected"); + + using ArgI = typename _Fun::Args::List::Head; + using ArgO = typename _Fun::Args::List::Tail::Head; + + template + struct MatchBuffArray + { + static_assert(not sizeof(ARG), "processing function expected to take array-of-buffer-pointers"); + }; + template + struct MatchBuffArray> + { + using Buff = BUF; + enum{ SIZ = N }; + }; + + using BuffI = typename MatchBuffArray::Buff; + using BuffO = typename MatchBuffArray::Buff; + + enum{ FAN_I = MatchBuffArray::SIZ + , FAN_O = MatchBuffArray::SIZ + }; + }; + }//(End)Introspection helpers. + + /** + * Adapter to handle a simple yet common setup for media processing + * - somehow we can invoke processing as a simple function + * - this function takes two arrays: the input- and output buffers + * @remark this setup is useful for testing, and as documentation example; + * actually the FeedManifold is mixed in as baseclass, and the + * buffer pointers are retrieved from the BuffHandles. + * @tparam MAN a FeedManifold, providing arrays of BuffHandles + * @tparam FUN the processing function + */ template - struct InvocationAdapter + struct SimpleFunctionInvocationAdapter : MAN { - static constexpr auto N = MAN::inBuff::size(); + using BuffI = typename _ProcFun::BuffI; + using BuffO = typename _ProcFun::BuffO; + + enum{ N = MAN::inBuff::size() + , FAN_I = _ProcFun::FAN_I + , FAN_O = _ProcFun::FAN_O + }; + + static_assert(FAN_I <= N and FAN_O <= N); + + using ArrayI = std::array; + using ArrayO = std::array; + FUN process; + ArrayI inParam; + ArrayO outParam; + + void connect (uint fanIn, uint fanOut) { @@ -307,13 +376,27 @@ namespace engine { } }; - - template - struct SimpleWeavingPattern - : PAR + /** + * Example base configuration for a Weaving-Pattern chain: + * - use a simple processing function + * - pass an input/output buffer array to this function + * - map all »slots« directly without any re-ordering + * - use a sufficiently sized FeedManifold as storage scheme + */ + template + struct Conf_DirectFunctionInvocation { using Manifold = FeedManifold; - using Feed = InvocationAdapter; + using Feed = SimpleFunctionInvocationAdapter; + enum{ MAX_SIZ = N }; + }; + + + template + struct SimpleWeavingPattern + : CONF + { + using Feed = typename CONF::Feed; static_assert (_verify_usable_as_InvocationAdapter()); @@ -321,7 +404,7 @@ namespace engine { uint fanOut{0}; template - using Storage = lib::UninitialisedStorage; + using Storage = lib::UninitialisedStorage; Storage leadPort; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index d5d32fd1e..698513610 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1223,9 +1223,7 @@ - - - +

nämlich @@ -1276,9 +1274,7 @@ - - - +

das heißt, die Diff-Implementierung muß länger leben @@ -1298,9 +1294,7 @@ - - - +

um das Diff zu pullen @@ -1338,9 +1332,7 @@ - - - +

jede Facade-Funktion brauch einen Dispatcher @@ -1361,9 +1353,7 @@ - - - +

bevor die Facade geöffnet wir @@ -2840,9 +2830,7 @@ - - - +

...und nicht bloß inaktiv schalten. @@ -4620,9 +4608,7 @@ - - - +

...wenn jemand zugreift @@ -7048,9 +7034,7 @@ - - - +

wir können den größten Teil dieser Einzeiler-Funktionen loswerden, @@ -87935,8 +87919,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
...und zwar seit dem Anfang des Lumiera-Projekts. Vorstellungen haben ist schön; aber um zu bauen, brauche ich entweder ein Baumuster, oder ich brauche einen Plan und ein formal definiertes Ziel. Ich habe aber nur eine klar (negativ) abgegrenzte Finalität

- -
+
@@ -87950,8 +87933,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
 — zu einer gewaltigen universellen Klassifikation jedweden Medien-Processings

- - +
@@ -87968,8 +87950,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
und zwar durch die Entscheidungen der letzten Wochen

- - +
@@ -87984,7 +87965,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + + @@ -87993,14 +87976,14 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
⟹ muß dafür den Buffer-Typ kennen

- -
+ - + + @@ -88010,15 +87993,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
der hier gecodete InvocationAdapter ist kein Inteface (sondern ein Concept)

- -
+
- - - +

Trennmauern zwischen allen Bauelementen im Baukastensystem @@ -88026,6 +88006,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + +