Lumiera  0.pre.03
»edit your freedom«
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"
38 
39 #include <vector>
40 #include <utility>
41 
42 
46 
47 namespace steam {
48 namespace engine {
49 
50  using std::pair;
51  using std::vector;
52 
53 
68  struct BuffTable
69  {
70  typedef BuffHandle * PHa;
71  typedef BuffHandle::PBuff * PBu;
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&
95  just_satisfy_the_compiler() { }
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 
120  BuffTable::Chunk
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
143  level_check (BuffTable::Chunk& prev_level)
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_;
163  BuffTable::Chunk tab_;
164  BuffTableStorage& sto_;
165 
166  public:
167  BuffTableChunk (WiringDescriptor const& wd, BuffTableStorage& storage)
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 
181  ~BuffTableChunk ()
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 steam::engine
194 #endif
Interface to the processing nodes and the render nodes network.
Obsolete, to be rewritten /////TICKET #826 to be allocated on the stack while evaluating a ProcNode::...
Obsolete, to be rewritten /////TICKET #826.
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
BuffTable::Chunk claim(uint slots)
allocate the given number of slots starting at current level to be used by the newly created BuffTabl...
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
An opaque descriptor to identify the type and further properties of a data buffer.
Definition: buffhandle.hpp:85
Lumiera error handling (C++ interface).
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:115
Representation of the Media type of a data channel used within the engine.
just a placeholder to decouple the existing code from the reworked BuffHandle logic.
Obsolete, to be rewritten /////TICKET #826.
placeholder type for the contents of a data buffer.
Definition: streamtype.hpp:121
Interface: Description of the input and output ports, processing function and predecessor nodes for a...
Definition: procnode.hpp:78