-
Notifications
You must be signed in to change notification settings - Fork 103
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
adding element default check #542
Conversation
Signed-off-by: Marco A. Gutierrez <[email protected]>
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.
Looks good! I have a few naming related comments and a request for additional testing.
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
4c88ec6
to
0a3dca6
Compare
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
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.
Looks like codecheck
is failing on github actions. Can you fix the style errors?
test/integration/default_elements.cc
Outdated
sdf::ElementPtr element_ptr = root.Element(); | ||
EXPECT_TRUE(root.Element()->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetFirstElement(); | ||
EXPECT_TRUE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetFirstElement(); | ||
EXPECT_TRUE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
sdf::ElementPtr road_ptr = element_ptr->GetFirstElement(); | ||
EXPECT_FALSE(road_ptr->GetExplicitlySetInFile()); | ||
|
||
road_ptr = road_ptr->GetNextElement(); | ||
EXPECT_FALSE(road_ptr->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetNextElement(); | ||
EXPECT_TRUE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
sdf::ElementPtr spherical_coords_ptr = element_ptr->GetFirstElement(); | ||
EXPECT_FALSE(spherical_coords_ptr->GetExplicitlySetInFile()); | ||
|
||
spherical_coords_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(spherical_coords_ptr->GetExplicitlySetInFile()); | ||
|
||
spherical_coords_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(spherical_coords_ptr->GetExplicitlySetInFile()); | ||
|
||
spherical_coords_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(spherical_coords_ptr->GetExplicitlySetInFile()); | ||
|
||
spherical_coords_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(spherical_coords_ptr->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
sdf::ElementPtr physics_ptr = element_ptr->GetFirstElement(); | ||
EXPECT_FALSE(physics_ptr->GetExplicitlySetInFile()); | ||
|
||
physics_ptr = physics_ptr->GetNextElement(); | ||
EXPECT_FALSE(physics_ptr->GetExplicitlySetInFile()); | ||
|
||
physics_ptr = physics_ptr->GetNextElement(); | ||
EXPECT_FALSE(physics_ptr->GetExplicitlySetInFile()); | ||
|
||
element_ptr = element_ptr->GetNextElement(); | ||
EXPECT_FALSE(element_ptr->GetExplicitlySetInFile()); | ||
|
||
sdf::ElementPtr scene_ptr = element_ptr->GetFirstElement(); | ||
EXPECT_FALSE(scene_ptr->GetExplicitlySetInFile()); | ||
|
||
scene_ptr = scene_ptr->GetNextElement(); | ||
EXPECT_FALSE(scene_ptr->GetExplicitlySetInFile()); | ||
|
||
scene_ptr = scene_ptr->GetNextElement(); | ||
EXPECT_FALSE(scene_ptr->GetExplicitlySetInFile()); |
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.
Can this be refactored into a recursive function? Or is there a particular order of traversal of the elements that prevents generalization?
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.
I believe it can't be generalized as I don't see a trivial way to figure out weather a certain element is expected to be ExplicitlySetInFile
or not
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
… sibling elements Signed-off-by: Addisu Z. Taddese <[email protected]>
Add failing test showing that SetExplicitlySetInFile incorrectly sets the flag on sibling elements
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
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.
Sorry for the delay, this looks great! I haven't taken a detailed look at what default elements are getting added in during parsing of empty_road_sph_coords.sdf
and empty_axis.sdf
, but would it be a good idea to have the missing default elements added in as comments in the sdf file so we know what to expect? For example the physics element (I might be placing it wrong here),
<sdf ...>
<!-- <physics .../> -->
<world name="default">
...
</world>
Other than that, just a few minor comments about the tests and test files below, thanks!
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
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.
Thanks for making the changes!
FYI @SeanCurtis-TRI |
…zebosim#542)" This reverts commit 9876a60. Signed-off-by: Addisu Z. Taddese <[email protected]>
There's already a way to do this for the Attribute class so adding a similar function for the Element class. To keep consistency with the code from in the Attribute class, we set it to true if the element was set, and false if it was created by default. Signed-off-by: Marco A. Gutierrez <[email protected]> Co-authored-by: Addisu Z. Taddese <[email protected]> Signed-off-by: Jenn Nguyen <[email protected]>
Signed-off-by: Marco A. Gutierrez [email protected]
🎉 New feature
Related to #287
Summary
There's already a check for the
Attribute
class so adding a default attribute and check functions for theElement
class. To keep consistency with the code from in theAttribute
class, we set it totrue
if the element was setfalse
if it was created by default.Since there's many cases where elements are added the base case considers that the element was not set by default so the value is true. When an attribute is being added by default, the
SetSet(bool _value)
should be called and theset
attribute set tofalse
, as done inparser.cc
.Thinks to take into account:
set
attribute totrue
Checklist
sh tools/code_check.sh
)