Loading [MathJax]/extensions/TeX/AMSsymbols.js
Radium Engine  1.5.29
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Ra::Dataflow::Core::DataflowGraph Class Reference

Represent a set of connected nodes that define a Direct Acyclic Computational Graph Ownership of nodes is given to the graph at construction time. More...

#include <Dataflow/Core/DataflowGraph.hpp>

+ Inheritance diagram for Ra::Dataflow::Core::DataflowGraph:
+ Collaboration diagram for Ra::Dataflow::Core::DataflowGraph:

Public Member Functions

 DataflowGraph (const std::string &name)
 
void init () override
 Initializes the node content.
 
bool execute () override
 Executes the node.
 
void destroy () override
 Delete the node's content.
 
bool loadFromJson (const std::string &jsonFilePath)
 Loads nodes and links from a JSON file.
 
void saveToJson (const std::string &jsonFilePath)
 Saves nodes and links to a JSON file.
 
virtual bool add_node (std::shared_ptr< Node > newNode)
 Adds a node to the graph.
 
template<typename T , typename... U>
std::shared_ptr< T > add_node (U &&... u)
 Conveniance typed alias.
 
virtual bool remove_node (std::shared_ptr< Node > node)
 Removes a node from the graph.
 
bool add_link (const std::shared_ptr< Node > &nodeFrom, const std::string &nodeFromOutputName, const std::shared_ptr< Node > &nodeTo, const std::string &nodeToInputName)
 Connects two nodes of the graph.
 
bool add_link (const std::shared_ptr< Node > &nodeFrom, Node::PortIndex portOutIdx, const std::shared_ptr< Node > &nodeTo, Node::PortIndex portInIdx)
 Convenience alias using port index.
 
bool add_link (Node::PortBaseOutRawPtr outputPort, Node::PortBaseInRawPtr inputPort)
 Convenience alias using port raw ptr, checks if ports' nodes are in the graph.
 
template<typename T , typename U >
bool add_link (const std::shared_ptr< PortOut< T > > &outputPort, const std::shared_ptr< PortIn< U > > &inputPort)
 Convenience typed alias.
 
bool can_link (const std::shared_ptr< Node > &nodeFrom, Node::PortIndex portOutIdx, const std::shared_ptr< Node > &nodeTo, Node::PortIndex portInIdx) const
 
bool can_link (const Node *nodeFrom, Node::PortIndex portOutIdx, const Node *nodeTo, Node::PortIndex portInIdx) const
 Convenience alias using raw pointer.
 
bool remove_link (std::shared_ptr< Node > node, const std::string &nodeInputName)
 Removes the link connected to a node's input port.
 
bool remove_link (std::shared_ptr< Node > node, const PortIndex &in_port_index)
 Removes the link connected to a node's input port.
 
const std::vector< std::shared_ptr< Node > > & nodes () const
 Get the vector of all the nodes on the graph.
 
std::shared_ptr< Nodenode (const std::string &instanceNameNode) const
 
template<typename T >
std::shared_ptr< T > node (const std::string &instanceNameNode) const
 
const std::vector< std::vector< Node * > > & nodes_by_level () const
 Gets the nodes ordered by level (after compilation)
 
bool compile () override
 Compile the graph to check its validity and simplify it.
 
void generate_ports ()
 fill input and output ports of graph from its input and output nodes if exists.
 
size_t node_count () const
 Gets the number of nodes.
 
virtual void clear_nodes ()
 Deletes all nodes from the render graph.
 
bool is_compiled () const
 Test if the graph is compiled.
 
void needs_recompile ()
 
Node::PortBaseInRawPtr input_node_port (const std::string &nodeName, const std::string &portName)
 Gets an input port form a node of the graph.
 
Node::PortBaseOutRawPtr output_node_port (const std::string &nodeName, const std::string &portName)
 Gets an output port from a node of the graph.
 
bool shouldBeSaved ()
 
void setNodesAndLinksProtection (bool on)
 protect nodes and links from deletion.
 
bool nodesAndLinksProtection () const
 get the protection status protect nodes and links from deletion
 
void add_input_output_nodes ()
 Create (if not already created) input/output node of the graph, and fills graph input/output.
 
void remove_unlinked_input_output_ports ()
 Removes unsused (unlinked) input/output ports.
 
std::shared_ptr< GraphOutputNode > output_node ()
 
std::shared_ptr< GraphInputNode > input_node ()
 
PortIndex add_input (PortBaseInPtr in)
 Convenience alias to add_port(inputs(), in)
 
template<typename T , typename... U>
auto add_input (U &&... u)
 Adds a typed input port.
 
PortIndex add_output (PortBaseOutPtr out)
 Convenience alias to add_port(outputs(), out)
 
template<typename T , typename... U>
auto add_output (U &&... u)
 Adds a typed output port.
 
- Public Member Functions inherited from Ra::Dataflow::Core::Node
virtual ~Node ()=default
 make Node a base abstract class
 
bool operator== (const Node &node)
 Two nodes are considered equal if there model and instance names are the same.
 
void add_metadata (const nlohmann::json &data)
 Add a metadata to the node to store application specific information.
 
const nlohmann::json & metadata ()
 Give access to extra json data stored on the node.
 
bool is_initialized () const
 
Ra::Core::VariableSetparameters ()
 Return node's parameters.
 
Ra::Core::VariableSetinput_variables ()
 Return a variable set of input ports default value reference, if any.
 
bool is_output ()
 Node is output if none of the output ports is linked.
 
bool is_input ()
 Node is input if all input ports have default values and not linked.
 
 Node (const Node &)=delete
 
Nodeoperator= (const Node &)=delete
 
auto port_by_name (const std::string &type, const std::string &name) const -> IndexAndPort< PortBaseRawPtr >
 Get a port by its name.
 
auto input_by_name (const std::string &name) const -> IndexAndPort< PortBaseInRawPtr >
 Convenience alias to port_by_name("in", name)
 
auto output_by_name (const std::string &name) const -> IndexAndPort< PortBaseOutRawPtr >
 Convenience alias to port_by_name("out", name)
 
PortBaseRawPtr port_by_index (const std::string &type, PortIndex index) const
 Get a port by its index.
 
auto input_by_index (PortIndex index) const
 Convenience alias to port_by_index("in", index)
 
auto output_by_index (PortIndex index) const
 Convenience alias to port_by_index("out", index)
 
template<typename T >
auto input_by_index (PortIndex index) const
 Convenience alias with typed port.
 
template<typename T >
auto output_by_index (PortIndex index) const
 Convenience alias with typed port.
 
const PortBaseInCollectioninputs () const
 Gets the in ports of the node.
 
const PortBaseOutCollectionoutputs () const
 Gets the out ports of the node.
 
const std::stringmodel_name () const
 Gets the model (type/class) name of the node.
 
const std::stringdisplay_name () const
 Gets the display name of the node (e.g. for gui), no need to be unique in a graph.
 
void set_display_name (const std::string &name)
 Set the display name.
 
const std::stringinstance_name () const
 Gets the instance name of the node.
 
void set_instance_name (const std::string &name)
 Sets the instance name the node (unused?) instance name must be unique in a graph.
 
void toJson (nlohmann::json &data) const
 Serialize the content of the node.
 
bool fromJson (const nlohmann::json &data)
 Unserialized the content of the node.
 

Static Public Member Functions

static const std::stringnode_typename ()
 
static std::shared_ptr< DataflowGraphloadGraphFromJsonFile (const std::string &filename)
 Load a graph from the given file.
 

Protected Member Functions

 DataflowGraph (const std::string &instanceName, const std::string &typeName)
 Allow derived class to construct the graph with their own static type.
 
bool fromJsonInternal (const nlohmann::json &data) override
 Internal json representation of the Node.
 
void toJsonInternal (nlohmann::json &) const override
 Internal json representation of the Node.
 
bool has_node_by_name (const std::string &instance, const std::string &model) const
 Check if there node with same instance and model is in the graph.
 
bool contains_node_recursive (const Node *node) const
 Check if node is part of the graph, or part of its "inner" graph.
 
- Protected Member Functions inherited from Ra::Dataflow::Core::Node
 Node (const std::string &instance, const std::string &typeName)
 Construct the base node given its name and type.
 
template<typename PortType >
auto port_by_name (const PortCollection< PortPtr< PortType > > &ports, const std::string &name) const -> IndexAndPort< PortRawPtr< PortType > >
 Gets the Port By Name.
 
template<typename PortType >
auto port_base (const PortCollection< PortPtr< PortType > > &ports, PortIndex idx) const -> PortRawPtr< PortType >
 Gets the PortBase In or Out by its index.
 
template<typename T , typename PortType >
auto port (const PortCollection< PortPtr< PortType > > &ports, PortIndex index) const
 Gets a port in a collection by its index.
 
template<typename PortType >
PortIndex add_port (PortCollection< PortPtr< PortType > > &, PortPtr< PortType > port)
 Adds a port to port collection.
 
PortIndex add_input (PortBaseInPtr in)
 Convenience alias to add_port(inputs(), in)
 
PortIndex add_output (PortBaseOutPtr out)
 Convenience alias to add_port(outputs(), out)
 
template<typename T , typename... U>
auto add_input (U &&... u)
 Adds a typed input port.
 
template<typename T , typename... U>
auto add_output (U &&... u)
 Adds a typed output port.
 
template<typename T >
auto input_port (PortIndex index)
 Gets a typed (input/output) port.
 
template<typename T >
auto output_port (PortIndex index)
 Gets a typed (input/output) port.
 
void remove_input (PortIndex index)
 Remove the given port from the managed (input/output) ports.
 
void remove_output (PortIndex index)
 Remove the given port from the managed (input/output) ports.
 
template<typename T >
auto add_parameter (const std::string &name, const T &value)
 
template<typename T >
bool remove_parameter (const std::string &name)
 
template<typename T >
bool remove_parameter (ParamHandle< T > &handle)
 

Additional Inherited Members

- Public Types inherited from Ra::Dataflow::Core::Node
using PortIndex = Ra::Core::Utils::Index
 
template<typename Port >
using PortCollection = std::vector<Port>
 
template<typename Port >
using PortPtr = std::shared_ptr<Port>
 
template<typename Port >
using PortRawPtr = Port*
 
template<typename Type >
using PortInPtr = PortPtr<PortIn<Type>>
 
template<typename Type >
using PortInRawPtr = PortIn<Type>*
 
template<typename Type >
using PortOutPtr = PortPtr<PortOut<Type>>
 
template<typename Type >
using PortOutRawPtr = PortOut<Type>*
 
using PortBasePtr = PortPtr<PortBase>
 
using PortBaseRawPtr = PortRawPtr<PortBase>
 
using PortBaseCollection = PortCollection<PortBasePtr>
 
using PortBaseInPtr = PortPtr<PortBaseIn>
 
using PortBaseInRawPtr = PortRawPtr<PortBaseIn>
 
using PortBaseInCollection = PortCollection<PortBaseInPtr>
 
using PortBaseOutPtr = PortPtr<PortBaseOut>
 
using PortBaseOutRawPtr = PortRawPtr<PortBaseOut>
 
using PortBaseOutCollection = PortCollection<PortBaseOutPtr>
 
template<typename Port >
using IndexAndPort = std::pair<PortIndex, Port>
 
template<typename T >
using ParamHandle = Ra::Core::VariableSet::VariableHandle<T>
 
- Protected Attributes inherited from Ra::Dataflow::Core::Node
bool m_initialized { false }
 Flag that checks if the node is already initialized.
 
std::string m_model_name
 The type name of the node. Initialized once at construction.
 
std::string m_instance_name
 The instance name of the node.
 
std::string m_display_name { "" }
 Node's name if needed for display.
 
PortCollection< PortPtr< PortBaseIn > > m_inputs
 The in ports of the node (own by the node)
 
PortCollection< PortPtr< PortBaseOut > > m_outputs
 The out ports of the node (own by the node)
 
Ra::Core::VariableSet m_parameters
 The editable parameters of the node.
 
Ra::Core::VariableSet m_input_variables
 
nlohmann::json m_metadata
 Additional data on the node, added by application or gui or ...
 

Detailed Description

Represent a set of connected nodes that define a Direct Acyclic Computational Graph Ownership of nodes is given to the graph at construction time.

Definition at line 23 of file DataflowGraph.hpp.

Constructor & Destructor Documentation

◆ DataflowGraph() [1/2]

Ra::Dataflow::Core::DataflowGraph::DataflowGraph ( const std::string & name)
explicit

The nodes pointing to external data are created here.

Parameters
nameThe name of the render graph.

Definition at line 20 of file DataflowGraph.cpp.

◆ DataflowGraph() [2/2]

Ra::Dataflow::Core::DataflowGraph::DataflowGraph ( const std::string & instanceName,
const std::string & typeName )
protected

Allow derived class to construct the graph with their own static type.

Definition at line 22 of file DataflowGraph.cpp.

Member Function Documentation

◆ add_input() [1/2]

Node::PortIndex Ra::Dataflow::Core::Node::add_input ( PortBaseInPtr in)
inline

Convenience alias to add_port(inputs(), in)

Definition at line 328 of file Node.hpp.

◆ add_input() [2/2]

template<typename T , typename... U>
auto Ra::Dataflow::Core::Node::add_input ( U &&... u)
inline

Adds a typed input port.

Template Parameters
TPort data type.
Parameters
uPort ctor parameter.
Returns
Typed port shared pointer.

Definition at line 340 of file Node.hpp.

◆ add_input_output_nodes()

void Ra::Dataflow::Core::DataflowGraph::add_input_output_nodes ( )
inline

Create (if not already created) input/output node of the graph, and fills graph input/output.

These nodes are usefull for using graph as node and stating the graph as node input/output ports.

Definition at line 415 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ add_link() [1/4]

bool Ra::Dataflow::Core::DataflowGraph::add_link ( const std::shared_ptr< Node > & nodeFrom,
const std::string & nodeFromOutputName,
const std::shared_ptr< Node > & nodeTo,
const std::string & nodeToInputName )

Connects two nodes of the graph.

The two nodes must already be in the graph (with the add_node), in order to be linked the seconde node's in port must be free and the connected in port and out port must have the same type of data.

Parameters
nodeFromThe node that contains the out port.
nodeFromOutputNameThe name of the out port in nodeFrom.
nodeToThe node that contains the in port.
nodeToInputNameThe name of the in port in nodeTo.
Returns
true if link added, false if link could not be made.

Definition at line 305 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ add_link() [2/4]

bool Ra::Dataflow::Core::DataflowGraph::add_link ( const std::shared_ptr< Node > & nodeFrom,
Node::PortIndex portOutIdx,
const std::shared_ptr< Node > & nodeTo,
Node::PortIndex portInIdx )

Convenience alias using port index.

Definition at line 325 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ add_link() [3/4]

template<typename T , typename U >
bool Ra::Dataflow::Core::DataflowGraph::add_link ( const std::shared_ptr< PortOut< T > > & outputPort,
const std::shared_ptr< PortIn< U > > & inputPort )

Convenience typed alias.

Definition at line 360 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ add_link() [4/4]

bool Ra::Dataflow::Core::DataflowGraph::add_link ( Node::PortBaseOutRawPtr outputPort,
Node::PortBaseInRawPtr inputPort )

Convenience alias using port raw ptr, checks if ports' nodes are in the graph.

Definition at line 368 of file DataflowGraph.cpp.

◆ add_node() [1/2]

bool Ra::Dataflow::Core::DataflowGraph::add_node ( std::shared_ptr< Node > newNode)
virtual

Adds a node to the graph.

Parameters
newNodeThe node to add to the graph.
Returns
true if node has been added to the graph (no other node with same model and instance name), false otherwise.

Definition at line 259 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ add_node() [2/2]

template<typename T , typename... U>
std::shared_ptr< T > Ra::Dataflow::Core::DataflowGraph::add_node ( U &&... u)

Conveniance typed alias.

Definition at line 353 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ add_output() [1/2]

Node::PortIndex Ra::Dataflow::Core::Node::add_output ( PortBaseOutPtr out)
inline

Convenience alias to add_port(outputs(), out)

Definition at line 330 of file Node.hpp.

◆ add_output() [2/2]

template<typename T , typename... U>
auto Ra::Dataflow::Core::Node::add_output ( U &&... u)
inline

Adds a typed output port.

Template Parameters
TPort data type.
Parameters
uPort ctor parameter.
Returns
Typed port shared pointer.

Definition at line 352 of file Node.hpp.

◆ can_link() [1/2]

bool Ra::Dataflow::Core::DataflowGraph::can_link ( const Node * nodeFrom,
Node::PortIndex portOutIdx,
const Node * nodeTo,
Node::PortIndex portInIdx ) const
inline

Convenience alias using raw pointer.

Definition at line 376 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ can_link() [2/2]

bool Ra::Dataflow::Core::DataflowGraph::can_link ( const std::shared_ptr< Node > & nodeFrom,
Node::PortIndex portOutIdx,
const std::shared_ptr< Node > & nodeTo,
Node::PortIndex portInIdx ) const
inline
Returns
true if ports can be linked

Definition at line 369 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ clear_nodes()

void Ra::Dataflow::Core::DataflowGraph::clear_nodes ( )
virtual

Deletes all nodes from the render graph.

Definition at line 504 of file DataflowGraph.cpp.

◆ compile()

bool Ra::Dataflow::Core::DataflowGraph::compile ( )
overridevirtual

Compile the graph to check its validity and simplify it.

The compilation has multiple goals:

  • Remove the nodes that have no direct or indirect connections to sink nodes
  • Order the nodes by level according to their dependencies
  • Check if every mandatory port is linked

Node -> level, linked nodes

Reimplemented from Ra::Dataflow::Core::Node.

Definition at line 429 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ contains_node_recursive()

bool Ra::Dataflow::Core::DataflowGraph::contains_node_recursive ( const Node * node) const
protected

Check if node is part of the graph, or part of its "inner" graph.

Parameters
nodeRaw pointer of the node to find.

Definition at line 412 of file DataflowGraph.cpp.

◆ destroy()

void Ra::Dataflow::Core::DataflowGraph::destroy ( )
overridevirtual

Delete the node's content.

The destroy() function is called once at the end of the lifetime of the node. Its goal is to free the internal data that have been allocated.

Reimplemented from Ra::Dataflow::Core::Node.

Definition at line 57 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ execute()

bool Ra::Dataflow::Core::DataflowGraph::execute ( )
overridevirtual

Executes the node.

Execute the node function on the input ports (to be fetched) and write the results to the output ports.

Returns
the execution status.

Implements Ra::Dataflow::Core::Node.

Definition at line 36 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ fromJsonInternal()

bool Ra::Dataflow::Core::DataflowGraph::fromJsonInternal ( const nlohmann::json & data)
overrideprotectedvirtual

Internal json representation of the Node.

Default implementation warn about unsupported deserialization. Effective deserialzation must be implemented by inheriting classes. Be careful with template specialization and function member overriding in derived classes.

Reimplemented from Ra::Dataflow::Core::Node.

Definition at line 174 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ generate_ports()

void Ra::Dataflow::Core::DataflowGraph::generate_ports ( )

fill input and output ports of graph from its input and output nodes if exists.

See also
add_input_output_nodes()

Definition at line 424 of file DataflowGraph.cpp.

◆ has_node_by_name()

bool Ra::Dataflow::Core::DataflowGraph::has_node_by_name ( const std::string & instance,
const std::string & model ) const
protected

Check if there node with same instance and model is in the graph.

Parameters
instanceInstance name to search
modelModel name to search

Definition at line 405 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ init()

void Ra::Dataflow::Core::DataflowGraph::init ( )
overridevirtual

Initializes the node content.

The init() function should be called once at the beginning of the lifetime of the node by the owner of the node (the graph which contains the node). Its goal is to initialize the node's internal data if any. The default do nothing.

Reimplemented from Ra::Dataflow::Core::Node.

Definition at line 25 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ input_node()

std::shared_ptr< GraphInputNode > Ra::Dataflow::Core::DataflowGraph::input_node ( )
inline

Definition at line 256 of file DataflowGraph.hpp.

◆ input_node_port()

Node::PortBaseInRawPtr Ra::Dataflow::Core::DataflowGraph::input_node_port ( const std::string & nodeName,
const std::string & portName )
inline

Gets an input port form a node of the graph.

This input port could then be used through setter->set_default_value( data ) to set the graph input from the data.

Note
The raw pointer is only valid as graph is valid.
Parameters
nodeNomeThe name of the node
portNameThe name of the input port
Returns
the port if exists, nullptr otherwise.

Definition at line 398 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ is_compiled()

bool Ra::Dataflow::Core::DataflowGraph::is_compiled ( ) const
inline

Test if the graph is compiled.

Definition at line 174 of file DataflowGraph.hpp.

◆ loadFromJson()

bool Ra::Dataflow::Core::DataflowGraph::loadFromJson ( const std::string & jsonFilePath)

Loads nodes and links from a JSON file.

Parameters
jsonFilePathThe path to the JSON file.
Returns
true if the file was loaded, false if an error occurs.

Definition at line 124 of file DataflowGraph.cpp.

◆ loadGraphFromJsonFile()

std::shared_ptr< DataflowGraph > Ra::Dataflow::Core::DataflowGraph::loadGraphFromJsonFile ( const std::string & filename)
static

Load a graph from the given file.

Any type of graph that inherits from DataflowGraph can be loaded by this function as soon as the appropriate constructor is registered in Ra::Dataflow::NodeFactoriesManager.

Parameters
filename
Returns
The loaded graph, as a DataFlowGraph pointer to be downcast to the correct type

Definition at line 585 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ needs_recompile()

void Ra::Dataflow::Core::DataflowGraph::needs_recompile ( )
inline

Mark the graph as needing recompilation (useful to force recompilation and resources update)

Definition at line 393 of file DataflowGraph.hpp.

◆ node() [1/2]

std::shared_ptr< Node > Ra::Dataflow::Core::DataflowGraph::node ( const std::string & instanceNameNode) const

Gets a specific node according to its instance name.

Parameters
instanceNameNodeThe instance name of the node.

Definition at line 574 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ node() [2/2]

template<typename T >
std::shared_ptr< T > Ra::Dataflow::Core::DataflowGraph::node ( const std::string & instanceNameNode) const
inline

Gets a specific node according to its instance name.

Parameters
instanceNameNodeThe instance name of the node.

Dynamic cast of the node pointer to T

Template Parameters
TNode's type to cast node to.

Definition at line 143 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ node_count()

size_t Ra::Dataflow::Core::DataflowGraph::node_count ( ) const
inline

Gets the number of nodes.

Definition at line 168 of file DataflowGraph.hpp.

◆ node_typename()

const std::string & Ra::Dataflow::Core::DataflowGraph::node_typename ( )
inlinestatic

Definition at line 430 of file DataflowGraph.hpp.

◆ nodes()

const std::vector< std::shared_ptr< Node > > & Ra::Dataflow::Core::DataflowGraph::nodes ( ) const
inline

Get the vector of all the nodes on the graph.

Definition at line 130 of file DataflowGraph.hpp.

◆ nodes_by_level()

const std::vector< std::vector< Node * > > & Ra::Dataflow::Core::DataflowGraph::nodes_by_level ( ) const
inline

Gets the nodes ordered by level (after compilation)

Definition at line 148 of file DataflowGraph.hpp.

◆ nodesAndLinksProtection()

bool Ra::Dataflow::Core::DataflowGraph::nodesAndLinksProtection ( ) const
inline

get the protection status protect nodes and links from deletion

Returns
the protection status

Definition at line 231 of file DataflowGraph.hpp.

◆ output_node()

std::shared_ptr< GraphOutputNode > Ra::Dataflow::Core::DataflowGraph::output_node ( )
inline

Definition at line 255 of file DataflowGraph.hpp.

◆ output_node_port()

Node::PortBaseOutRawPtr Ra::Dataflow::Core::DataflowGraph::output_node_port ( const std::string & nodeName,
const std::string & portName )
inline

Gets an output port from a node of the graph.

Allows to get the data stored at this port after the execution of the graph. The return port can be use as in port->data().

Note
ownership is left to the graph, not shared. The graph must survive the returned raw pointer to be able to use the dataGetter.
Parameters
nodeNomeThe name of the node
portNameThe name of the output port
Returns
the port if exists, nullptr otherwise.

Definition at line 406 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ remove_link() [1/2]

bool Ra::Dataflow::Core::DataflowGraph::remove_link ( std::shared_ptr< Node > node,
const PortIndex & in_port_index )

Removes the link connected to a node's input port.

Parameters
nodethe node to unlink
in_port_indexindex of the port's input port to unlink
Returns
true if link is removed, false if not.

Definition at line 387 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ remove_link() [2/2]

bool Ra::Dataflow::Core::DataflowGraph::remove_link ( std::shared_ptr< Node > node,
const std::string & nodeInputName )

Removes the link connected to a node's input port.

Parameters
nodethe node to unlink
nodeInputNamethe name of the port to unlink
Returns
true if link is removed, false if not.

Definition at line 382 of file DataflowGraph.cpp.

◆ remove_node()

bool Ra::Dataflow::Core::DataflowGraph::remove_node ( std::shared_ptr< Node > node)
virtual

Removes a node from the graph.

Parameters
nodeThe node to remove from the graph.
Returns
true if the node was removed.

Definition at line 269 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ remove_unlinked_input_output_ports()

void Ra::Dataflow::Core::DataflowGraph::remove_unlinked_input_output_ports ( )
inline

Removes unsused (unlinked) input/output ports.

A (e.g. input) port is unlink, if the corresponding ports of input_node is unlink both on input (outside the graph) and input (inside the graph).

Note
invalidate port indices

Definition at line 424 of file DataflowGraph.hpp.

+ Here is the call graph for this function:

◆ saveToJson()

void Ra::Dataflow::Core::DataflowGraph::saveToJson ( const std::string & jsonFilePath)

Saves nodes and links to a JSON file.

Parameters
jsonFilePathThe path to the JSON file.

Definition at line 66 of file DataflowGraph.cpp.

+ Here is the call graph for this function:

◆ setNodesAndLinksProtection()

void Ra::Dataflow::Core::DataflowGraph::setNodesAndLinksProtection ( bool on)
inline

protect nodes and links from deletion.

Parameters
ontrue to protect, false to unprotect.
Todo
should this be only on gui side ?

Definition at line 225 of file DataflowGraph.hpp.

◆ shouldBeSaved()

bool Ra::Dataflow::Core::DataflowGraph::shouldBeSaved ( )
inline

Definition at line 206 of file DataflowGraph.hpp.

◆ toJsonInternal()

void Ra::Dataflow::Core::DataflowGraph::toJsonInternal ( nlohmann::json & data) const
overrideprotectedvirtual

Internal json representation of the Node.

Default implementation warn about unsupported deserialization. Effective deserialzation must be implemented by inheriting classes. Be careful with template specialization and function member overriding in derived classes.

Reimplemented from Ra::Dataflow::Core::Node.

Definition at line 76 of file DataflowGraph.cpp.


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