Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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
96#ifndef STEAM_ENGINE_PROC_NODE_H
97#define STEAM_ENGINE_PROC_NODE_H
98
99#include "lib/error.hpp"
100#include "lib/nocopy.hpp"
101#include "lib/hash-value.h"
104#include "lib/format-string.hpp"
105#include "lib/several.hpp"
106
107#include <string>
108#include <optional>
109
110
111
112namespace steam {
113namespace engine {
114 namespace err = lumiera::error;
115
116 using std::move;
117 using std::string;
118 using std::nullopt;
119 using std::optional;
120 using lib::HashVal;
121 using util::_Fmt;
122
123 class ProcID;
124 class ProcNode;
125 class ProcNodeDiagnostic;
126
128 using OptionalBuff = std::optional<BuffHandle>;
129
130
134
135
136
137 class Port
139 {
140 public:
141 virtual ~Port();
142 Port (ProcID& id) : procID{id} { }
143
144 virtual BuffHandle weave (TurnoutSystem&, OptionalBuff =std::nullopt) =0;
145
147
149 friend bool operator== (Port const& pl, Port const& pr){ return & pl == & pr;}
150 friend bool operator!= (Port const& pl, Port const& pr){ return not (pl == pr); }
151 };
152
154
169 {
170 public: /* === public information record describing the node graph === */
171
174
177
179 : ports(move(pr))
180 , leads(move(lr))
181 { }
182
183 };
184
185
186
187
195 {
196
198
199 public:
201 : wiring_(move(con))
202 { }
203
204
205 Port&
206 getPort (uint portIdx)
207 {
208 if (portIdx >= wiring_.ports.size())
209 throw err::Logic{_Fmt{"Accessing node-port #%d, while only %d ports are defined."}
210 % portIdx % wiring_.ports.size()
211 ,LERR_(INDEX_BOUNDS)
212 };
213 return wiring_.ports[portIdx];
214 }
215
217 friend bool operator== (ProcNode const& nl, ProcNode const& nr){ return & nl == & nr;}
218 friend bool operator!= (ProcNode const& nl, ProcNode const& nr){ return not (nl == nr); }
219
220
221 /*************************************************************/
234 pull (uint portIdx, BuffHandle output, Time nomTime, ProcessKey procKey)
235 {
236 TurnoutSystem turnoutSystem{nomTime, procKey};
237 return getPort(portIdx).weave (turnoutSystem, output);
238 }
239
241 friend class ProcNodeDiagnostic;
242 };
243
244
245 /* ========== Diagnostic and Testing ========== */
246
247 class PortDiagnostic;
248
251 {
253
254 public:
256 : n_{theNode}
257 { }
258
259 auto& leads() { return n_.wiring_.leads; }
260 auto& ports() { return n_.wiring_.ports; }
261
262 bool isSrc() { return n_.wiring_.leads.empty(); }
263
264 bool
266 {
267 return 0 < ports().size();
269 }
270
271 string getNodeName();
272 string getNodeSpec();
273 HashVal getNodeHash();
274
275 string getPortSpec (uint portIdx);
276 HashVal getPortHash (uint portIdx);
277
280 };
281
282 inline ProcNodeDiagnostic
283 watch (ProcNode& theNode)
284 {
285 return ProcNodeDiagnostic{theNode};
286 }
287
288
289
292 {
294
295 public:
297 : p_{thePort}
298 { }
299
301
302 bool isSrc() { return srcPorts().empty(); }
303
304 string getProcName();
305 string getProcSpec();
306 HashVal getProcHash();
307
309
310 bool verify_connected (uint input, Port&);
312 };
313
314 inline PortDiagnostic
315 watch (Port& thePort)
316 {
317 return PortDiagnostic{thePort};
318 }
319
320
321
322
326 {
328 ProcNode* srcNode{nullptr};
329 Port* srcPort{nullptr};
330 optional<uint> leadNo{nullopt};
331 optional<uint> portNo{nullopt};
332 optional<uint> srcNo {nullopt};
333 optional<uint> srcPNo{nullopt};
334
335 public:
337 : anchor{watch(n)}
338 { }
339
341 operator bool();
342
343 _ConCheck to (ProcNode& n) { srcNode = &n; return move(*this); }
344 _ConCheck to (Port& p) { srcPort = &p; return move(*this); }
345 _ConCheck asLead (uint idx){ leadNo = idx; return move(*this); }
346 _ConCheck toLead (uint idx){ leadNo = idx; return move(*this); }
347 _ConCheck asSrc (uint idx){ srcNo = idx; return move(*this); }
348 _ConCheck port (uint idx){ portNo = idx; return move(*this); }
349 _ConCheck atPort (uint idx){ srcPNo = idx; return move(*this); }
350 };
351
356 inline _ConCheck
358 {
359 return _ConCheck{n};
360 }
361
362
363}} // namespace steam::engine
364#endif /*STEAM_ENGINE_PROC_NODE_H*/
A front-end to support the buffer management within the render nodes.
size_t size() const
Definition several.hpp:194
bool empty() const
Definition several.hpp:200
Lumiera's internal time value datatype.
Handle for a buffer for processing data, abstracting away the actual implementation.
Interface: Description of the input and output ports, processing function and predecessor nodes for a...
Connectivity(Ports &&pr, Leads &&lr)
string getProcName()
generate a combined name for the node and the qualification of the port
HashVal getProcHash()
calculate an unique, stable and reproducible hash-key to identify the associated operation
PortDiagnostic watchLead(uint leadIdx)
string getProcSpec()
generate a descriptive diagnostic Spec for the Turnout sitting behind this Port
bool verify_connected(uint input, Port &)
lib::Several< PortRef > const & srcPorts()
friend bool operator!=(Port const &pl, Port const &pr)
virtual BuffHandle weave(TurnoutSystem &, OptionalBuff=std::nullopt)=0
friend bool operator==(Port const &pl, Port const &pr)
Port has reference semantics: all instances are distinct.
virtual ~Port()
this is an interface
Metadata to qualify a Port (and implicitly the enclosing Node).
Definition proc-id.hpp:124
string getPortSpec(uint portIdx)
generate a descriptive diagnostic Spec for the designated Turnout
string getNodeSpec()
generate a descriptive Spec of this ProcNode for diagnostics
PortDiagnostic watchPort(uint portIdx)
HashVal getNodeHash()
calculate an unique hash-key to designate this node
string getNodeName()
show the node's descriptive name
ProcNodeDiagnostic(ProcNode &theNode)
ProcNodeDiagnostic watchLead(uint leadIdx)
HashVal getPortHash(uint portIdx)
calculate an unique, stable and reproducible hash-key to identify the Turnout
Key abstraction of the Render Engine: A Data processing Node.
Port & getPort(uint portIdx)
friend bool operator!=(ProcNode const &nl, ProcNode const &nr)
ProcNode(Connectivity &&con)
friend bool operator==(ProcNode const &nl, ProcNode const &nr)
ProcNode has reference semantics: all instances are distinct.
BuffHandle pull(uint portIdx, BuffHandle output, Time nomTime, ProcessKey procKey)
Engine Core operation: render and pull output from this node.
Communication hub to coordinate and activate the »Render Node Network« performance.
Helper for connectivity-checks in tests.
optional< uint > portNo
ProcNodeDiagnostic anchor
optional< uint > leadNo
_ConCheck to(ProcNode &n)
_ConCheck atPort(uint idx)
_ConCheck asSrc(uint idx)
optional< uint > srcNo
_ConCheck to(Port &p)
_ConCheck asLead(uint idx)
_ConCheck port(uint idx)
_ConCheck toLead(uint idx)
optional< uint > srcPNo
Types marked with this mix-in may be moved but not copied.
Definition nocopy.hpp:50
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
A front-end for using printf-style formatting.
Lumiera error handling (C++ interface).
#define LERR_(_NAME_)
Definition error.hpp:45
Front-end for printf-style string template interpolation.
Hash value types and utilities.
unsigned int uint
Definition integral.hpp:29
#define LUMIERA_MAX_ORDINAL_NUMBER
Definition limits.hpp:34
size_t HashVal
a STL compatible hash value
Definition hash-value.h:52
LumieraError< LERR_(LOGIC)> Logic
Definition error.hpp:207
std::reference_wrapper< ProcNode > ProcNodeRef
ProcNodeDiagnostic watch(ProcNode &theNode)
const size_t MAX_NODE_ARG
arbitrary safety limit on fain-in / fan-out
_ConCheck is_linked(ProcNode &n)
start a DSL expression to verify node connectivity.
std::optional< BuffHandle > OptionalBuff
std::reference_wrapper< Port > PortRef
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Abstraction interface: array-like random access by subscript.
A actual state of a rendering evaluation parametrised for a single job.