GraphNode Class Reference

#include <graph.h>

Inheritance diagram for GraphNode:

Detailed Description

A GraphNode represents a general node (g-node for short) in the hierarchy of a GraphModelInterface. There are five different kinds of such a node: It may be a true node, an input or output port or an input port list or output port list. A node may have attributes, and if it is a port, it may be connected to other ports. For a general overview, see GraphModelInterface.

Most functions of GraphNode can be used for all node kinds, some functions are specific for certain kinds (such as Connect which is only supported for ports).

GraphNode holds a strong GraphModelRef reference on the graph, see GetGraph(). The node within the graph is referenced symbolically by a NodePath, see GetPath(). Therefore it is guaranteed for the referenced graph that it exists as long as the GraphNode, but not for the referenced node. Namely, a GraphNode can be in one of three states:

  1. It may be a null value, then it doesn't represent any node. IsNull() returns true in this state.
  2. It may be a valid node in a graph (IsValid() returns true). GetGraph() returns the graph, GetPath() the path of the node, and all supported functions can be called.
  3. It represents a node which doesn't exist any longer. IsValid() returns false, but IsPopulated() still returns true. Also GetGraph() and GetPath() return valid values, but you can't call any functions which would require access to the node. Such a state can be used to identify deleted nodes. A transition between the cases 2 and 3 can happen without this GraphNode being directly involved, namely when the graph is modified through another GraphNode and a node with the path of this GraphNode is added or removed.

Public Member Functions

Bool IsValid () const
 
Bool IsPopulated () const
 
Bool IsInner () const
 
const GraphModelRef & GetGraph () const
 
const NodePath & GetPath () const
 
 operator const NodePath & () const
 
const InternedIdGetId () const
 
NODE_KIND GetKind () const
 
 GraphNode ()=default
 
 ~GraphNode ()
 
 GraphNode (GraphNode &&src)
 
 MAXON_OPERATOR_MOVE_ASSIGNMENT (GraphNode)
 
 GraphNode (const GraphNode &src)
 
 MAXON_OPERATOR_COPY_ASSIGNMENT (GraphNode)
 
void Reset ()
 
Bool operator== (const GraphNode &other) const
 
Bool operator!= (const GraphNode &other) const
 
HashInt GetHashCode () const
 
UniqueHash GetUniqueHashCode () const
 
String ToString (const FormatStatement *fs=nullptr) const
 
const GraphNodeBaseGetBase () const
 
GraphNodeBaseGetBase ()
 
- Public Member Functions inherited from GraphNodeFunctions< Protected< GraphNodeBase > >
 GraphNodeFunctions ()=default
 
 GraphNodeFunctions (ARG &&arg)
 
Result< void > Remove () const
 
Result< BoolGetChildren (const ValueReceiver< const GraphNode & > &callback, NODE_KIND mask=NODE_KIND::ALL_MASK) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeGetParent () const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeGetAncestor (NODE_KIND mask) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeGetInputs () const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeGetOutputs () const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeGetPortList (PORT_DIR dir) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeFindChild (const InternedId &name) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeFindChild (const Id &name) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeFindChild (NODE_KIND mask) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeFindPort (const InternedId &name) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeFindInnerNode (const PathBlock &relativePath) const
 
Result< BoolGetInnerNodes (NODE_KIND mask, Bool includeThis, const ValueReceiver< const GraphNode & > &receiver) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::typeAddPort (const Id &name) const
 
Result< BaseArray< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > > AddPorts (Int index, Int count) const
 
Result< void > RemovePorts (const Block< const InternedId > &ports) const
 
Result< BoolGetConnections (PORT_DIR dir, const ValueReceiver< const GraphConnection & > &conns, Wires mask=Wires::All(), GraphModelInterface::GET_CONNECTIONS_MODE mode=GraphModelInterface::GET_CONNECTIONS_MODE::CONNECTIONS) const
 
Result< WiresGetWires (const GraphNode &target) const
 
Result< BoolGetConnectionValues (const GraphNode &target, const ValueReceiver< CONNECTION_POSITION, InternedId, const ConstDataPtr & > &receiver) const
 
Result< ConstDataPtrGetConnectionValue (const GraphNode &target, CONNECTION_POSITION position, const InternedId &attr, const DataType &expectedType, Bool reverse=false) const
 
Result< Opt< const T & > > GetConnectionValue (const GraphNode &target, CONNECTION_POSITION position, const InternedId &attr, Bool reverse=false) const
 
Result< Opt< const typename ATTR::ValueType & > > GetConnectionValue (const GraphNode &target, CONNECTION_POSITION position, const ATTR &attr, Bool reverse=false) const
 
Result< BoolSetConnectionValue (const GraphNode &target, CONNECTION_POSITION position, const InternedId &attr, ForwardingDataPtr &&value) const
 
Result< BoolSetConnectionValue (const GraphNode &target, CONNECTION_POSITION position, const ATTR &attr, const typename ATTR::ValueType &value) const
 
Result< BoolSetConnectionValue (const GraphNode &target, CONNECTION_POSITION position, const ATTR &attr, typename ATTR::ValueType &&value) const
 
Result< void > Connect (const GraphNode &target, Wires modes=WIRE_MODE::CONNECT_DEFAULT, Bool reverse=false) const
 
Result< void > Connect (const Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > &target, Wires modes=WIRE_MODE::CONNECT_DEFAULT, Bool reverse=false) const
 
Result< void > RemoveConnections (PORT_DIR dir, Wires mask=Wires::All(WIRE_MODE::FULL_MASK)) const
 
Result< BoolIsConnectable (const GraphNode &target) const
 
Result< void > GetValues (GraphAttributeInterface::FLAGS mask, GraphAttributeMap &map) const
 
Result< BoolRemoveValue (const InternedId &attr) const
 
Result< BoolInheritValue (const InternedId &attr) const
 
Result< ConstDataPtrGetValue (const InternedId &attr, const DataType &expectedType) const
 
Result< Opt< const T & > > GetValue (const InternedId &attr) const
 
Result< Opt< const typename ATTR::ValueType & > > GetValue () const
 
Result< Opt< const typename ATTR::ValueType & > > GetValue (const ATTR &attr) const
 
Result< ConstDataPtrGetStoredValue (const InternedId &attr, const DataType &expectedType) const
 
Result< Opt< const typename ATTR::ValueType & > > GetStoredValue () const
 
Result< Opt< const typename ATTR::ValueType & > > GetStoredValue (const ATTR &attr) const
 
Result< BoolGetBaseValues (const InternedId &attr, const DataType &expectedType, const ValueReceiver< const ConstDataPtr &, Int > &valueReceiver) const
 
Result< BoolSetValue (const InternedId &attr, ForwardingDataPtr &&value, Bool checkAndInvalidate=true) const
 
Result< BoolSetValue (const ATTR &attr, const typename ATTR::ValueType &value) const
 
Result< BoolSetValue (const ATTR &attr, typename ATTR::ValueType &&value) const
 
Result< BoolSetValue (const typename ATTR::ValueType &value) const
 
Result< BoolSetValue (typename ATTR::ValueType &&value) const
 
Result< void > TouchValue (const InternedId &attr) const
 
Result< void > ChangeValue (const InternedId &attr, const SubDataOperation &op, const SubDataPathBlock &path, ForwardingDataPtr &&value)
 
Result< BoolSetDefaultValue (T &&value) const
 
Result< const T & > GetDefaultValue (const T &def=maxon::NullValue< const T & >()) const
 
Result< const T & > GetConstantValue (const T &def=maxon::NullValue< const T & >()) const
 
Result< BoolGetAttributeModificationsSince (TimeStamp stamp, const ValueReceiver< InternedId, ConstDataPtr > &receiver) const
 
Result< TimeStampGetAttributeStamp (const InternedId &attr) const
 
Result< TimeStampGetConnectionStamp (PORT_DIR direction) const
 
Result< void > CopyValuesFrom (const GraphNode &source, Bool includeInner) const
 
Result< void > CopyConnectionsFrom (const GraphNode &source, PORT_DIR direction, Bool includeInner) const
 
Result< GraphAttribute::FLAGS > GetMessageFlags (const InternedId &attr) const
 
Result< BoolGetMessages (const InternedId &attr, const ValueReceiver< const GraphMessage & > &receiver) const
 
- Public Member Functions inherited from Protected< SUPER >
template<typename... ARGS>
 __attribute__ ((always_inline)) explicit Protected(ARGS &&... args)
 

Private Types

template<typename SUPER >
using ResultFunctions = GraphNodeFunctions< GraphNodeResultBase< SUPER > >
 

Friends

class GraphNodeBase
 
class GraphModelInterface
 
class GraphNodeFunctions< Protected< GraphNodeBase > >
 
class GraphNodeFunctions< GraphNodeResultBase< ResultBase< GraphNode > > >
 

Member Typedef Documentation

◆ ResultFunctions

Constructor & Destructor Documentation

◆ GraphNode() [1/3]

GraphNode ( )
default

◆ ~GraphNode()

~GraphNode ( )

◆ GraphNode() [2/3]

GraphNode ( GraphNode &&  src)

◆ GraphNode() [3/3]

GraphNode ( const GraphNode src)

Member Function Documentation

◆ IsValid()

Bool IsValid ( ) const

Checks whether this GraphNode points to a valid node. This is not the same as IsPopulated():

  • IsValid() return true if the node is a valid, existing node in the graph.
  • IsPopulated() also returns true for graph nodes which point to non-existing (deleted) nodes. They have a valid graph and path to identify the node, but you can't call any function which would require access to the node.
    Returns
    True if this GraphNode points to a valid node, false if it is a null node or a reference to a deleted node.

◆ IsPopulated()

Bool IsPopulated ( ) const

Checks whether this GraphNode has graph and path references. This is not the same as IsValid(), because IsPopulated() just checks if graph and path are set, but not if the graph really contains a node with the path, see IsValid(). Therefore we also don't have an IsEmpty() counterpart, because it would hide that there are two different functions to check the content of a GraphNode.

Returns
True if this GraphNode has graph and path set, false otherwise.

◆ IsInner()

Bool IsInner ( ) const

Checks if this GraphNode belongs to an inner node of the graph. The root node and its port lists and ports aren't inner nodes, all other nodes are.

Returns
True if this GraphNode is an inner node of the graph.

◆ GetGraph()

const GraphModelRef& GetGraph ( ) const

Returns the graph to which this node belongs.

Returns
Owning graph of this node.

◆ GetPath()

const NodePath& GetPath ( ) const

Returns the path of this node. It is not guaranteed that a node with that path still exists in the graph, to check this use IsValid().

Returns
Path of this node.

◆ operator const NodePath &()

operator const NodePath & ( ) const

Returns the path of this node. It is not guaranteed that a node with that path still exists in the graph, to check this use IsValid().

Returns
Path of this node.

◆ GetId()

const InternedId& GetId ( ) const

Returns the identifier of this node. This is the last part of the path, so it's unique within the siblings of this node, but not within the whole graph.

Returns
Identifier of this node.

◆ GetKind()

NODE_KIND GetKind ( ) const

Returns the kind of this node. This can be used to check whether this node is a true node, a port or a port list, see NODE_KIND and GraphModelInterface.

Returns
Kind of this node.

◆ MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( GraphNode  )

◆ MAXON_OPERATOR_COPY_ASSIGNMENT()

MAXON_OPERATOR_COPY_ASSIGNMENT ( GraphNode  )

◆ Reset()

void Reset ( )

Resets this @CLASS to the state it has right after default construction. This includes freeing all resources held by this @CLASS.

◆ operator==()

Bool operator== ( const GraphNode other) const

Checks if this @CLASS equals other.

Parameters
[in]otherAnother @CLASS.
Returns
True if this equals other, false otherwise.

◆ operator!=()

Bool operator!= ( const GraphNode other) const

Checks if this @CLASS is not equal to other.

Parameters
[in]otherAnother @CLASS.
Returns
True if this is not equal to other, false otherwise.

◆ GetHashCode()

HashInt GetHashCode ( ) const

Returns the hash code of this @CLASS.

Returns
Hash code of this @CLASS.

◆ GetUniqueHashCode()

UniqueHash GetUniqueHashCode ( ) const

Returns the 128-bit hash value of this @CLASS. The implementation ensures uniform distribution, so for practical purposes you can safely assume that two objects are equal if their hash values are equal.

Returns
Hash value of this @CLASS.

◆ ToString()

String ToString ( const FormatStatement fs = nullptr) const

Returns a String representation of this @CLASS.

Parameters
[in]formatStatementNullptr or additional formatting instruction.
Returns
String representation of this @CLASS.

◆ GetBase() [1/2]

const GraphNodeBase& GetBase

Returns this GraphNode, downcasted to its protected base class GraphNodeBase. This function is needed by implementations of GraphModelInterface to access the protected data members of GraphNodeBase.

Returns
OK on success.

◆ GetBase() [2/2]

GraphNodeBase& GetBase

Returns this GraphNode, downcasted to its protected base class GraphNodeBase. This function is needed by implementations of GraphModelInterface to access the protected data members of GraphNodeBase.

Returns
OK on success.

Friends And Related Function Documentation

◆ GraphNodeBase

friend class GraphNodeBase
friend

◆ GraphModelInterface

friend class GraphModelInterface
friend

◆ GraphNodeFunctions< Protected< GraphNodeBase > >

friend class GraphNodeFunctions< Protected< GraphNodeBase > >
friend

◆ GraphNodeFunctions< GraphNodeResultBase< ResultBase< GraphNode > > >