yarp icon indicating copy to clipboard operation
yarp copied to clipboard

New class for return values of interface methods.

Open randaz81 opened this issue 1 year ago • 3 comments
trafficstars

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:

  • No need to change the user application code.
  • Only devices (e.g. xxxmotioncontrol) must be updated.
  • In this example, the error code is not actually propagated through the network (i.e. from the nws to the nwc).

randaz81 avatar Nov 21 '23 13:11 randaz81

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 doc/release/<target_branch>, based on your changes.

update-docs[bot] avatar Nov 21 '23 13:11 update-docs[bot]

As we typically use CamelCase names for classes, and given this is return value is device-specific, could we call this type yarp::os::DeviceReturnValue ? Or perhaps we can move it to yarp::dev, unless there is some reason to keep it on yarp::os?

traversaro avatar Nov 22 '23 09:11 traversaro

As we typically use CamelCase names for classes, and given this is return value is device-specific, could we call this type yarp::os::DeviceReturnValue ? Or perhaps we can move it to yarp::dev, unless there is some reason to keep it on yarp::os?

Still not sure about the class name, but I like the idea of moving it to yarp::dev!

randaz81 avatar Nov 23 '23 19:11 randaz81