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

Added non-const accessors for Link child objects #838

Merged
merged 5 commits into from
Feb 15, 2022

Conversation

nkoenig
Copy link
Contributor

@nkoenig nkoenig commented Feb 2, 2022

Signed-off-by: Nate Koenig nate@openrobotics.org

🎉 New feature

Summary

I need the ability to access mutable versions of child objects. This is part of my effort to support building and editing the SDF DOM programmatically. I've added private helper functions in order to reduce code duplication.

Test it

Run the tests.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Nate Koenig <nate@openrobotics.org>
@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2022

Codecov Report

Merging #838 (27207bf) into sdf12 (8e832e7) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            sdf12     #838      +/-   ##
==========================================
+ Coverage   90.76%   90.80%   +0.03%     
==========================================
  Files          78       78              
  Lines       12535    12555      +20     
==========================================
+ Hits        11378    11400      +22     
+ Misses       1157     1155       -2     
Impacted Files Coverage Δ
src/Link.cc 98.53% <100.00%> (+0.90%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e832e7...27207bf. Read the comment docs.

src/Link.cc Outdated
/////////////////////////////////////////////////
Visual *Link::VisualByIndex(uint64_t _index)
{
return const_cast<Visual*>(this->dataPtr->VisualByIndex(_index));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine, but we could avoid creating all the helper functions by keeping the implementation in the original const function (i.e Link::VisualByIndex() const) and calling that from here via const_cast: https://stackoverflow.com/a/123995/283225

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, the double cast. Done in 9ef6f94. I'll make similar changes to the other PRs.

Signed-off-by: Nate Koenig <nate@openrobotics.org>
@nkoenig nkoenig requested a review from azeey February 2, 2022 21:09
@nkoenig nkoenig changed the title Added non-const accessors for child objects Added non-const accessors for Link child objects Feb 7, 2022
@nkoenig nkoenig merged commit 8e89865 into sdf12 Feb 15, 2022
@nkoenig nkoenig deleted the link_mutable_accessors branch February 15, 2022 00:47
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-04-13-fortress-edifice/1367/1

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

Successfully merging this pull request may close these issues.

5 participants