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

New class for return values of interface methods PART1 #3051

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

randaz81
Copy link
Member

@randaz81 randaz81 commented Nov 21, 2023

This new class can be used in all interface methods to provide extra info about the success/failure of the method.
In this example, in the interface ISpeechSynthesizer is modified as follows:
virtual bool setLanguage(const std::string& language="auto") = 0;
becomes:
virtual yarp::dev::yarp_ret_value setLanguage(const std::string& language="auto") = 0;
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 which implement the interface (e.g. FakeSpeechSynthesizer) must be updated.

Copy link

update-docs bot commented Nov 21, 2023

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.

@traversaro
Copy link
Member

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?

@randaz81
Copy link
Member Author

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 randaz81 changed the title New class for return values of interface methods. New class for return values of interface methods PART1 Jan 21, 2025
@randaz81
Copy link
Member Author

Waiting for further comments.
PR ready for merge.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
52.3% Coverage on New Code (required ≥ 80%)
20.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@Nicogene
Copy link
Member

@traversaro @Nicogene @PeterBowman resuming the development on this PR

I am not sure if it is the right time, it can be done also later but, at some point it would be nice to have a documentation/migration guide for introducing this new return value type instead of using bool, in the form of doxygen page or issue or discussion or even in the body of this PR. We may then link this guide when we announce the distro.
Something similar to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants