Lumiera  0.pre.03
»edityourfreedom«
bufftable-obsolete.hpp
Go to the documentation of this file.
1 /*
2  BUFFTABLE-OBSOLTE.hpp - Old dead code to be removed when rewriting ProcNode!!!!!
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 
23 
30 #ifndef ENGINE_BUFFHTABLE_OBSOLETE_H
31 #define ENGINE_BUFFHTABLE_OBSOLETE_H
32 
33 
34 #include "lib/error.hpp"
35 #include "lib/nocopy.hpp"
37 #include "proc/engine/procnode.hpp"
38 
39 #include <vector>
40 #include <utility>
41 
42 
46 
47 namespace proc {
48 namespace engine {
49 
50  using std::pair;
51  using std::vector;
52 
53 
68  struct BuffTable
69  {
70  typedef BuffHandle * PHa;
72  typedef pair<PHa const,PBu const> Chunk;
73 
74  PHa outHandle;
75  PHa inHandle;
76  PBu outBuff;
77  PBu inBuff;
78  };
79 
80  class BufferDescriptor;
81 
84  {
86 
90  struct BuffHaXXXX
91  : BuffHandle
92  {
93  BuffHaXXXX() : BuffHandle(just_satisfy_the_compiler()) { /* wont work ever */ }
94  static BufferDescriptor const&
96  };
97 
99  vector<BuffHaXXXX> hTab_;
100  vector<BuffHandle::PBuff> pTab_;
101  size_t level_;
102 
103  public:
104  BuffTableStorage (const size_t maxSiz)
105  : hTab_(maxSiz),
106  pTab_(maxSiz),
107  level_(0)
108  { }
109 
110  ~BuffTableStorage() { ASSERT (0==level_, "buffer management logic broken."); }
111 
112  protected:
113 
114  friend class BuffTableChunk;
115 
121  claim (uint slots)
122  {
123  ASSERT (pTab_.size() == hTab_.size());
124  REQUIRE (level_+slots <= hTab_.size());
125 
126  size_t prev_level (level_);
127  level_ += slots;
128  return std::make_pair (&hTab_[prev_level],
129  &pTab_[prev_level]);
130  }
131 
132  void
133  release (uint slots)
134  {
135  ASSERT (slots <= level_);
136  REQUIRE (level_ <= hTab_.size());
137  REQUIRE (level_ <= pTab_.size());
138 
139  level_ -= slots;
140  }
141 
142  bool
144  {
145  return prev_level.first == &hTab_[level_]
146  && prev_level.second == &pTab_[level_];
147  }
148  };
149 
150 
159  : public BuffTable,
161  {
162  const uint siz_;
165 
166  public:
168  : siz_(wd.nrI + wd.nrO),
169  tab_(storage.claim (siz_)),
170  sto_(storage)
171  {
172  const uint nrO(wd.nrO);
173 
174  // Setup the publicly visible table locations
175  this->outHandle = &tab_.first[ 0 ];
176  this->inHandle = &tab_.first[nrO];
177  this->outBuff = &tab_.second[ 0 ];
178  this->inBuff = &tab_.second[nrO];
179  }
180 
182  {
183  sto_.release (siz_);
184  ASSERT ( sto_.level_check (tab_),
185  "buffer management logic broken.");
186  }
187  };
188 
189 
190 
191 
192 
193 }} // namespace proc::engine
194 #endif
Interface to the processing nodes and the render nodes network.
static BufferDescriptor const & just_satisfy_the_compiler()
placeholder type for the contents of a data buffer.
Definition: streamtype.hpp:121
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
An opaque descriptor to identify the type and further properties of a data buffer.
Definition: buffhandle.hpp:81
Obsolete, to be rewritten /////TICKET #826.
BuffTableChunk(WiringDescriptor const &wd, BuffTableStorage &storage)
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
Mix-Ins to allow or prohibit various degrees of copying and cloning.
pair< PHa const, PBu const > Chunk
BuffTable::Chunk claim(uint slots)
allocate the given number of slots starting at current level to be used by the newly created BuffTabl...
Interface: Description of the input and output ports, processing function and predecessor nodes for a...
Definition: procnode.hpp:78
Lumiera error handling (C++ interface).
bool level_check(BuffTable::Chunk &prev_level)
just a placeholder to decouple the existing code from the reworked BuffHandle logic.
Representation of the Media type of a data channel used within the engine.
Obsolete, to be rewritten /////TICKET #826 to be allocated on the stack while evaluating a ProcNode::...
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63
vector< BuffHandle::PBuff > pTab_
Obsolete, to be rewritten /////TICKET #826.