Enzo
Loading...
Searching...
No Matches
NodeImpl.h
1#pragma once
2#include "Engine/Core/Types.h"
3#include "Engine/Network/CookContext.h"
4#include "Engine/Network/NodePacket.h"
5#include <boost/config.hpp>
6#include <filesystem>
7#include <string>
8#include <vector>
9
10namespace enzo::prm {
11class Ramp;
12}
13
14namespace enzo::nt {
15class Node;
16
39class BOOST_SYMBOL_EXPORT NodeImpl
40{
41 public:
42 NodeImpl(Node& node, CookContext& context) : node_{node}, context_{context} {}
43 virtual ~NodeImpl() = default;
44
47 virtual void cook() = 0;
48
49 protected:
52 void throwError(std::string error);
53
56 void throwWarning(std::string warning);
57
59 NodeId getNodeId() const;
60
62 const std::filesystem::path& getNodeFolder() const;
63
66 bool outputRequested(unsigned int outputIndex);
67
70 void setOutputPacket(unsigned int outputIndex, enzo::NodePacket packet);
71
73 enzo::NodePacket cloneInputPacket(unsigned int inputIndex);
74
76 std::shared_ptr<const enzo::NodePacket> getInputPacket(unsigned int inputIndex);
77
79 bool hasInput(unsigned int inputIndex);
80
83 unsigned int getInputCount();
84
87 floatT getFrame() const;
88
90 floatT getTime() const;
91
92 floatT evalParmFloat(std::string_view parmName, const unsigned int index = 0) const;
93 intT evalParmInt(std::string_view parmName, const unsigned int index = 0) const;
94 boolT evalParmBool(std::string_view parmName, const unsigned int index = 0) const;
95 String evalParmString(std::string_view parmName, const unsigned int index = 0) const;
96
97 // Read every value of a multi value parameter at once, where the singular
98 // forms above read one value by index.
99 std::vector<floatT> evalParmFloats(std::string_view parmName) const;
100 std::vector<intT> evalParmInts(std::string_view parmName) const;
101 std::vector<String> evalParmStrings(std::string_view parmName) const;
102
103 Vector2 evalParmVector2(std::string_view parmName) const;
104 Vector3 evalParmVector3(std::string_view parmName) const;
105
107 enzo::prm::Ramp evalParmRamp(std::string_view parmName) const;
108
109 private:
110 Node& node_;
111 CookContext& context_;
112};
113
114} // namespace enzo::nt
Basic attribute, parameter, and node types for Enzo.
uint64_t NodeId
The unique ID assigned to each node in the network.
Definition Types.h:335
Definition NodePacket.h:12
The handle a node holds while it cooks to get context about the network.
Definition CookContext.h:23
The base class a node author subclasses to write a node's behaviour.
Definition NodeImpl.h:40
virtual void cook()=0
Produces this node's output packets from its inputs and parameters.
The unique runtime representation of a node.
Definition Node.h:18
A sampled snapshot of a ramp parameter read during cook.
Definition Ramp.h:25