Lumiera  0.pre.03
»edit your freedom«
feed-manifold-obsolete.hpp
Go to the documentation of this file.
1 /*
2  FEED-MANIFOLD.hpp - data feed connection system for render nodes
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6  2023, Hermann Vosseler <Ichthyostega@web.de>
7 
8   **Lumiera** is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by the
10   Free Software Foundation; either version 2 of the License, or (at your
11   option) any later version. See the file COPYING for further details.
12 
13 */
14 
15 
23 #ifndef ENGINE_FEED_MANIFOLD_OBSOLETE_H
24 #define ENGINE_FEED_MANIFOLD_OBSOLETE_H
25 
26 
27 #include "lib/error.hpp"
28 #include "lib/nocopy.hpp"
30 //#include "steam/engine/proc-node.hpp" ///////////////////////////////TODO this is a dead end
32 
33 #include <vector>
34 #include <utility>
35 
36 
38 
39 namespace steam {
40 namespace engine {
41 
42  using std::pair;
43  using std::vector;
44 
45 
60  struct FeedManifold
61  {
62  typedef BuffHandle * PHa;
63  typedef BuffHandle::PBuff * PBu;
64  typedef pair<PHa const,PBu const> Chunk;
65 
66  PHa outHandle;
67  PHa inHandle;
68  PBu outBuff;
69  PBu inBuff;
70  };
71 
72  class BuffDescr;
73 
76  {
78 
82  struct BuffHaXXXX
83  : BuffHandle
84  {
85  BuffHaXXXX() : BuffHandle(just_satisfy_the_compiler()) { /* wont work ever */ }
86  static BuffDescr const&
87  just_satisfy_the_compiler() { }
88  };
89 
91  vector<BuffHaXXXX> hTab_;
92  vector<BuffHandle::PBuff> pTab_;
93  size_t level_;
94 
95  public:
96  BuffTableStorage (const size_t maxSiz)
97  : hTab_(maxSiz),
98  pTab_(maxSiz),
99  level_(0)
100  { }
101 
102  ~BuffTableStorage() { ASSERT (0==level_, "buffer management logic broken."); }
103 
104  protected:
105 
106  friend class BuffTableChunk;
107 
112  FeedManifold::Chunk
113  claim (uint slots)
114  {
115  ASSERT (pTab_.size() == hTab_.size());
116  REQUIRE (level_+slots <= hTab_.size());
117 
118  size_t prev_level (level_);
119  level_ += slots;
120  return std::make_pair (&hTab_[prev_level],
121  &pTab_[prev_level]);
122  }
123 
124  void
125  release (uint slots)
126  {
127  ASSERT (slots <= level_);
128  REQUIRE (level_ <= hTab_.size());
129  REQUIRE (level_ <= pTab_.size());
130 
131  level_ -= slots;
132  }
133 
134  bool
135  level_check (FeedManifold::Chunk& prev_level)
136  {
137  return prev_level.first == &hTab_[level_]
138  && prev_level.second == &pTab_[level_];
139  }
140  };
141 
142 
151  : public FeedManifold,
153  {
154  const uint siz_;
155  FeedManifold::Chunk tab_;
156  BuffTableStorage& sto_;
157 
158  public:
159  BuffTableChunk (Connectivity const& wd, BuffTableStorage& storage)
160  : siz_(wd.nrI + wd.nrO),
161  tab_(storage.claim (siz_)),
162  sto_(storage)
163  {
164  const uint nrO(wd.nrO);
165 
166  // Setup the publicly visible table locations
167  this->outHandle = &tab_.first[ 0 ];
168  this->inHandle = &tab_.first[nrO];
169  this->outBuff = &tab_.second[ 0 ];
170  this->inBuff = &tab_.second[nrO];
171  }
172 
173  ~BuffTableChunk ()
174  {
175  sto_.release (siz_);
176  ASSERT ( sto_.level_check (tab_),
177  "buffer management logic broken.");
178  }
179  };
180 
181 
182 
183 
184 
185 }} // namespace steam::engine
186 #endif /*ENGINE_FEED_MANIFOLD_OBSOLETE_H*/
Obsolete, to be rewritten /////TICKET #826 to be allocated on the stack while evaluating a ProcNode::...
Obsolete, to be rewritten /////TICKET #826.
Obsolete, to be rewritten /////TICKET #826.
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
An opaque descriptor to identify the type and further properties of a data buffer.
Definition: buffhandle.hpp:77
Representation of the Media type of a data channel used within the engine.
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
FeedManifold::Chunk claim(uint slots)
allocate the given number of slots starting at current level to be used by the newly created BuffTabl...
Lumiera error handling (C++ interface).
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
Interface: Description of the input and output ports, processing function and predecessor nodes for a...
just a placeholder to decouple the existing code from the reworked BuffHandle logic.
placeholder type for the contents of a data buffer.
Definition: streamtype.hpp:112