Enzo
Loading...
Searching...
No Matches
enzo::nt::Network Class Reference

Every node in a scene, their wiring, and the scopes they live in. More...

#include <Network.h>

Public Types

using NodeStore = std::unordered_map<NodeId, std::unique_ptr<Node>>
 

Public Member Functions

 Network (const Network &)=delete
 
Networkoperator= (const Network &)=delete
 
ScopegetScope (const Path &path)
 Returns the scope at a path, or null when no scope sits there.
 
NetworkGraphgraph ()
 Returns the wiring and dependencies between the nodes.
 
void clear ()
 Empties the network back to a bare root scope.
 
Nodes
auto nodes ()
 Returns an iterable range over every node, yielding {NodeId, Node&} pairs.
 
NodegetNode (NodeId nodeId)
 Returns the node with the given id.
 
bool isValidNode (NodeId nodeId) const
 Returns whether a node with the given id is present.
 
NodegetNodeAtPath (const Path &path)
 Returns the node at an exact path, or null when no node is there.
 
std::vector< NodeIdgetChildNodeIds (const Path &scope)
 Returns the ids of the nodes living directly inside a scope, in no particular order.
 
NodecreateNode (NodeId nodeId, const NodeType &nodeType, const Path &path)
 Builds a node, stores it, and opens the child scope its type declares.
 
void deleteNode (NodeId nodeId)
 Drops a node, the scope it held, and its wiring.
 
NodeId reserveNodeId ()
 Returns an id no node has used yet.
 
NodefindNode (const NetworkPath &path, NodeId fromNode=nullNode)
 Resolves a node reference to its node.
 
std::weak_ptr< prm::NodeParameterfindParameter (const NetworkPath &path, NodeId fromNode=nullNode)
 Resolves a parameter reference to its parameter.
 

Detailed Description

Every node in a scene, their wiring, and the scopes they live in.

This is the whole node graph as one value. It holds data and answers questions about what it holds. Cooking, undo, selection, and signalling all belong to the nt::NetworkManager that owns one of these.

Nodes are stored flat and keyed by nt::NodeId, with nesting carried entirely in their paths, so /container1/grid1 lives in the scope at /container1 without anything holding it there.

Note
Not copyable. Each node carries signal connections to the interface, so duplicating a network needs an explicit clone that leaves those behind.

Member Function Documentation

◆ createNode()

nt::Node & enzo::nt::Network::createNode ( nt::NodeId nodeId,
const NodeType & nodeType,
const Path & path )

Builds a node, stores it, and opens the child scope its type declares.

Returns
The stored node.

◆ deleteNode()

void enzo::nt::Network::deleteNode ( nt::NodeId nodeId)

Drops a node, the scope it held, and its wiring.

Note
The nodes living inside that scope are not dropped with it.

◆ findNode()

nt::Node * enzo::nt::Network::findNode ( const NetworkPath & path,
NodeId fromNode = nullNode )

Resolves a node reference to its node.

A relative path is read from the scope holding fromNode, so a bare name finds a sibling and ".." steps out to the scope above.

Parameters
pathA node path such as "grid1", "../grid1", or "/grid1". An empty node path resolves to fromNode itself.
fromNodeThe node a relative path resolves against, nullNode when there is none.
Returns
The node, or null when no node matches the path.

◆ findParameter()

std::weak_ptr< prm::NodeParameter > enzo::nt::Network::findParameter ( const NetworkPath & path,
NodeId fromNode = nullNode )

Resolves a parameter reference to its parameter.

Parameters
pathA parameter path such as "grid1.tx".
fromNodeThe node a path with no node part resolves against, nullNode when there is none.
Returns
The parameter, or an empty handle when nothing matches.

◆ getChildNodeIds()

std::vector< nt::NodeId > enzo::nt::Network::getChildNodeIds ( const Path & scope)

Returns the ids of the nodes living directly inside a scope, in no particular order.

Note
Nodes deeper inside a nested scope are not included.

◆ getNode()

nt::Node & enzo::nt::Network::getNode ( nt::NodeId nodeId)

Returns the node with the given id.

Note
Throws std::out_of_range when no node carries that id.

◆ getNodeAtPath()

nt::Node * enzo::nt::Network::getNodeAtPath ( const Path & path)

Returns the node at an exact path, or null when no node is there.

Note
Takes a resolved absolute path.

◆ getScope()

nt::Scope * enzo::nt::Network::getScope ( const Path & path)

Returns the scope at a path, or null when no scope sits there.

Note
The root scope always exists, so getScope("/") never returns null.

The documentation for this class was generated from the following files: