Invocation: define accessor-functor to work on extension block

This is rather the easy part, building upon the foundation developed with `HeteroData`:
 * the `TurnoutSystem` will now accept a `HeteroData`-Accessor
 * the `ParamBuldSpec` can thus construct an Accessor-Type for each »slot«

...the more tricky part will be how actually to build, populate and attach
such an extension data slot, placed into the local stack frame...
This commit is contained in:
Fischlurch 2024-12-29 18:27:05 +01:00
parent f990f97c41
commit ee59162418
5 changed files with 71 additions and 2 deletions

View file

@ -204,7 +204,7 @@ namespace lib {
/**
* Accessor-functor to get at the data residing within some tuple element
* Using the enclosing typed scope to ensure safe storage access
* @tparam slot numer of the data element, counting from zero over the full chain
* @tparam slot number of the data element, counting from zero over the full chain
* @note this functor holds no data, but shall be applied to some existing HeteroData.
*/
template<size_t slot>

View file

@ -102,6 +102,23 @@ namespace engine {
return addSlot ([paramVal](TurnoutSystem&){ return paramVal; });
}
/** @internal the _chain constructor type_ is a type rebinding meta function (nested struct),
* which extends the HeteroData chain given by \a ANK with the sequence of types derived from
* the result-values of all functors stored in the ParamBuildSpec, i.e. the resulting param tuple.
* @remark HeteroData defines a nested struct `Chain`, and with the help of `RebindVariadic`,
* the type sequence from the ParamTup can be used to instantiate this Chain context.
*/
using ChainCons = typename lib::meta::RebindVariadic<ANK::template Chain, ParamTup>::Type;
typename ChainCons::NewFrame
buildParamDataBlock (TurnoutSystem& turnoutSys)
{
auto invoke = [&](auto& fun) { return fun(turnoutSys); };
ParamTup params = lib::meta::mapEach(functors_, invoke);
//////////////////////////////////////////////////////////////OOO now need to extract them
}
template<size_t slot>
class Slot
: util::MoveOnly
@ -119,6 +136,17 @@ namespace engine {
{
return std::get<slot> (spec_.functors_) (turnoutSys);
}
/** a getter functor able to work on the full extended HeteroData-Chain
* @remark the front-end of this chain resides in TurnoutSystem */
using Accessor = typename ChainCons::template Accessor<slot>;
static auto makeAccessor() { return Accessor{}; }
static auto&
getParamVal (TurnoutSystem& turnoutSys)
{
return turnoutSys.get (makeAccessor());
}
};
template<size_t idx>

View file

@ -67,6 +67,10 @@ namespace engine {
};
private:
template<class SPEC, size_t idx>
using Accessor = typename lib::HeteroData<SPEC>::template Accessor<idx>;
FrontBlock invoParam_;
public:
@ -79,6 +83,26 @@ namespace engine {
{
return invoParam_.get<SLOT_TIME>();
}
ProcessKey
getProcKey()
{
return invoParam_.get<SLOT_KEY>();
}
template<class SPEC, size_t idx>
auto&
get (Accessor<SPEC,idx> const& getter)
{
return getter.get (invoParam_);
}
template<class CHAIN>
void
attachChainBlock (CHAIN& chainBlock)
{
chainBlock.linkInto (invoParam_);
}
};

View file

@ -129,6 +129,9 @@ SHOW_TYPE(Spec::ParamTup)
auto v1 = spec.slot<1>().invokeParamFun (turnoutSys);
SHOW_EXPR(v0)
SHOW_EXPR(v1)
auto paramBlock = spec.buildParamDataBlock (turnoutSys);
TODO ("implement a simple Builder for ParamAgent-Node");
TODO ("then use both together to demonstrate a param data feed here");
}

View file

@ -94230,7 +94230,10 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="yes"/>
<node CREATED="1735424265508" ID="ID_1814686800" MODIFIED="1735424277302" TEXT="speichert ein Tupel von parameter-Funktoren"/>
<node CREATED="1735424284183" ID="ID_318636546" MODIFIED="1735424295714" TEXT="daraus ergibt sich auch der Parameter-Tupel-Typ"/>
<node CREATED="1735426958276" ID="ID_803365380" MODIFIED="1735426990030" TEXT="au&#xdf;erdem m&#xf6;chte man konkrete Accessoren via TurnoutSystem"/>
<node CREATED="1735426958276" ID="ID_803365380" MODIFIED="1735426990030" TEXT="au&#xdf;erdem m&#xf6;chte man konkrete Accessoren via TurnoutSystem">
<node CREATED="1735486902396" ID="ID_1232505017" MODIFIED="1735486920171" TEXT="zur Verwendung in einem Param-Funktor"/>
<node CREATED="1735486938666" ID="ID_1675979650" MODIFIED="1735487816128" TEXT="also direkt anwendbar auf&apos;s Turnout-System"/>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1735427341106" ID="ID_29906476" MODIFIED="1735427368610" TEXT="L&#xf6;sung aufbauen...">
<icon BUILTIN="pencil"/>
@ -94315,10 +94318,21 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1735438726120" ID="ID_1670785950" MODIFIED="1735438739642" TEXT="Daten-Accessor konstruieren">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1735487309329" ID="ID_1516453754" MODIFIED="1735487326656" TEXT="Bassis sind Accessoren auf HeteroData"/>
<node CREATED="1735489834862" ID="ID_1311598461" MODIFIED="1735489845645" TEXT="mu&#xdf; dazu den Chain-Block-Typ konstruieren">
<node CREATED="1735489850973" ID="ID_1621449411" MODIFIED="1735489863415" TEXT="aus dem Anker-Typ :: Chain"/>
<node CREATED="1735489870625" ID="ID_429993797" MODIFIED="1735489884596" TEXT="sowie der Parameter-Typ-Sequenz"/>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1735438743590" ID="ID_973914193" MODIFIED="1735438756220" TEXT="Storage-Tupel erzeugen">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1735492888686" ID="ID_810676585" MODIFIED="1735492933273" TEXT="Problem: Storage-Block is non-copyable">
<icon BUILTIN="messagebox_warning"/>
</node>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1735492909340" ID="ID_1181823322" MODIFIED="1735492933273" TEXT="erzeugen / bef&#xfc;llen ist auch tricky">
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
</node>
</node>