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 getType and getStaticType functions to Joint #392

Merged
merged 3 commits into from
May 27, 2015
Merged

Added getType and getStaticType functions to Joint #392

merged 3 commits into from
May 27, 2015

Conversation

mkoval
Copy link
Collaborator

@mkoval mkoval commented May 24, 2015

This pull request adds:

  1. a virtual getType method to the Joint base class
  2. a static getStaticType method to each concrete Joint class.

Both of these methods return a string representation of the class name. This is useful for debugging, for logic that needs to change depending upon the joint type, and for language bindings (where wrapping templates is difficult). This currently requires an exhaustive search over all Joint subclasses by checking the return value by dynamic_cast.

We were careful to make both of these functions return a const reference to a statically allocated string.

@mxgrey
Copy link
Member

mxgrey commented May 24, 2015

I like the idea of the const reference to the static string inside the member function. Since it's not a reference to a member variable, there's no chance of an inheriting class or a friend class doing something silly and altering it in some way. It also means that all instances share the same memory for the string.

Although I do wonder if it would be better for the Joint::getType(), SingleDofJoint::getType(), ZeroDofJoint::getType(), and MultiDofJoint::getType(), versions to be pure abstract. That way we would enforce that all the fully derived classes must explicitly report their Joint type.

@mkoval
Copy link
Collaborator Author

mkoval commented May 24, 2015

That makes sense to me. I removed getType from those joint types.

@mkoval
Copy link
Collaborator Author

mkoval commented May 25, 2015

I just pushed some fixes (mostly missing virtual keywords) to my branch.

@mxgrey
Copy link
Member

mxgrey commented May 25, 2015

There seems to be a bizarre GCC bug related to the use of default that's preventing it from compiling when BUILD_DEFAULT_ONLY BUILD_CORE_ONLY is off. This is especially strange, because it claims to be erroring when compiling MultiDofJoint::Properties, but that should be getting compiled whether or not BUILD_DEFAULT_ONLY BUILD_CORE_ONLY is off, so I can't imagine why it only seems to happen when it's off.

@mxgrey
Copy link
Member

mxgrey commented May 26, 2015

The GCC bug I mentioned seems to be either platform dependent or it's been resolved in 4.9.2, because I can't manage to reproduce it on my own machine. I'll play around with the usage of the default keyword and see if we can convince Travis-CI to build it.

@mxgrey mxgrey merged commit 71cd7b3 into dartsim:memory_management May 27, 2015
@mkoval
Copy link
Collaborator Author

mkoval commented May 27, 2015

@mxgrey What is BUILD_DEFAULT_ONLY? Do you have any idea what caused this?

@mkoval mkoval deleted the feature/JointGetType branch May 27, 2015 17:35
@mxgrey
Copy link
Member

mxgrey commented May 27, 2015

Whoops, I meant to say BUILD_CORE_ONLY. I had the word "default" in my head so I wound up replacing "CORE" with "DEFAULT" while I was typing. I've edited my post above.

It seems to be an internal GCC bug. I saw reports for it from early 2014. It doesn't happen on my machine, and I'm using GCC 4.9, whereas Travis seems to use older versions. I'm guessing the bug has been removed in the latest versions of GCC.

@jslee02 jslee02 added this to the Release DART 5.0 milestone Jun 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants