Lumiera  0.pre.03
»edit your freedom«
nodeinvocation.hpp
Go to the documentation of this file.
1 /*
2  NODEINVOCATION.hpp - Organise the invocation state within a single pull() call
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
54 #ifndef ENGINE_NODEINVOCATION_H
55 #define ENGINE_NODEINVOCATION_H
56 
57 
58 #include "steam/state.hpp"
62 
63 
64 
65 
66 namespace steam {
67 namespace engine {
68 
69 
79  : public State
80  {
81  protected:
82  State& parent_;
83  State& current_;
84 
85  StateAdapter (State& callingProcess)
86  : parent_ (callingProcess),
87  current_(callingProcess.getCurrentImplementation())
88  { }
89 
90  virtual State& getCurrentImplementation () { return current_; }
91 
92 
93 
94  public: /* === proxying the State interface === */
95 
96  virtual void releaseBuffer (BuffHandle& bh) { current_.releaseBuffer (bh); }
97 
98  virtual void is_calculated (BuffHandle const& bh) { current_.is_calculated (bh); }
99 
100  virtual BuffHandle fetch (FrameID const& fID) { return current_.fetch (fID); }
101 
102  virtual BuffTableStorage& getBuffTableStorage() { return current_.getBuffTableStorage(); }
103 
104  // note: allocateBuffer() is chosen specifically based on the actual node wiring
105 
106  };
107 
108 
109 
110 
111 
124  struct Invocation
125  : StateAdapter
126  {
127  WiringDescriptor const& wiring;
128  const uint outNr;
129 
130  BuffTable* buffTab;
131 
132  protected:
134  Invocation (State& callingProcess, WiringDescriptor const& w, uint o)
135  : StateAdapter(callingProcess),
136  wiring(w), outNr(o),
137  buffTab(0)
138  { }
139 
140  public:
141  uint nrO() const { return wiring.nrO; }
142  uint nrI() const { return wiring.nrI; }
143  uint buffTabSize() const { return nrO()+nrI(); }
144 
146  void setBuffTab (BuffTable* b) { this->buffTab = b; }
147 
148  bool
149  buffTab_isConsistent ()
150  {
151  return (buffTab)
152  && (0 < buffTabSize())
153  && (nrO()+nrI() <= buffTabSize())
154  && (buffTab->inBuff == &buffTab->outBuff[nrO()] )
155  && (buffTab->inHandle == &buffTab->outHandle[nrO()])
156  ;
157  }
158 
159 
160  public:
163  virtual FrameID const&
165  {
166  return current_.genFrameID(wiring.nodeID, outNr);
167  }
168 
169  virtual FrameID const&
170  genFrameID (NodeID const& nID, uint chanNo)
171  {
172  return current_.genFrameID (nID,chanNo);
173  }
174 
175  };
176 
177 
180  : Invocation
181  {
182  AllocBufferFromParent (State& sta, WiringDescriptor const& w, const uint outCh)
183  : Invocation(sta, w, outCh) {}
184 
185  virtual BuffHandle
186  allocateBuffer (const lumiera::StreamType* ty) { return parent_.allocateBuffer(ty); }
187  };
188 
190  : Invocation
191  {
192  AllocBufferFromCache (State& sta, WiringDescriptor const& w, const uint outCh)
193  : Invocation(sta, w, outCh) {}
194 
195  virtual BuffHandle
196  allocateBuffer (const lumiera::StreamType* ty) { return current_.allocateBuffer(ty); }
197  };
198 
199 
215  template<class Strategy, class BufferProvider>
217  : public BufferProvider
218  , private Strategy
219  {
220  public:
221  ActualInvocationProcess (State& callingProcess, WiringDescriptor const& w, const uint outCh)
222  : BufferProvider(callingProcess, w, outCh)
223  { }
224 
230  {
231  return Strategy::step (*this);
232  }
233  };
234 
235 
236 
237 
238 }} // namespace steam::engine
239 #endif
Interface to the processing nodes and the render nodes network.
Abstraction to access the state of a currently ongoing render/calculation process, as it is tied to the supporting facilities of the vault layer.
Definition: state.hpp:59
Identification tuple for addressing frames unambiguously.
Definition: frameid.hpp:78
Obsolete, to be rewritten /////TICKET #826.
Access point to an ongoing render&#39;s processing state.
virtual void releaseBuffer(BuffHandle &)=0
resign control of the buffer denoted by the handle
Adapter to shield the ProcNode from the actual buffer management, allowing the processing function wi...
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 *ty)
allocate a new writable buffer with type and size according to the BufferDescriptor.
void setBuffTab(BuffTable *b)
setup the link to an externally allocated buffer table
virtual BuffTableStorage & getBuffTableStorage()=0
necessary for creating a local BuffTableChunk
virtual BuffHandle allocateBuffer(const lumiera::StreamType *ty)
allocate a new writable buffer with type and size according to the BufferDescriptor.
Invocation context state.
virtual BuffHandle fetch(FrameID const &)=0
try to fetch an existing buffer containing the denoted frame from a cache or similar backing system (...
virtual void releaseBuffer(BuffHandle &bh)
resign control of the buffer denoted by the handle
virtual void is_calculated(BuffHandle const &)=0
declare the data contained in the Buffer to be ready.
< using the parent StateAdapter for buffer allocations
Invocation(State &callingProcess, WiringDescriptor const &w, uint o)
creates a new invocation context state, without BuffTable
< using the global current State, which will delegate to Cache
virtual State & getCurrentImplementation()=0
resolves to the State object currently "in charge".
virtual FrameID const & genFrameID(NodeID const &nID, uint chanNo)
generate (or calculate) an ID denoting a media data frame appearing at the given position in the rend...
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:115
virtual FrameID const & genFrameID()
specialised version filling in the additional information, i.e the concrete node id and the channel n...
Identification tuple for denoting render nodes unambiguously.
Definition: frameid.hpp:51
virtual BuffTableStorage & getBuffTableStorage()
necessary for creating a local BuffTableChunk
Representation of the Media type of a data channel used within the engine.
Interface: a facility providing and managing working buffers for media calculations.
Obsolete, to be rewritten /////TICKET #826.
BuffHandle retrieve()
contains the details of Cache query and recursive calls to the predecessor node(s), eventually followed by the ProcNode::process() callback
virtual State & getCurrentImplementation()
resolves to the State object currently "in charge".
Interface: Description of the input and output ports, processing function and predecessor nodes for a...
Definition: procnode.hpp:78
The real invocation context state implementation.
virtual void is_calculated(BuffHandle const &bh)
declare the data contained in the Buffer to be ready.