PortListFunctions< BASE > Class Template Reference

#include <nodesystem.h>

Inheritance diagram for PortListFunctions< BASE >:

Detailed Description

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

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

Public Types

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

Public Member Functions

PORT_DIR GetPortDirection () const
 
Result< NodeSelector< BASE::MUTABLE > > GetNode () const
 
Result< IteratorGetPorts () const
 
Result< PortSelector< BASE::MUTABLE > > GetSinglePort () const
 
Result< PortSelector< BASE::MUTABLE > > FindPort (const InternedId &port) const
 
Result< PortSelector< BASE::MUTABLE > > FindPort (const Id &port) const
 
template<typename PATH >
Result< void > InitFromPath (typename maxon::nodes::details::NodeFunctionsSuper< BASE >::NodeSystemCtorParam system, PATH &&path, NODE_KIND check=NODE_KIND::PORTLIST_MASK|NODE_KIND::PORT_MASK)
 

Private Types

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

Static Private Attributes

static const NODE_KIND KIND_MASK
 

Member Typedef Documentation

◆ Iterator

using Iterator = GNodeIterator<PortSelector<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:1519
Template Parameters
NODEThe node class over which the iterator loops (e.g. Node or MutablePort).

◆ Selector

using Selector = PortListSelector<MUT>
private

◆ ResultFunctions

◆ Super

Member Function Documentation

◆ GetPortDirection()

PORT_DIR GetPortDirection ( ) const

Returns the direction of this port or port list (either PORT_DIR::INPUT or PORT_DIR::OUTPUT).

Returns
Direction of this port or port list.

◆ GetNode()

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

Returns the enclosing (true) node to which this port list or port belongs.

Returns
The enclosing node of this port list or port.

◆ GetPorts()

Result<Iterator> GetPorts ( ) const

Returns an iterator over the ports of this port list. This does only include direct children, but not nested ports.

for (auto p : portlist.GetPorts())
{
const Port& port = p iferr_return;
...
}
See also
$ref usernodes_nodes
Returns
Iterator over the ports of this port list.

◆ GetSinglePort()

Result<PortSelector<BASE::MUTABLE> > GetSinglePort ( ) const

Returns the single port of this port list. If this port list does not have exactly one port, an error is returned.

Returns
Single port of this port list.

◆ FindPort() [1/2]

Result<PortSelector<BASE::MUTABLE> > FindPort ( const InternedId port) const

Finds the port with the given identifier. Returns a null reference if no such port exists.

Parameters
[in]portThe identifier to search for.
Returns
Reference to the found port, or a null reference when there is no matching port.

◆ FindPort() [2/2]

Result<PortSelector<BASE::MUTABLE> > FindPort ( const Id port) const

Finds the port with the given identifier. Returns a null reference if no such port exists.

Parameters
[in]portThe identifier to search for.
Returns
Reference to the found port, or a null reference when there is no matching port.

◆ InitFromPath()

Result<void> InitFromPath ( typename maxon::nodes::details::NodeFunctionsSuper< BASE >::NodeSystemCtorParam  system,
PATH &&  path,
NODE_KIND  check = NODE_KIND::PORTLIST_MASK | NODE_KIND::PORT_MASK 
)

Initializes a g-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. If a node exists but its kind doesn't match the check mask, an IllegalArgumentError is returned.

Parameters
[in]systemThe node system to use.
[in]pathA path which points to a g-node in the given node system.
[in]checkA mask of the expected node kind(s).
Returns
Usually OK (even when path doesn't exist), but an IllegalArgumentError if path exists but doesn't match check.

Member Data Documentation

◆ KIND_MASK

const NODE_KIND KIND_MASK
staticprivate