Go to the documentation of this file.
25 #include <boost/python.hpp>
31 template<
class T,
class T_IN>
32 concept
INPUT_C = std::is_base_of_v<InputNode<T_IN>, T>;
37 template <
class T_IN,
class T_OUT, INPUT_C<T_IN> INPUT_CLASS>
59 boost::python::object
pySetup(
const boost::python::object& obj)
62 std::shared_ptr<ComputationalNode> node(
makeNewNode());
64 INPUT_CLASS* iNode =
dynamic_cast<INPUT_CLASS*
>(node.get());
66 throw NRPException::logCreate(
"Error in creating Input Node: a node with the same name (\""+node->id()+
"\") is already registered with a different type");
70 iNode->registerOutput(
_port);
73 if(boost::python::extract<std::shared_ptr<PythonFunctionalNode>>(obj).check()) {
75 std::shared_ptr<PythonFunctionalNode> pyFn = boost::python::extract<std::shared_ptr<PythonFunctionalNode>>(obj);
78 else if(boost::python::extract<std::shared_ptr<FunctionalNodeBase>>(obj).check()) {
80 std::shared_ptr<FunctionalNodeBase> pyFn = boost::python::extract<std::shared_ptr<FunctionalNodeBase>>(obj);
84 throw NRPException::logCreate(
"InputEdge \""+node->id()+
"\" was called with the wrong argument type. Argument must be a FunctionalNode object");
100 cgm.registerEdge<T_IN, boost::python::object>(
101 iNode->getSinglePort(
_port), pyFn->getOrRegisterInput<T_IN>(
_keyword));
103 cgm.registerEdge<std::vector<const T_IN*>, boost::python::object>(
104 iNode->getListPort(
_port), pyFn->getOrRegisterInput<std::vector<const T_IN*>>(
_keyword));
107 throw NRPException::logCreate(
"An error occurred while creating graph edge to input node \""+iNode->id()+
"\"");
118 std::string errorMsg =
"Port \"" +
_keyword +
"\" of Node \"" + pyFn->id() +
119 "\" can't be connected to port \"" +
_port +
"\" of Node " + iNode->id() +
120 "\". Probably there is a mismatch between the port types. Review your CG configuration.";
126 cgm.registerEdge<T_IN, T_OUT>(
127 iNode->getSinglePort(
_port), iPort);
134 cgm.registerEdge<std::vector<const T_IN *>, std::vector<const T_OUT *>>(
135 iNode->getListPort(
_port), iPort);
139 throw NRPException::logCreate(
"An error occurred while creating graph edge to input node \""+iNode->id()+
"\"");
158 template <
class T_IN, INPUT_C<T_IN> INPUT_CLASS>
161 #endif //INPUT_EDGE_H
Base NRPException class.
Definition: nrp_exceptions.h:36
void registerNode(std::shared_ptr< ComputationalNode > &obj)
Register a node in the graph.
Definition: computational_graph_manager.h:75
static ComputationalGraphManager & getInstance()
Get singleton instance of ComputationalGraphManager.
Definition: computational_graph_manager.cpp:31
static EXCEPTION logCreate(LOG_EXCEPTION_T &exception, const std::string &msg, NRPLogger::spdlog_out_fcn_t spdlogCall=NRPLogger::critical)
Definition: nrp_exceptions.h:73
port
Definition: python_json_engine.py:197