PeriDyno 1.2.1
Loading...
Searching...
No Matches
WtNodeData.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Wt/WLogger.h>
4#include <Wt/WString.h>
5
6#include "NodePort.h"
7
15
17{
18 std::string id;
19 std::string name;
21};
22
23enum class PortType
24{
28};
29
30enum class CntType
31{
34};
35
36static const int INVALID_PORT = -1;
37
38using PortIndex = int;
39
40struct Port
41{
43
45
47
48 Port(PortType t, PortIndex i) : type(t), index(i) {}
49
50 bool indexIsValid() { return index != INVALID_PORT; }
51
52 bool portTypeIsValid() { return type != PortType::None; }
53};
54
56{
57 PortType result = PortType::None;
58
59 switch (port)
60 {
61 case PortType::In:
62 result = PortType::Out;
63 break;
64
65 case PortType::Out:
66 result = PortType::In;
67 break;
68
69 default:
70 break;
71 }
72
73 return result;
74}
75
77{
78public:
79 virtual ~WtNodeData() = default;
80
81 virtual bool sameType(WtNodeData &nodeData) const
82 {
83 return (this->type().id == nodeData.type().id);
84 }
85
86 virtual NodeDataType type() const = 0;
87
89 {
90 return cType;
91 }
92
94 {
95 cType = t;
96 }
97
98private:
100};
101
102using dyno::Node;
103using dyno::NodePort;
104
106{
107public:
111
112 NodeDataType type() const override
113 {
114 return NodeDataType{"nodeport",
115 "NodePort",
117 }
118
120
121 bool isEmpty() { return node_port == nullptr; }
122
123 bool sameType(WtNodeData &nodeData) const override;
124
125private:
126 NodePort *node_port = nullptr;
127};
128
130{
131public:
133 {
134 }
135
136 WtExportNode(std::shared_ptr<Node> n)
137 : export_node(n)
138 {
139 }
140
141 NodeDataType type() const override
142 {
143 return NodeDataType{"nodeexport",
144 "NodeExport",
146 }
147
148 inline std::shared_ptr<Node> getNode() { return export_node; }
149
150 bool isEmpty() { return export_node == nullptr; }
151
152 bool sameType(WtNodeData &nodeData) const override;
153
154private:
155 std::shared_ptr<Node> export_node = nullptr;
156};
int PortIndex
static const int INVALID_PORT
PortShape
Definition WtNodeData.hpp:9
PortType oppositePort(PortType port)
PortType
CntType
bool sameType(WtNodeData &nodeData) const override
std::shared_ptr< Node > export_node
std::shared_ptr< Node > getNode()
WtExportNode(std::shared_ptr< Node > n)
NodeDataType type() const override
bool sameType(WtNodeData &nodeData) const override
Definition WtNodeData.cpp:3
WtImportNode(NodePort *n)
NodeDataType type() const override
NodePort * node_port
NodePort * getNodePort()
CntType cType
void setConnectionType(CntType t)
virtual NodeDataType type() const =0
virtual bool sameType(WtNodeData &nodeData) const
CntType connectionType()
virtual ~WtNodeData()=default
Input ports for Node.
Definition NodePort.h:38
std::string id
std::string name
PortShape shape
bool portTypeIsValid()
PortIndex index
Port(PortType t, PortIndex i)
PortType type
bool indexIsValid()