-
Notifications
You must be signed in to change notification settings - Fork 194
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
New class for return values of interface methods. #3051
base: master
Are you sure you want to change the base?
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update the release notes by adding a file in |
d60a482
to
a410446
Compare
As we typically use |
Still not sure about the class name, but I like the idea of moving it to yarp::dev! |
a410446
to
c3863ab
Compare
c3863ab
to
e24c709
Compare
71900d2
to
ead1caf
Compare
case return_code::return_value_unitialized: | ||
return std::string("return_value_unitialized"); |
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.
Typo: "uninitialized".
Suggestion: isn't the "return_value_" prefix a bit verbose? I'm also thinking of an overload to LogStream so that this would be possible:
double val;
auto ret = iMotor->getTemperature(0, &val);
yInfo() << ret; // prints "ok", "error_generic" "error_not_implemented" and so on
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.
That's a nice idea! Just give me a little more time before proceeding since we need to edit a few things more before.
This new class can be used in all interface methods to provide extra info about the success/failure of the method.
In this example:
bool getTemperature(int m, double* val) override;
becomes:
yarp::os::yarp_ret_value getTemperature(int m, double* val) override;
So the user can distinguish if a failure is due to missing implementation/internal error/communication error etc.
The class is also automatically converted to bool when tested by conditions.
Extra Notes: