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

Making PrintValues() and ToString() able to not print default elements #575

Merged
merged 24 commits into from
Jun 17, 2021

Conversation

marcoag
Copy link
Member

@marcoag marcoag commented May 19, 2021

Related to #287

Summary

Now PrintValues() and ToString() will not output the elements that were added by default during parsing. There's also the option to call them with a boolean flag that will allow the caller to decide weather they want defaults int the output or not.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Code check passed (In source directory, run sh tools/code_check.sh)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review

Note to maintainers: Remember to use Squash-Merge

Marco A. Gutierrez and others added 18 commits April 19, 2021 13:40
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
… sibling elements

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Add failing test showing that SetExplicitlySetInFile incorrectly sets the flag on sibling elements
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
…add_default_check

Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
@github-actions github-actions bot added the 🏰 citadel Ignition Citadel label May 19, 2021
Copy link
Collaborator

@aaronchongth aaronchongth left a comment

Choose a reason for hiding this comment

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

Just did a quick look through and requested some changes to the API functions. Looks great! Are all the bullet points in #287 addressed at this point, such that it closes it?

include/sdf/Element.hh Outdated Show resolved Hide resolved
include/sdf/Element.hh Outdated Show resolved Hide resolved
include/sdf/Element.hh Outdated Show resolved Hide resolved
include/sdf/Element.hh Outdated Show resolved Hide resolved
include/sdf/Element.hh Outdated Show resolved Hide resolved
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
@marcoag
Copy link
Member Author

marcoag commented May 20, 2021

I thought we got to that point, but maybe @azeey should confirm...

@azeey
Copy link
Collaborator

azeey commented May 20, 2021

I thought we got to that point, but maybe @azeey should confirm...

I think #287 only needed #542, but I remember @marcoag mentioning there were still some issues when upconverting SDFormat files. If that's the case, we should probably keep it open until that's resolved.

@marcoag
Copy link
Member Author

marcoag commented May 20, 2021

True that, let me confirm if there's issues upconverting SDFormat with default values first, before closing #287

Copy link
Collaborator

@aaronchongth aaronchongth left a comment

Choose a reason for hiding this comment

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

This looks awesome! Thanks for making the changes!

@azeey
Copy link
Collaborator

azeey commented May 24, 2021

Per VC, we should keep the default behavior (when printing via ign sdf -p or using sdf::Element::ToString() of printing values and elements added by default for libsdformat9-libsdformat11. For libsdformat12, we'll change the default behavior to print only user added content.

Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
@marcoag
Copy link
Member Author

marcoag commented May 28, 2021

Now it's a bit of a weird behavior since it will print any default Element but not their default Attributes. Shall we add another flag to print or not attributes in a similar way to Element here?

Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
@azeey
Copy link
Collaborator

azeey commented Jun 3, 2021

I suggest we have two behaviors: (1) a default behavior that is consistent with what the code did before this PR, (2) a new behavior enabled by a flag that does not print default elements or attributes. So I don't think we need an extra flag.

Marco A. Gutierrez added 2 commits June 10, 2021 09:35
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
@marcoag
Copy link
Member Author

marcoag commented Jun 10, 2021

As agreed on our previous VC this has been added:

  • kept behavior consistent with the code before this PR (print/toString default elements and not print/toString default attributes).
  • Added two flags: one to print/toString default elements and another one to print/toString default attributes

src/Element.cc Show resolved Hide resolved
Copy link
Collaborator

@azeey azeey left a comment

Choose a reason for hiding this comment

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

LGTM! Just a few minor comments.

src/Element_TEST.cc Outdated Show resolved Hide resolved
src/Element_TEST.cc Outdated Show resolved Hide resolved
include/sdf/Element.hh Show resolved Hide resolved
src/Element.cc Show resolved Hide resolved
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
@azeey azeey merged commit c60e8f3 into gazebosim:sdf9 Jun 17, 2021
@marcoag marcoag self-assigned this Jun 28, 2021
@marcoag
Copy link
Member Author

marcoag commented Jun 28, 2021

As per VC we agreed to not consider default elements those added when the auto-conversion to the latest sdf version happens.

azeey added a commit to azeey/sdformat that referenced this pull request Jun 28, 2021
… elements (gazebosim#575)"

This reverts commit c60e8f3.

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@scpeters scpeters mentioned this pull request Jul 1, 2021
7 tasks
jennuine pushed a commit that referenced this pull request Jul 29, 2021
#575)

Now PrintValues() and ToString() will not output the elements that were added by default during parsing. There's also the option to call them with a boolean flag that will allow the caller to decide weather they want defaults in the output or not.

Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>

Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
@nkoenig nkoenig mentioned this pull request Mar 4, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants