Lumiera  0.pre.03
»edit your freedom«
proc-node.hpp
Go to the documentation of this file.
1 /*
2  PROC-NODE.hpp - Key abstraction of the Render Engine: a Processing Node
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
33 #ifndef STEAM_ENGINE_PROC_NODE_H
34 #define STEAM_ENGINE_PROC_NODE_H
35 
36 #include "lib/error.hpp"
37 #include "lib/nocopy.hpp"
38 #include "lib/hash-value.h"
39 //#include "steam/asset/proc.hpp"
40 //#include "steam/mobject/parameter.hpp"
43 #include "lib/ref-array.hpp"
44 #include "lib/format-string.hpp"
45 #include "lib/several.hpp"
46 
47 #include <string>
48 #include <vector>
49 #include <optional>
50 
51 
52 
53 namespace steam {
54 namespace engine {
55  namespace err = lumiera::error;
56 
57  using std::move;
58  using std::string;
59  using lib::HashVal;
60  using util::_Fmt;
61 
62  class ProcID;
63  class ProcNode;
64  class ProcNodeDiagnostic;
65 
66  using ProcNodeRef = std::reference_wrapper<ProcNode>;
67  using OptionalBuff = std::optional<BuffHandle>;
68 
69 
70  class Port
71 // : util::MoveOnly //////////////////////////////////////////////////OOO not clear if necessary here, and requires us to declare the ctors!!! See Turnout
73  {
74  public:
75  virtual ~Port();
76  Port (ProcID& id) : procID{id} { }
77 
78  virtual BuffHandle weave (TurnoutSystem&, OptionalBuff =std::nullopt) =0;
79 
80 // // compiler does not generate a move-ctor automatically due to explicit dtor
81 // Port() = default;
82 // Port(Port&&) = default;
83  ProcID& procID;
84  };
85 
87 
101  class Connectivity
102  {
103  public: /* === public information record describing the node graph === */
105  using Ports = lib::Several<Port>;
106  using Leads = lib::Several<ProcNodeRef>;
107 
108  Ports ports;
109  Leads leads;
110 
112 
113 // protected:
115  Connectivity (Ports&& pr, Leads&& lr)
116  : ports(move(pr))
117  , leads(move(lr))
118  { }
120 
121 
123  /* ==== strategy API for configuring the node operation ==== */
124 
125  friend class ProcNode;
126 
132 #if false
133  virtual BuffHandle
134  callDown (StateClosure_OBSOLETE& currentProcess, uint requiredOutputNr) const =0;
135 #endif
136 
138  };
139 
140 
141 
142 
154  class ProcNode
156  {
157 
158  Connectivity wiring_;
159 
160  public:
162  ProcNode (Connectivity&& con)
163  : wiring_(move(con))
164  { }
165 
167 
168 
169  public:
171 
172  Port&
173  getPort (uint portIdx)
174  {
175  if (portIdx >= wiring_.ports.size())
176  throw err::Logic{_Fmt{"Accessing node-port #%d, while only %d ports are defined."}
177  % portIdx % wiring_.ports.size()
178  ,LERR_(INDEX_BOUNDS)
179  };
180  return wiring_.ports[portIdx];
181  }
182 
195 #if false
196  BuffHandle
197  pull (StateClosure_OBSOLETE& currentProcess, uint requestedOutputNr=0) const
198  {
199  return this->wiringConfig_.callDown (currentProcess, requestedOutputNr);
200  }
201 #endif
202 
204  friend class ProcNodeDiagnostic;
206  };
207 
208 
212  {
213  ProcNode& n_;
214 
215  public:
216  ProcNodeDiagnostic (ProcNode& theNode)
217  : n_{theNode}
218  { }
219 
220  auto& leads() { return n_.wiring_.leads; }
221  auto& ports() { return n_.wiring_.ports; }
222 
223  bool isSrc() { return n_.wiring_.leads.empty(); }
224 
225  bool
226  isValid()
227  {
228  return 0 < ports().size();
230  }
231 
232  string getNodeSpec();
233  HashVal getNodeHash();
234 
235  string getPortSpec (uint portIdx);
236  HashVal getPortHash (uint portIdx);
237  };
238 
239  inline ProcNodeDiagnostic
240  watch (ProcNode& theNode)
241  {
242  return ProcNodeDiagnostic{theNode};
243  }
244 
245 
246 }} // namespace steam::engine
247 #endif /*STEAM_ENGINE_PROC_NODE_H*/
virtual ~Port()
this is an interface
Definition: proc-node.cpp:60
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
Types marked with this mix-in may be moved but not copied.
Definition: nocopy.hpp:49
Front-end for printf-style string template interpolation.
Communication hub to coordinate and activate the »Render Node Network« performance.
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Abstraction interface: array-like random access by subscript.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
Abstraction to access the state of a currently ongoing render/calculation process, as it is tied to the supporting facilities of the vault layer.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Abstraction interface: array-like access by subscript.
A front-end to support the buffer management within the render nodes.
Lumiera error handling (C++ interface).
Hash value types and utilities.
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:52
Interface: Description of the input and output ports, processing function and predecessor nodes for a...
Key abstraction of the Render Engine: A Data processing Node.
Definition: proc-node.hpp:154
THe actual state of a frame rendering evaluation parametrised for a single job.