diff --git a/include/aidge/graph/GraphView.hpp b/include/aidge/graph/GraphView.hpp index 59c538ce640f9fb8a45c26a29b0c2599d883553e..6a0460941940f33a3be33bc9edbf84da32777730 100644 --- a/include/aidge/graph/GraphView.hpp +++ b/include/aidge/graph/GraphView.hpp @@ -160,7 +160,7 @@ public: /** * @brief List outside input connections of the GraphView. The vector - * size is garanteed to match the number of outside inputs of the GraphView. If there is + * size is guaranteed to match the number of outside inputs of the GraphView. If there is * no external connection to a given input, a pair of nullptr and gk_IODefaultIndex is returned. * @return std::vector<std::pair<NodePtr, IOIndex_t>> */ @@ -376,6 +376,12 @@ public: addChild(toOtherNode, mNodeRegistry.at(fromOutNodeName), fromTensor, toTensor); } + inline void updateNodeName(const std::string& oldName, const std::string& newName){ + AIDGE_ASSERT(mNodeRegistry.find(oldName) != mNodeRegistry.end(), "No node named {} in graph {}, the graph may be corrupted !", oldName, name()); + mNodeRegistry[newName] = mNodeRegistry[oldName]; + mNodeRegistry.erase(oldName); + } + /** * @brief Include a GraphView content in the current GraphView and link * the two sets by linking one Node from each GraphView. diff --git a/include/aidge/graph/Node.hpp b/include/aidge/graph/Node.hpp index 908f56295887bd2fbed3350a026045a4ab6b21d9..2a0a4a3b703670c8ace05e03fc5c797fe861a423 100644 --- a/include/aidge/graph/Node.hpp +++ b/include/aidge/graph/Node.hpp @@ -235,8 +235,8 @@ public: /////////////////////////////////////////////////////// /** - * @brief Vector of pointers to each GraphView containing the object - * @return std::vector<GraphView> + * @brief Set of pointers to each GraphView containing this Node + * @return std::set<GraphView> */ inline std::set<std::shared_ptr<GraphView>> views() const noexcept { std::set<std::shared_ptr<GraphView>> res; @@ -460,10 +460,10 @@ private: // OPERATOR FUNCTIONNAL but commented out to avoid iostream inclusion // /** // * @brief operator<< overload to ease print & debug of nodes - // * @param[inout] ostream to print to + // * @param[inout] ostream to print to // * @param[in] n node to print // */ - // friend std::ostream& operator << (std::ostream& os, Node& n); + // friend std::ostream& operator << (std::ostream& os, Node& n); }; } // namespace Aidge diff --git a/src/graph/Node.cpp b/src/graph/Node.cpp index 149691f796d1d84212e9d7842a28e4cb79469e6a..b08bb4c2056e8c14f5b1dd3aae62fbacf8d8c14e 100644 --- a/src/graph/Node.cpp +++ b/src/graph/Node.cpp @@ -57,7 +57,10 @@ Aidge::Connector Aidge::Node::operator()(const std::vector<Connector>& ctors) { // INNER /////////////////////////////////////////////////////// -void Aidge::Node::setName(const std::string& name) { mName = name; } +void Aidge::Node::setName(const std::string& name) { + for (auto graphView : views()) graphView->updateNodeName(mName, name); + mName = name; +} /////////////////////////////////////////////////////// // OPERATORS