Lumiera  0.pre.03
»edit your freedom«
turnout.hpp
Go to the documentation of this file.
1 /*
2  TURNOUT.hpp - Fixed standard scheme to generate data within a Render Node
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6  2024, Hermann Vosseler <Ichthyostega@web.de>
7 
8   **Lumiera** is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by the
10   Free Software Foundation; either version 2 of the License, or (at your
11   option) any later version. See the file COPYING for further details.
12 
13 */
14 
15 
51 #ifndef STEAM_ENGINE_TURNOUT_H
52 #define STEAM_ENGINE_TURNOUT_H
53 
54 #include "steam/common.hpp"
59 //#include "vault/gear/job.h"
60 //#include "steam/engine/exit-node.hpp"
61 //#include "lib/time/timevalue.hpp"
62 //#include "lib/linked-elements.hpp"
63 #include "lib/several.hpp"
64 //#include "lib/util-foreach.hpp"
65 //#include "lib/iter-adapter.hpp"
66 #include "lib/meta/function.hpp"
67 //#include "lib/itertools.hpp"
68 //#include "lib/util.hpp" ////////OOO wegen manifoldSiz<FUN>()
69 
70 #include <utility>
71 #include <array>
72 //#include <stack>
73 
74 
75 namespace steam {
76 namespace engine {
77 
78  using std::forward;
79  using lib::Several;
80 
81 
90  template<class ADA>
91  constexpr bool
93  {
94  ASSERT_MEMBER_FUNCTOR (&ADA::connect, void(uint, uint));
95  ASSERT_MEMBER_FUNCTOR (&ADA::invoke, void());
96  return sizeof(ADA);
97  }
98 
99 
100 
113  template<class INVO>
115  : INVO
116  {
117  using Feed = typename INVO::Feed;
118 
119  static_assert (_verify_usable_as_InvocationAdapter<Feed>());
120 
121  Several<PortRef> leadPort;
122  Several<BuffDescr> outTypes;
123 
124  uint resultSlot{0};
125 
127  template<typename...ARGS>
129  ,Several<BuffDescr>&& dr
130  ,uint resultIdx
131  ,ARGS&& ...args)
132  : INVO{forward<ARGS>(args)...}
133  , leadPort{move(pr)}
134  , outTypes{move(dr)}
135  , resultSlot{resultIdx}
136  { }
137 
138 
139  Feed
140  mount()
141  {
142  return INVO::buildFeed();
143  }
144 
145  void
146  pull (Feed& feed, TurnoutSystem& turnoutSys)
147  {
148  for (uint i=0; i<leadPort.size(); ++i)
149  {
150  BuffHandle inputData = leadPort[i].get().weave (turnoutSys);
151  feed.inBuff.createAt(i, move(inputData));
152  }
153  }
154 
155  void
156  shed (Feed& feed, OptionalBuff outBuff)
157  {
158  for (uint i=0; i<outTypes.size(); ++i)
159  {
160  BuffHandle resultData =
161  i == resultSlot and outBuff? *outBuff
162  : outTypes[i].lockBuffer();
163  feed.outBuff.createAt(i, move(resultData));
164  }
165  feed.connect (leadPort.size(),outTypes.size());
166  }
167 
168  void
169  weft (Feed& feed)
170  {
171  feed.invoke(); // process data
172  }
173 
174  BuffHandle
175  fix (Feed& feed)
176  {
177  for (uint i=0; i<leadPort.size(); ++i)
178  {
179  feed.inBuff[i].release();
180  }
181  for (uint i=0; i<outTypes.size(); ++i)
182  {
183  feed.outBuff[i].emit(); // state transition: data ready
184  if (i != resultSlot)
185  feed.outBuff[i].release();
186  }
187  ENSURE (resultSlot < INVO::MAX_SIZ, "invalid result buffer configured.");
188  return feed.outBuff[resultSlot];
189  }
190 
191  };
192 
193 
201  template<class PAT>
202  class Turnout
203  : public Port
204  , public PAT
205 // , util::MoveOnly
206  {
207  using Feed = typename PAT::Feed;
208 
209  public:
210  template<typename...INIT>
211  Turnout (ProcID& id, INIT&& ...init)
212  : Port{id}
213  , PAT{forward<INIT> (init)...}
214  { }
215 
221  BuffHandle
222  weave (TurnoutSystem& turnoutSys, OptionalBuff outBuff =std::nullopt) override
223  {
224  Feed feed = PAT::mount();
225  PAT::pull(feed, turnoutSys);
226  PAT::shed(feed, outBuff);
227  PAT::weft(feed);
228  return PAT::fix (feed);
229  }
230  };
231 
232 
233 
234 
235 }}// namespace steam::engine
236 #endif /*STEAM_ENGINE_TURNOUT_H*/
Basic set of definitions and includes commonly used together.
Processing structure to activate a Render Node and produce result data.
Definition: turnout.hpp:202
SimpleWeavingPattern(Several< PortRef > &&pr, Several< BuffDescr > &&dr, uint resultIdx, ARGS &&...args)
forwarding-ctor to provide the detailed input/output connections
Definition: turnout.hpp:128
Standard implementation for a Weaving Pattern to connect the input and output data feeds (buffers) in...
Definition: turnout.hpp:114
#define ASSERT_MEMBER_FUNCTOR(_EXPR_, _SIG_)
Macro for a compile-time check to verify some member is present and comprises something invokable wit...
Definition: function.hpp:273
Communication hub to coordinate and activate the »Render Node Network« performance.
Steam-Layer implementation namespace root.
Abstraction interface: array-like random access by subscript.
Metaprogramming tools for transforming functor types.
Abstraction: Fixed array of elements.
Definition: several.hpp:156
Interface to the processing nodes and the render nodes network.
BuffHandle weave(TurnoutSystem &turnoutSys, OptionalBuff outBuff=std::nullopt) override
Entrance point to the next recursive step of media processing.
Definition: turnout.hpp:222
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
THe actual state of a frame rendering evaluation parametrised for a single job.
constexpr bool _verify_usable_as_InvocationAdapter()
Definition to emulate a Concept for the Invocation Adapter.
Definition: turnout.hpp:92