72#ifndef ENGINE_FEED_MANIFOLD_H
73#define ENGINE_FEED_MANIFOLD_H
105 using std::is_pointer;
106 using std::is_reference;
107 using std::is_convertible;
108 using std::is_constructible;
109 using std::is_copy_constructible;
110 using std::remove_pointer_t;
111 using std::tuple_element_t;
112 using std::add_pointer_t;
113 using std::conditional_t;
120 : __and_<__not_<is_pointer<V>>
121 ,__not_<is_reference<V>>
122 ,std::is_default_constructible<V>
123 ,std::is_copy_assignable<V>
129 : __and_<is_pointer<B>
131 ,std::is_default_constructible<remove_pointer_t<B>>
156 static_assert(
_Fun<FUN>() ,
"something funktion-like required");
157 static_assert(0 <
_Fun<FUN>::ARITY ,
"function with at least one argument expected");
158 static_assert(3 >=
_Fun<FUN>::ARITY ,
"function with up to three arguments accepted");
165 template<
size_t i,
template<
class>
class COND>
178 template<
class SIG,
typename SEL =
void>
181 static_assert (not
sizeof(SIG),
"use case could not be determined from function signature");
184 struct _Case<SIG, enable_if<is_UnaryFun<SIG>>>
191 struct _Case<SIG, enable_if<is_BinaryFun<SIG>>>
194 , SLOT_I = (nonEmpty<0> and is_BuffSlot<0>)? 0 : 1
198 struct _Case<SIG, enable_if<is_TernaryFun<SIG>>>
224 static constexpr bool hasInput() {
return SLOT_I != SLOT_O; }
225 static constexpr bool hasParam() {
return 0 < SLOT_I; }
228 static_assert (nonEmpty<SLOT_O> or nonEmpty<SLOT_I> or nonEmpty<SLOT_P>
229 ,
"At least one slot of the function must accept data");
230 static_assert (is_BuffSlot<SLOT_O>,
"Output slot of the function must accept buffer pointers");
231 static_assert (is_BuffSlot<SLOT_I>,
"Input slot of the function must accept buffer pointers");
232 static_assert (is_ParamSlot<SLOT_P> or not hasParam()
233 ,
"Param slot must accept value data");
250 static constexpr bool hasParam() {
return _Proc::hasParam(); }
252 using Param = conditional_t<hasParam(),
typename _Proc::SigP, std::tuple<>>;
257 using SigP = add_pointer_t<typename _Fun<PF>::Sig>;
262 using canInvoke = std::is_invocable<PF, TurnoutSystem&>;
266 ,__not_<is_convertible<PF&, SigP<PF>>>
275 return bool(paramFun);
294 void operator() (
void)
const {}
301 template<
class FUN,
class PAM =_Disabled>
322 static constexpr bool hasInput() {
return _Trait::hasInput(); }
323 static constexpr bool hasParam() {
return _Trait::hasParam(); }
336 using Param = conditional_t<
hasParam(),
typename _Trait::SigP, std::tuple<>>;
337 using ArgI = conditional_t<
hasInput(),
typename _Trait::SigI, std::tuple<>>;
350 template<
typename...INIT>
352 :
param{forward<INIT> (paramInit)...}
376 template<
bool yes,
class B>
401 template<
typename F,
typename =enable_if_hasParam<F>>
446 using _T = _ProcFun<FUN>;
473 template<
size_t i,
class ARG>
477 if constexpr (tuple_like<ARG>)
492 forEachIDX<TupI> ([&](
auto i)
494 using BuffI = tuple_element_t<i, TupI>;
495 accessArg<i> (_F::inArgs) = & _F::inBuff[i].template accessAs<BuffI>();
500 forEachIDX<TupO> ([&](
auto i)
502 using BuffO = tuple_element_t<i, TupO>;
547 template<
class FUN,
class PAM>
559 enum{
FAN_I = Feed::FAN_I
565 using ElmsP = conditional_t<_Trait::hasParam(),
typename _Proc::ArgP, Types<>>;
568 template<
template<
class>
class META>
584 static constexpr bool hasParam() {
return _Trait::hasParam(); }
585 static constexpr bool hasParamFun() {
return _Trait::template isParamFun<PAM>(); }
586 static constexpr bool canActivate() {
return _Trait::template canActivate<PAM>(); }
612 template<
typename PFX>
616 template<
typename PFX>
619 return hasParam() and _Trait::template isParamFun<PFX>();
623 template<
typename PFX>
626 return hasParam() and _Trait::template canAdapt<PFX>();
638 template<
typename PFX>
642 using OtherParamFun = std::decay_t<PFX>;
643 return Adapted<OtherParamFun>{move(
procFun_), move(otherParamFun)};
650 enable_if<__and_<is_copy_constructible<FUN>
651 ,is_copy_constructible<PAM>>, FeedPrototype>
664 template<
typename PFX =PAM,
typename = enable_if<std::is_assignable<PAM,PFX>>>
675 template<
typename TRA>
679 static_assert (_Trait::hasParam(),
"Processing-functor with parameters expected");
680 static_assert (isSuitableParamAdaptor<TRA>(),
"Given functor's output not suitable "
681 "for adapting the proc-functor's 1st argument");
683 using SigI = _Proc::SigI;
684 using SigO = _Proc::SigO;
685 if constexpr (_Proc::hasInput())
688 ,transform = move(paramTransformer)
690 (SigP par, SigI in, SigO out)
692 return procFun (transform(par), in, out);
698 ,transform = move(paramTransformer)
702 return procFun (transform(par), out);
707 template<
typename TRA>
708 using DecoratedProcFun =
decltype(std::declval<FeedPrototype>().decorateProcParam (std::declval<TRA>()));
710 template<
typename TRA>
719 template<
typename TRA>
A front-end to support the buffer management within the render nodes.
Block of raw uninitialised storage with array like access.
Builder-Prototype to create FeedManifold instances.
static constexpr bool canActivate()
FeedPrototype(FUN &&proc, PAM &&par)
FeedPrototype< DecoratedProcFun< TRA >, PAM > Decorated
Feed buildFeed(TurnoutSystem &turnoutSys)
create suitable Feed(Manifold) for processing a Node invocation
auto decorateProcParam(TRA paramTransformer)
static constexpr bool hasParamFun()
auto moveTransformedParam(TRA paramTransformer)
Adapt parameter handling of the processing-function by passing parameters through an adapter functor ...
static constexpr bool isSuitableParamFun()
is the given functor suitable as parameter functor for this Feed?
FeedPrototype< FUN, PFX > Adapted
ElmsO::template Apply< META > OutTypesApply
static constexpr bool hasParam()
FeedPrototype(FUN &&proc)
setup with processing-functor only
static constexpr bool isSuitableParamAdaptor()
is the given functor suitable to adapt the parameter argument of the processing-functor to accept dif...
auto moveAdaptedParam(PFX otherParamFun=PFX{})
Cross-Builder to add configuration with a given parameter-functor.
FeedPrototype && assignParamFun(PFX &¶mFunDef=PAM{})
Change the current parameter-functor setup by assigning some value.
decltype(std::declval< FeedPrototype >().decorateProcParam(std::declval< TRA >())) DecoratedProcFun
enable_if< __and_< is_copy_constructible< FUN >, is_copy_constructible< PAM > >, FeedPrototype > clone() const
build a clone-copy of this prototype, holding the same functors
conditional_t< _Trait::hasParam(), typename _Proc::ArgP, Types<> > ElmsP
Communication hub to coordinate and activate the »Render Node Network« performance.
Types marked with this mix-in may be moved but not copied.
Any copy and copy construction prohibited.
Lumiera error handling (C++ interface).
Metaprogramming tools for detecting and transforming function types.
Helpers for working with lib::meta::Types (i.e.
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Adapter to connect input/output buffers to a processing functor backed by an external library.
static constexpr bool hasInput()
FeedPrototype< FUN > Prototype
cross-builder: Prototype can be used to attach parameter-provider-functors and then to create several...
auto & accessArg(ARG &arg)
static constexpr bool hasParam()
FeedManifold building block: hold output buffer pointers.
FeedManifold building block: hold parameter data.
ParamStorage(INIT &&...paramInit)
Data Storage block for the FeedManifold Flexibly configured based on the processing function.
Storage(Param p, F &&fun)
Configuration context for a FeedManifold.
static constexpr bool hasInput()
conditional_t< yes, B, NotProvided< B > > Provide_if
Provide_if< hasParam(), ParamStorage > FeedParam
conditional_t< hasParam(), typename _Trait::SigP, std::tuple<> > Param
Provide_if< hasInput(), BufferSlot_Input > FeedInput
lib::meta::enable_if_c< _ProcFun< F >::hasParam()>::type enable_if_hasParam
static constexpr bool hasParam()
Tagged< Nil, X > NotProvided
conditional_t< hasInput(), typename _Trait::SigI, std::tuple<> > ArgI
Trait template to handle an associated parameter functor.
static constexpr bool canAdapt()
static constexpr bool canActivate()
static bool isActivated(PF const ¶mFun)
is_constructible< Param, Res< PF > > isSuitable
conditional_t< hasParam(), typename _Proc::SigP, std::tuple<> > Param
static constexpr bool isParamFun()
static constexpr bool hasParam()
__and_< is_constructible< bool, PF & >,__not_< is_convertible< PF &, SigP< PF > > > > isConfigurable
add_pointer_t< typename _Fun< PF >::Sig > SigP
std::is_invocable< PF, TurnoutSystem & > canInvoke
Trait template to analyse and adapt to the given processing function.
ElmTypes< SigO >::Seq ArgO
_Arg< _Case< Sig >::SLOT_O > SigO
static constexpr bool hasInput()
ElmTypes< SigP >::Seq ArgP
static constexpr bool hasParam()
_Arg< _Case< Sig >::SLOT_I > SigI
ElmTypes< typename ElmTypes< SigI >::template Apply< remove_pointer_t > > ElmsI
ElmTypes< _Arg< i > >::template AndAll< COND > AllElements
ElmTypes< typename ElmTypes< SigO >::template Apply< remove_pointer_t > > ElmsO
ElmTypes< SigI >::Seq ArgI
Detect use-case as indicated by the function signature.
A collection of frequently used helper functions to support unit testing.
Helpers for type detection, type rewriting and metaprogramming.
Metaprogramming with tuples-of-types and the std::tuple record.
Some basic facilities for manipulating type sequences.
A raw memory block with proper alignment and array access.
Metaprogramming with type sequences based on variadic template parameters.