HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_Node Class Reference

#include <UN_Node.h>

+ Inheritance diagram for UN_Node:

Public Member Functions

 UN_Node ()=default
 Constructs a handle for an invalid node. More...
 
 UN_Node (UN_GraphData *graph_data, UN_NodeID node_id)
 Constructs a handle referencing the given node in the given graph. More...
 
UN_Graph graph () const
 Returns the graph within which this node exists. More...
 
void setName (const UT_StringRef &name) const
 Sets the node name that differentiates it among its siblings. More...
 
void setTypeName (const UT_StringRef &type_name) const
 Sets the node's type that determines its functional behavour. More...
 
void setSignature (const UT_StringRef &signature_name) const
 Sets the signature on the node. More...
 
void setComment (const UT_StringRef &comment) const
 Sets the comment on the node. The comment can show up in network editor. More...
 
void setPosition (const UT_Vector2D &position) const
 Sets the node's location. Used for the node position in network editor. More...
 
void setColor (const UT_Color &color) const
 Sets the node's color. The color is used in network editor. More...
 
void setTags (const UT_StringArray &tags) const
 Sets the tags for the node (copy-assignment). More...
 
void setTags (UT_StringArray &&tags) const
 Sets the tags for the node (move-assignment). More...
 
UT_StringArray stealTags () const
 
template<typename OP >
void updateTags (const OP &op) const
 
void setMetadata (const UN_MetadataHolder &metadata) const
 Sets the metadata for the node (copy-assignment). More...
 
void setMetadata (UN_MetadataHolder &&metadata) const
 Sets the metadata for the node (move-assignment). More...
 
UN_MetadataHolder stealMetadata () const
 Returns the metadata moved out of the node. More...
 
template<typename OP >
void updateMetadata (const OP &op) const
 
void updateMetadata (const UT_StringHolder &key, UT_OptionEntryPtr &&value)
 Simpler method to update a single metadata value in-place. More...
 
void destroy () const
 Deletes this node from the graph. More...
 
UN_Parm createParm (const UT_StringRef &parm_name, const UT_StringRef &parm_type_name=UN_UNDEFINED_PARM_TYPE_NAME.asRef()) const
 
UN_Port createPort (UN_PortKind port_kind, const UT_StringRef &port_name=UT_StringRef(), const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef(), const UT_Optional< exint > &index=std::nullopt) const
 
UN_Port findOrCreatePort (UN_PortKind port_kind, const UT_StringRef &port_name, const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef()) const
 
UN_Port createInputPort (const UT_StringRef &port_name=UT_StringRef(), const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef(), const UT_Optional< exint > &index=std::nullopt) const
 
UN_Port findOrCreateInputPort (const UT_StringRef &port_name, const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef()) const
 
UN_Port createOutputPort (const UT_StringRef &port_name=UT_StringRef(), const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef(), const UT_Optional< exint > &index=std::nullopt) const
 
UN_Port findOrCreateOutputPort (const UT_StringRef &port_name, const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef()) const
 
UN_Node createChildNode (const UT_StringRef &child_name=UT_StringRef(), const UT_StringRef &child_type=UT_StringRef(), const UT_StringRef &child_category=UT_StringRef()) const
 Creates and returns a new node that is a child of this node. More...
 
void deleteChildNode (const UT_StringRef &child_name) const
 Deletes the child node from the graph (removing it from this network). More...
 
UN_StickyNote createChildStickyNote (const UT_StringRef &note_name=UT_StringRef(), const UT_StringRef &note_text=UT_StringRef()) const
 Creates and returns a new sticky note that is a child of this node. More...
 
void deleteChildStickyNote (const UT_StringRef &sticky_note_name) const
 
void setFromOptions (const UN_Options &node_opts) const
 Configure the node based on the given options. More...
 
bool operator== (const UN_Node &other) const
 Comparison operators. More...
 
bool operator!= (const UN_Node &other) const
 Comparison operators. More...
 
- Public Member Functions inherited from UN_NodeBase< UN_Handle, UN_GraphData, UN_Node, UN_Parm, UN_Port, UN_StickyNote, UN_Wire >
UN_NodeID nodeID () const
 Returns the unique ID of the node this handle refers to. More...
 
UN_Node parent () const
 
UN_Node nonRootParent () const
 
const UT_StringHoldername () const
 Returns the node name that differentiates it among its siblings. More...
 
const UT_StringHoldertypeName () const
 Returns the node's type that determines its functional behavour. More...
 
const UT_StringHoldercategoryName () const
 
const UT_StringHoldersignatureName () const
 Returns the signature for the node. More...
 
UT_StringHolder path () const
 Returns the node path. More...
 
const UT_StringHoldercomment () const
 Returns the comment for the node. More...
 
const UT_Vector2Dposition () const
 Returns the node's position in the node editor. More...
 
const UT_Colorcolor () const
 Returns the node's color. More...
 
const UT_StringArraytags () const
 Returns the node's tags. More...
 
const UN_MetadataHoldermetadata () const
 Returns the node's metadata. More...
 
UT_Array< UT_StringHolderparmNames () const
 Returns the names of the node parameters. More...
 
UT_Array< UT_StringHolderparmTypeNames () const
 Returns the type names of the node parameters. More...
 
UN_Parm findParm (const UT_StringRef &parm_name) const
 Returns a parameter by the given name, or an invalid parm if not found. More...
 
ParmRange parmRange () const
 Returns a range for iterating over node parameters. More...
 
UT_Array< UN_Parmparms () const
 Returns the parameters of this node. More...
 
UT_Array< UT_StringHolderportNames (UN_PortKind port_kind) const
 Returns the names of the node ports of a given kind. More...
 
UT_Array< UT_StringHolderportTypeNames (UN_PortKind port_kind) const
 Returns the type names of the node ports of a given kind. More...
 
UN_Port findPort (UN_PortKind port_kind, const UT_StringRef &port_name) const
 
PortRange portRange (UN_PortKind port_kind) const
 
PortReverseRange portReverseRange (UN_PortKind port_kind) const
 
UT_Array< UN_Portports (UN_PortKind port_kind) const
 Returns this node's ports of the given kind. More...
 
bool isAnyInputPortConnectedToSrc () const
 
UT_Array< UT_StringHolderinputPortNames () const
 Returns the names of the node input ports. More...
 
UT_Array< UT_StringHolderinputPortTypeNames () const
 Returns the type names of the node input ports. More...
 
UN_Port findInputPort (const UT_StringRef &port_name) const
 
PortRange inputPortRange () const
 
PortReverseRange inputPortReverseRange () const
 
UT_Array< UN_PortinputPorts () const
 Returns this node's input ports of the given kind. More...
 
bool isAnyOutputPortConnectedToDst () const
 
UT_Array< UT_StringHolderoutputPortNames () const
 Returns the names of the node output ports. More...
 
UT_Array< UT_StringHolderoutputPortTypeNames () const
 Returns the type names of the node output ports. More...
 
UN_Port findOutputPort (const UT_StringRef &port_name) const
 
PortRange outputPortRange () const
 
PortReverseRange outputPortReverseRange () const
 
UT_Array< UN_PortoutputPorts () const
 Returns this node's output ports of the given kind. More...
 
UT_StringHolder findValidUniqueChildNodeName (const UT_StringRef &child_name) const
 Returns a node name that is not taken by any of this nodes' children. More...
 
bool isSubnet () const
 Returns true if the node can have child nodes inside. More...
 
UT_Array< UT_StringHolderchildNodeNames () const
 Returns the names of the node children nodes. More...
 
UN_Node findChildNode (const UT_StringRef &child_name) const
 
UN_Node findNode (const UT_StringRef &node_path) const
 
ChildNodeRange childNodeRange () const
 Returns a range for iterating over node's immediate children. More...
 
UT_Array< UN_NodechildNodes () const
 Returns the children nodes directly inside this node. More...
 
DescendantNodeRange descendantNodeRange () const
 
ChildWireRange childWireRange () const
 
UT_Array< UN_WirechildWires () const
 
DescendantWireRange descendantWireRange () const
 
UN_StickyNote findChildStickyNote (const UT_StringRef &child_name) const
 
UT_Array< UN_StickyNotechildStickyNotes () const
 Returns the child sticky notes directly inside this node. More...
 
UN_OptionsPtr asOptions () const
 
UN_GraphDatagraphData () const
 Returns the owner of the underlying graph data structures. More...
 
const UN_GraphDataconstGraphData () const
 Returns the owner of the underlying graph data structures. More...
 
bool isValid () const
 Returns true if this node is valid within the graph; false otherwise. More...
 
 operator bool () const
 Returns true if this node is valid within the graph; false otherwise. More...
 
- Public Member Functions inherited from UN_Handle
 UN_Handle ()
 Constructs a reference handle for an invalid entity in the graph. More...
 
 UN_Handle (UN_GraphData *graph_data, UN_DataID data_id)
 Constructs reference handle to the data for a given entity in the graph. More...
 
UN_GraphDatagraphData () const
 Returns the graph that owns, manages, and operates on the data object. More...
 
const UN_GraphDataconstGraphData () const
 Returns the graph that owns, manages, and operates on the data object. More...
 
- Public Member Functions inherited from UN_ConstHandle
 UN_ConstHandle ()
 Constructs a reference handle for an invalid entity in the graph. More...
 
 UN_ConstHandle (const UN_GraphData *graph_data, UN_DataID data_id)
 Constructs reference handle to the data for a given entity in the graph. More...
 
UN_DataID dataID () const
 
const UN_GraphDatagraphData () const
 Returns the underlying graph data object. More...
 
const UN_GraphDataconstGraphData () const
 Returns the underlying graph data object. More...
 

Additional Inherited Members

- Public Types inherited from UN_NodeBase< UN_Handle, UN_GraphData, UN_Node, UN_Parm, UN_Port, UN_StickyNote, UN_Wire >
using ParmIterator = UN_HandleIterator< UN_Parm, UN_GraphData, UN_NodeUtils::ParmIterator >
 An iterator and a range for parameters that belong to this node. More...
 
using ParmRange = UT_IteratorRange< ParmIterator >
 
using PortIterator = UN_HandleIterator< UN_Port, UN_GraphData, UN_NodeUtils::PortIterator >
 And iterator and a range for ports that belong to this node. More...
 
using PortRange = UT_IteratorRange< PortIterator >
 
using PortReverseIterator = UN_HandleIterator< UN_Port, UN_GraphData, UN_NodeUtils::PortReverseIterator >
 And iterator and a range for ports that belong to this node. More...
 
using PortReverseRange = UT_IteratorRange< PortReverseIterator >
 
using ChildNodeIterator = UN_HandleIterator< UN_Node, UN_GraphData, UN_NodeUtils::ChildNodeIterator >
 An iterator and a range for the children of this parent node. More...
 
using ChildNodeRange = UT_IteratorRange< ChildNodeIterator >
 
using DescendantNodeIterator = UN_HandleIterator< UN_Node, UN_GraphData, UN_NodeUtils::DescendantNodeIterator >
 
using DescendantNodeRange = UT_IteratorRange< DescendantNodeIterator >
 
using ChildWireIterator = UN_HandleIterator< UN_Wire, UN_GraphData, UN_NodeUtils::ChildWireIterator >
 
using ChildWireRange = UT_IteratorRange< ChildWireIterator >
 
using DescendantWireIterator = UN_HandleIterator< UN_Wire, UN_GraphData, UN_NodeUtils::DescendantWireIterator >
 
using DescendantWireRange = UT_IteratorRange< DescendantWireIterator >
 
- Protected Member Functions inherited from UN_NodeBase< UN_Handle, UN_GraphData, UN_Node, UN_Parm, UN_Port, UN_StickyNote, UN_Wire >
 UN_NodeBase ()=default
 Constructs a handle for an invalid node. More...
 
 UN_NodeBase (UN_GraphData *graph_data, UN_NodeID node_id)
 Constructs a handle that references the given node in the given graph. More...
 
- Protected Member Functions inherited from UN_ConstHandle
bool isNumericallyValid () const
 
bool operator== (const UN_ConstHandle &other) const
 
bool operator!= (const UN_ConstHandle &other) const
 

Detailed Description

A handle that references a mutable node in a graph. It abstracts the APIs that operate on this node's data, which is stored inside graph's data containers. It is a non-const (read-write) handle, so allows both queries and mutations of the node's data.

Definition at line 524 of file UN_Node.h.

Constructor & Destructor Documentation

UN_Node::UN_Node ( )
default

Constructs a handle for an invalid node.

UN_Node::UN_Node ( UN_GraphData graph_data,
UN_NodeID  node_id 
)
inline

Constructs a handle referencing the given node in the given graph.

Definition at line 532 of file UN_Node.h.

Member Function Documentation

UN_Node UN_Node::createChildNode ( const UT_StringRef child_name = UT_StringRef(),
const UT_StringRef child_type = UT_StringRef(),
const UT_StringRef child_category = UT_StringRef() 
) const
inline

Creates and returns a new node that is a child of this node.

Definition at line 757 of file UN_Node.h.

UN_StickyNote UN_Node::createChildStickyNote ( const UT_StringRef note_name = UT_StringRef(),
const UT_StringRef note_text = UT_StringRef() 
) const
inline

Creates and returns a new sticky note that is a child of this node.

Definition at line 774 of file UN_Node.h.

UN_Port UN_Node::createInputPort ( const UT_StringRef port_name = UT_StringRef(),
const UT_StringRef port_type_name = UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
const UT_StringRef port_label = UT_StringRef(),
const UT_Optional< exint > &  index = std::nullopt 
) const
inline

Adds and returns a new input port to this node. If another input port of a given name already exists, returns an invalid port, indicating a failure because of the name collision.

Definition at line 705 of file UN_Node.h.

UN_Port UN_Node::createOutputPort ( const UT_StringRef port_name = UT_StringRef(),
const UT_StringRef port_type_name = UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
const UT_StringRef port_label = UT_StringRef(),
const UT_Optional< exint > &  index = std::nullopt 
) const
inline

Adds and returns a new output port to this node. If another outupt port of a given name already exists, returns an invalid port, indicating a failure because of the name collision.

Definition at line 732 of file UN_Node.h.

UN_Parm UN_Node::createParm ( const UT_StringRef parm_name,
const UT_StringRef parm_type_name = UN_UNDEFINED_PARM_TYPE_NAME.asRef() 
) const
inline

Adds and returns a new parameter to this node. If another parameter of a given name already exists, returns an invalid parameter, indicating a failure because of the name collision.

Definition at line 662 of file UN_Node.h.

UN_Port UN_Node::createPort ( UN_PortKind  port_kind,
const UT_StringRef port_name = UT_StringRef(),
const UT_StringRef port_type_name = UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
const UT_StringRef port_label = UT_StringRef(),
const UT_Optional< exint > &  index = std::nullopt 
) const
inline

Adds a new port to this node and returns it. If another port of a given kind and name already exists, returns an invalid port, indicating a failure because of the name collision.

Definition at line 675 of file UN_Node.h.

void UN_Node::deleteChildNode ( const UT_StringRef child_name) const
inline

Deletes the child node from the graph (removing it from this network).

Definition at line 768 of file UN_Node.h.

void UN_Node::deleteChildStickyNote ( const UT_StringRef sticky_note_name) const
inline

Deletes the child sticky note from the graph (removing it from this network).

Definition at line 785 of file UN_Node.h.

void UN_Node::destroy ( ) const
inline

Deletes this node from the graph.

Definition at line 653 of file UN_Node.h.

UN_Port UN_Node::findOrCreateInputPort ( const UT_StringRef port_name,
const UT_StringRef port_type_name = UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
const UT_StringRef port_label = UT_StringRef() 
) const
inline

Returns an existing input port by the given name, or creates one (with the given type and label) if not found.

Definition at line 718 of file UN_Node.h.

UN_Port UN_Node::findOrCreateOutputPort ( const UT_StringRef port_name,
const UT_StringRef port_type_name = UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
const UT_StringRef port_label = UT_StringRef() 
) const
inline

Returns an existing output port by the given name, or creates one (with the given type and label) if not found.

Definition at line 745 of file UN_Node.h.

UN_Port UN_Node::findOrCreatePort ( UN_PortKind  port_kind,
const UT_StringRef port_name,
const UT_StringRef port_type_name = UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
const UT_StringRef port_label = UT_StringRef() 
) const
inline

Returns an existing port by the given name, or creates one (with the given type and label) if not found.

Definition at line 690 of file UN_Node.h.

UN_Graph UN_Node::graph ( ) const

Returns the graph within which this node exists.

bool UN_Node::operator!= ( const UN_Node other) const
inline

Comparison operators.

Definition at line 542 of file UN_Node.h.

bool UN_Node::operator== ( const UN_Node other) const
inline

Comparison operators.

Definition at line 540 of file UN_Node.h.

void UN_Node::setColor ( const UT_Color color) const
inline

Sets the node's color. The color is used in network editor.

Definition at line 582 of file UN_Node.h.

void UN_Node::setComment ( const UT_StringRef comment) const
inline

Sets the comment on the node. The comment can show up in network editor.

Definition at line 570 of file UN_Node.h.

void UN_Node::setFromOptions ( const UN_Options node_opts) const
inline

Configure the node based on the given options.

Definition at line 792 of file UN_Node.h.

void UN_Node::setMetadata ( const UN_MetadataHolder metadata) const
inline

Sets the metadata for the node (copy-assignment).

Definition at line 618 of file UN_Node.h.

void UN_Node::setMetadata ( UN_MetadataHolder &&  metadata) const
inline

Sets the metadata for the node (move-assignment).

Definition at line 624 of file UN_Node.h.

void UN_Node::setName ( const UT_StringRef name) const
inline

Sets the node name that differentiates it among its siblings.

Definition at line 552 of file UN_Node.h.

void UN_Node::setPosition ( const UT_Vector2D position) const
inline

Sets the node's location. Used for the node position in network editor.

Definition at line 576 of file UN_Node.h.

void UN_Node::setSignature ( const UT_StringRef signature_name) const
inline

Sets the signature on the node.

Definition at line 564 of file UN_Node.h.

void UN_Node::setTags ( const UT_StringArray tags) const
inline

Sets the tags for the node (copy-assignment).

Definition at line 588 of file UN_Node.h.

void UN_Node::setTags ( UT_StringArray &&  tags) const
inline

Sets the tags for the node (move-assignment).

Definition at line 594 of file UN_Node.h.

void UN_Node::setTypeName ( const UT_StringRef type_name) const
inline

Sets the node's type that determines its functional behavour.

Definition at line 558 of file UN_Node.h.

UN_MetadataHolder UN_Node::stealMetadata ( ) const
inline

Returns the metadata moved out of the node.

Definition at line 630 of file UN_Node.h.

UT_StringArray UN_Node::stealTags ( ) const
inline

Returns the tags moved out of the node. This is useful in combination with rvalue ref version of setTags() to optimize the edits to the tag list.

Definition at line 602 of file UN_Node.h.

template<typename OP >
void UN_Node::updateMetadata ( const OP &  op) const
inline

Sets metadata in-place, which is faster than setting whole dictionary. Intended usage: n.updateTags([&value](auto &m) { m.set("key", value) });

Definition at line 639 of file UN_Node.h.

void UN_Node::updateMetadata ( const UT_StringHolder key,
UT_OptionEntryPtr &&  value 
)
inline

Simpler method to update a single metadata value in-place.

Definition at line 645 of file UN_Node.h.

template<typename OP >
void UN_Node::updateTags ( const OP &  op) const
inline

Sets tags in-place, which is faster than setting the whole dictionary. Intended usage: n.updateTags([&value](auto &t) { t.set("key", value) });

Definition at line 611 of file UN_Node.h.


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