-
Notifications
You must be signed in to change notification settings - Fork 422
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
Make loaned messages const on the subscription side #1971
base: rolling
Are you sure you want to change the base?
Conversation
Signed-off-by: Nikolai Morin <[email protected]>
…sage Signed-off-by: Nikolai Morin <[email protected]>
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.
It would be nice to see some test cases before we merge this.
typename std::enable_if<std::is_same<ROSMessageType, | ||
typename std::remove_const<MaybeConstROSMessageType>::type | ||
>::value | ||
>::type | ||
dispatch( |
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.
could you add tests making sure that loaned messages work well with all types of callbacks?
There're a lot of codepaths here, and it's pretty hard to make sure you didn't break anything else.
So it would be nice to make sure all cases are covered in tests (some of the cases might already be covered).
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.
lgtm with test cases mentioned https://github.com/ros2/rclcpp/pull/1971/files#r919331175
I've picked this up again – sorry for the delay. Are you fine if I make it an error to dispatch a loaned message to a callback that would require making a copy of the loaned message? Because I think that making a copy would in most cases not be intended. But type adaptation should probably be allowed. |
I'm not sure. @wjwwood what do you think? |
Related to ros2/rcl#992.
To make callback dispatching work, I generalized
dispatch()
to work with both const and non-const messages. Maybe there is a better way.