Go to the documentation of this file.
29 template<
class T,
class T_OUT>
30 concept
OUTPUT_C = std::is_base_of_v<OutputNode<T_OUT>, T>;
35 template <
class T_IN,
class T_OUT, OUTPUT_C<T_OUT> OUTPUT_CLASS>
46 bool publishFromCache,
47 unsigned int computePeriod) :
59 boost::python::object
pySetup(
const boost::python::object& obj)
62 std::shared_ptr<ComputationalNode> node(
makeNewNode());
64 OUTPUT_CLASS* oNode =
dynamic_cast<OUTPUT_CLASS*
>(node.get());
67 "was already registered with a different type");
70 if(boost::python::extract<std::shared_ptr<PythonFunctionalNode>>(obj).check()) {
72 std::shared_ptr<PythonFunctionalNode> pyFn = boost::python::extract<std::shared_ptr<PythonFunctionalNode>>(obj);
75 else if(boost::python::extract<std::shared_ptr<FunctionalNodeBase>>(obj).check()) {
77 std::shared_ptr<FunctionalNodeBase> pyFn = boost::python::extract<std::shared_ptr<FunctionalNodeBase>>(obj);
99 checkPortCanConnectOrThrow<boost::python::object>(iPort, oNode);
106 std::string error_msg =
"An error occurred while creating graph edge to output node \"" + oNode->id() +
"\"";
121 checkPortCanConnectOrThrow<T_IN>(iPort, oNode);
127 "\" can't be connected to port \"" +
_port +
"\" of Node " + oNode->id() +
128 "\". Probably there is a mismatch between the port types. Review your CG configuration.");
134 std::string error_msg =
"An error occurred while creating graph edge to output node \"" + oNode->id() +
"\"";
140 template<
class T_INPUT>
143 std::string error_info =
"";
145 error_info =
"port couldn't be found";
147 error_info =
"the maximum limit of connections for this port has been reached";
148 if(oNode->getComputePeriod() != 1)
149 error_info=
"the node has been configured with a compute period different than one and can only have one connection per port";
150 else if(oNode->publishFromCache())
151 error_info =
"the node has been configured to publish from cache and can only have one connection per port";
154 if(!error_info.empty()) {
155 std::string msg =
"Error when creating graph edge to output node \"" + oNode->id() +
"\", port \"" +
_port +
"\": " +
156 error_info +
". Check your graph definition.";
176 template <
class T_OUT, OUTPUT_C<T_OUT> OUTPUT_CLASS>
180 #endif //OUTPUT_EDGE_H
void registerEdge(OutputPort< T_IN > *source, InputPort< T_IN, T_OUT > *target)
Connects an InputPort to an Output port and registers an edge in the graph between their parent nodes...
Definition: computational_graph_manager.h:107
Base NRPException class.
Definition: nrp_exceptions.h:36
unsigned int _computePeriod
Definition: output_edge.h:173
bool _publishFromCache
Definition: output_edge.h:172
std::string _id
Definition: output_edge.h:170
void registerNode(std::shared_ptr< ComputationalNode > &obj)
Register a node in the graph.
Definition: computational_graph_manager.h:75
boost::python::object pySetup(const boost::python::object &obj)
call function in the decorator
Definition: output_edge.h:59
OutputEdge(std::string keyword, std::string id, std::string port, bool publishFromCache, unsigned int computePeriod)
Constructor.
Definition: output_edge.h:45
void checkPortCanConnectOrThrow(InputPort< T_INPUT, T_OUT > *iPort, OUTPUT_CLASS *oNode)
Definition: output_edge.h:141
std::string _port
Definition: output_edge.h:171
void registerEdgePythonFN(OUTPUT_CLASS *oNode, std::shared_ptr< PythonFunctionalNode > &pyFn)
registers an edge between oNode and pyFn. PythonFunctionalNode case
Definition: output_edge.h:92
Helper class used to implement Python output edge decorators.
Definition: output_edge.h:36
static ComputationalGraphManager & getInstance()
Get singleton instance of ComputationalGraphManager.
Definition: computational_graph_manager.cpp:31
virtual OUTPUT_CLASS * makeNewNode()=0
static EXCEPTION logCreate(LOG_EXCEPTION_T &exception, const std::string &msg, NRPLogger::spdlog_out_fcn_t spdlogCall=NRPLogger::critical)
Definition: nrp_exceptions.h:73
Implementation of an output port in the computation graph.
Definition: output_port.h:36
port
Definition: python_json_engine.py:197
void registerEdgeFNBase(OUTPUT_CLASS *oNode, const std::shared_ptr< FunctionalNodeBase > &pyFn)
registers an edge between oNode and pyFn. FunctionalNodeBase case
Definition: output_edge.h:114
std::string _keyword
Definition: output_edge.h:169
concept OUTPUT_C
Definition: output_edge.h:30