Skip to content
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

Add the ability to move a Connectable (#382) #434

Open
wants to merge 3 commits into
base: integration/v1.6.0
Choose a base branch
from

Conversation

sebalaig
Copy link
Contributor

@sebalaig sebalaig commented May 11, 2022

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest
Closes #382

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change or deprecate an API? If yes, check the following:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

(if any of the questions/checkboxes don't apply, please delete them entirely)

@sebalaig sebalaig self-assigned this May 11, 2022
@sebalaig sebalaig linked an issue May 11, 2022 that may be closed by this pull request
friend class bus_terminal::BusBreakerViewImpl;

friend class node_terminal::BusBreakerViewImpl;
friend class node_terminal::NodeBreakerViewImpl;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very proud of that... But this is necessary because move methods are not supposed to be in the public API...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree: I wonder if the methods are well placed. Looking to the C++ implementation, you can access to the attach/detach methods of the voltage level from the different views. It's probably better to move the code there to avoid these friend declarations.

Could you please ensure it is feasible or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be discussed: I'm not sure to understand and/or I think we have an issue in C++ implementation: attach & detach methods are in the public API of the VoltageLevel in C++, and not in Java.

include/powsybl/iidm/Connectable.hpp Outdated Show resolved Hide resolved
auto it = std::find_if(m_terminals.begin(), m_terminals.end(), [&oldTerminal](const std::unique_ptr<Terminal>& term) {
return stdcxx::areSame(*term, oldTerminal);
});
*it = std::move(terminal);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it working properly if the terminal is not found (could it really happen)?

Copy link
Contributor Author

@sebalaig sebalaig May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would crash... But I don't see how it could be possible, because the Connectable has a list of Terminal, and oldTerminal is one of them (by definition).

Maybe we should check it and throw an AssertionError if the terminal could not be found?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: write a unit test with a detached connectable

friend class bus_terminal::BusBreakerViewImpl;

friend class node_terminal::BusBreakerViewImpl;
friend class node_terminal::NodeBreakerViewImpl;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree: I wonder if the methods are well placed. Looking to the C++ implementation, you can access to the attach/detach methods of the voltage level from the different views. It's probably better to move the code there to avoid these friend declarations.

Could you please ensure it is feasible or not?

Signed-off-by: Sébastien LAIGRE <slaigre@silicom.fr>
Signed-off-by: Sébastien LAIGRE <slaigre@silicom.fr>
@powsybl powsybl deleted a comment from mathbagu May 24, 2022
…no notification)

Signed-off-by: Sébastien LAIGRE <slaigre@silicom.fr>
@sonarcloud
Copy link

sonarcloud bot commented May 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

56.5% 56.5% Coverage
0.0% 0.0% Duplication

@mathbagu
Copy link

mathbagu commented Jul 1, 2022

I have to dig into this PR: could you please remember me what information you are waiting for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move connectable
2 participants