Skip to content
Snippets Groups Projects

Enhance createUniqueName

Merged Benjamin Halimi requested to merge createUniqueName into dev
All threads resolved!
+ 16
5
@@ -73,13 +73,24 @@ void Aidge::Node::setName(const std::string& name) {
mName = name;
}
std::string Aidge::Node::createUniqueName(std::string name){
for (auto graphView : views()){
if (graphView->inView(name)){
return createUniqueName(name.append("_"));
std::string Aidge::Node::createUniqueName(std::string baseName)
{
int index = 0;
bool isInside = true;
std::string newName;
while (isInside) {
std::string suffix = "_" + std::to_string(index);
newName = (index == 0) ? baseName : baseName + suffix;
isInside = false;
for (auto graphView : views()) {
if (graphView->inView(newName)) {
isInside = true;
break;
}
}
index++;
}
return name;
return newName;
}
///////////////////////////////////////////////////////
Loading