diff --git a/src/graph/Node.cpp b/src/graph/Node.cpp index cbaa4e59eeeb445f5e29f0178c001e0942b3df63..5d210144e2faa122416186734c52b67f1a0f8281 100644 --- a/src/graph/Node.cpp +++ b/src/graph/Node.cpp @@ -187,8 +187,12 @@ void Aidge::Node::setInputId(const IOIndex_t inId, const IOIndex_t newNodeoutId) void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t outId, const IOIndex_t otherInId) { - assert((otherInId < otherNode->nbInputs()) && "Input index out of bound."); - assert((outId < nbOutputs()) && "Output index out of bound."); + AIDGE_ASSERT(otherInId < otherNode->nbInputs(), + "Input index (#{}) of the node {} (of type {}) is out of bound (it has {} inputs), when trying to add it as a child of node {} (of type {})", + otherInId, otherNode->name(), otherNode->type(), otherNode->nbInputs(), name(), type()); + AIDGE_ASSERT(outId < nbOutputs(), + "Output index (#{}) of the node {} (of type {}) is out of bound (it has {} outputs), when trying to add the child node {} (of type {})", + outId, name(), type(), nbOutputs(), otherNode->name(), otherNode->type()); if (otherNode->input(otherInId).second != gk_IODefaultIndex) { fmt::print("Warning, the {}-th Parent of the child node already existed.\n", otherInId); } @@ -203,18 +207,11 @@ void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t ou void Aidge::Node::addChildView(std::shared_ptr<GraphView> otherGraph, const IOIndex_t outId, std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) { - assert((otherInId.second < otherInId.first->nbInputs()) && - "Other graph input index out of bound."); - assert((outId < nbOutputs()) && "Output index out of bound."); - std::set<std::shared_ptr<Node>> inNodes = otherGraph->inputNodes(); - if (inNodes.size() == std::size_t(0)) { // no input Node - fmt::print("Cannot add GraphView to the Node. No input node detected.\n"); - } else // inNodes.size() >= 1 - { - assert((inNodes.find(otherInId.first) != - inNodes.end())); // assert it really is an input node - addChildOp(otherInId.first, outId, otherInId.second); - } + const auto inNodes = otherGraph->inputNodes(); + AIDGE_ASSERT(otherInId.first != nullptr && inNodes.find(otherInId.first) != inNodes.end(), + "Node {} (of type {}) is not a valid input node of GraphView {}, when trying to add it as a child of node {} (of type {})", + (otherInId.first) ? otherInId.first->name() : "#nullptr", (otherInId.first) ? otherInId.first->type() : "", otherGraph->name(), name(), type()); + addChildOp(otherInId.first, outId, otherInId.second); } void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outId, @@ -229,9 +226,9 @@ void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outI void Aidge::Node::addChild(std::shared_ptr<GraphView> otherView, const IOIndex_t outId, std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) { if (!otherInId.first) { - assert((otherView->inputNodes().size() == 1U) && - "Specify an input Node for the GraphView. More or less than one " - "Node is not explicit."); + AIDGE_ASSERT(otherView->inputNodes().size() == 1U, + "Input node of GraphView {} need to be specified, because it has more than one input ({} inputs), when trying to add it as a child of node {} (of type {})", + otherView->name(), otherView->inputNodes().size(), name(), type()); otherInId.first = *(otherView->inputNodes().begin()); } otherInId.second = (otherInId.second != gk_IODefaultIndex)