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
 
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 > >::type > GetParent () const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > GetAncestor (NODE_KIND mask) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > GetInputs () const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > GetOutputs () const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > GetPortList (PORT_DIR dir) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > FindChild (const InternedId &name) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > FindChild (const Id &name) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > FindChild (NODE_KIND mask) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > FindInnerNode (const PathBlock &relativePath) const
 
Result< BoolGetInnerNodes (NODE_KIND mask, Bool includeThis, const ValueReceiver< const GraphNode & > &receiver) const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > AddPort (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, 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 typename ATTR::ValueType &value) const
 
Result< BoolSetConnectionValue (const GraphNode &target, CONNECTION_POSITION position, 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 > Connect (const GraphNode &dst, const String &portName)
 
Result< void > Connect (const GraphNode &dst, const Id &portId)
 
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< ConstDataPtrGetStoredValue (const InternedId &attr, const DataType &expectedType) const
 
Result< Opt< const typename ATTR::ValueType & > > GetStoredValue () 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 typename ATTR::ValueType &value, Bool checkAndInvalidate=true) const
 
Result< BoolSetValue (typename ATTR::ValueType &&value, Bool checkAndInvalidate=true) 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
 
Result< BoolIsSelected () const
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > CreateOutputPort (const CString &id, const String &name=String("Output"))
 
Result< typename SFINAEHelper< GraphNode, Protected< GraphNodeBase > >::type > CreateInputPort (const CString &id, const String &name=String("Input"))
 
Result< void > GetDirectPredecessors (const ValueReceiver< const GraphNode & > &callback, NODE_KIND filter=NODE_KIND::NODE) const
 
Result< void > GetAllPredecessors (const ValueReceiver< const GraphNode & > &callback, NODE_KIND filter=NODE_KIND::NODE) const
 
Result< void > GetDirectSuccessors (const ValueReceiver< const GraphNode & > &callback, NODE_KIND filter=NODE_KIND::NODE) const
 
Result< void > GetAllSuccessors (const ValueReceiver< const GraphNode & > &callback, NODE_KIND filter=NODE_KIND::NODE) const
 
Result< BoolIsConnectedTo (const GraphNode &port) const
 
Result< BoolIsConnectedTo (const String &portName) const
 
Result< BoolIsConnectedTo (const Id &portId) const
 
Result< void > MuteConnectionWith (const GraphNode &port)
 
Result< void > MuteConnectionWith (const String &portName)
 
Result< void > MuteConnectionWith (const Id &portId)
 
Result< void > MuteAllConnections (PORT_DIR direction)
 
Result< void > UnmuteConnectionWith (const GraphNode &port)
 
Result< void > UnmuteConnectionWith (const String &portName)
 
Result< void > UnmuteConnectionWith (const Id &portId)
 
Result< void > UnmuteAllConnections (PORT_DIR direction)
 
Result< BoolRemoveAllConnections ()
 
- Public Member Functions inherited from Protected< GraphNodeBase >
 __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 > > >
 

Additional Inherited Members

- Protected Types inherited from GraphNodeBase< NODEDATA, EDGE >
typedef GraphNodeBase< NODEDATA, EDGE > NodeType
 
- Protected Member Functions inherited from GraphNodeBase< NODEDATA, EDGE >
const GraphNodeGetGraphNode () const
 
GraphModelInterfacePrivateGetGraph () const
 
const ThreadReferencedErrorGetErrorStorage () const
 
 GraphNodeBase ()
 
 GraphNodeBase (const NODEDATA &data, Vector pos=Vector())
 
 ~GraphNodeBase ()
 
 GraphNodeBase (GraphNodeBase &&src)
 
Result< void > CopyFrom (const GraphNodeBase &src)
 
Vector GetPosition () const
 
void SetPosition (const Vector &pos)
 
Int GetEdgesCount () const
 
Result< EDGE * > GetEdge (Int pos) const
 
Result< NodeType * > GetNeighbor (Int pos) const
 
Result< EDGE * > FindEdge (NodeType *otherHand)
 
Result< void > AddEdge (EDGE *edge)
 
Result< void > DeleteEdge (Int32 pos)
 
Result< void > DeleteEdge (EDGE *edge)
 
const NODEDATA * GetData () const
 
Result< void > SetData (const NODEDATA &data)
 
void Visit ()
 
void Unvisit ()
 
Bool IsVisited () const
 
void Reset ()
 
const GraphNodeBaseGetBase () const
 
GraphNodeBaseGetBase ()
 
- Protected Attributes inherited from GraphNodeBase< NODEDATA, EDGE >
NODEDATA _data
 
Vector _pos
 
Bool _visited
 
BaseArray< EDGE * > _edges
 
GraphModelRef _graph
 
Int _mem [MEMCOUNT]
 
- Static Protected Attributes inherited from GraphNodeBase< NODEDATA, EDGE >
static const Int MEMCOUNT
 

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.

◆ 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 > > >