Invocation: draft a way to decorate the processing-functor
...the idea is to limit the scope of possible changes and rather directly accept a functor to transform the parameters. We need then to account for the possible flexibility in processing-functor arguments, while in fact only two cases must be actually handled. ''This proof-of-concept works in test setup''
This commit is contained in:
parent
61c685fa9f
commit
0e5ffe7780
4 changed files with 65 additions and 19 deletions
|
|
@ -256,7 +256,9 @@ namespace engine {
|
|||
using SigP = add_pointer_t<typename _Fun<PF>::Sig>;
|
||||
|
||||
template<class PF>
|
||||
using isSuitable = is_constructible<Param, Res<PF>>;
|
||||
using isSuitable = __and_<is_constructible<Param, Res<PF>>
|
||||
,std::is_invocable<PF, TurnoutSystem&>
|
||||
>;
|
||||
|
||||
template<class PF>
|
||||
using isConfigurable = __and_<is_constructible<bool, PF&>
|
||||
|
|
@ -605,8 +607,8 @@ namespace engine {
|
|||
template<typename PFX>
|
||||
using Adapted = FeedPrototype<FUN,PFX>;
|
||||
|
||||
template<typename DEC>
|
||||
using Decorated = FeedPrototype<DEC,PAM>;
|
||||
template<typename FUX>
|
||||
using Decorated = FeedPrototype<FUX,PAM>;
|
||||
|
||||
/** is the given functor suitable as parameter functor for this Feed? */
|
||||
template<typename PFX>
|
||||
|
|
@ -632,12 +634,42 @@ namespace engine {
|
|||
return Adapted<OtherParamFun>{move(procFun_), move(otherParamFun)};
|
||||
}
|
||||
|
||||
template<typename DEC>
|
||||
template<typename FUX>
|
||||
auto
|
||||
moveDecoratedProc (DEC procFunDecorator)
|
||||
moveDecoratedProc (FUX adaptedProcFun)
|
||||
{
|
||||
using AugmentedProcFun = std::decay_t<decltype(procFunDecorator(move(procFun_)))>;
|
||||
return Decorated<AugmentedProcFun>{procFunDecorator (move(procFun_)), move(paramFun_)};
|
||||
using AugmentedProcFun = std::decay_t<FUX>;
|
||||
return Decorated<AugmentedProcFun>{move(adaptedProcFun), move(paramFun_)};
|
||||
}
|
||||
|
||||
template<typename TRA>
|
||||
auto
|
||||
moveTransformedParam (TRA paramTransformer)
|
||||
{
|
||||
static_assert (_Trait::hasParam(), "Processing-functor with parameters expected");
|
||||
using SigP = lib::meta::_FunArg<TRA>;
|
||||
using SigI = typename _Proc::SigI;
|
||||
using SigO = typename _Proc::SigO;
|
||||
if constexpr (_Proc::hasInput())
|
||||
{
|
||||
return moveDecoratedProc([procFun = move(procFun_)
|
||||
,transform = move(paramTransformer)
|
||||
]
|
||||
(SigP par, SigI in, SigO out)
|
||||
{
|
||||
return procFun (transform(par), in, out);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return moveDecoratedProc([procFun = move(procFun_)
|
||||
,transform = move(paramTransformer)
|
||||
]
|
||||
(SigP par, SigO out)
|
||||
{
|
||||
return procFun (transform(par), out);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ namespace engine {
|
|||
using Adapted = WeavingBuilder<POL, AdaptedPrototype<PFX>>;
|
||||
|
||||
template<class DEC>
|
||||
using DecoratedPrototype = typename PROT::template Decorated<DEC>;
|
||||
using DecoratedPrototype = decltype(std::declval<PROT>().moveTransformedParam (move (std::declval<DEC>()))); /////OOO ugly!!!!
|
||||
template<class DEC>
|
||||
using Decorated = WeavingBuilder<POL, DecoratedPrototype<DEC>>;
|
||||
|
||||
|
|
@ -324,13 +324,12 @@ namespace engine {
|
|||
adaptProcFunParam (DEC decorator)
|
||||
{
|
||||
// static_assert (PROT::template isSuitable<DEC>()
|
||||
// ,"suitable as param-functor for given processing-functor"); //////////////////////////TODO
|
||||
// ,"suitable as param-functor for given processing-functor"); //////////////////////////OOO need some static check here to reject processing-fun without params
|
||||
//
|
||||
using AdaptedWeavingBuilder = Decorated<DEC>;
|
||||
//
|
||||
return AdaptedWeavingBuilder{move(*this)
|
||||
,prototype_.moveDecoratedProc (move (decorator))
|
||||
//////////////////////////////////////////////////////////////////////OOO need to do the actual adaptation here
|
||||
,prototype_.moveTransformedParam (move (decorator))
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,15 +176,16 @@ namespace test {
|
|||
build_Node_adaptedParam()
|
||||
{
|
||||
auto procFun = [](ulong param, int* buff){ *buff = int(param); };
|
||||
auto adaptor = [](string const& spec){ return boost::lexical_cast<int>(spec); };
|
||||
auto adaptor = [](string spec){ return boost::lexical_cast<int>(spec); };
|
||||
|
||||
ProcNode node{prepareNode("Test")
|
||||
.preparePort()
|
||||
.invoke ("fun()", procFun)
|
||||
// .adaptParam (adaptor) /////////////////////OOO engage here!
|
||||
// .setParam ("55")
|
||||
.adaptParam (adaptor)
|
||||
.setParam ("55")
|
||||
.completePort()
|
||||
.build()};
|
||||
SHOW_EXPR(invokeRenderNode (node));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -98072,8 +98072,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1721838899545" ID="ID_960529387" MODIFIED="1734389385989" TEXT="doch wieder auf die Buffer-Konstruktor-Closure zurückkommen?">
|
||||
<arrowlink COLOR="#b42d6a" DESTINATION="ID_1819206244" ENDARROW="Default" ENDINCLINATION="43;40;" ID="Arrow_ID_1051671986" STARTARROW="None" STARTINCLINATION="13;-15;"/>
|
||||
<linktarget COLOR="#a94eac" DESTINATION="ID_960529387" ENDARROW="Default" ENDINCLINATION="-357;-399;" ID="Arrow_ID_1864365252" SOURCE="ID_1655919747" STARTARROW="None" STARTINCLINATION="822;40;"/>
|
||||
<linktarget COLOR="#332ba3" DESTINATION="ID_960529387" ENDARROW="Default" ENDINCLINATION="-46;-257;" ID="Arrow_ID_977971374" SOURCE="ID_1119846327" STARTARROW="None" STARTINCLINATION="-22;219;"/>
|
||||
<linktarget COLOR="#a94eac" DESTINATION="ID_960529387" ENDARROW="Default" ENDINCLINATION="-357;-399;" ID="Arrow_ID_1864365252" SOURCE="ID_1655919747" STARTARROW="None" STARTINCLINATION="822;40;"/>
|
||||
<font NAME="SansSerif" SIZE="12"/>
|
||||
<icon BUILTIN="help"/>
|
||||
<icon BUILTIN="hourglass"/>
|
||||
|
|
@ -105488,8 +105488,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
...was auch immer das heißt — es gibt nämlich dafür noch kein Konzept; nur die Vorstellung, daß dafür <i>irgendwo ein Schieberegler </i>existiert
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1739227669817" ID="ID_190154455" MODIFIED="1739227683744" TEXT="andererseits: immer noch ein explizites Node-Setup">
|
||||
|
|
@ -105509,8 +105508,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
demnach sollte auch die <b>Param-Node</b> zum Einsatz kommen
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -105557,6 +105555,22 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<icon BUILTIN="full-2"/>
|
||||
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1739242429615" ID="ID_1933481502" MODIFIED="1739242459785" TEXT="muß die verschiedenen Definitionsvarianten des Processing-Functors beachten">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
<node CREATED="1739289987481" ID="ID_714942938" MODIFIED="1739290007177" TEXT="kann Variante mit Parameter voraussetzen">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node CREATED="1739290008790" ID="ID_1368112591" MODIFIED="1739290022440" TEXT="⟹ damit bleiben nur zwei Varianten abzudecken">
|
||||
<node CREATED="1739290024044" ID="ID_1231244481" MODIFIED="1739290032550" TEXT="fun(par,out)"/>
|
||||
<node CREATED="1739290033703" ID="ID_1390721734" MODIFIED="1739290039925" TEXT="fun(par, in, out)"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1739290047617" ID="ID_1720918617" MODIFIED="1739290061188" TEXT="erstmal die Logik grob ausformulieren">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node BACKGROUND_COLOR="#cfa0bf" COLOR="#690f14" CREATED="1739290063125" ID="ID_1127173969" MODIFIED="1739290092107" TEXT="noch ziemlich hässlich">
|
||||
<icon BUILTIN="smiley-angry"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#dcd4b8" COLOR="#435e98" CREATED="1739290178567" ID="ID_1825991532" MODIFIED="1739290223471" TEXT="aber läßt sich aufrufen �� mit korrektem Ergebnis">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1739242477076" ID="ID_509590719" MODIFIED="1739242501812" TEXT="statische Fehlermeldung wenn es gar keine Parameter gibt">
|
||||
<icon BUILTIN="yes"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue