3#include "Engine/NetworkGraph/Connection.h"
4#include "Engine/NetworkGraph/Unit.h"
6#include <unordered_map>
7#include <unordered_set>
75 using ConnectionMap = std::unordered_map<NodeId, std::vector<Connection>>;
76 using CapturedMap = std::unordered_map<Unit, std::vector<Unit>>;
79 static void eraseConnection_(ConnectionMap& side,
NodeId key,
const Connection& connection);
82 static void eraseConnectionsTouching_(ConnectionMap& side,
NodeId nodeId);
85 static void eraseCapturedTouching_(CapturedMap& map,
NodeId nodeId);
88 static void eraseUnit_(CapturedMap& map,
const Unit& key,
const Unit& value);
91 static void addDependent_(
93 std::vector<Unit>& dependents,
94 std::unordered_set<Unit>& seen,
95 std::vector<Unit>& pending
101 std::vector<NodeId>& nodeOrder,
102 std::unordered_set<NodeId>& addedNodes,
103 std::unordered_set<NodeId>& nodesBeingAdded
107 ConnectionMap byTarget_;
109 ConnectionMap bySource_;
116 CapturedMap capturedDependents_;
118 CapturedMap capturedDependencies_;
122 std::unordered_set<Unit> timeDependents_;
Basic attribute, parameter, and node types for Enzo.
uint64_t NodeId
The unique ID assigned to each node in the network.
Definition Types.h:306
The single owner of the network's wiring and dependencies.
Definition NetworkGraph.h:24
std::vector< NodeId > getCookOrder(NodeId target) const
Returns the nodes to cook before target, in cook order.
Definition NetworkGraph.cpp:217
std::optional< Connection > getInputConnection(NodeId target, unsigned int inputIndex) const
Returns the connection on one input of target, if any.
Definition NetworkGraph.cpp:56
std::vector< Connection > getOutputs(NodeId source) const
Returns the connections leaving source.
Definition NetworkGraph.cpp:67
void disconnect(const Connection &connection)
Removes a wired connection between two nodes.
Definition NetworkGraph.cpp:14
void setTimeDependent(const Unit &dependent, bool dependsOnTime)
Records whether a unit reads the scene time.
Definition NetworkGraph.cpp:122
std::vector< Unit > getTimeDependents() const
Returns every unit the scene time reaches, in no particular order.
Definition NetworkGraph.cpp:130
std::vector< Unit > getDependents(const Unit &changed) const
Returns everything that depends on changed, directly or through a chain.
Definition NetworkGraph.cpp:254
std::vector< Connection > getInputs(NodeId target) const
Returns the connections feeding target, ordered by input index.
Definition NetworkGraph.cpp:45
void setCapturedDependencies(const Unit &dependent, const std::vector< Unit > &dependencies)
Replaces every captured dependency of one parameter at once.
Definition NetworkGraph.cpp:82
void connect(const Connection &connection)
Records a wired connection between two nodes.
Definition NetworkGraph.cpp:8
std::vector< Connection > getConnections() const
Returns every wired connection in the graph, in no particular order.
Definition NetworkGraph.cpp:74
void removeNode(NodeId nodeId)
Removes every connection and captured edge touching the node.
Definition NetworkGraph.cpp:142
void clear()
Empties the graph.
Definition NetworkGraph.cpp:208
One wired link between two nodes, the ground truth of the network's wiring.
Definition Connection.h:20
A point in the network graph, either a node output or a parameter.
Definition Unit.h:20