-
Notifications
You must be signed in to change notification settings - Fork 285
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
Added getType and getStaticType functions to Joint #392
Conversation
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. |
That makes sense to me. I removed |
I just pushed some fixes (mostly missing |
There seems to be a bizarre GCC bug related to the use of |
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 |
@mxgrey What is |
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. |
This pull request adds:
getType
method to theJoint
base classgetStaticType
method to each concreteJoint
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 bydynamic_cast
.We were careful to make both of these functions return a const reference to a statically allocated string.