#include <nodesgraph.h>
A NodesGraphModelRef is an implementation of GraphModelInterface which wraps a NodeSystem. There may be more than one model working on the same NodeSystem reference, this is handled by a shared NodeSystemManagerRef: Each NodesGraphModelRef is a certain view on the NodeSystem with individual filter settings and root paths, and the manager coordinates the accesses of the views.
NodesGraphModelClass is the base implementation of this interface. It has to be used as base class for custom implementations.
Protected Member Functions | |
MAXON_METHOD Result< void > | CopyToImpl (NodesGraphModelImpl &dst) const |
MAXON_METHOD Result< void > | PrivateInit () |
MAXON_METHOD Result< NodesGraphModelRef > | CreateView (NodeSystemManagerInterface::FILTER filter, const NodePath &rootPath, const Class<> &graphModelClass) |
Private Member Functions | |
MAXON_INTERFACE (NodesGraphModelInterface, MAXON_REFERENCE_NORMAL, "net.maxon.node.interface.nodesgraphmodel") | |
MAXON_METHOD Result< ForwardRef< UserStateDerivationRef > > | CreateUserStateDerivation (const Block< const Id > &categories, Bool lazy) |
|
private |
MAXON_METHOD Result<NodeSystemManagerRef> CreateManager | ( | ) | const |
Creates a new manager to be used for this graph model. This method should not be invoked by user code, however you can override the default implementation to create a customized manager.
MAXON_METHOD Result<void> Init | ( | const NodeSystem & | system, |
const AssetRepositoryRef & | lookup, | ||
NodeSystemManagerInterface::FILTER | filter = NodeSystemManagerInterface::FILTER::NONE , |
||
Bool | supportRollback = true |
||
) |
Initializes a new NodesGraphModelRef view for the node system. Also a NodeSystemManagerRef is created which manages the NodesGraphModelRef and possible further views.
[in] | system | The initial state of the node system. |
[in] | lookup | The asset search scope to use for the graph model. |
[in] | filter | The filter to use for the view. |
[in] | supportRollback | Use true if GraphTransaction::Rollback shall be supported by the graph model. This keeps a copy of the original state of the node system before a transaction is started. |
MAXON_METHOD const AssetRepositoryRef& GetLookupRepository | ( | ) | const |
Returns the asset repository to use for lookups for the node graph. This repository is used whenever an asset is looked up.
MAXON_METHOD const NodeSystemManagerRef& GetManager | ( | ) | const |
Returns the manager which manages this graph model. The manager may manage more than one graph model, each model represents a specific view on the underlying node system.
MAXON_METHOD Result<NodesGraphModelRef> CreateView | ( | NodeSystemManagerInterface::FILTER | filter, |
const NodePath & | rootPath | ||
) |
Creates a new view for the node system of this view. The returned view will be managed by the same NodeSystemManagerRef as this view.
[in] | filter | The filter to use for the view. If this view is read-only, the FILTER::READ_ONLY flag will be set implicitly. |
[in] | rootPath | The absolute path to the root node of the new view. Use this if the new view shall not represent the whole graph, but only a node and its inner parts. Note that this is an absolute path, so the path of the current view is always ignored. |
MAXON_METHOD NodeSystem GetNodeSystem | ( | ) |
Returns the node system reference wrapped by this graph. The node system itself may change over time due to its copy-on-write nature.
MAXON_METHOD const NodeSystem& GetBase | ( | const GraphNode & | node | ) |
MAXON_METHOD Result<Bool> GetAllBases | ( | const GraphNode & | node, |
const ValueReceiver< const NodeSystem & > & | receiver | ||
) |
Recursively finds all the bases of a node or port. This is useful for ports which are made from an asset and resource different then their ancestor node.
[in] | node | The node for which we want all base NodeSystem. |
[in] | receiver | ValueReceiver or Array that will receive all the base NodeSystem found. |
MAXON_METHOD const NodeTemplate& GetTemplate | ( | const GraphNode & | node | ) |
Returns the NodeTemplate which instantiated node.
[in] | node | The node for which we want the template. |
MAXON_METHOD Result<Bool> GetAllTemplates | ( | const GraphNode & | node, |
const ValueReceiver< const NodeTemplate & > & | receiver | ||
) |
Recursively finds all the templates of a node or port. This is useful for ports which are made from an asset and resource different then their ancestor node.
[in] | node | The node for which we want all templates. |
[in] | receiver | ValueReceiver or Array that will receive all the NodeTemplate found. |
MAXON_METHOD Result<NodeSystemInterface*> GetMutableNodeSystem | ( | Bool | outsideOfTransaction = false | ) |
Returns a pointer to the node system in mutable state. When outsideOfTransaction is false (the default) a GraphTransaction has to be active, otherwise an IllegalStateError is returned. When outsideOfTransaction is true the NodeSystem is made writable like a usual copy-on-write reference, you should use this only to set values of attributes which don't need validation or notification.
[in] | outsideOfTransaction | Usually false (the default), use true for a modification which shall bypass the normal validation and notification mechanism. |
MAXON_USING | ( | GraphModelInterface::AddChild | ) |
MAXON_METHOD Result<GraphNode> AddChild | ( | const Id & | childId, |
const NodeSystem & | base | ||
) |
Adds an instance of a node system as child of the root node to this graph. If #childId is empty, a UUID will be chosen as identifier of the child, otherwise #childId. In the latter case it is an error if this root node already has a child with that identifier.
[in] | childId | Identifier for the child node (if empty, a UUID is chosen). |
[in] | base | Node system to add as an instance. |
MAXON_FUNCTION Result<GraphNode> AddChild | ( | const Id & | childId, |
const NodeTemplate & | templ, | ||
const TemplateArguments & | args = maxon::NullValue< const TemplateArguments & >() |
||
) |
Adds an instance of a node system as child of the root node to this graph. If #childId is empty, a UUID will be chosen as identifier of the child, otherwise #childId. In the latter case it is an error if this root node already has a child with that identifier.
[in] | childId | Identifier for the child node (if empty, a UUID is chosen). |
[in] | templ | NodeTemplate of which an instantiation shall be added as an instance to the root node. |
[in] | args | Template arguments for templ. |
MAXON_METHOD Result<void> ReplaceChild | ( | const GraphNode & | childNode, |
const NodeSystem & | base, | ||
const HashMap< NodePath, NodePath > & | portMap = GetZeroRef< HashMap< NodePath, NodePath >>() |
||
) |
Replaces the given child node with an instance of a node system. This removes the original child, adds an instance of base as new child (with the same identifier), and finally tries to re-establish connections and attribute values of the original node at the new node.
[in] | childNode | The child node which shall be replaced. |
[in] | base | Node system to use for the replacement. |
[in] | portMap | An optional port mapping from old port paths to new port paths, see MutableRoot::ReplaceChild. |
MAXON_METHOD Result<GraphNode> MoveToGroup | ( | MutableRoot & | groupRoot, |
const Id & | groupId, | ||
const Block< const GraphNode > & | selection | ||
) |
Groups the selection of nodes of this graph into a new group node. groupRoot is used to set up the new group node. You can leave this empty, then a new node system will be created as an instance of a group asset which fits to the selection (group assets already used by the selection are considered). But you can also provide a valid node system.
All selected nodes are moved to the group using their original identifiers, including inner connections. Afterwards the group is finalized and an instance of the group is added to this graph using the given groupId. Connections which leave the group are kept by adding ports to the group node as needed, and connecting them correspondingly. If the used group node already has ports, these will be used where identifiers mach.
[in] | groupRoot | The MutableRoot of another (usually empty) node system which will become the group, can be empty. The function will clear this reference after successful creation of the group. |
[in] | groupId | Identifier for the new group within this node system (if empty, a UUID is chosen). |
[in] | selection | A selection of nodes. Only nodes which are direct children of the root node of this view are considered. |
MAXON_METHOD Result<HashMap<InternedId, InternedId> > Ungroup | ( | const GraphNode & | group | ) |
Dissolves the given group into its children. This moves all children of group including their inner connections to the parent of group. External connections (from the group to other nodes) are moved to the inner nodes as well.
[in] | group | The group node to dissolve. |
MAXON_METHOD Result<AssetDescription> MoveToAsset | ( | const GraphNode & | node, |
const AssetRepositoryRef & | repository, | ||
const Id & | assetId, | ||
const Delegate< Result< void >(const MutableRoot &rootNode)> & | finalizer | ||
) |
Makes an asset for the given node and replaces the node by a reference to that asset.
[in] | node | The node which shall be made an asset. |
[in] | repository | The asset repository where the node asset shall be stored. |
[in] | assetId | The asset identifier to use. This must not be empty. |
[in] | finalizer | This Delegate is called right before the asset is stored. This allows to do some finalization on the node system. |
MAXON_METHOD Result<Bool> GetSupportedAssets | ( | const ValueReceiver< const AssetDescription & > & | receiver | ) |
Yields the descriptions of all node template assets which are supported by this graph to receiver.
[in] | receiver | All supported assets are reported to this receiver. |
|
private |
MAXON_METHOD const GNodeHandle& PrivateGetHandle | ( | const GraphNode & | node | ) |
MAXON_METHOD Result<GNode> PrivateToGNode | ( | const GraphNode & | node, |
NODE_KIND | mask | ||
) |
MAXON_METHOD Result<MutableGNode> PrivateToMutableGNode | ( | const GraphNode & | node, |
NODE_KIND | mask | ||
) |
MAXON_METHOD Result<Bool> GetAllAssetIds | ( | const GraphNode & | node, |
const ValueReceiver< const IdAndVersion & > & | receiver | ||
) |
Recursively finds all the node asset identifier and version of a node. The top level assets will be reported first.
[in] | node | The node for which we want all templates (NODE_KIND::NODE is mandatory). |
[in] | receiver | ValueReceiver or Array that will collect all asset identifiers found. |
|
protected |
|
protected |
Common init code used by Init method and CreateView method can be placed here.
MAXON_METHOD Result<GraphNode> MoveToGroup | ( | const NodeSystem & | base, |
const Id & | groupId, | ||
const Block< const GraphNode > & | selection | ||
) |
Groups the selection of nodes of this graph into a new group node. The new group node will be set up as an instance of base.
All selected nodes are moved to the group using their original identifiers, including inner connections. Afterwards the group is finalized and an instance of the group is added to this graph using the given groupId. Connections which leave the group are kept by adding ports to the group node as needed, and connecting them correspondingly. If the used group node already has ports, these will be used where identifiers match.
[in] | base | The base NodeSystem for the group. If null, an instantiation of the NODE::GROUP template is used. |
[in] | groupId | Identifier for the new group within this node system (if empty, a UUID is chosen). |
[in] | selection | A selection of nodes. Only nodes which are direct children of the root node of this view are considered. |
|
protected |
Creates a view of the node system using the given class.
[in] | filter | The filter to use for the view. |
[in] | rootPath | The path to the root node of the view. Use this if the view shall not represent the whole graph, but only a node and its inner parts. |
[in] | graphModelClass | The class to use. Usually "self.GetClass()" is used internally to keep the same model implementation. |
MAXON_METHOD Result<void> ReplaceBase | ( | const GraphNode & | node, |
const NodeSystem & | newBase | ||
) |
Replaces the base node system of the given node with another one.
[in] | node | The node whose base shall be replaced, either the root node or a group node. |
[in] | newBase | The new base node system to use for node. |