Go to the documentation of this file.
22 #ifndef COMPUTATIONAL_NODE_H
23 #define COMPUTATIONAL_NODE_H
57 const std::string&
id()
const
64 {
return this->_type; }
70 {
return this->nodeTypeStr.at(this->
type()); }
76 { this->_visited = visited; }
82 {
return this->_visited; }
97 {
return _doCompute; }
106 static std::pair<std::string, std::string>
parseNodeAddress(
const std::string& address,
bool hasPort =
true)
108 if(address.at(0) !=
'/')
109 throw std::invalid_argument(
"Error while parsing node address \""+ address +
"\". Computational Graph addresses must start with '/'");
111 auto n = address.find(
'/',1);
112 if(n == std::string::npos && hasPort)
113 throw std::invalid_argument(
"Error while parsing node address \""+ address +
"\". Expected format is '/node_id/port_id'");
115 auto node = hasPort ? address.substr(1, n-1) : address.substr(1);
116 auto port = hasPort ? address.substr(n+1, address.size()) : node;
118 return std::make_pair(node,
port);
156 bool _visited =
false;
158 bool _doCompute =
false;
161 #endif //COMPUTATIONAL_NODE_H
NodeType
All the possible node types.
Definition: computational_node.h:35
ComputationalNode()=delete
void setDoCompute(bool doCompute)
Sets a value for the node 'doCompute' property, used in some graph execution modes.
Definition: computational_node.h:87
NodeType type() const
Returns the node 'type'.
Definition: computational_node.h:63
void setVisited(bool visited)
Sets a value for the node 'visited' property, used for graph traversing.
Definition: computational_node.h:75
@ Output
Definition: computational_node.h:37
const std::string & id() const
Returns the node 'id'.
Definition: computational_node.h:57
bool isVisited() const
Returns true if the node has been marked as visited, false otherwise.
Definition: computational_node.h:81
virtual void compute()=0
Requests the node to execute its computation.
friend class ComputationalGraphPythonNodes_PYTHON_DECORATORS_BASIC_Test
Definition: computational_node.h:147
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 addr...
Definition: computational_node.h:106
virtual bool doCompute() const
Tells if this node should be executed in this graph execution cycle, used in some graph execution mod...
Definition: computational_node.h:96
const static std::map< NodeType, std::string > nodeTypeStr
Definition: computational_node.h:41
@ Functional
Definition: computational_node.h:38
virtual void configure()=0
Configures the node making it ready to execute 'compute'.
virtual ~ComputationalNode()=default
ComputationalNode(std::string id, NodeType type)
Constructor.
Definition: computational_node.h:49
port
Definition: python_json_engine.py:197
virtual void graphLoadedCB()
Function called by the Computational Graph to nodes that the graph has been completely loaded.
Definition: computational_node.h:142
Definition: computational_graph.h:53
Singleton class managing a computational graph.
Definition: computational_graph_manager.h:45
virtual void graphCycleStartCB()
Function called by the Computational Graph at the beginning of a new execution cycle.
Definition: computational_node.h:136
@ Input
Definition: computational_node.h:36
Base class implementing a node in the computational graph.
Definition: computational_node.h:31
virtual std::string typeStr() const
Returns the node 'type' as a string.
Definition: computational_node.h:69