1- #ifndef NODE_STATE_HPP
2- #define NODE_STATE_HPP
1+ #pragma once
32
43#include < vector>
54
65#include < QtCore/QUuid>
76
87#include " EndType.hpp"
98
9+ // / Contains vectors of connected input and output connections.
10+ // / Stores bool for reacting on hovering connections
1011class NodeState
1112{
1213public:
@@ -18,57 +19,30 @@ class NodeState
1819
1920public:
2021 NodeState (unsigned int nSources,
21- unsigned int nSinks)
22- : _sources(nSources, QUuid())
23- , _sinks(nSinks, QUuid())
24- , _reaction(NOT_REACTING )
25- {}
22+ unsigned int nSinks);
2623
2724public:
2825
29- std::vector<QUuid> const & getEntries (EndType endType) const
30- {
31- Q_ASSERT (endType != EndType::NONE );
32-
33- if (endType == EndType::SOURCE )
34- return _sources;
35- else
36- return _sinks;
37- }
38-
39- QUuid const connectionID (EndType endType, size_t nEntry) const
40- {
41- std::vector<QUuid> const & entries =
42- getEntries (endType);
26+ // / Returns vector of connections ID.
27+ // / Some of them can be empty (null)
28+ std::vector<QUuid> const & getEntries (EndType endType) const ;
4329
44- if (nEntry >= entries.size ())
45- return QUuid ();
30+ // / Returns connection id for given endtype and
31+ // / given connection number
32+ QUuid const connectionID (EndType endType, size_t nEntry) const ;
4633
47- return entries[nEntry];
48- }
34+ // / Assign connection id to the given entry
35+ void setConnectionId (EndType endType, size_t nEntry, QUuid id);
4936
50- void setConnectionId (EndType endType, size_t nEntry, QUuid id)
51- {
52- std::vector<QUuid> const & entries =
53- const_cast <NodeState const &>(*this ).getEntries (endType);
54-
55- const_cast <std::vector<QUuid>&>(entries)[nEntry] = id;
56- }
37+ ReactToConnectionState reaction () const ;
5738
58- ReactToConnectionState reaction () const
59- { return _reaction; }
39+ void setReaction (ReactToConnectionState reaction);
6040
61- void setReaction (ReactToConnectionState reaction)
62- { _reaction = reaction; }
63-
64- bool isReacting () const
65- { return _reaction == REACTING ; }
41+ bool isReacting () const ;
6642
6743private:
6844 std::vector<QUuid> _sources;
6945 std::vector<QUuid> _sinks;
7046
7147 ReactToConnectionState _reaction;
7248};
73-
74- #endif // NODE_STATE_HPP
0 commit comments