Rumba C++ SDK
maquina::Node Class Reference

Base class of all Rumba nodes. More...

#include <Node.h>

Classes

class  Children
 A Node children accessor. More...
 
class  Plugs
 A Plug accessor. More...
 

Public Types

using Flags = Plug::Flags
 

Public Member Functions

 Node (const char *type, const char *name, Node *parent=nullptr, bool undo_stack=false)
 Create a node. More...
 
Node duplicate (Node *parent=nullptr, bool undo_stack=false) const
 Duplicate this node, plugs, dynamic plugs and children. More...
 
void delete_node (bool undo_stack=false)
 Delete this node from the document. More...
 
void rename (const char *new_name, bool undo_stack=false)
 Rename the node. More...
 
const char * name () const
 Return the node name. More...
 
std::string full_name () const
 Return the node full name starting at the workspace node. More...
 
std::string full_document_name () const
 Return the node full name starting at the document node. More...
 
std::shared_ptr< AttributeDescriptordescription () const
 Returns the node's description, always returns a valid pointer. More...
 
void set_description (const std::string &description, bool undo_stack=false)
 Set the description of this node. More...
 
const char * type_name () const
 Return the node type name. More...
 
bool is_deleted () const
 Return true if this node has been deleted. In that case, it shall not be used any more. More...
 
bool is_instance (const char *node_type_name) const
 Check if this node derive from another node type. More...
 
bool is_referenced () const
 Check if this node is referenced. More...
 
bool is_mutable () const
 Check if this node can be modified. More...
 
bool is_reference_root () const
 Check if this node is the root node of a reference. More...
 
bool is_reference_loaded () const
 Returns true if this node is a root reference node and the reference is loaded. More...
 
bool is_serializable () const
 Returns true if this node and all its children will be serialised on save. More...
 
bool is_singleton () const
 
void set_singleton (bool singleton)
 
bool is_document_node () const
 Returns true if this node belong to a document. More...
 
void set_serializable (bool serialize)
 
std::wstring reference_filename () const
 Returns the reference file name for this node. More...
 
void unload_reference ()
 Unload this root reference node. More...
 
void load_reference ()
 Load this root reference node. More...
 
void replace_reference (const std::wstring &new_reference)
 Replace this root reference node with another file. More...
 
void flatten_reference ()
 Flattens this root reference node. More...
 
void write (const std::wstring &filename) const
 Write the node into a file. More...
 
Children children () const
 Get the node children accessor. More...
 
bool has_parent () const
 Check if this node has a parent. More...
 
Node parent () const
 Get the node parent. More...
 
void set_parent (Node &parent, bool undo_stack)
 Set the node parent. More...
 
std::optional< Nodedocument () const
 Get the Document parent node. More...
 
bool has_child (const char *child_name) const
 Check if a child node exists. More...
 
Node child (const char *name) const
 Get a child node by its name. More...
 
bool is_child_of (const Node &parent) const
 Return true if this node is child of parent or is parent. More...
 
Node find_first (const char *name) const
 Get the first node named name in the children hierarchy of this node. More...
 
Plugs plugs () const
 Return the node plugs iteration. More...
 
bool has_plug (const char *plug_name) const
 Check if a plug exists. More...
 
Plug add_plug (const char *name, const Value &default_value, int flags=Flags::serial, bool undo_stack=false, const std::string &description="")
 
void rename_plug (const Plug &plug, const char *new_name, bool undo_stack=false)
 
void remove_plug (const char *name, bool undo_stack=false)
 
void remove_plug (const Plug &plug, bool undo_stack=false)
 
Plug plug (const char *plug_name) const
 Return a plug by its name. More...
 
std::vector< Plugchannel_plugs () const
 
std::vector< Channelchannels () const
 Return all the node's channels. More...
 
std::shared_ptr< Channelchannel (ChannelType channel_type) const
 Return the specified channel if available, return nullptr otherwise. More...
 
std::vector< Noderelationship ()
 Returns the nodes in relationship with this node. More...
 
const std::vector< std::string > & bases () const
 Returns a list of all the types this class derives. More...
 
Node random_child ()
 Returns a Node with a random name as child of this node. More...
 
std::shared_ptr< NodePluginplugin () const
 Returns the node plug-in, if this node has been created by a plug-in, or nullptr. More...
 
std::vector< Nodesearch (const std::string &key) const
 Search in the node childrens all the name that satisfies the key. More...
 
std::shared_ptr< class NodeDelegatenode_delegate ()
 Get the NodeDelegate pointing to this node. More...
 
void notify_first_init (bool undo_stack)
 Do the one shot initialization tasks for this node. More...
 
void set_graph_properties (const class GraphProperties &gp)
 Set the graph_properties plug value and invalidates the connected nodes graph_properties plugs. More...
 
bool is_selected () const
 true if the node is selected More...
 
std::optional< Plugchannel_switch_sub_channel (const std::string_view &sub_channel) const
 Return the plug for the sub channel name if available. More...
 
bool operator== (const Node &o) const
 
bool operator!= (const Node &o) const
 

Detailed Description

Base class of all Rumba nodes.

A Node has plugs and children nodes.

C++ example

Member Typedef Documentation

◆ Flags

Constructor & Destructor Documentation

◆ Node()

maquina::Node::Node ( const char *  type,
const char *  name,
Node parent = nullptr,
bool  undo_stack = false 
)

Create a node.

Exceptions
std::runtime_errorif the type is unknown.
Parameters
typeThe node type to use
nameThe node name
parentThe optional parent node
undo_stacktrue if this node creation is undoable

Member Function Documentation

◆ add_plug()

Plug maquina::Node::add_plug ( const char *  name,
const Value default_value,
int  flags = Flags::serial,
bool  undo_stack = false,
const std::string &  description = "" 
)

Add a new plug to this node.

Parameters
nameInitial name of the plug, may be changed if a plug with this name already exists
default_valueDefault value held by this plug
flagsA combination of Flags
undo_stackThe modification is undoable if this parameter is true.
Exceptions
std::runtime_errorWhen no plug can be added.

◆ bases()

const std::vector<std::string>& maquina::Node::bases ( ) const

Returns a list of all the types this class derives.

◆ channel()

std::shared_ptr<Channel> maquina::Node::channel ( ChannelType  channel_type) const

Return the specified channel if available, return nullptr otherwise.

◆ channel_plugs()

std::vector<Plug> maquina::Node::channel_plugs ( ) const

◆ channel_switch_sub_channel()

std::optional<Plug> maquina::Node::channel_switch_sub_channel ( const std::string_view &  sub_channel) const

Return the plug for the sub channel name if available.

◆ channels()

std::vector<Channel> maquina::Node::channels ( ) const

Return all the node's channels.

◆ child()

Node maquina::Node::child ( const char *  name) const

Get a child node by its name.

Exceptions
std::runtime_errorif the child doesn't exist.

◆ children()

Children maquina::Node::children ( ) const

Get the node children accessor.

◆ delete_node()

void maquina::Node::delete_node ( bool  undo_stack = false)

Delete this node from the document.

Once deleted, only the is_deleted() method can be called on the node. The node shall not be used anymore.

Parameters
undo_stackif true, this action is undoable

◆ description()

std::shared_ptr<AttributeDescriptor> maquina::Node::description ( ) const

Returns the node's description, always returns a valid pointer.

◆ document()

std::optional<Node> maquina::Node::document ( ) const

Get the Document parent node.

Exceptions
std::runtime_errorif the node is not a child of a Document node.

◆ duplicate()

Node maquina::Node::duplicate ( Node parent = nullptr,
bool  undo_stack = false 
) const

Duplicate this node, plugs, dynamic plugs and children.

Parameters
parentThe optional parent node
undo_stacktrue if this node creation is undoable

◆ find_first()

Node maquina::Node::find_first ( const char *  name) const

Get the first node named name in the children hierarchy of this node.

Exceptions
std::runtime_errorif the node doesn't exist.

◆ flatten_reference()

void maquina::Node::flatten_reference ( )

Flattens this root reference node.

Flattens the reference starting at this node, keeping all internal references as such. If Node::is_reference_root returns false or if Node::is_reference_loaded returns false, this method has no effect.

Exceptions
std::runtime_errorif the file is corrupted

◆ full_document_name()

std::string maquina::Node::full_document_name ( ) const

Return the node full name starting at the document node.

◆ full_name()

std::string maquina::Node::full_name ( ) const

Return the node full name starting at the workspace node.

◆ has_child()

bool maquina::Node::has_child ( const char *  child_name) const

Check if a child node exists.

◆ has_parent()

bool maquina::Node::has_parent ( ) const

Check if this node has a parent.

◆ has_plug()

bool maquina::Node::has_plug ( const char *  plug_name) const

Check if a plug exists.

◆ is_child_of()

bool maquina::Node::is_child_of ( const Node parent) const

Return true if this node is child of parent or is parent.

◆ is_deleted()

bool maquina::Node::is_deleted ( ) const

Return true if this node has been deleted. In that case, it shall not be used any more.

◆ is_document_node()

bool maquina::Node::is_document_node ( ) const

Returns true if this node belong to a document.

Returns true if the node is a document or is in a document, and is serializable.

◆ is_instance()

bool maquina::Node::is_instance ( const char *  node_type_name) const

Check if this node derive from another node type.

◆ is_mutable()

bool maquina::Node::is_mutable ( ) const

Check if this node can be modified.

The node is mutable if it is not inside a reference.

◆ is_reference_loaded()

bool maquina::Node::is_reference_loaded ( ) const

Returns true if this node is a root reference node and the reference is loaded.

◆ is_reference_root()

bool maquina::Node::is_reference_root ( ) const

Check if this node is the root node of a reference.

Returns true if the node is the root of a reference node, or an unloaded reference node. In case the node is unloaded, Node::is_referenced() returns false.

◆ is_referenced()

bool maquina::Node::is_referenced ( ) const

Check if this node is referenced.

Returns true if the node is inside a reference node (read only) or if the node is a loaded root reference node (mutable).

◆ is_selected()

bool maquina::Node::is_selected ( ) const

true if the node is selected

◆ is_serializable()

bool maquina::Node::is_serializable ( ) const

Returns true if this node and all its children will be serialised on save.

◆ is_singleton()

bool maquina::Node::is_singleton ( ) const

◆ load_reference()

void maquina::Node::load_reference ( )

Load this root reference node.

Load the reference for this node from file, applying the overrides stored in the reference edits. If Node::is_reference_root returns false or if Node::is_reference_loaded returns true, this method has no effect.

Exceptions
std::runtime_errorif the file is corrupted

◆ name()

const char* maquina::Node::name ( ) const

Return the node name.

◆ node_delegate()

std::shared_ptr<class NodeDelegate> maquina::Node::node_delegate ( )

Get the NodeDelegate pointing to this node.

The NodeDelegate object is valid as long as the Node object lives.

◆ notify_first_init()

void maquina::Node::notify_first_init ( bool  undo_stack)

Do the one shot initialization tasks for this node.

This method must be called after the first time the node has been created and added to the workspace. This will call the NodePlugin::on_first_init callback to performe extra initialization tasks.

◆ operator!=()

bool maquina::Node::operator!= ( const Node o) const
inline

◆ operator==()

bool maquina::Node::operator== ( const Node o) const
inline

◆ parent()

Node maquina::Node::parent ( ) const

Get the node parent.

Exceptions
std::runtime_errorif the node has no parent.

◆ plug()

Plug maquina::Node::plug ( const char *  plug_name) const

Return a plug by its name.

Exceptions
std::runtime_errorif the plug does not exist.

◆ plugin()

std::shared_ptr<NodePlugin> maquina::Node::plugin ( ) const

Returns the node plug-in, if this node has been created by a plug-in, or nullptr.

◆ plugs()

Plugs maquina::Node::plugs ( ) const

Return the node plugs iteration.

◆ random_child()

Node maquina::Node::random_child ( )

Returns a Node with a random name as child of this node.

◆ reference_filename()

std::wstring maquina::Node::reference_filename ( ) const

Returns the reference file name for this node.

If the node is not a reference root node, return an empty string.

◆ relationship()

std::vector<Node> maquina::Node::relationship ( )

Returns the nodes in relationship with this node.

A relationship can have different meanings. For a layer for instance, the relationship are the controllers animated in this layer.

◆ remove_plug() [1/2]

void maquina::Node::remove_plug ( const char *  name,
bool  undo_stack = false 
)

Remove a plug from this node that was added by add_plug(). If no plug with such name exists or such a plug was not added by add_plug(), this method throws an exception. Otherwise the plug is detached from the evaluation graph (inputs, outputs, dependences and back dependences are removed) and it will be destroyed when the last reference to it disappear. *

Parameters
nameActual name of the plug, not necessarily the one given to add_plug().
undo_stackThe modification is undoable if this parameter is true.
Exceptions
std::runtime_errorWhen no plug with this name can be removed.

◆ remove_plug() [2/2]

void maquina::Node::remove_plug ( const Plug plug,
bool  undo_stack = false 
)

Remove a plug from this node that was added by add_plug(). If the given plug does not belong to this node or was not added by add_plug(), this method throws an exception. Otherwise the plug is detached from the evaluation graph (inputs, outputs, dependences and back dependences are removed) and it will be destroyed when the last reference to it disappear. *

Parameters
plugThe plug to remove.
undo_stackThe modification is undoable if this parameter is true.
Exceptions
std::runtime_errorWhen no plug with this name can be removed.

◆ rename()

void maquina::Node::rename ( const char *  new_name,
bool  undo_stack = false 
)

Rename the node.

Parameters
new_nameThe new name for the node
undo_stackif true, this action is undoable

◆ rename_plug()

void maquina::Node::rename_plug ( const Plug plug,
const char *  new_name,
bool  undo_stack = false 
)

Rename a plug of this node.

Parameters
plugThe plug to rename.
nameThe new name for the plug
undo_stackThe modification is undoable if this parameter is true.
Exceptions
std::runtime_errorWhen no plug can be renamed.

◆ replace_reference()

void maquina::Node::replace_reference ( const std::wstring &  new_reference)

Replace this root reference node with another file.

Replace the reference with another file. The reference stays loaded or unload.

Exceptions
std::runtime_errorif the file is corrupted

◆ search()

std::vector<Node> maquina::Node::search ( const std::string &  key) const

Search in the node childrens all the name that satisfies the key.

Returns a list of nodes that satisfies the search key.

Parameters
keyThe key use in the regex to search node by name, must follow regex standard

◆ set_description()

void maquina::Node::set_description ( const std::string &  description,
bool  undo_stack = false 
)

Set the description of this node.

◆ set_graph_properties()

void maquina::Node::set_graph_properties ( const class GraphProperties gp)

Set the graph_properties plug value and invalidates the connected nodes graph_properties plugs.

Use this method to set the node graph_properties plug value when the node moved in order to correctly invalidate its sibling connected nodes.

◆ set_parent()

void maquina::Node::set_parent ( Node parent,
bool  undo_stack 
)

Set the node parent.

Exceptions
std::runtime_errorif the node can't be re-parented.

◆ set_serializable()

void maquina::Node::set_serializable ( bool  serialize)

Set the serialization flag on this node.

Parameters
serializeif false, this node and all its children will not be serialized on save.

◆ set_singleton()

void maquina::Node::set_singleton ( bool  singleton)

◆ type_name()

const char* maquina::Node::type_name ( ) const

Return the node type name.

◆ unload_reference()

void maquina::Node::unload_reference ( )

Unload this root reference node.

Unload the reference starting at this node from memory, and keep all its overriden values, connections and descriptions in the reference edits. If Node::is_reference_loaded returns false, this method has no effect.

◆ write()

void maquina::Node::write ( const std::wstring &  filename) const

Write the node into a file.

Exceptions
std::runtime_errorif the writing fails.

The documentation for this class was generated from the following file: