From 532408a305beaaca9f935715ff69644033d620b9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 5 Jul 2026 22:12:18 +0200 Subject: [PATCH] Parameters: design sketch for base-domain and conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While it is unfortunate that I seem to get deeper and deeper into that topic... - it should be noted that data size matters most (pervasive use expected) - the design is leaning towards multiple functional closures - both together suggest to use a classical virtual interface, without much ado - yet parameters must be copyable values, to allow for evaluation graphs and snapshots - so this turns out as yet another use case for ''polymorphic values'' - furthermore, fluid usage requires flexible conversions between result values - given the situation with numeric value types and strings, this implies ''to build a visitor'' 🠲 ''putting that work aside for the moment, since I need to focus on my IO_URING research (for FrOSCon 26)'' --- src/lib/par/domain.hpp | 54 +++++++++++++ tests/lib/par/parameter-domain-test.cpp | 24 ++++-- wiki/thinkPad.ichthyo.mm | 101 +++++++++++++++++++++--- 3 files changed, 163 insertions(+), 16 deletions(-) diff --git a/src/lib/par/domain.hpp b/src/lib/par/domain.hpp index 968a6fe82..0069237ff 100644 --- a/src/lib/par/domain.hpp +++ b/src/lib/par/domain.hpp @@ -34,11 +34,52 @@ #define LIB_PAR_DOMAIN_H +#include "lib/meta/typelist.hpp" +//#include "lib/meta/typelist-util.hpp" +#include "lib/meta/generator.hpp" namespace lib { namespace par { + + struct ValBuff { /*placeholder*/ }; + template + constexpr inline ValBuff& + asValBuff (X& something) + { + void* rawMem{& something}; + return * static_cast (rawMem); + } + + template + constexpr inline ValBuff const& + asValBuff (X const& something) + { + void const * rawMem{& something}; + return * static_cast (rawMem); + } + + template + class TypeHandler + : public BAS + { + public: + virtual void extractAs (X&, ValBuff&) =0; + }; + +// using lib::meta::typeseq; + + + using BaseTypes = meta::Types; + /** build a generic visitor interface for all types in list */ + using TypeHandlerInterface = meta::InstantiateChained; /** @@ -52,9 +93,22 @@ namespace par { * at compile time, if a sensible conversion can not be provided. */ class Domain + : public TypeHandlerInterface { public: virtual ~Domain(); ///< this is an interface + + protected: + + }; + + + template + class BaseDomain + : public Domain + { + void extractAs (uint&, ValBuff& valBuff) override { UNIMPLEMENTED("ex uint"); } + void extractAs (double&, ValBuff& valBuff) override { UNIMPLEMENTED("ex double"); } }; diff --git a/tests/lib/par/parameter-domain-test.cpp b/tests/lib/par/parameter-domain-test.cpp index 61bd4fde1..b568e345f 100644 --- a/tests/lib/par/parameter-domain-test.cpp +++ b/tests/lib/par/parameter-domain-test.cpp @@ -48,7 +48,7 @@ namespace test{ }; typedef Some SomeThing; - + }//(End)Test fixture @@ -68,20 +68,34 @@ namespace test{ virtual void run (Arg) { - simpleUsage(); - verify_typeMarker(); + seedRand(); + basics(); + verify_typeVisitor(); } void - simpleUsage() + basics() { } void - verify_typeMarker() + verify_typeVisitor() { + BaseDomain domInt; + Domain& d1{domInt}; + + int val1 = 1 + rani (1000); + ValBuff& src1 = asValBuff (val1); + + uint target1{0}; + CHECK (not target1); + +// TypeHandler& dd1{d1}; +// dd1.extractAs (target1, src1); + d1.extractAs (target1, src1); + CHECK (target1 == uint(val1)); } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 6832905eb..7a36a0253 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -82174,7 +82174,19 @@ - + + + + + + +

+ bestimmt die Art und Weise des Zugriffs auf eine Datenquelle: entweder als Wert der in enem Buffer abgelegt ist, oder als pull von einem Funktor +

+ + +
+
@@ -82290,12 +82302,12 @@ - + - + @@ -82554,12 +82566,14 @@ - + - + + +

- Konsequenz: pull-Prinzip ist verfplichtend + Konsequenz: pull-Prinzip ist verpflichtend

@@ -82577,6 +82591,27 @@
+ + + + + + + + + + + + + + + + + + + + + @@ -82605,9 +82640,8 @@ - - + @@ -82616,15 +82650,60 @@ + + + - - + + + + + + + + + + + +

+ ...interessanterweise auch nicht (mehr) beim Variant-Visitor: auch dort habe ich in die Zugriffsfunktion schon vor einiger Zeit einen Upcast auf das Type-Handler-Interface eingebaut. Der Compiler erlaubt anscheinend nicht mehr, verschiedene Overloads einer gleich benannten Funktion aus mehreren Basisklassen zusammenzuführen +

+ +
+ + + + + + +

+ ...auch das Problem kenne ich schon: -Woverloaded-virtual : da hatten die Compiler-Entwickler durchaus relevante Gefahren im Blick, aber haben die Warnung zu billig implementiert, nämlich bereits bei der Definition eines überladenen Virtual. Die Gefahr würde jedoch erst beim zweideutigen Aufruf bestehen. Daher kann man diese Warnung per Pragma übersteuern. Hab ich bereits bei verschiedenen Verwendungen des Generator-Templates getan. +

+ +
+
+
+ + + + + + +

+ das ist kniffelig, da das ein template-template-Parameter ist, mit zwei bereits festgelegten Typ-Parametern (Zieltyp und Basisklasse). Hier implementieren wir aber Domain<X>, also muß der Quell-Parameter X auch irgendiw zusätzlich in den Type-Handler gebracht werden. Idee: als nested-Templates definieren und dann am Ende per templated Typedef rausziehen +

+ +
+
+
+
+
@@ -113809,8 +113888,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - +