Invocation: Prototyping how to setup invocation wiring
...still fighting to find a suitable API to define how inputs and outputs are connected and mapped to function parameters. The solution drafted here uses the reshaped `DataBuilder` (≙`lib::SeveralBuilder`) to add up connections for each »slot«, disregarding the possibility of permutations. Similar to `NodeBuilder`, a policy template is used to pass down the setup for an actual custom allocator.
This commit is contained in:
parent
352ef31ab0
commit
42f8f8d5af
4 changed files with 200 additions and 89 deletions
|
|
@ -91,6 +91,7 @@
|
|||
#define ENGINE_NODE_BUILDER_H
|
||||
|
||||
|
||||
#include "steam/engine/weaving-pattern-builder.hpp"
|
||||
#include "steam/engine/proc-node.hpp"
|
||||
#include "steam/engine/turnout.hpp"
|
||||
#include "lib/several-builder.hpp"
|
||||
|
|
@ -107,10 +108,7 @@ namespace engine {
|
|||
using std::forward;
|
||||
|
||||
|
||||
namespace { // policy configuration for allocator
|
||||
|
||||
template<template<typename> class ALO =std::void_t, typename...INIT>
|
||||
using AlloPolicySelector = lib::allo::SetupSeveral<ALO,INIT...>;
|
||||
namespace { // default policy configuration to use heap allocator
|
||||
|
||||
struct UseHeapAlloc
|
||||
{
|
||||
|
|
@ -118,23 +116,13 @@ namespace engine {
|
|||
using Policy = lib::allo::HeapOwn<I,E>;
|
||||
};
|
||||
//
|
||||
}//(End) internal policy configuration
|
||||
}//(End) policy
|
||||
|
||||
|
||||
/**
|
||||
* Convenience builder to collect working data.
|
||||
* A builder to collect working data.
|
||||
* Implemented through a suitable configuration of lib::SeveralBuilder,
|
||||
* such as to embed and connect to the configured custom allocator, which
|
||||
* serves the goal to package all generated node configuration data together
|
||||
* into a compact memory block, which can be discarded in bulk, once a given
|
||||
* segment of the low-level-Model has been superseded.
|
||||
* @tparam POL policy configuration pick the desired allocator
|
||||
* @tparam I interface type for lib::Several<I>
|
||||
* @remark in essence, this wrapper class creates the following setup
|
||||
* \code
|
||||
* makeSeveral<I>()
|
||||
* .withAllocator<ALO> (args...);
|
||||
* \endcode
|
||||
* with a policy configuration parameter to define the allocator to use.
|
||||
*/
|
||||
template<class POL, class I, class E=I>
|
||||
using DataBuilder = lib::SeveralBuilder<I,E, POL::template Policy>;
|
||||
|
|
@ -193,7 +181,7 @@ namespace engine {
|
|||
auto
|
||||
withAllocator (INIT&& ...alloInit)
|
||||
{
|
||||
using AllocatorPolicy = AlloPolicySelector<ALO,INIT...>;
|
||||
using AllocatorPolicy = lib::allo::SetupSeveral<ALO,INIT...>;
|
||||
return NodeBuilder<AllocatorPolicy>{forward<INIT>(alloInit)...};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@
|
|||
//#include "lib/time/timevalue.hpp"
|
||||
//#include "lib/linked-elements.hpp"
|
||||
#include "lib/several.hpp"
|
||||
#include "lib/several-builder.hpp"/////////////////TODO extract with a WeavingPattern builder
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/iter-adapter.hpp"
|
||||
#include "lib/meta/function.hpp"
|
||||
|
|
@ -413,13 +412,16 @@ namespace engine {
|
|||
|
||||
static_assert (_verify_usable_as_InvocationAdapter<Feed>());
|
||||
|
||||
uint fanIn{0};
|
||||
uint fanOut{0};
|
||||
|
||||
Several<PortRef> leadPort;
|
||||
Several<BuffDescr> outDescr;
|
||||
Several<BuffDescr> outTypes;
|
||||
|
||||
//////////////////////////////////////////OOO builder must set-up those descriptors
|
||||
SimpleWeavingPattern(Several<PortRef>&& pr, Several<BuffDescr> dr)
|
||||
: CONF{}
|
||||
, leadPort{move(pr)}
|
||||
, outTypes{move(dr)}
|
||||
{ }
|
||||
|
||||
|
||||
Feed
|
||||
mount()
|
||||
|
|
@ -430,7 +432,7 @@ namespace engine {
|
|||
void
|
||||
pull (Feed& feed, TurnoutSystem& turnoutSys)
|
||||
{
|
||||
for (uint i=0; i<fanIn; ++i)
|
||||
for (uint i=0; i<leadPort.size(); ++i)
|
||||
{
|
||||
BuffHandle inputData = leadPort[i].get().weave (turnoutSys);
|
||||
feed.inBuff.createAt(i, move(inputData));
|
||||
|
|
@ -440,12 +442,12 @@ namespace engine {
|
|||
void
|
||||
shed (Feed& feed)
|
||||
{
|
||||
for (uint i=0; i<fanOut; ++i)
|
||||
for (uint i=0; i<outTypes.size(); ++i)
|
||||
{
|
||||
BuffHandle resultData = outDescr[i].lockBuffer();
|
||||
BuffHandle resultData = outTypes[i].lockBuffer();
|
||||
feed.outBuff.createAt(i, move(resultData));
|
||||
}
|
||||
feed.connect (fanIn,fanOut);
|
||||
feed.connect (leadPort.size(),outTypes.size());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -457,11 +459,11 @@ namespace engine {
|
|||
void
|
||||
fix (Feed& feed)
|
||||
{
|
||||
for (uint i=0; i<fanIn; ++i)
|
||||
for (uint i=0; i<leadPort.size(); ++i)
|
||||
{
|
||||
feed.inBuff[i].release();
|
||||
}
|
||||
for (uint i=0; i<fanOut; ++i)
|
||||
for (uint i=0; i<outTypes.size(); ++i)
|
||||
{
|
||||
feed.outBuff[i].emit();
|
||||
if (i != feed.resultSlot)
|
||||
|
|
@ -485,6 +487,8 @@ namespace engine {
|
|||
//////////////////////////////OOO non-copyable? move-only??
|
||||
{
|
||||
using Feed = typename PAT::Feed;
|
||||
using PAT::PAT;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
|
@ -504,32 +508,6 @@ namespace engine {
|
|||
}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1367 : Prototyping: how to assemble a Turnout
|
||||
template<uint N, class FUN>
|
||||
using SimpleDirectInvoke = SimpleWeavingPattern<Conf_DirectFunctionInvocation<N,FUN>>;
|
||||
|
||||
template<uint N, class FUN>
|
||||
struct SimpleWeavingBuilder
|
||||
: Turnout<SimpleDirectInvoke<N,FUN>> /////////////////////////////////OOO can no longer directly inherit from the product(Turnout), due to SeveralBuilder!!!
|
||||
{
|
||||
SimpleWeavingBuilder
|
||||
attachToLeadPort(ProcNode& lead, uint portNr)
|
||||
{
|
||||
ASSERT (this->fanIn < N);
|
||||
PortRef leadPort; /////////////////////////////////////OOO TODO need Accessor on ProcNode!!!!!
|
||||
this->leadPort.createAt(this->fanIn, leadPort)
|
||||
++(this->fanIn);
|
||||
return move(*this);
|
||||
}
|
||||
|
||||
Turnout<SimpleDirectInvoke<N,FUN>>
|
||||
build()
|
||||
{
|
||||
///////////////////////////////OOO need a way to prepare SeveralBuilder-instances for leadPort and outDescr --> see NodeBuilder
|
||||
return move(*this);
|
||||
}
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1367 : (End)Prototyping: how to assemble a Turnout
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
46
src/steam/engine/weaving-pattern-builder.hpp
Normal file
46
src/steam/engine/weaving-pattern-builder.hpp
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
WEAVING-PATTERN-BUILDER.hpp - build an invocation pattern for media calculations
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2024, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/** @file weaving-pattern-builder.hpp
|
||||
** Construction kit for establishing an invocation scheme for media calculations.
|
||||
**
|
||||
** @see turnout.hpp
|
||||
** @see node-builder.hpp
|
||||
** @see NodeLinkage_test
|
||||
**
|
||||
** @todo WIP-WIP-WIP as of 7/2024 prototyping how to build and invoke render nodes /////////////////////////TICKET #1367
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef STEAM_ENGINE_WEAVING_PATTERN_BUILDER_H
|
||||
#define STEAM_ENGINE_WEAVING_PATTERN_BUILDER_H
|
||||
|
||||
//#include "steam/common.hpp"
|
||||
//#include "steam/engine/channel-descriptor.hpp"
|
||||
//#include "vault/gear/job.h"
|
||||
#include "lib/several-builder.hpp"
|
||||
#include "steam/engine/turnout.hpp"
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/iter-adapter.hpp"
|
||||
//#include "lib/meta/function.hp
|
||||
Loading…
Reference in a new issue