forked from kovacsv/VisualScriptEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNE_NodeManager.hpp
More file actions
174 lines (139 loc) · 6.98 KB
/
Copy pathNE_NodeManager.hpp
File metadata and controls
174 lines (139 loc) · 6.98 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#ifndef NE_NODEMANAGER_HPP
#define NE_NODEMANAGER_HPP
#include "NE_NodeEngineTypes.hpp"
#include "NE_Serializable.hpp"
#include "NE_Node.hpp"
#include "NE_NodeId.hpp"
#include "NE_SlotId.hpp"
#include "NE_Value.hpp"
#include "NE_ConnectionInfo.hpp"
#include "NE_ConnectionManager.hpp"
#include "NE_NodeList.hpp"
#include "NE_NodeGroupList.hpp"
#include "NE_NodeValueCache.hpp"
#include "NE_UniqueIdGenerator.hpp"
#include <functional>
namespace NE
{
class OutputSlotList
{
public:
OutputSlotList ();
virtual ~OutputSlotList ();
bool IsEmpty () const;
virtual size_t GetSize () const = 0;
virtual void Enumerate (const std::function<bool (OutputSlotConstPtr)>& processor) const = 0;
};
class InputSlotList
{
public:
InputSlotList ();
virtual ~InputSlotList ();
bool IsEmpty () const;
virtual size_t GetSize () const = 0;
virtual void Enumerate (const std::function<bool (InputSlotConstPtr)>& processor) const = 0;
};
class NodeManager
{
SERIALIZABLE;
friend class NodeManagerMerge;
friend class NodeManagerSerialization;
public:
enum class UpdateMode
{
Automatic = 0,
Manual = 1
};
NodeManager ();
NodeManager (const NodeManager& src) = delete;
NodeManager (NodeManager&& src) = delete;
~NodeManager ();
NodeManager& operator= (const NodeManager& rhs) = delete;
NodeManager& operator= (NodeManager&& rhs) = delete;
void Clear ();
bool IsEmpty () const;
size_t GetNodeCount () const;
size_t GetNodeGroupCount () const;
size_t GetConnectionCount () const;
void EnumerateNodes (const std::function<bool (NodePtr)>& processor);
void EnumerateNodes (const std::function<bool (NodeConstPtr)>& processor) const;
bool ContainsNode (const NodeId& id) const;
NodeConstPtr GetNode (const NodeId& id) const;
NodePtr GetNode (const NodeId& id);
NodePtr AddNode (const NodePtr& node);
bool DeleteNode (const NodeId& id);
bool DeleteNode (const NodePtr& node);
bool IsOutputSlotConnectedToInputSlot (const OutputSlotConstPtr& outputSlot, const InputSlotConstPtr& inputSlot) const;
bool CanConnectOutputSlotToInputSlot (const InputSlotConstPtr& inputSlot) const;
bool CanConnectOutputSlotToInputSlot (const OutputSlotConstPtr& outputSlot, const InputSlotConstPtr& inputSlot) const;
bool CanConnectOutputSlotsToInputSlot (const OutputSlotList& outputSlots, const InputSlotConstPtr& inputSlot) const;
bool CanConnectOutputSlotToInputSlots (const OutputSlotConstPtr& outputSlot, const InputSlotList& inputSlots) const;
bool ConnectOutputSlotToInputSlot (const OutputSlotConstPtr& outputSlot, const InputSlotConstPtr& inputSlot);
bool ConnectOutputSlotsToInputSlot (const OutputSlotList& outputSlots, const InputSlotConstPtr& inputSlot);
bool ConnectOutputSlotToInputSlots (const OutputSlotConstPtr& outputSlot, const InputSlotList& inputSlots);
bool DisconnectOutputSlotFromInputSlot (const OutputSlotConstPtr& outputSlot, const InputSlotConstPtr& inputSlot);
bool DisconnectOutputSlotsFromInputSlot (const OutputSlotList& outputSlots, const InputSlotConstPtr& inputSlot);
bool DisconnectOutputSlotFromInputSlots (const OutputSlotConstPtr& outputSlot, const InputSlotList& inputSlots);
bool DisconnectAllInputSlotsFromOutputSlot (const OutputSlotConstPtr& outputSlot);
bool DisconnectAllOutputSlotsFromInputSlot (const InputSlotConstPtr& inputSlot);
bool HasConnectedOutputSlots (const InputSlotConstPtr& inputSlot) const;
bool HasConnectedInputSlots (const OutputSlotConstPtr& outputSlot) const;
size_t GetConnectedOutputSlotCount (const InputSlotConstPtr& inputSlot) const;
size_t GetConnectedInputSlotCount (const OutputSlotConstPtr& outputSlot) const;
void EnumerateConnectedOutputSlots (const InputSlotConstPtr& inputSlot, const std::function<void (const OutputSlotConstPtr&)>& processor) const;
void EnumerateConnectedInputSlots (const OutputSlotConstPtr& outputSlot, const std::function<void (const InputSlotConstPtr&)>& processor) const;
void EnumerateConnections (const std::function<void (const OutputSlotConstPtr&, const InputSlotConstPtr&)>& processor) const;
void EnumerateConnections (const NodeCollection& nodes, const std::function<void (const OutputSlotConstPtr&, const InputSlotConstPtr&)>& processor) const;
void EvaluateAllNodes (EvaluationEnv& env) const;
void ForceEvaluateAllNodes (EvaluationEnv& env) const;
void InvalidateNodeValue (const NodeId& nodeId) const;
void InvalidateNodeValue (const NodeConstPtr& node) const;
void EnumerateDependentNodes (const NodeConstPtr& node, const std::function<void (const NodeId&)>& processor) const;
void EnumerateDependentNodesRecursive (const NodeConstPtr& node, const std::function<void (const NodeId&)>& processor) const;
void EnumerateDependentNodes (const NodePtr& node, const std::function<void (const NodePtr&)>& processor);
void EnumerateDependentNodesRecursive (const NodePtr& node, const std::function<void (const NodePtr&)>& processor);
void EnumerateDependentNodes (const NodeConstPtr& node, const std::function<void (const NodeConstPtr&)>& processor) const;
void EnumerateDependentNodesRecursive (const NodeConstPtr& node, const std::function<void (const NodeConstPtr&)>& processor) const;
bool ContainsNodeGroup (const NodeGroupId& groupId) const;
NodeGroupPtr AddNodeGroup (const NodeGroupPtr& group);
void DeleteNodeGroup (const NodeGroupId& groupId);
void AddNodeToGroup (const NodeGroupId& groupId, const NodeId& nodeId);
void RemoveNodeFromGroup (const NodeId& nodeId);
NodeGroupConstPtr GetNodeGroup (const NodeId& nodeId) const;
const NodeCollection& GetGroupNodes (const NodeGroupId& groupId) const;
void EnumerateNodeGroups (const std::function<bool (NodeGroupConstPtr)>& processor) const;
void EnumerateNodeGroups (const std::function<bool (NodeGroupPtr)>& processor);
void DeleteAllNodeGroups ();
bool IsCalculationEnabled () const;
UpdateMode GetUpdateMode () const;
void SetUpdateMode (UpdateMode newUpdateMode);
Stream::Status Read (InputStream& inputStream);
Stream::Status Write (OutputStream& outputStream) const;
static bool Clone (const NodeManager& source, NodeManager& target);
static bool ReadFromBuffer (NodeManager& nodeManager, const std::vector<char>& buffer);
static bool WriteToBuffer (const NodeManager& nodeManager, std::vector<char>& buffer);
private:
enum class IdPolicy
{
KeepOriginal,
GenerateNew
};
enum class InitPolicy
{
Initialize,
DoNotInitialize
};
NodePtr AddNode (const NodePtr& node, IdPolicy idHandling, InitPolicy initPolicy);
NodeGroupPtr AddNodeGroup (const NodeGroupPtr& group, IdPolicy idHandling);
void MakeNodesAndGroupsSorted ();
UniqueIdGenerator idGenerator;
NodeList nodeList;
ConnectionManager connectionManager;
NodeGroupList nodeGroupList;
UpdateMode updateMode;
mutable NodeValueCache nodeValueCache;
mutable NodeEvaluatorConstPtr nodeEvaluator;
mutable bool isForceCalculate;
};
}
#endif