GNodeFunctions< BASE > Class Template Reference

#include <nodesystem.h>

Inheritance diagram for GNodeFunctions< BASE >:

Detailed Description

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

This class template contains the functions of a general g-node which shall also be available on Result<NODE>.

Public Member Functions

Bool IsPort () const
 
const PortSelector< BASE::MUTABLE > & ToPort () const
 
Result< void > GetValues (GraphAttribute::FLAGS mask, GraphAttributeMap &attribs, Bool includeInherited=true, Bool includeRemoved=false) const
 
Result< ConstDataPtrGetValue (const InternedId &attr, const DataType &expectedType) const
 
Result< ConstDataPtrGetValue (const InternedId &attr, const DataType &expectedType, Int &nesting, Bool negativeRootNesting=false) const
 
template<typename T >
Result< Opt< const T & > > GetValue (const InternedId &attr) const
 
template<typename ATTR >
Result< Opt< const typename ATTR::ValueType & > > GetValue (const ATTR &attr) const
 
template<typename ATTR >
Result< Opt< const typename ATTR::ValueType & > > GetValue () const
 
template<typename ATTR >
Result< Opt< const typename ATTR::ValueType & > > GetValue (const ATTR &attr, Int &nesting) const
 
Result< BoolGetBaseValues (const InternedId &attr, const DataType &expectedType, const ValueReceiver< const ConstDataPtr &, Int > &receiver) const
 
template<typename T >
Result< const T & > GetDefaultValue (const T &def=maxon::NullValue< const T & >()) const
 
template<typename T >
Result< const T & > GetConstantValue (const T &def=maxon::NullValue< const T & >()) const
 
Result< BoolGetAttributeModificationsSince (TimeStamp stamp, const ValueReceiver< InternedId, ConstDataPtr > &receiver) const
 
TimeStamp GetAttributeStamp (const InternedId &attr) const
 
Result< NodeSelector< BASE::MUTABLE > > GetNode () const
 
Result< GNodeSelector< BASE::MUTABLE > > GetParent () const
 
Result< GNodeSelector< BASE::MUTABLE > > FindChild (const InternedId &name, NODE_KIND mask) const
 
template<typename NODE >
Result< typename NODE::template Selector< BASE::MUTABLE > > FindInnerNode (const PathBlock &relativePath) const
 
Result< BoolGetInnerNodes (NODE_KIND mask, Bool includeThis, const ValueReceiver< const GNodeSelector< BASE::MUTABLE > & > &receiver) const
 
const NodeSystemGetBase () const
 
const Block< const NodeSystem > & GetBases () const
 
Result< BoolGetAllBases (const ValueReceiver< const NodeSystem & > &receiver) const
 
const NodeTemplate & GetTemplate () const
 
Result< BoolGetAllTemplates (const ValueReceiver< const NodeTemplate & > &receiver) const
 
const NodeSystemDerivationHandler & GetDerivationHandler () const
 

Protected Types

using Super = BASE
 

Member Typedef Documentation

◆ Super

using Super = BASE
protected

Member Function Documentation

◆ IsPort()

Bool IsPort ( void  ) const

Checks whether this reference addresses a port or a port list. PortList is a base class of Port, so a PortList reference may actually refer to a port.

Returns
True if this reference points to a port, false if it points to a port list.

◆ ToPort()

const PortSelector<BASE::MUTABLE>& ToPort ( ) const

Downcasts this reference to a port reference. This function may only be invoked if this reference really points to a port and not just to a port list (see IsPort()), otherwise the behaviour is undefined.

Returns
This reference, cast to a port reference.

◆ GetValues()

Result<void> GetValues ( GraphAttribute::FLAGS  mask,
GraphAttributeMap attribs,
Bool  includeInherited = true,
Bool  includeRemoved = false 
) const

Collects all attribute values which are defined for this g-node in #attribs. This includes values which are set at the node itself, but also values which are inherited from a base node unless they have been marked as removed by MutableGNode::RemoveValue().

Parameters
[in]maskA mask to filter the attributes which shall be added to attribs. The mask filter is split into two parts: You have to set at least one of the flags from GraphAttribute::FLAGS::TYPE_MASK to determine which attribute types shall be taken into account at all. Optionally you can add further flags, then these have to be matched too.
[in]attribsThe map to write the values to.
[in]includeInheritedUse true if attributes inherited from base node systems shall be added (the default).
[in]includeRemovedUse true if removed attributes shall be added, too (false by default, the corresponding attribute value to signal a removed attribute is empty).
Returns
OK on success.

◆ GetValue() [1/6]

Result<ConstDataPtr> GetValue ( const InternedId attr,
const DataType expectedType 
) const

Returns a pointer to the value of #attr at this g-node. The value may be defined at this node itself or at one of its bases. If no value is found or the found value doesn't match the expectedType, nullptr is returned.

Parameters
[in]attrThe attribute whose value shall be obtained.
[in]expectedTypeThe expected type of the value. May be nullptr, then no type-check is done.
Returns
Pointer to the value of #attr (to be cast to the type of #attr), or nullptr if this g-node has no value for the attribute.

◆ GetValue() [2/6]

Result<ConstDataPtr> GetValue ( const InternedId attr,
const DataType expectedType,
Int nesting,
Bool  negativeRootNesting = false 
) const

Returns a pointer to the value of #attr at this g-node. The value may be defined at this node itself or at one of its bases. If no value is found or the found value doesn't match the expectedType, nullptr is returned.

Compared to the basic GetValue function this function has an additional output parameter nesting. If a value is found, the nesting of the node system which contained the value is written to nesting. For example if the attribute value is defined at a node system which is a child of the root node system, the nesting is 1. If it's a child of a child the nesting is 2. However if the root node system overrides an attribute value for a g-node of a child, then the nesting is 0, or -1 when negativeRootNesting is true.

Parameters
[in]attrThe attribute whose value shall be obtained.
[in]expectedTypeThe expected type of the value. May be nullptr, then no type-check is done.
[out]nestingIf a value is found, the nesting of the node system which contained the value is written to nesting.
[in]negativeRootNestingIf this is true #nesting will be set to -1 if the value is defined at the root node system. This allows to distinguish between values which are set at the root and those which are inherited from a base (they will report a nesting of 0).
Returns
Pointer to the value of #attr (to be cast to the type of #attr), or nullptr if this g-node has no value for the attribute.

◆ GetValue() [3/6]

Result<Opt<const T&> > GetValue ( const InternedId attr) const

Returns a pointer to the value of #attr at this g-node. The value may be defined at this node itself or at one of its bases. If no value is found or the found value doesn't match the expected type T, nullptr is returned.

Parameters
[in]attrThe attribute whose value shall be obtained.
Template Parameters
TThe expected type of the value.
Returns
The value of attr for this g-node, or an empty Opt if this g-node has no value for the attribute.

◆ GetValue() [4/6]

Result<Opt<const typename ATTR::ValueType&> > GetValue ( const ATTR &  attr) const

Returns a pointer to the value of #attr at this g-node. The value may be defined at this node itself or at one of its bases. If no value is found or the found value doesn't match the expected type of the attribute, nullptr is returned.

Parameters
[in]attrThe attribute whose value shall be obtained.
Returns
The value of attr for this g-node, or an empty Opt if this g-node has no value for the attribute.

◆ GetValue() [5/6]

Result<Opt<const typename ATTR::ValueType&> > GetValue ( void  ) const

Returns a pointer the value of #ATTR at this g-node. The value may be defined at this node itself or at one of its bases. If no value is found, nullptr is returned.

Template Parameters
ATTRThe attribute whose value shall be obtained.
Returns
The value of ATTR for this g-node, or an empty Opt if this g-node has no value for the attribute.

◆ GetValue() [6/6]

Result<Opt<const typename ATTR::ValueType&> > GetValue ( const ATTR &  attr,
Int nesting 
) const

Returns a pointer the value of #attr at this g-node. The value may be defined at this node itself or at one of its bases. If no value is found, nullptr is returned.

Parameters
[in]attrThe attribute whose value shall be obtained.
[out]nestingIf a value is found, the nesting of the node system which contained the value is written to nesting, see GetValue(InternedId, DataType, Int).
Returns
The value of attr for this g-node, or an empty Opt if this g-node has no value for the attribute.

◆ GetBaseValues()

Result<Bool> GetBaseValues ( const InternedId attr,
const DataType expectedType,
const ValueReceiver< const ConstDataPtr &, Int > &  receiver 
) const

Yields all values which are stored for attr at this g-node and its bases. While the normal getter functions only return the outmost value (which overrides the inner ones) this function allows to obtain also the hidden values.

The found values are reported together with their nesting in ascending order of the nesting. The nesting is defined as for GetValue(InternedId, DataType, Int) with one exception: A value which is stored at the root node system itself has a nesting of -1 instead of 0. This allows to distinguish between such values and values stored at a base of the root node system (which have a nesting of 0).

Parameters
[in]attrThe attribute whose values shall be obtained.
[in]expectedTypeThe expected type of the attribute. May be nullptr, then no type-check is done.
[in]receiverA callback which receives the attribute values and their nestings.
Returns
false if the receiver cancelled further evaluation, true otherwise.

◆ GetDefaultValue()

Result<const T&> GetDefaultValue ( const T &  def = maxon::NullValue<const T&>()) const

Returns the default value of this port. This is the value of the DefaultValue attribute, which in turn is synthesized from DESCRIPTION::DATA::BASE::DEFAULTVALUE: Default values are derived from right to left along connections.

Template Parameters
TThe type to return.
Parameters
[in]defThe default value to use when there is no value for DefaultValue (or the type didn't match).
Returns
Value of the DefaultValue attribute (or def).

◆ GetConstantValue()

Result<const T&> GetConstantValue ( const T &  def = maxon::NullValue<const T&>()) const

Returns the constant value of this port. The constant value is set whenever the graph implementation is able to determine a constant value for the port, either because the default value has been set directly at the port, or because it is possible to compute the value from connected ports and nodes.

Template Parameters
TThe type to return.
Parameters
[in]defThe value to return when there is no constant value of matching type.
Returns
The constant value of this port.

◆ GetAttributeModificationsSince()

Result<Bool> GetAttributeModificationsSince ( TimeStamp  stamp,
const ValueReceiver< InternedId, ConstDataPtr > &  receiver 
) const

Reports all attribute modifications which have been made for this g-node since the given stamp to the receiver. Only stored attributes will be reported, so to also check for new values of computed attributes you should use GraphAttributeInterface::IsComputedFrom().

See also
NodeSystemInterface::GetModificationsSince
Parameters
[in]stampA reference time stamp. Only modifications newer than this stamp are reported.
[in]receiverModifications are reported to this receiver as a pair of the attribute identifier and the current value.
Returns
false if the receiver cancelled further evaluation, true otherwise.

◆ GetAttributeStamp()

TimeStamp GetAttributeStamp ( const InternedId attr) const

Returns the modification stamp of the given attribute for this g-node. This is the value of the node system's time stamp (see NodeSystemInterface::GetModificationStamp) at the time when the attribute value has been set last for this g-node, or a null value if it hasn't been set at all.

Parameters
[in]attrAn attribute.
Returns
The modification stamp of the last change of the attribute value.

◆ GetNode()

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

Returns the enclosing (true) node to which this g-node belongs. If this g-node is already a node, then it is returned itself.

Returns
The enclosing node if this g-node is a port list or port, otherwise this node itself.

◆ GetParent()

Result<GNodeSelector<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()

Result<GNodeSelector<BASE::MUTABLE> > FindChild ( const InternedId name,
NODE_KIND  mask 
) const

Finds a child with the given name or kind. If name is given, this returns the first direct child of this node which has the identifier name and whose kind matches the mask. If name is empty, the function returns the first direct child with matching kind (in this case children whose identifiers start with a dot are ignored).

Parameters
[in]nameThe identifier to look for.
[in]maskA mask for the node kind.
Returns
The first direct child which matches name and mask, or a null node.

◆ FindInnerNode()

Result<typename NODE::template Selector<BASE::MUTABLE> > FindInnerNode ( const PathBlock relativePath) const

Finds the inner child of this g-node with the given relative path. If no such child can be found, a null node is returned.

Template Parameters
NODEThe expected node type (such as Node or MutablePort).
Parameters
[in]relativePathThe relative path of the child to find, starting at this node.
Returns
The inner child of this node with the given relativePath, or a null node if no such child exists.

◆ GetInnerNodes()

Result<Bool> GetInnerNodes ( NODE_KIND  mask,
Bool  includeThis,
const ValueReceiver< const GNodeSelector< BASE::MUTABLE > & > &  receiver 
) const

Yields all inner nodes of this g-node matching #mask in pre-order. The recursive traversal stops at nodes which don't match #mask.

Parameters
[in]maskMask to filter the tree traversal. Only nodes matching this mask are considered. The node on which GetInnerNodes is called isn't checked for mask.
[in]includeThisIf true, the node on which GetInnerNodes is called is yielded to #receiver too.
[in]receiverInner nodes are reported to this value receiver.
Returns
false if #receiver cancelled further evaluation, true otherwise.

◆ GetBase()

const NodeSystem& GetBase ( ) const

Returns the base node system of this node (or in other words, the node system of which this node is an instance).

  • For a root node, this is the base of the root's node system (which may be null). In the instancing graph below the base of B is A and the base of E is D. A, C and D have no bases.
  • Otherwise we have a nested node, then we follow the chain of bases until we reach a root node. In the instancing graph the base node system of the nodes n of C, m/n of D as well as m/n of E is B. The base node system of the node m of D and of E is C.

@graph +-D-----------—+ +-E-----------—+ +-C-------—+ | +-m-------—+ | | +-m-------—+ | +-A---—+ +-B---—+ | +-n---—+ | | | +-n---—+ | | | | +-n---—+ | | | |<- - -| |<- - - -| | |<- - - -| | | | |<- - -| | | | | | +-----—+ +-----—+ | +-----—+ | | | +-----—+ | | | | +-----—+ | | +---------—+ | +---------—+ | | +---------—+ | +-------------—+ +-------------—+ @endgraph If this node is not a true node but a port or port list, the base of the enclosing true node is returned.

Returns
The base node system of this node, may be a null reference.

◆ GetBases()

const Block<const NodeSystem>& GetBases ( ) const

Returns the base node systems of which this node is an instance. The entry at index 0 refers to the node system of which this node has been created as instance by CreateInstance(), this will be a null reference if the node systems hasn't been created this way. It's the same as the node system returned by GetBase(). The remaining entries list the bases which have been added by AddBase().

Returns
The bases of this node system, this will have at least one entry. The first entry may be a null reference.

◆ GetAllBases()

Result<Bool> GetAllBases ( const ValueReceiver< const NodeSystem & > &  receiver) const

Recursively finds all the bases of the node.

Parameters
[in]receiverValueReceiver or Array that will receive all the base NodeSystem found.
Returns
False if the receiver cancelled further evaluation, true otherwise.

◆ GetTemplate()

const NodeTemplate& GetTemplate ( ) const

Returns the NodeTemplate which instantiated this node. For a root node, this is the template of the root's node system. Otherwise it is the template of the base of this node.

Returns
The NodeTemplate which instantiated this node, may be a null reference.

◆ GetAllTemplates()

Result<Bool> GetAllTemplates ( const ValueReceiver< const NodeTemplate & > &  receiver) const

Returns the NodeTemplate which instantiated this node also those from all the bases.

Parameters
[in]receiverValueReceiver or Array that will receive all the NodeTemplate found.
Returns
False if ValueReceiver was canceled. True otherwise.

◆ GetDerivationHandler()

const NodeSystemDerivationHandler& GetDerivationHandler ( ) const

Returns the derivation handler of this node.

Returns
The NodeSystemDerivationHandler of this node.