Enzo
Loading...
Searching...
No Matches
NodeType.h
1#pragma once
2#include "Engine/Parameter/Template.h"
3#include <filesystem>
4#include <string>
5#include <vector>
6
7namespace enzo::nt {
8class Node;
9class NodeImpl;
10class CookContext;
11
13using nodeConstructor = NodeImpl* (*)(Node&, CookContext&);
14
22{
23 std::string label;
24 bool multiInput = false;
25
27 bool optional = false;
28};
29
39{
40 std::string internalName;
41
44 std::string typeNamespace;
45
46 std::string displayName;
47 nodeConstructor ctorFunc = nullptr;
48 std::vector<enzo::prm::Template> templates;
49
51 std::vector<InputPort> inputPorts;
52
53 unsigned int maxOutputs = 1;
54
56 std::vector<std::string> tags;
57
59 std::filesystem::path folder;
60
62 std::string iconPath;
63
65 std::string docsPath;
66
73 std::string childScopeType;
74
77 const std::string& getName() const { return internalName; }
80 std::string getFullName() const { return typeNamespace + "::" + internalName; }
82 const std::string& getLabel() const { return displayName; }
83
85 bool hasChildScope() const { return !childScopeType.empty(); }
86
88 bool hasMultiInputPort() const { return !inputPorts.empty() && inputPorts.back().multiInput; }
89
91 unsigned int getSinglePortCount() const
92 {
93 const auto declaredCount = static_cast<unsigned int>(inputPorts.size());
94 return hasMultiInputPort() ? declaredCount - 1 : declaredCount;
95 }
96
98 bool isMultiInputPortAt(unsigned int inputIndex) const
99 {
100 return hasMultiInputPort() && inputIndex >= getSinglePortCount();
101 }
102
106 const InputPort* getPortAt(unsigned int inputIndex) const
107 {
108 if (inputIndex < getSinglePortCount()) return &inputPorts[inputIndex];
109 if (hasMultiInputPort()) return &inputPorts.back();
110 return nullptr;
111 }
112
115 std::filesystem::path getIconFile() const
116 {
117 if (iconPath.empty()) return {};
118 return folder / iconPath;
119 }
120};
121} // namespace enzo::nt
One input port a node type declares.
Definition NodeType.h:22
bool optional
Whether the node cooks with nothing wired into this port.
Definition NodeType.h:27
Everything every node of one kind shares.
Definition NodeType.h:39
std::filesystem::path folder
The folder the node was loaded from, which is also where its assets live.
Definition NodeType.h:59
bool hasChildScope() const
Returns whether this node holds a scope of other nodes inside it.
Definition NodeType.h:85
std::vector< InputPort > inputPorts
The input ports the node declares, in the order their inputs run.
Definition NodeType.h:51
bool hasMultiInputPort() const
Returns whether the last declared port holds any number of inputs.
Definition NodeType.h:88
std::string typeNamespace
The namespace the node was published under, such as "enzo".
Definition NodeType.h:44
std::vector< std::string > tags
The words the tab menu searches on, such as "curve" or "primitive".
Definition NodeType.h:56
std::filesystem::path getIconFile() const
Returns the icon file on disk.
Definition NodeType.h:115
std::string docsPath
The documentation file relative to the folder, empty when there is none.
Definition NodeType.h:65
unsigned int getSinglePortCount() const
Returns the number of ports that hold a single input each.
Definition NodeType.h:91
const std::string & getName() const
Returns the internal type name shared by all nodes of this type (eg. "copy_to_points")
Definition NodeType.h:77
std::string getFullName() const
Returns the name that uniquely identifies this type (eg. "enzo::copy_to_points")
Definition NodeType.h:80
const std::string & getLabel() const
Returns the human readable type label shown in the UI (eg. "Copy To Points")
Definition NodeType.h:82
bool isMultiInputPortAt(unsigned int inputIndex) const
Returns whether the input at this index belongs to the multi input port.
Definition NodeType.h:98
std::string iconPath
The icon file relative to the folder, empty when the node ships none.
Definition NodeType.h:62
std::string childScopeType
The kind of scope this node holds inside it, empty when it holds none.
Definition NodeType.h:73
const InputPort * getPortAt(unsigned int inputIndex) const
Returns the port holding an input.
Definition NodeType.h:106