Lumiera  0.pre.03
»edit your freedom«
nodeoperation-obsolete.hpp
Go to the documentation of this file.
1 /*
2  NODEOPERATION.hpp - Specify how the nodes call each other and how processing is organized
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
52 #ifndef ENGINE_NODEOPERATION_H
53 #define ENGINE_NODEOPERATION_H
54 
55 
56 //#include "steam/engine/proc-node.hpp" ///////////////////////////////TODO clarify if required further on
58 #include "steam/engine/state-closure-obsolete.hpp"
62 
63 #include "lib/meta/util.hpp"
64 #include "lib/meta/configflags.hpp"
65 #include "lib/frameid.hpp"
66 
67 
68 
69 
70 namespace steam {
71 namespace engine {
72 namespace config {
73 
74 
82  {
83  typedef lib::meta::Yes_t is_defined;
84 
86  getSource (Invocation& ivo, uint chanNo)
87  {
88  UNIMPLEMENTED ("retrieve source data provided by the vault/scheduler");
89  }
90 
92  pullPredecessor (Invocation& ivo, uint chanNo)
93  {
94  UNIMPLEMENTED ("invoke pull() on the denoted predecessor node");
95  }
96 
97  void
98  releaseBuffers(BuffHandle* table, uint slotCnt, uint slot_to_retain)
99  {
100  UNIMPLEMENTED ("release all buffers with the exception of the desired output");
101  }
102 
103  bool
104  validateBuffers (Invocation& ivo)
105  {
106  UNIMPLEMENTED ("Do a final, specifically tailored validation step on the buffers prior to invoking the process function");
107  }
108  };
109 
110 
111  template<class NEXT>
112  struct QueryCache : NEXT
113  {
114  BuffHandle
115  step (Invocation& ivo)
116  {
117  BuffHandle fetched = ivo.fetch (ivo.genFrameID());
118  if (fetched)
119  return fetched;
120  else
121  return NEXT::step (ivo);
122  }
123  };
124 
125 
126  template<class NEXT>
127  struct AllocBufferTable : NEXT
128  {
129  BuffHandle
130  step (Invocation& ivo)
131  {
132  BuffTableChunk buffTab (ivo.wiring, ivo.getBuffTableStorage());
133  ivo.setBuffTab(&buffTab);
134  ASSERT (ivo.feedManifold);
135  ASSERT (ivo.buffTab_isConsistent());
136 
137  return NEXT::step (ivo);
138  }
139  };
140 
141 
142  template<class NEXT>
143  struct PullInput : NEXT
144  {
145  BuffHandle
146  step (Invocation& ivo)
147  {
148  BuffHandle * inH = ivo.feedManifold->inHandle;
149  BuffHandle::PBuff *inBuff = ivo.feedManifold->inBuff;
150 
151  for (uint i = 0; i < ivo.nrI(); ++i )
152  {
153  inBuff[i] =
154  &*(inH[i] = this->pullPredecessor(ivo,i)); // invoke predecessor
155  // now Input #i is ready...
156  }
157  return NEXT::step (ivo);
158  }
159  };
160 
161 
162  template<class NEXT>
163  struct ReadSource : NEXT
164  {
165  BuffHandle
166  step (Invocation& ivo)
167  {
168  BuffHandle *inH = ivo.feedManifold->inHandle;
169  BuffHandle *outH = ivo.feedManifold->outHandle;
170  BuffHandle::PBuff *inBuff = ivo.feedManifold->inBuff;
171  BuffHandle::PBuff *outBuff = ivo.feedManifold->outBuff;
172 
173  ASSERT (ivo.nrO() == ivo.nrI() );
174 
175  for (uint i = 0; i < ivo.nrI(); ++i )
176  {
177  inBuff[i] = outBuff[i] =
178  &*(inH[i] = outH[i] = this->getSource(ivo,i));
179  // now Input #i is ready...
180  }
181  return NEXT::step (ivo);
182  }
183  };
184 
185 
186  template<class NEXT>
187  struct AllocOutput : NEXT
188  {
189  BuffHandle
190  step (Invocation& ivo)
191  {
192  ASSERT (ivo.feedManifold);
193  ASSERT (ivo.nrO() < ivo.buffTabSize());
194  BuffHandle *outH = ivo.feedManifold->outHandle;
195  BuffHandle::PBuff *outBuff = ivo.feedManifold->outBuff;
196 
197  for (uint i = 0; i < ivo.nrO(); ++i )
198  {
199  outBuff[i] =
200  &*(outH[i] = ivo.allocateBuffer (ivo.wiring.out[i].bufferType));
201  // now Output buffer for channel #i is available...
202  }
203  return NEXT::step (ivo);
204  }
205  };
206 
207 
208  template<class NEXT>
209  struct ProcessData : NEXT
210  {
211  BuffHandle
212  step (Invocation& ivo)
213  {
214  ASSERT (ivo.feedManifold);
215  ASSERT (ivo.buffTab_isConsistent());
216  ASSERT (this->validateBuffers(ivo));
217 
218  // Invoke our own process() function,
219  // providing the array of outBuffer+inBuffer ptrs
220  (*ivo.wiring.procFunction) (*ivo.feedManifold->outBuff);
221 
222  return NEXT::step (ivo);
223  }
224  };
225 
226 
227  template<class NEXT>
228  struct FeedCache : NEXT
229  {
230  BuffHandle
231  step (Invocation& ivo)
232  {
233  for (uint i = 0; i < ivo.nrO(); ++i )
234  {
235  // declare all Outputs as finished
236  ivo.is_calculated(ivo.feedManifold->outHandle[i]);
237  }
238 
239  return NEXT::step (ivo);
240  }
241  };
242 
243 
244  template<class NEXT>
245  struct ReleaseBuffers : NEXT
246  {
247  BuffHandle
248  step (Invocation& ivo)
249  {
250  // all buffers besides the required Output no longer needed
251  this->releaseBuffers(ivo.feedManifold->outHandle,
252  ivo.buffTabSize(),
253  ivo.outNr);
254 
255  return ivo.feedManifold->outHandle[ivo.outNr];
256  }
257  };
258 
259 
260 
261 
262 
263  /* =============================================================== */
264  /* === declare the possible Assembly of these elementary steps === */
265 
266  enum Cases
267  {
268  CACHING = 1,
269  PROCESS,
270  INPLACE,
271 
272  NOT_SET = 0,
273  NUM_Cases = INPLACE
274  };
275 
276 
277  using lib::meta::Config;
280  template<class CONF>
282  template<uint PROC_ign, uint INPLA_ign>
283  struct SelectBuffProvider< Config<CACHING, PROC_ign, INPLA_ign>> { typedef AllocBufferFromCache Type; };
284 
285 
286  template<class Config>
287  struct Strategy ;
288 
289 
290  template<uint INPLACE_ign>
291  struct Strategy< Config<CACHING,PROCESS,INPLACE_ign>>
292  : QueryCache<
293  AllocBufferTable<
294  PullInput<
295  AllocOutput<
296  ProcessData<
297  FeedCache<
298  ReleaseBuffers<
299  OperationBase > > > > > > >
300  { };
301 
302  template<uint INPLACE_ign>
303  struct Strategy< Config<PROCESS,INPLACE_ign>>
305  PullInput<
306  AllocOutput<
307  ProcessData<
308  ReleaseBuffers<
309  OperationBase > > > > >
310  { };
311 
312  template<>
313  struct Strategy< Config<> >
315  ReadSource<
316  ReleaseBuffers<
317  OperationBase > > >
318  { };
319 
320  template<>
321  struct Strategy< Config<INPLACE> > : Strategy< Config<> > { };
322 
323  template<>
324  struct Strategy< Config<CACHING> >
326  ReadSource<
327  AllocOutput<
328  ProcessData< // wiring_.processFunction is supposed to do just buffer copying here
329  ReleaseBuffers<
330  OperationBase > > > > >
331  { };
332 
333 
334 
335 
336 }}} // namespace steam::engine::config
337 #endif
Base class of all concrete invocation sequences.
Obsolete, to be rewritten /////TICKET #826 to be allocated on the stack while evaluating a ProcNode::...
Under some circumstances it is necessary to assemble functionality out of elementary building blocks...
Marker tuple to identify a specific frame.
Simple and lightweight helpers for metaprogramming and type detection.
Representation of the Media type of a data channel used within the engine.
Steam-Layer implementation namespace root.
virtual BuffHandle fetch(FrameID const &fID)
try to fetch an existing buffer containing the denoted frame from a cache or similar backing system (...
virtual BuffHandle allocateBuffer(const lumiera::StreamType *)=0
allocate a new writable buffer with type and size according to the BuffDescr.
void setBuffTab(FeedManifold *b)
setup the link to an externally allocated buffer table
Invocation context state.
char Yes_t
helper types to detect the overload resolution chosen by the compiler
Definition: meta/util.hpp:95
< using the parent StateAdapter for buffer allocations
< using the global current StateClosure, which will delegate to Cache
Organise the state related to the invocation of s single ProcNode::pull() call This header defines pa...
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
virtual FrameID const & genFrameID()
specialised version filling in the additional information, i.e the concrete node id and the channel n...
virtual BuffTableStorage & getBuffTableStorage()
necessary for creating a local BuffTableChunk
placeholder type for the contents of a data buffer.
Definition: streamtype.hpp:112
< distinct type representing a configuration
Definition: configflags.hpp:81
virtual void is_calculated(BuffHandle const &bh)
declare the data contained in the Buffer to be ready.