SerializationNodeData Class Reference

#include <nodes_import.h>

Detailed Description

SerializationNodeData represents the data of a Node, PortList or Port for serialization. It can be adapted by an ImportAdapter to the current version, for example if attribute values shall be modified. @MAXON_ANNOTATION{noUnresolved}

Public Types

enum class  CHILD_MODE {
  ADD ,
  INHERIT ,
  REMOVE
}
 

Public Member Functions

MAXON_METHOD const NodePath & GetPath () const
 
MAXON_METHOD MapInterface< InternedId, Data > & GetAttributes ()
 
MAXON_METHOD MapInterface< NodePath, Wires > & GetTargets ()
 
MAXON_METHOD IdAndVersionGetBaseTemplate ()
 
MAXON_METHOD DataDictionary & GetBaseTemplateArguments ()
 
MAXON_METHOD Result< BoolGetChildren (const ValueReceiver< SerializationNodeData & > &receiver)
 
MAXON_METHOD SerializationNodeDataFindChild (const Id &child)
 
MAXON_METHOD void RemoveChild (const Id &child)
 
enum maxon::nodes::SerializationNodeData::CHILD_MODE MAXON_ENUM_LIST_CLASS (CHILD_MODE)
 
MAXON_METHOD Result< SerializationNodeData * > FindOrAddChild (const InternedId &child, CHILD_MODE mode, const IdAndVersion &base=GetZeroRef< IdAndVersion >(), const DataDictionary &baseArgs=DataDictionary::DefaultValue(), ASSET_UPDATE_POLICY updatePolicy=ASSET_UPDATE_POLICY::IMPLICIT)
 
MAXON_METHOD ASSET_UPDATE_POLICYGetUpdatePolicy ()
 
MAXON_METHOD CHILD_MODE GetChildMode () const
 
MAXON_METHOD Result< void > SetBaseTemplate (const IdAndVersion &newAid)
 
MAXON_METHOD const IdAndVersionGetBaseTemplate () const
 
MAXON_METHOD Result< void > SetUpdatePolicy (ASSET_UPDATE_POLICY newPolicy)
 
MAXON_METHOD ASSET_UPDATE_POLICY GetUpdatePolicy () const
 
MAXON_METHOD Result< void > SetBaseTemplateLink (const AssetLink &newLink)
 
MAXON_METHOD const AssetLink & GetBaseTemplateLink () const
 
MAXON_METHOD Result< void > SetBaseTemplateArguments (const DataDictionary &args)
 
MAXON_METHOD const DataDictionary & GetBaseTemplateArguments () const
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (SerializationNodeData, MAXON_REFERENCE_NONE, "net.maxon.node.interface.serializationdata", MAXON_IMPLEMENTATION_MODULE("net.maxon.nodes"))
 

Member Enumeration Documentation

◆ CHILD_MODE

enum CHILD_MODE
strong

This enum is used for the mode parameter of FindOrAddChild.

Enumerator
ADD 

Add the child node, it doesn't exist in a base.

INHERIT 

Inherit the child node, it already exists in a base.

REMOVE 

Remove the child node which would otherwise be inherited from a base.

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( SerializationNodeData  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.node.interface.serializationdata"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.nodes")   
)
private

◆ GetPath()

MAXON_METHOD const NodePath& GetPath ( ) const

Returns the complete node path of this node.

Returns
Path of this node.

◆ GetAttributes()

MAXON_METHOD MapInterface<InternedId, Data>& GetAttributes ( )

Returns the attributes of this node. An ImportAdapter can use this to modify, add or remove attribute values.

Returns
Attributes of this node as a map.

◆ GetTargets()

MAXON_METHOD MapInterface<NodePath, Wires>& GetTargets ( )

Returns the targets of this port. The map represents the outgoing connections of a port where the target port is identified by its path. An ImportAdapter can modify the connections by direct modification of the map.

Returns
Outgoing connections of this port as a map.

◆ GetBaseTemplate() [1/2]

MAXON_METHOD IdAndVersion& GetBaseTemplate ( )

Returns the asset identifier of the base template for this SerializationNodeData. An ImportAdapter can modify the identifier to handle renaming of node assets. The asset identifier is defined only for true nodes, but not if this serialization node represents a port or port list.

Returns
Asset identifier of the base template. @MAXON_ANNOTATION{deprecated="Use SetBaseTemplate and const GetBaseTemplate versions"}

◆ GetBaseTemplateArguments() [1/2]

MAXON_METHOD DataDictionary& GetBaseTemplateArguments ( )

Returns the template arguments for the base template for this SerializationNodeData. Template arguments are defined only for true nodes, but not if this serialization node represents a port or port list.

Returns
Template arguments for base template. @MAXON_ANNOTATION{deprecated="Use SetBaseTemplateArguments and const GetBaseTemplateArguments versions"}

◆ GetChildren()

MAXON_METHOD Result<Bool> GetChildren ( const ValueReceiver< SerializationNodeData & > &  receiver)

Yields the children of this node to #receiver.

Parameters
[in]receiverAll children are reported to this receiver.

◆ FindChild()

MAXON_METHOD SerializationNodeData* FindChild ( const Id child)

Finds the child of this node with the given identifer.

Parameters
[in]childIdentifier of the child.
Returns
Found child or nullptr.

◆ RemoveChild()

MAXON_METHOD void RemoveChild ( const Id child)

Removes the child of this node with the given identifier (if it exists).

Parameters
[in]childIdentifier of the child.

◆ MAXON_ENUM_LIST_CLASS()

◆ FindOrAddChild()

MAXON_METHOD Result<SerializationNodeData*> FindOrAddChild ( const InternedId child,
CHILD_MODE  mode,
const IdAndVersion base = GetZeroRef< IdAndVersion >(),
const DataDictionary &  baseArgs = DataDictionary::DefaultValue(),
ASSET_UPDATE_POLICY  updatePolicy = ASSET_UPDATE_POLICY::IMPLICIT 
)

Adds a new child node entry to the serialization data, or returns the already existing one. The added parameter has to be set correctly:

  • Either the node would already exist in the deserialized NodeSystem even without the added child entry. That's when the node is inherited from a base, and you just want to override some of its properties or need access to nested nodes. Then you have to use CHILD_MODE::INHERIT for mode, and it's not necessary to set the base template.
  • Or the node wouldn't exist in the deserialized NodeSystem. Then you have to use CHILD_MODE::ADD for added, and in case of a true node (instead of a port) you have to set the correct values for the base template.
  • Or you want to remove a node which otherwise would be inherited from a base, then you have to use CHILD_MODE::REMOVE. If the child node entry already existed before, the given arguments for the base template are ignored.
    Parameters
    [in]childIdentifier of the child.
    [in]modeCHILD_MODE::ADD if the child node didn't exist in the deserialized NodeSystem without the new child node entry, CHILD_MODE::INHERIT if the child node is inherited from a base, or CHILD_MODE::REMOVE if you want to flag an inherited node as to be removed.
    [in]baseIdentifier of the base template to use for the node. Only needed for true nodes when mode is CHILD_MODE::ADD.
    [in]baseArgsIdentifier of the base template arguments to use for the node. Only needed for true nodes when mode is CHILD_MODE::ADD.
    [in]updatePolicyThe update policy to use when the base template is resolved. Only needed for true nodes when mode is CHILD_MODE::ADD.
    Returns
    Added (or already existing) child node.

◆ GetUpdatePolicy() [1/2]

MAXON_METHOD ASSET_UPDATE_POLICY& GetUpdatePolicy ( )

Returns a reference to the asset update policy for the base template of the SerializationNodeData. The update policy is used only for true nodes, but not if this serialization node represents a port or port list.

Returns
Asset update policy for the base template.

◆ GetChildMode()

MAXON_METHOD CHILD_MODE GetChildMode ( ) const

Returns the child mode of this entry.

Returns
Child mode of entry.

◆ SetBaseTemplate()

MAXON_METHOD Result<void> SetBaseTemplate ( const IdAndVersion newAid)

Sets the asset identifier of the base template for this SerializationNodeData. An ImportAdapter can modify the identifier to handle renaming of node assets. The asset identifier is defined only for true nodes, but not if this serialization node represents a port or port list.

Parameters
[in]newAidThe asset identifier of the new base template to use.
Returns
OK on success.

◆ GetBaseTemplate() [2/2]

MAXON_METHOD const IdAndVersion& GetBaseTemplate ( ) const

Returns the asset identifier of the base template for this SerializationNodeData. An ImportAdapter can modify the identifier to handle renaming of node assets. The asset identifier is defined only for true nodes, but not if this serialization node represents a port or port list.

Returns
Asset identifier of the base template.

◆ SetUpdatePolicy()

MAXON_METHOD Result<void> SetUpdatePolicy ( ASSET_UPDATE_POLICY  newPolicy)

Sets the asset update policy of the base template for this SerializationNodeData. The update policy is used only for true nodes, not for ports or port lists.

Parameters
[in]newPolicyThe new base template asset update policy.
Returns
OK on success.

◆ GetUpdatePolicy() [2/2]

MAXON_METHOD ASSET_UPDATE_POLICY GetUpdatePolicy ( ) const

Returns the asset update policy of the base template for this SerializationNodeData. The update policy is used only for true nodes, but not if this serialization node represents a port or port list.

Returns
Asset update policy for the base template.

◆ SetBaseTemplateLink()

MAXON_METHOD Result<void> SetBaseTemplateLink ( const AssetLink &  newLink)

Sets a link to the base template's asset for this SerializationNodeData. Note that this will override any existing origin data.

See also
AssetLinkInterface
Parameters
[in]newLinkThe new base template's asset link.
Returns
OK on success.

◆ GetBaseTemplateLink()

MAXON_METHOD const AssetLink& GetBaseTemplateLink ( ) const

Returns the link to the base template's asset for this SerializationNodeData.

Returns
Asset identifier of the base template.

◆ SetBaseTemplateArguments()

MAXON_METHOD Result<void> SetBaseTemplateArguments ( const DataDictionary &  args)

Overwrites the template arguments for the base template for this SerializationNodeData. Template arguments are defined only for true nodes, but not if this serialization node represents a port or port list.

Parameters
[in]argsThe new base template arguments.
Returns
OK on success.

◆ GetBaseTemplateArguments() [2/2]

MAXON_METHOD const DataDictionary& GetBaseTemplateArguments ( ) const

Returns the template arguments for the base template for this SerializationNodeData. Template arguments are defined only for true nodes, but not if this serialization node represents a port or port list.

Returns
Template arguments for base template.