DerivedAttributeInterface Class Reference

#include <portattributes.h>

Inheritance diagram for DerivedAttributeInterface:

Detailed Description

DerivedAttributeInterface stands for derived attributes of ports.

The public declaration as well as the access to values of derived attributes is the same as for non-derived attributes, namely with MAXON_ATTRIBUTE. However, the values of derived attributes can't be set directly, instead they are derived based on other values of a NodeSystem.

Public Types

enum class  KIND {
  NONE ,
  INHERITED ,
  SYNTHESIZED ,
  COMPUTED ,
  FILTERED ,
  INDUCED_DEPENDENCIES ,
  NODE_PRE ,
  NODE_POST ,
  DERIVED_MASK
}
 
enum class  DEPENDENCY {
  NONE ,
  SELF ,
  CHILDREN ,
  PARENT ,
  HAS_CHILDREN ,
  SELF_INPUT ,
  SELF_OUTPUT ,
  VALUE_SOURCES ,
  VALUE_TARGETS ,
  DEP_SOURCES ,
  DEP_TARGETS ,
  VALUE_DEP_SOURCES ,
  VALUE_DEP_TARGETS ,
  SOURCES_MASK ,
  TARGETS_MASK ,
  SHORTCUT_SOURCES ,
  SHORTCUT_TARGETS ,
  INDUCED_SOURCES ,
  INDUCED_TARGETS ,
  CTX_SOURCES_DEEP ,
  CTX_TARGETS_DEEP ,
  SHORTCUT_SOURCES_MASK ,
  SHORTCUT_TARGETS_MASK ,
  SOURCES_ALL ,
  TARGETS_ALL
}
 

Public Member Functions

enum maxon::nodes::DerivedAttributeInterface::KIND MAXON_ENUM_FLAGS_CLASS (KIND)
 
enum maxon::nodes::DerivedAttributeInterface::DEPENDENCY MAXON_ENUM_FLAGS_CLASS (DEPENDENCY)
 
MAXON_METHOD KIND GetKind () const
 
MAXON_METHOD Block< const Tuple< InternedId, DEPENDENCY > > GetDependencies () const
 
MAXON_METHOD Bool ValuesEqual (const ConstDataPtr &newValue, const NodePath &port, const ConstDataPtr &oldValue, Int oldNesting) const
 
MAXON_METHOD Result< Opt< Data > > DeriveAttributeValue (const Block< const Port > &nesting) const
 
MAXON_METHOD Result< ConstDataPtrComputeAttributeValue (const GNode &node, const DataType &expectedType) const
 

Private Member Functions

 MAXON_INTERFACE (DerivedAttributeInterface, MAXON_REFERENCE_CONST, "net.maxon.node.interface.derivedattribute")
 

Member Enumeration Documentation

◆ KIND

enum KIND
strong

There are three kinds of derived attributes:

  1. INHERITED: These are inherited attributes in the sense of attribute grammars, i.e., for a port their value is derived based on values at the port and its direct predecessors in the graph. The NodeTemplate which created the node of the port decides how exactly the derivation is carried out (via NodeTemplateInterface::DeriveAttributeValue).
  2. SYNTHESIZED: The opposite of inherited attributes, i.e., for a port their value is derived based on values at the port and its direct successors in the graph. The NodeTemplate which created the node of the port decides how exactly the derivation is carried out (via NodeTemplateInterface::DeriveAttributeValue).
  3. COMPUTED: These attributes are computed on the fly using ComputeAttributeValue when a value is requested.
Enumerator
NONE 
INHERITED 

The attribute is an inherited attribute whose value is derived from values at direct predecessor ports.

SYNTHESIZED 

The attribute is a synthesized attribute whose value is derived from the values at direct successor ports.

COMPUTED 

The attribute is computed on-the-fly whenever its value is requested.

FILTERED 

This flag has to be set for inherited or synthesized attributes which shall use the derivation filter for connections.

INDUCED_DEPENDENCIES 

This flag has to be set for inherited or synthesized attributes when the derivation needs induced dependencies as well (see GraphModelInterface::GET_CONNECTIONS_MODE::INDUCED_DEPENDENCIES).

NODE_PRE 

The attribute is a derived attribute for true nodes which has to be derived before ports.

NODE_POST 

The attribute is a derived attribute for true nodes which has to be derived after ports.

DERIVED_MASK 

Use this to test for derived port attributes (INHERITED or SYNTHESIZED).

◆ DEPENDENCY

enum DEPENDENCY
strong

The flags of this enum tell on which ports (relative to the current port) a derived attribute depends.

Enumerator
NONE 

No flags.

SELF 

The attribute depends on another attribute value of the same port. Can be used for node or port attributes.

CHILDREN 

The attribute depends on attribute values of children ports. Can be used for node attributes only.

PARENT 

The attribute depends on attribute values of parent ports.

HAS_CHILDREN 

The attribute depends on the port's property of having children.

SELF_INPUT 

The attribute depends on another attribute value of the same port, but only if the port is an input port.

SELF_OUTPUT 

The attribute depends on another attribute value of the same port, but only if the port is an output port.

VALUE_SOURCES 

The attribute depends on attribute values of ports of incoming value connections. Can be used for port attributes only.

VALUE_TARGETS 

The attribute depends on attribute values of ports of outgoing value connections. Can be used for port attributes only.

DEP_SOURCES 

The attribute depends on attribute values of ports of incoming dependency connections. Can be used for port attributes only.

DEP_TARGETS 

The attribute depends on attribute values of ports of outgoing dependency connections. Can be used for port attributes only.

VALUE_DEP_SOURCES 
VALUE_DEP_TARGETS 
SOURCES_MASK 
TARGETS_MASK 
SHORTCUT_SOURCES 

The attribute depends on attribute values of ports of incoming connections. Can be used for port attributes only.

SHORTCUT_TARGETS 

The attribute depends on attribute values of ports of outgoing connections. Can be used for port attributes only.

INDUCED_SOURCES 

The attribute depends on attribute values of ports of incoming connections. Can be used for port attributes only.

INDUCED_TARGETS 

The attribute depends on attribute values of ports of outgoing connections. Can be used for port attributes only.

CTX_SOURCES_DEEP 

The attribute depends on attribute values of ports of incoming context connections. Can be used for port attributes only.

CTX_TARGETS_DEEP 

The attribute depends on attribute values of ports of outgoing context connections. Can be used for port attributes only.

SHORTCUT_SOURCES_MASK 
SHORTCUT_TARGETS_MASK 
SOURCES_ALL 
TARGETS_ALL 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( DerivedAttributeInterface  ,
MAXON_REFERENCE_CONST  ,
"net.maxon.node.interface.derivedattribute"   
)
private

◆ MAXON_ENUM_FLAGS_CLASS() [1/2]

enum maxon::nodes::DerivedAttributeInterface::KIND MAXON_ENUM_FLAGS_CLASS ( KIND  )

◆ MAXON_ENUM_FLAGS_CLASS() [2/2]

◆ GetKind()

MAXON_METHOD KIND GetKind ( ) const

Returns the kind of this attribute, i.e., whether it is an inherited, synthesized or computed attribute.

Returns
Kind of this attribute.

◆ GetDependencies()

MAXON_METHOD Block<const Tuple<InternedId, DEPENDENCY> > GetDependencies ( ) const

Returns the dependencies of this derived attribute as attribute/DEPENDENCY pairs. This has to include all other attributes which are needed for the derivation of this attribute.

Returns
Dependencies of this attribute.

◆ ValuesEqual()

MAXON_METHOD Bool ValuesEqual ( const ConstDataPtr newValue,
const NodePath &  port,
const ConstDataPtr oldValue,
Int  oldNesting 
) const

Compares two derived attribute values for equality. Usually this is the same as {newValue == oldValue}, but there are derived attributes whose values have to be interpreted in the context of the enclosing nodes.

Parameters
[in]newValueThe newly derived attribute value for port.
[in]portThe port for which newValue has been derived.
[in]oldValueThe previously derived attribute value for port.
[in]oldNestingThe nesting depth of the port's node which derived oldValue in the current node system.
Returns
True if both values are equal, taking into account the nesting.

◆ DeriveAttributeValue()

MAXON_METHOD Result<Opt<Data> > DeriveAttributeValue ( const Block< const Port > &  nesting) const

Derives the value of this attribute (either a synthesized or an inherited attribute) for the port given by the last element of nesting. The derivation may use attribute values of

  • the port itself
  • its enclosing ports (which are also found in nesting) as well as its nested ports, but if the value of this attribute itself is queried, then only enclosing ports are allowed if KIND::POST_ORDER isn't set, otherwise only nested ports
  • direct predecessor ports in case of an inherited attribute
  • direct successor ports in case of a synthesized attribute.

But the dependency of this attribute on the accessed attributes has to be properly reflected by GetDependencies.

Parameters
[in]nestingThe port for which the attribute value shall be derived (last element) and its enclosing ports.
Returns
The derived attribute value, or an empty Opt if there shall be no derived value.

◆ ComputeAttributeValue()

MAXON_METHOD Result<ConstDataPtr> ComputeAttributeValue ( const GNode node,
const DataType expectedType 
) const

Computes the value of this computed attribute for the given node.

Parameters
[in]nodeThe g-node for which the attribute value shall be computed.
[in]expectedTypeThe expected type of the value. If this is non-null, the returned value has to be castable to that type.
Returns
The computed attribute value.