00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00052 #ifndef ENGINE_NODEINVOCATION_H
00053 #define ENGINE_NODEINVOCATION_H
00054
00055
00056 #include "proc/state.hpp"
00057 #include "proc/engine/procnode.hpp"
00058 #include "proc/engine/buffhandle.hpp"
00059 #include "proc/engine/bufftable.hpp"
00060
00061
00062
00063
00064 namespace engine {
00065
00066
00075 class StateAdapter
00076 : public State
00077 {
00078 protected:
00079 State& parent_;
00080 State& current_;
00081
00082 StateAdapter (State& callingProcess)
00083 : parent_ (callingProcess),
00084 current_(callingProcess.getCurrentImplementation())
00085 { }
00086
00087 virtual State& getCurrentImplementation () { return current_; }
00088
00089
00090
00091 public:
00092
00093 virtual void releaseBuffer (BuffHandle& bh) { current_.releaseBuffer (bh); }
00094
00095 virtual void is_calculated (BuffHandle const& bh) { current_.is_calculated (bh); }
00096
00097 virtual BuffHandle fetch (FrameID const& fID) { return current_.fetch (fID); }
00098
00099 virtual BuffTableStorage& getBuffTableStorage() { return current_.getBuffTableStorage(); }
00100
00101
00102
00103 };
00104
00105
00106
00107
00108
00121 struct Invocation
00122 : StateAdapter
00123 {
00124 WiringDescriptor const& wiring;
00125 const uint outNr;
00126
00127 BuffTable* buffTab;
00128
00129 protected:
00131 Invocation (State& callingProcess, WiringDescriptor const& w, uint o)
00132 : StateAdapter(callingProcess),
00133 wiring(w), outNr(o),
00134 buffTab(0)
00135 { }
00136
00137 public:
00138 uint nrO() const { return wiring.nrO; }
00139 uint nrI() const { return wiring.nrI; }
00140 uint buffTabSize() const { return nrO()+nrI(); }
00141
00143 void setBuffTab (BuffTable* b) { this->buffTab = b; }
00144
00145 bool
00146 buffTab_isConsistent ()
00147 {
00148 return (buffTab)
00149 && (0 < buffTabSize())
00150 && (nrO()+nrI() <= buffTabSize())
00151 && (buffTab->inBuff == &buffTab->outBuff[nrO()] )
00152 && (buffTab->inHandle == &buffTab->outHandle[nrO()])
00153 ;
00154 }
00155
00156
00157 public:
00160 virtual FrameID const&
00161 genFrameID ()
00162 {
00163 return current_.genFrameID(wiring.nodeID, outNr);
00164 }
00165
00166 virtual FrameID const&
00167 genFrameID (NodeID const& nID, uint chanNo)
00168 {
00169 return current_.genFrameID (nID,chanNo);
00170 }
00171
00172 };
00173
00174
00175 struct AllocBufferFromParent
00176 : Invocation
00177 {
00178 AllocBufferFromParent (State& sta, WiringDescriptor const& w, const uint outCh)
00179 : Invocation(sta, w, outCh) {}
00180
00181 virtual BuffHandle
00182 allocateBuffer (BufferDescriptor const& bd) { return parent_.allocateBuffer(bd); }
00183 };
00184
00185 struct AllocBufferFromCache
00186 : Invocation
00187 {
00188 AllocBufferFromCache (State& sta, WiringDescriptor const& w, const uint outCh)
00189 : Invocation(sta, w, outCh) {}
00190
00191 virtual BuffHandle
00192 allocateBuffer (BufferDescriptor const& bd) { return current_.allocateBuffer(bd); }
00193 };
00194
00195
00211 template<class Strategy, class BufferProvider>
00212 class ActualInvocationProcess
00213 : public BufferProvider
00214 , private Strategy
00215 {
00216 public:
00217 ActualInvocationProcess (State& callingProcess, WiringDescriptor const& w, const uint outCh)
00218 : BufferProvider(callingProcess, w, outCh)
00219 { }
00220
00225 BuffHandle retrieve ()
00226 {
00227 return Strategy::step (*this);
00228 }
00229 };
00230
00231
00232
00233
00234 }
00235 #endif