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 const std::filesystem::path& getNodeFolder() const;
60
63 bool outputRequested(unsigned int outputIndex);
64
67 void setOutputPacket(unsigned int outputIndex, enzo::NodePacket packet);
68
70 enzo::NodePacket cloneInputPacket(unsigned int inputIndex);
72 bool hasInput(unsigned int inputIndex);
73
76 unsigned int getInputCount();
77
80 floatT getFrame() const;
81
83 floatT getTime() const;
84
85 floatT evalParmFloat(std::string_view parmName, const unsigned int index = 0) const;
86 intT evalParmInt(std::string_view parmName, const unsigned int index = 0) const;
87 boolT evalParmBool(std::string_view parmName, const unsigned int index = 0) const;
88 String evalParmString(std::string_view parmName, const unsigned int index = 0) const;
89
90 // Read every value of a multi value parameter at once, where the singular
91 // forms above read one value by index.
92 std::vector<floatT> evalParmFloats(std::string_view parmName) const;
93 std::vector<intT> evalParmInts(std::string_view parmName) const;
94 std::vector<String> evalParmStrings(std::string_view parmName) const;
95
96 Vector2 evalParmVector2(std::string_view parmName) const;
97 Vector3 evalParmVector3(std::string_view parmName) const;
98
100 enzo::prm::Ramp evalParmRamp(std::string_view parmName) const;
101
102 private:
103 Node& node_;
104 CookContext& context_;
105};
106
107} // namespace enzo::nt
Basic attribute, parameter, and node types for Enzo.
Definition NodePacket.h:9
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