Invocation: add cross-builder to inject a specific (node) allocator

...using the same pattern here as was successful also for the underlying lib::SeveralBuilder;
even if it may seem logically backwards, it just reads much better and
is more understandable, and has the added benefit of providing a dedicated
definition scope, which can be kept separate from the constructor definition
of the actual builder

{{{
  prepareNode()
    .withAllocator<XYZ>()
    .addLead(predecessor)
    .build()
}}}
This commit is contained in:
Fischlurch 2024-07-08 00:44:46 +02:00
parent cedb1830dc
commit d291853174

View file

@ -91,7 +91,7 @@ namespace engine {
using std::forward;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1367 : Rebuild the Node Invocation
namespace {
namespace { // policy configuration
template<template<typename> class ALO =std::void_t, typename...INIT>
struct AlloPolicySelector
@ -123,7 +123,9 @@ namespace engine {
template<class POL, class I, class E=I>
using DataBuilder = typename POL::template BuilderType<I,E>;
}
}//(End) internal policy configuration
template<class POL>
class PortBuilder;
@ -132,6 +134,13 @@ namespace engine {
class NodeBuilder
: util::MoveOnly
{
template<class I, class E=I, typename...INIT>
static auto
setupBuilder (INIT&& ...alloInit)
{
return POL::template setupBuilder<I,E> (forward<INIT> (alloInit)...);
}
using PortData = DataBuilder<POL, Port>;
@ -140,7 +149,7 @@ namespace engine {
public:
template<typename...INIT>
NodeBuilder (INIT&& ...alloInit)
: ports_{POL::template setupBuilder<Port> (forward<INIT> (alloInit)...)}
: ports_{setupBuilder<Port> (forward<INIT> (alloInit)...)}
{ }
NodeBuilder
@ -158,6 +167,16 @@ namespace engine {
// return move(*this);
}
/** cross-builder function to specify usage of a dedicated *node allocator* */
template<template<typename> class ALO =std::void_t, typename...INIT>
auto
withAllocator (INIT&& ...alloInit)
{
return NodeBuilder<AlloPolicySelector<ALO,INIT...>>{forward<INIT>(alloInit)...};
}
/****************************************************//**
* Terminal: complete the Connectivity defined thus far.
*/