-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modeler 4.7: Import connections and ports #2662
base: develop
Are you sure you want to change the base?
Conversation
src/io/inputs/model-converter/include/antares/io/inputs/model-converter/modelConverter.h
Outdated
Show resolved
Hide resolved
for (const auto& port: model.ports) | ||
{ | ||
// Can't have port with the same ID | ||
if (std::ranges::find_if(ports, [&port](const auto& p) { return p.Id() == port.id; }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line with legacy behaviour maybe we should collect all errors.
Somethings like :
for port in model.ports {
for each port {
if duplicate id => errors.add(ObjectWithThisIdAlreadyExists);
if idNotFound => errors.add(PortTypeNotFound)
}
}
if (error) {
log
throw/exit/whatever
}
for (const auto& port: model.ports) | ||
{ | ||
// Can't have port with the same ID | ||
if (std::ranges::find_if(ports, [&port](const auto& p) { return p.Id() == port.id; }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of find_if you can store ids in a map.
std::map<PortID, bool> already_foundId;
for port in model.ports{
if (already_foundId[port.id])) => error
already_foundId[port.id] = true;
...
src/io/inputs/model-converter/include/antares/io/inputs/model-converter/modelConverter.h
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many std::ranges::find_if
could be replaced with std::map::contains (if we used maps instead of vectors)
|
No description provided.