From 4f89ce4ab05735a8e8a00e6b8b319908f5bf1532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20KUBLER?= <gregoire.kubler@proton.me> Date: Mon, 18 Mar 2024 16:58:45 +0100 Subject: [PATCH] feat : new operator<< for node. --- include/aidge/graph/Node.hpp | 9 +++++++++ src/graph/Node.cpp | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/aidge/graph/Node.hpp b/include/aidge/graph/Node.hpp index de2a7b6aa..c9004a8e4 100644 --- a/include/aidge/graph/Node.hpp +++ b/include/aidge/graph/Node.hpp @@ -456,7 +456,16 @@ private: * @param inId index for adding the parent. */ 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 5d210144e..c84e19df9 100644 --- a/src/graph/Node.cpp +++ b/src/graph/Node.cpp @@ -382,6 +382,26 @@ 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 -- GitLab