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

Use strongly typed 'enum' instead of 'int' for properties in PCLVisua… #5526

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theoniko
Copy link
Contributor

@theoniko theoniko commented Nov 24, 2022

…lizer code
Fixes #1692

@theoniko theoniko force-pushed the theoniko-use-strongly-type-enum-RenderingProperties branch 8 times, most recently from e0eb54e to 1d9340d Compare November 27, 2022 12:36
@theoniko theoniko force-pushed the theoniko-use-strongly-type-enum-RenderingProperties branch from 1d9340d to f4b6104 Compare November 27, 2022 13:33
@theoniko theoniko marked this pull request as ready for review November 30, 2022 16:22
* \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
*/
bool
setPointCloudRenderingProperties (int property, double val1, double val2, double val3,
Copy link
Contributor Author

@theoniko theoniko Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All setters return some boolean flag which is never checked in code. I was thinking adding and attribute [[noreturn]] if the wrong behavior (false value return) could cause issues. If is not critical, without the attribute should also be fine.

@theoniko
Copy link
Contributor Author

theoniko commented Mar 20, 2023

@mvieth/ @larshg: Could you please review this PR?

@mvieth
Copy link
Member

mvieth commented Apr 20, 2023

@theoniko Sorry for the late response, this pull request was kind of lost in my notifications list ☹️
Changing enum RenderingProperties to enum class RenderingProperties is problematic if it changes the way the enum values can be used (additional scoping with RenderingProperties:: necessary). This would break many people's code, which we definitely want to avoid.

Similar problem for the removal of the parameter viewport: If we simply remove it but someone uses it (even if it does not do anything), they would get a compiler error. If we want to remove it for a function, we need to add a copy of that function where viewport still exists and has no default value, then deprecate this copy (see here for example), and call the function without viewport from the copy. You can decide whether you want to do this work, I am also fine with keeping viewport.

Maybe it would also make sense to state in the documentation which properties are accepted? For example that the functions with 3 double parameters only accepts PCL_VISUALIZER_COLOR? Yes, the print_error tells the user if a function is not used correctly, but it could be nice to see this directly in the function documentation.

All setters return some boolean flag which is never checked in code. I was thinking adding and attribute [[noreturn]] if the wrong behavior (false value return) could cause issues. If is not critical, without the attribute should also be fine.

You probably mean [[nodiscard]]? PCL currently still aims to be C++14 compatible, while nodiscard was added in C++17.

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.

Use strongly typed 'enum' instead of 'int' for properties in PCLVisualizer code
2 participants