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.
This commit is contained in:
Fischlurch 2024-10-11 02:45:51 +02:00
parent 5f0b8b8a81
commit 9490192ef8
4 changed files with 141 additions and 106 deletions

View file

@ -129,7 +129,7 @@ namespace engine {
template<class POL>
class PortBuilder;
class PortBuilderRoot;
template<class POL>
class NodeBuilder
@ -159,7 +159,7 @@ namespace engine {
/** recursively enter detailed setup of a single processing port */
PortBuilder<POL> preparePort ();
PortBuilderRoot<POL> preparePort();
/**
@ -198,28 +198,63 @@ namespace engine {
}
};
template<class POL>
class PortBuilder
class PortBuilderRoot
: protected NodeBuilder<POL>
, util::MoveOnly
{
public:
NodeBuilder<POL>
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<typename FUN>
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<class ADA, typename...ARGS>
PortBuilder
adaptInvocation(ARGS&& ...args)
{
UNIMPLEMENTED ("specify an `InvocationAdapter` to use explicitly");
return move(*this);
}
auto adaptInvocation(ARGS&& ...args);
private:
PortBuilderRoot(NodeBuilder<POL>&& anchor)
: NodeBuilder<POL>{move(anchor)}
{ }
friend PortBuilderRoot NodeBuilder<POL>::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<class POL>
inline PortBuilderRoot<POL>
NodeBuilder<POL>::preparePort ()
{
return PortBuilderRoot<POL>{move(*this)};
}
template<class POL, class WAB>
class PortBuilder
: public PortBuilderRoot<POL>
{
using _Par = PortBuilderRoot<POL>;
WAB weavingBuilder_;
public:
template<class ILA, typename...ARGS>
PortBuilder
@ -283,27 +318,31 @@ namespace engine {
} // slice away the subclass
private:
PortBuilder(NodeBuilder<POL>&& anchor)
PortBuilder(_Par&& base)
: _Par{move(base)}
{ }
friend PortBuilder NodeBuilder<POL>::preparePort();
friend class PortBuilderRoot<POL>;
};
/**
* @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<class POL>
inline PortBuilder<POL>
NodeBuilder<POL>::preparePort ()
{
return PortBuilder<POL>{move(*this)};
}
template<typename FUN>
auto
PortBuilderRoot<POL>::invoke (FUN&& fun)
{
using WeavingBuilder_FUN = WeavingBuilder<POL, manifoldSiz<FUN>(), FUN>;
return PortBuilder<POL, WeavingBuilder_FUN>{move(*this)};
}
/*
template<class POL>
template<class ADA, typename...ARGS>
auto
PortBuilderRoot<POL>::adaptInvocation(ARGS&& ...args)
{
return move(*this);
}
*/
/**
* Entrance point for building actual Render Node Connectivity (Level-2)

View file

@ -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<FUN>()
#include <utility>
#include <array>
@ -328,6 +328,29 @@ namespace engine {
, FAN_O = MatchBuffArray<ArgO>::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<class FUN>
inline constexpr uint
manifoldSiz()
{
using _F = _ProcFun<FUN>;
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.

View file

@ -70,7 +70,7 @@ namespace engine {
using SimpleDirectInvoke = SimpleWeavingPattern<Conf_DirectFunctionInvocation<N,FUN>>;
template<class POL, uint N, class FUN>
struct SimpleWeavingBuilder
struct WeavingBuilder
: util::MoveOnly
{
DataBuilder<POL, PortRef> 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<class BU>
SimpleWeavingBuilder
WeavingBuilder
appendBufferTypes(uint cnt)
{
while (cnt--)
@ -112,7 +112,7 @@ namespace engine {
return move(*this);
}
SimpleWeavingBuilder
WeavingBuilder
selectResultSlot(uint idx)
{
this->resultSlot = idx;

View file

@ -6887,9 +6887,7 @@
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1679087725579" ID="ID_1392812297" MODIFIED="1679087800628" TEXT="zun&#xe4;chst zur&#xfc;ckgestellt">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
...das k&#246;nnen wir erst dann sinnvoll angehen, wenn die Application-Core weiter ausgereift ist
@ -6944,9 +6942,7 @@
<icon BUILTIN="stop-sign"/>
<node CREATED="1487034063408" ID="ID_1251347399" MODIFIED="1518487921062">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
das <i>verschiebt</i>&#160;das Problem nur
@ -7061,9 +7057,7 @@
</node>
<node CREATED="1506175115772" FOLDED="true" HGAP="318" ID="ID_1448696607" MODIFIED="1561827464751" VSHIFT="64">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
<b>UI-Koordinaten </b>(UICoord)
@ -7134,9 +7128,7 @@
</node>
<node CREATED="1506180752099" ID="ID_1588059901" MODIFIED="1576282358129" TEXT="incomplete">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
...need to be extended to allow anchoring
@ -7172,9 +7164,7 @@
</node>
<node CREATED="1506180752102" ID="ID_478035492" MODIFIED="1576282358129" TEXT="covering">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
we may construct the covered part of a given spec, including automatic anchoring.
@ -7751,9 +7741,7 @@
<icon BUILTIN="button_ok"/>
<node CREATED="1508537010868" ID="ID_484491629" MODIFIED="1508537050161">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
welche Operationen
@ -7803,9 +7791,7 @@
<icon BUILTIN="idea"/>
<node CREATED="1509323532816" ID="ID_1206148872" MODIFIED="1576282358126" TEXT="covern kann scheitern">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
...denn wir verlangen, da&#223; wir nach dem Interpolieren &#252;ber eine L&#252;cke
@ -8297,9 +8283,7 @@
</node>
<node CREATED="1509582922140" ID="ID_1687957458" MODIFIED="1510272742518">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
Puffer ab Tiefe
@ -9553,9 +9537,7 @@
<node CREATED="1512439586771" ID="ID_1378758194" MODIFIED="1512439588983" TEXT="geht nicht"/>
<node CREATED="1512439589594" ID="ID_1211811605" MODIFIED="1512439628493" TEXT="Transformer rufen sich wechselseitig">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
....und dann k&#246;nnten diese Transformer in der Kette
@ -11492,9 +11474,7 @@
</node>
<node CREATED="1513893892581" ID="ID_447708501" MODIFIED="1513893978568">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
das <b>Nav</b>-Interface k&#246;nnte daraus entstehen
@ -14515,9 +14495,7 @@
<node CREATED="1523117678010" ID="ID_988976556" MODIFIED="1523117691307" TEXT="die Schnittstelle ist ohnehin schon nicht leicht zu verstehen"/>
<node CREATED="1523117735746" ID="ID_1310906003" MODIFIED="1523117755013">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
klassischer Fall von &#187;<b>premature optimisation</b>&#171;
@ -19172,9 +19150,7 @@
</node>
<node COLOR="#338800" CREATED="1664313591898" ID="ID_1408861050" MODIFIED="1664313653715" TEXT="Probleme aufgekl&#xe4;rt">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<ul>
<li>
@ -26189,9 +26165,7 @@
<node CREATED="1612742574675" ID="ID_20715943" MODIFIED="1612742616893" TEXT="d.h. der TrackBody ist minimal Gr&#xf6;&#xdf;er, als die H&#xf6;he, die wir als Delta anwenden"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1674603031791" ID="ID_328296925" LINK="#ID_1742313131" MODIFIED="1674603318681" TEXT="Nein: da war die Layout-Implementierung noch ziemlich &#x201e;daneben&#x201c;">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
...was bisher nur nicht aufgefallen war, weil die Display-Evaluation nur einmal lief;<br />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 &#252;berarbeitet und systematisch ausgestaltet hatte
@ -39491,9 +39465,7 @@
<node CREATED="1619104785553" ID="ID_1913808351" MODIFIED="1619104792020" TEXT="Cairo und GDK liefern doubles"/>
<node CREATED="1619104793778" ID="ID_988488039" MODIFIED="1619105005937" TEXT="die Maus-Events haben typischerweise eine Nachkommastelle">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
BUTT true flag=&#171;GdkEventType&#187;
@ -51152,9 +51124,7 @@
<icon BUILTIN="messagebox_warning"/>
<node CREATED="1488936835940" ID="ID_1322149090" MODIFIED="1576282357996" TEXT="separates Problem">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
hat &#252;berhaupt nichts mit dem Zugang zu Commands zu tun,
@ -51167,9 +51137,7 @@
</node>
<node COLOR="#435e98" CREATED="1488936840059" ID="ID_1305671938" MODIFIED="1576282357995" TEXT="generisches Problem">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
es geht um Service-Dependencies
@ -51221,9 +51189,7 @@
<node CREATED="1614379249966" ID="ID_1395628620" MODIFIED="1614379269183" TEXT="feste verdrahtete Command-ID"/>
<node CREATED="1614379269938" ID="ID_487933301" MODIFIED="1614379285059">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
nur eine Art <i>remote procedure call</i>
@ -51264,9 +51230,7 @@
<node CREATED="1488937551514" ID="ID_1024843173" MODIFIED="1518487921092" TEXT="es k&#xf6;nnte Binde-Regeln geben"/>
<node CREATED="1488937996901" ID="ID_1000532365" MODIFIED="1576282357994" TEXT="L&#xf6;sungsweg vom Command vorkonfiguriert">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
...nicht klar, ob das notwendig (und gut) ist
@ -51280,9 +51244,7 @@
</node>
<node CREATED="1488937565632" ID="ID_1990212985" MODIFIED="1576282357994" TEXT="dem User (UI-Element) ist das egal">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
denn InteractionStateManager ist ein <b>Interface</b>!
@ -89326,8 +89288,8 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1728516514596" ID="ID_378624147" MODIFIED="1728516534984" TEXT="gegeben: eine Media-Processing-Function"/>
<node CREATED="1728516546003" ID="ID_1336878974" MODIFIED="1728516576658" TEXT="gesucht: Spec oder Pattern der Verdrahtung um diese im pull() aufzurufen"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1728516623352" ID="ID_352122889" MODIFIED="1728516642591" TEXT="L&#xf6;sungsweg: einen WeavingPatternBuilder konstruieren">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1728516623352" ID="ID_352122889" MODIFIED="1728607004029" TEXT="L&#xf6;sungsweg: einen WeavingBuilder konstruieren">
<icon BUILTIN="pencil"/>
<node CREATED="1728517219272" ID="ID_1949349210" MODIFIED="1728517230595" TEXT="Aufgaben zu l&#xf6;sen....">
<node CREATED="1728517232983" ID="ID_1901356657" MODIFIED="1728517254807" TEXT="Storage: wo und wie wird er erzeugt und gehalten?">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1728517853488" ID="ID_207532070" MODIFIED="1728517876717">
@ -89341,16 +89303,26 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</html></richcontent>
<icon BUILTIN="yes"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1728581656920" ID="ID_739845793" MODIFIED="1728581671370" TEXT="denkbar w&#xe4;re ein Quer-Builder-Ansatz">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1728581656920" ID="ID_739845793" MODIFIED="1728606608232" TEXT="denkbar w&#xe4;re ein Quer-Builder-Ansatz">
<icon BUILTIN="pencil"/>
<node CREATED="1728581685771" ID="ID_1910481768" MODIFIED="1728581777685" TEXT="da der Builder per-Value/move arbeitet">
<icon BUILTIN="idea"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1728581711706" ID="ID_133629991" MODIFIED="1728581797422" TEXT="d.h. die Funktions-Angabe schwenkt den Typ">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#435e98" CREATED="1728581711706" ID="ID_133629991" MODIFIED="1728606651381" TEXT="d.h. die Funktions-Angabe schwenkt den Typ"/>
<node COLOR="#338800" CREATED="1728581783087" ID="ID_854272919" MODIFIED="1728606654976" TEXT="brauche dann einen Bottom-Platzhalter-Builder">
<icon BUILTIN="button_ok"/>
<node CREATED="1728606661629" ID="ID_375745142" MODIFIED="1728606669819" TEXT="Einstieg: PortBuilderRoot"/>
<node CREATED="1728606671002" ID="ID_1348108364" MODIFIED="1728606695258" TEXT="Funktions-Spec &#x27fc; PortBuilder"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1728581783087" ID="ID_854272919" MODIFIED="1728581797423" TEXT="brauche dann einen Bottom-Platzhalter-Builder">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1728606701317" ID="ID_21267401" MODIFIED="1728606728547" TEXT="diese L&#xf6;sung auf ein explizit gegebenes WeavingPattern ausweiten?">
<icon BUILTIN="help"/>
</node>
</node>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1728606737481" ID="ID_1233624332" MODIFIED="1728606826787" TEXT="mu&#xdf; aufpassen: Template-Kombinatorik-Explosion">
<linktarget COLOR="#ff1551" DESTINATION="ID_1233624332" ENDARROW="Default" ENDINCLINATION="-1880;100;" ID="Arrow_ID_62498933" SOURCE="ID_1123241919" STARTARROW="None" STARTINCLINATION="4449;305;"/>
<icon BUILTIN="messagebox_warning"/>
<node COLOR="#435e98" CREATED="1728606829352" ID="ID_1673505171" MODIFIED="1728606854295" TEXT="limitiere N &#x2259; Slot-Anzahl in der FeedManifold">
<icon BUILTIN="yes"/>
</node>
</node>
</node>
@ -89365,15 +89337,15 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</body>
</html></richcontent>
</node>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1728517479781" ID="ID_1252289489" MODIFIED="1728517495890" TEXT="wer setzt dann eigentlich die &#xbb;einfache Verdrahtung&#xab; um?">
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#435e98" CREATED="1728517479781" ID="ID_1252289489" MODIFIED="1728606973889" TEXT="wer setzt dann eigentlich die &#xbb;einfache Verdrahtung&#xab; um?">
<icon BUILTIN="help"/>
<node CREATED="1728517499131" ID="ID_1437141043" MODIFIED="1728517516268" TEXT="ich habe gesagt, 1:1-Verschaltung sei der Default"/>
<node CREATED="1728517519366" ID="ID_1357247017" MODIFIED="1728517704540">
<node CREATED="1728517519366" ID="ID_1357247017" MODIFIED="1728606956796">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
jetzt habe ich einen <font face="Monospaced" color="#7e01e1"><b>SimpleWeavingBuilder</b></font>&#160;geschrieben, dem man das alles explizit sagen mu&#223;
jetzt habe ich einen <font color="#7e01e1" face="Monospaced"><b>WeavingBuilder</b></font>&#160;geschrieben, dem man das alles explizit sagen mu&#223;
</p>
</body>
</html></richcontent>
@ -89381,7 +89353,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1728517544812" ID="ID_948060527" MODIFIED="1728517603668" TEXT="aber die Idee war doch, da&#xdf; das &#xbb;Weaving-Pattern&#xab; schematisch festlegt, wie verdrahtet wird">
<icon BUILTIN="broken-line"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1728569398198" ID="ID_1013813267" MODIFIED="1728569435495" TEXT="&#x27f9; das f&#xe4;llt dann der n&#xe4;chst h&#xf6;heren Ebene zu &#x2259; dem PortBuilder">
<node COLOR="#435e98" CREATED="1728569398198" ID="ID_1013813267" MODIFIED="1728606967970" TEXT="&#x27f9; das f&#xe4;llt dann der n&#xe4;chst h&#xf6;heren Ebene zu &#x2259; dem PortBuilder">
<icon BUILTIN="idea"/>
</node>
</node>
@ -89574,7 +89546,8 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1719968185473" ID="ID_1239704157" MODIFIED="1719968217280" TEXT="ein bestimmtes Resultat-BuffHandle wird weitergegeben und nicht geschlossen"/>
</node>
</node>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1719787368938" ID="ID_1123241919" MODIFIED="1719787463871" TEXT="freie Kombinatorik geschickt vermeiden">
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1719787368938" ID="ID_1123241919" MODIFIED="1728606826787" TEXT="freie Kombinatorik geschickt vermeiden">
<arrowlink COLOR="#ff1551" DESTINATION="ID_1233624332" ENDARROW="Default" ENDINCLINATION="-1880;100;" ID="Arrow_ID_62498933" STARTARROW="None" STARTINCLINATION="4449;305;"/>
<linktarget COLOR="#8d0757" DESTINATION="ID_1123241919" ENDARROW="Default" ENDINCLINATION="-491;33;" ID="Arrow_ID_771540131" SOURCE="ID_1412088712" STARTARROW="None" STARTINCLINATION="-327;758;"/>
<icon BUILTIN="yes"/>
</node>