NodeFunctions< BASE > Class Template Reference

#include <nodesystem.h>

Inheritance diagram for NodeFunctions< BASE >:

Detailed Description

template<typename BASE>
class maxon::nodes::NodeFunctions< BASE >

This class template contains the functions of Node which shall also be available on Result<Node> (and likewise for MutableNode).

Public Types

using Iterator = GNodeIterator< NodeSelector< BASE::MUTABLE > >
 
template<typename SUPER >
using ResultFunctions = NodeFunctions< maxon::nodes::details::GNodeResultBase< SUPER > >
 
using Super = maxon::nodes::details::NodeFunctionsSuper< BASE >
 

Public Member Functions

Result< NodeSelector< BASE::MUTABLE > > GetParent () const
 
Result< NodeSelector< BASE::MUTABLE > > FindChild (const InternedId &name) const
 
Result< NodeSelector< BASE::MUTABLE > > FindChild (const Id &name) const
 
template<typename NODE >
Result< typename NODE::template Selector< BASE::MUTABLE > > FindInnerNode (const NODE &baseInner) const
 
Result< PortListSelector< BASE::MUTABLE > > GetPortList (PORT_DIR dir) const
 
Result< PortListSelector< BASE::MUTABLE > > GetInputs () const
 
Result< PortListSelector< BASE::MUTABLE > > GetOutputs () const
 
Result< IteratorGetChildren () const
 
template<typename PATH >
Result< void > InitFromPath (typename maxon::nodes::details::NodeFunctionsSuper< BASE >::NodeSystemCtorParam system, PATH &&path)
 

Private Types

template<Bool MUT>
using Selector = NodeSelector< MUT >
 

Static Private Attributes

static const NODE_KIND KIND_MASK
 

Member Typedef Documentation

◆ Iterator

using Iterator = GNodeIterator<NodeSelector<BASE::MUTABLE> >

A GNodeIterator iterates over all children of a g-node. It is returned by NodeFunctions::GetChildren and PortListFunctions::GetPorts. Because both creation and iterator advance can return errors, the iteration doesn't provide the node of the current iteration directly, but wrapped in a Result. Therefore you have to write the loop as follows:

for (auto p : portlist.GetPorts())
{
const Port& port = p iferr_return;
...
}
unsigned char * p
Definition: floatobject.h:87
#define iferr_return
Definition: resultbase.h:1524
Template Parameters
NODEThe node class over which the iterator loops (e.g. Node or MutablePort).

◆ Selector

using Selector = NodeSelector<MUT>
private

◆ ResultFunctions

◆ Super

Member Function Documentation

◆ GetParent()

Result<NodeSelector<BASE::MUTABLE> > GetParent ( ) const

Returns the parent node of this node. If this node is null or a root node, a null reference is returned.

Returns
Parent node.

◆ FindChild() [1/2]

Result<NodeSelector<BASE::MUTABLE> > FindChild ( const InternedId name) const

Finds the direct child node with the given identifier. If this node is null or if there is not exactly one such child, a null reference. This function only searches for true nodes, but not for port lists.

Parameters
[in]nameIdentifier of the child node to find.
Returns
Found node or a null reference.

◆ FindChild() [2/2]

Result<NodeSelector<BASE::MUTABLE> > FindChild ( const Id name) const

Finds the direct child node with the given identifier. If this node is null or if there is not exactly one such child, a null reference. This function only searches for true nodes, but not for port lists.

Parameters
[in]nameIdentifier of the child node to find.
Returns
Found node or a null reference.

◆ FindInnerNode()

Result<typename NODE::template Selector<BASE::MUTABLE> > FindInnerNode ( const NODE &  baseInner) const

Returns a reference to the nested g-node which corresponds to the given nested g-node of a base of this node. #baseInner has to refer to a node which is nested within a base of this node. For example consider the following graph: @graph +-C-------------—+ +-B---------—+ | +-m---------—+ | +-A-----—+ | +-n-----—+ | | | +-n-----—+ | | o port | | o port | | | | o port | | | | |<- - - -| | |<- - - -| | | | | +-------—+ | +-------—+ | | | +-------—+ | | +-----------—+ | +-----------—+ | +---------------—+ @endgraph The nested node m/n of node system C has the root node of node system A as its base (via the intermediate base n of B). The root node of A has port as a nested g-node, and the corresponding nested g-node of m/n is the port nested within m/n:

Port port = ...; // port of A
Node n = ...; // node m/n of C
Port portInN = n.FindInnerNode(port) iferr_return; // returns reference to port within m/n
const Py_UNICODE size_t n
Definition: unicodeobject.h:1184
Parameters
[in]baseInnerInner node of the base of this node.
Returns
Found node or a null reference.

◆ GetPortList()

Result<PortListSelector<BASE::MUTABLE> > GetPortList ( PORT_DIR  dir) const

Returns the input or output port list of this node, depending on dir.

See also
$ref usernodes_nodes
Parameters
[in]dirPORT_DIR::INPUT to return the input port list, PORT_DIR::OUTPUT to return the output port list.
Returns
Port list of this node.

◆ GetInputs()

Result<PortListSelector<BASE::MUTABLE> > GetInputs ( ) const

Returns the input port list of this node. All top-level input ports of a node can be found as children of its input port list.

See also
$ref usernodes_nodes
Returns
Input port list of this node.

◆ GetOutputs()

Result<PortListSelector<BASE::MUTABLE> > GetOutputs ( ) const

Returns the output port list of this node. All top-level output ports of a node can be found as children of its output port list.

See also
$ref usernodes_nodes
Returns
Output port list of this node.

◆ GetChildren()

Result<Iterator> GetChildren ( ) const

Returns an iterator over the child nodes of this node. This does only include true nodes, but not the input/output port lists.

for (auto c : node.GetChildren())
{
Node child = c iferr_return;
...
}
Py_UNICODE c
Definition: unicodeobject.h:1200
Definition: node.h:10
See also
$ref usernodes_nodes
Returns
Iterator over the children of this node.

◆ InitFromPath()

Result<void> InitFromPath ( typename maxon::nodes::details::NodeFunctionsSuper< BASE >::NodeSystemCtorParam  system,
PATH &&  path 
)

Initializes a node reference from a node system and a path. If there's no node in the node system for the given path, this reference is set to a null reference.

Parameters
[in]systemThe node system to use.
[in]pathA path which points to a node in the given node system.
Returns
Usually OK (even when path doesn't exist), but an IllegalArgumentError if path exists but doesn't point to a true node.

Member Data Documentation

◆ KIND_MASK

const NODE_KIND KIND_MASK
staticprivate