forked from paceholder/nodeeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeState.cpp
More file actions
81 lines (62 loc) · 1.36 KB
/
NodeState.cpp
File metadata and controls
81 lines (62 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "NodeState.hpp"
#include "NodeDataModel.hpp"
NodeState::
NodeState(std::unique_ptr<NodeDataModel> const &model)
: _outConnections(model->nPorts(PortType::OUT))
, _inConnections(model->nPorts(PortType::IN))
, _reaction(NOT_REACTING)
{}
std::vector<std::weak_ptr<Connection> > const&
NodeState::
getEntries(PortType portType) const
{
Q_ASSERT(portType != PortType::NONE);
if (portType == PortType::OUT)
return _outConnections;
else
return _inConnections;
}
std::vector<std::weak_ptr<Connection> > &
NodeState::
getEntries(PortType portType)
{
Q_ASSERT(portType != PortType::NONE);
if (portType == PortType::OUT)
return _outConnections;
else
return _inConnections;
}
std::shared_ptr<Connection>
NodeState::
connection(PortType portType, PortIndex portIndex) const
{
auto const &connections = getEntries(portType);
return connections[portIndex].lock();
}
void
NodeState::
setConnection(PortType portType,
PortIndex portIndex,
std::shared_ptr<Connection> connection)
{
auto &connections = getEntries(portType);
connections[portIndex] = connection;
}
NodeState::ReactToConnectionState
NodeState::
reaction() const
{
return _reaction;
}
void
NodeState::
setReaction(ReactToConnectionState reaction)
{
_reaction = reaction;
}
bool
NodeState::
isReacting() const
{
return _reaction == REACTING;
}