diff --git a/include/aidge/graph/Node.hpp b/include/aidge/graph/Node.hpp index 7271b6bca72594823ac7316146c6248fbe1a60b4..c9004a8e4a5a34c9092a80f9044a5a343b5b7ad7 100644 --- a/include/aidge/graph/Node.hpp +++ b/include/aidge/graph/Node.hpp @@ -457,10 +457,15 @@ private: */ void addParent(const NodePtr otherNode, const IOIndex_t inId); + /** + * @brief operator<< overload to ease print & debug of nodes + * @param[inout] ostream to print to + * @param[in] n node to print + */ + friend std::ostream& operator << (std::ostream& os, Node& n); }; } // namespace Aidge - #endif /* AIDGE_CORE_GRAPH_NODE_H_ */ diff --git a/src/graph/Node.cpp b/src/graph/Node.cpp index a417300cf45f38f8af3909c24b1dc85b21e7b7ea..fb252c349ca1cb966dee3e4aa72872a3d358f0a0 100644 --- a/src/graph/Node.cpp +++ b/src/graph/Node.cpp @@ -390,6 +390,25 @@ std::set<Aidge::NodePtr> Aidge::Node::getNodeDelta(int delta, std::set<Aidge::No return out; } +namespace Aidge { +std::ostream& operator << (std::ostream& os, Aidge::Node& n) { + using namespace std; + os << "Node :\tName :\t\"" << n.name() << "\"\tType : \"" << n.getOperator()->type()<< "\"\tIN/OUTputs : "<< n.nbInputs() <<"/"<< n.nbOutputs() <<endl; + os << "\tParents :\t" ; + for (const auto & p : n.getParents()) + { + os << "\"" <<p->name() << "\"\t"; + } + os << endl; + os << "\tChildren :\t" ; + for (const auto & c : n.getChildren()) + { + os << "\"" << c->name() << "\"\t"; + } + os << endl; + return os; +} +} ///////////////////////////////////////////////////////////////////////////////////////////// // private