NRP Core  1.4.1
ComputationalNode Class Referenceabstract

Base class implementing a node in the computational graph. More...

#include <computational_node.h>

Inheritance diagram for ComputationalNode:
FunctionalNodeBase InputNode< DATA > InputNode< boost::python::object > InputNode< DataPack< MSG_TYPE > > InputNode< DataPackInterface > InputNode< MSG_TYPE > InputNode< nlohmann::json > InputNode< ulong > OutputNode< DATA > OutputNode< boost::python::object > OutputNode< DataPack< MSG_TYPE > * > OutputNode< DataPackInterface * > OutputNode< MSG_TYPE > OutputNode< nlohmann::json >

Public Types

enum  NodeType { Input, Output, Functional }
 All the possible node types. More...
 

Public Member Functions

 ComputationalNode ()=delete
 
virtual ~ComputationalNode ()=default
 
 ComputationalNode (std::string id, NodeType type)
 Constructor. More...
 
const std::string & id () const
 Returns the node 'id'. More...
 
NodeType type () const
 Returns the node 'type'. More...
 
virtual std::string typeStr () const
 Returns the node 'type' as a string. More...
 
void setVisited (bool visited)
 Sets a value for the node 'visited' property, used for graph traversing. More...
 
bool isVisited () const
 Returns true if the node has been marked as visited, false otherwise. More...
 
void setDoCompute (bool doCompute)
 Sets a value for the node 'doCompute' property, used in some graph execution modes. More...
 
virtual bool doCompute () const
 Tells if this node should be executed in this graph execution cycle, used in some graph execution modes. More...
 

Static Public Member Functions

static std::pair< std::string, std::string > parseNodeAddress (const std::string &address, bool hasPort=true)
 Parses a computational node address returning the node id and the port (if any) contained in the address. More...
 

Static Public Attributes

const static std::map< NodeType, std::string > nodeTypeStr
 

Protected Member Functions

virtual void configure ()=0
 Configures the node making it ready to execute 'compute'. More...
 
virtual void compute ()=0
 Requests the node to execute its computation. More...
 
virtual void graphCycleStartCB ()
 Function called by the Computational Graph at the beginning of a new execution cycle. More...
 
virtual void graphLoadedCB ()
 Function called by the Computational Graph to nodes that the graph has been completely loaded. More...
 

Friends

class ComputationalGraph
 
class ComputationalGraphManager
 
class ComputationalGraphPythonNodes_PYTHON_DECORATORS_BASIC_Test
 

Detailed Description

Base class implementing a node in the computational graph.

Member Enumeration Documentation

◆ NodeType

All the possible node types.

Enumerator
Input 

only can be source in edges

Output 

only can be target in edges

Functional 

can be source and target, ie. can receive inputs and send outputs

Constructor & Destructor Documentation

◆ ComputationalNode() [1/2]

ComputationalNode::ComputationalNode ( )
delete

◆ ~ComputationalNode()

virtual ComputationalNode::~ComputationalNode ( )
virtualdefault

◆ ComputationalNode() [2/2]

ComputationalNode::ComputationalNode ( std::string  id,
NodeType  type 
)
inline

Constructor.

Member Function Documentation

◆ compute()

◆ configure()

◆ doCompute()

virtual bool ComputationalNode::doCompute ( ) const
inlinevirtual

Tells if this node should be executed in this graph execution cycle, used in some graph execution modes.

ComputationalNode returns the value of its 'doCompute' property. Subclasses of ComputationalNode can implement further logic that can override this value

Reimplemented in OutputNode< DATA >.

◆ graphCycleStartCB()

virtual void ComputationalNode::graphCycleStartCB ( )
inlineprotectedvirtual

Function called by the Computational Graph at the beginning of a new execution cycle.

Reimplemented in OutputNode< DATA >, OutputNode< DataPack< MSG_TYPE > * >, OutputNode< MSG_TYPE >, OutputNode< boost::python::object >, OutputNode< nlohmann::json >, and OutputNode< DataPackInterface * >.

◆ graphLoadedCB()

virtual void ComputationalNode::graphLoadedCB ( )
inlineprotectedvirtual

Function called by the Computational Graph to nodes that the graph has been completely loaded.

Reimplemented in FunctionalNodeBase.

◆ id()

const std::string& ComputationalNode::id ( ) const
inline

Returns the node 'id'.

◆ isVisited()

bool ComputationalNode::isVisited ( ) const
inline

Returns true if the node has been marked as visited, false otherwise.

◆ parseNodeAddress()

static std::pair<std::string, std::string> ComputationalNode::parseNodeAddress ( const std::string &  address,
bool  hasPort = true 
)
inlinestatic

Parses a computational node address returning the node id and the port (if any) contained in the address.

Parameters
addressstring containing a computational graph connection address with the format /node_id/port_id
hasPortif the address contains a port id or just a node id
Returns
a pair with the node and port ids parsed from 'address'

◆ setDoCompute()

void ComputationalNode::setDoCompute ( bool  doCompute)
inline

Sets a value for the node 'doCompute' property, used in some graph execution modes.

◆ setVisited()

void ComputationalNode::setVisited ( bool  visited)
inline

Sets a value for the node 'visited' property, used for graph traversing.

◆ type()

NodeType ComputationalNode::type ( ) const
inline

Returns the node 'type'.

◆ typeStr()

virtual std::string ComputationalNode::typeStr ( ) const
inlinevirtual

Friends And Related Function Documentation

◆ ComputationalGraph

friend class ComputationalGraph
friend

◆ ComputationalGraphManager

friend class ComputationalGraphManager
friend

◆ ComputationalGraphPythonNodes_PYTHON_DECORATORS_BASIC_Test

friend class ComputationalGraphPythonNodes_PYTHON_DECORATORS_BASIC_Test
friend

Member Data Documentation

◆ nodeTypeStr

const std::map< ComputationalNode::NodeType, std::string > ComputationalNode::nodeTypeStr
static
Initial value:

The documentation for this class was generated from the following files:
ComputationalNode::Output
@ Output
Definition: computational_node.h:37
ComputationalNode::Functional
@ Functional
Definition: computational_node.h:38
ComputationalNode::Input
@ Input
Definition: computational_node.h:36