In this PR the API used when overriding the MessageTypeDetails is strictly separated from the end user API.
When overriding the MessageTypeDetails you must use [CustomPayloadMarker] as message type
You can only loan samples via Publisher::loan_custom_payload()
You can only receive samples via Subscriber::receive_custom_payload().
The reason is, that in those cases the Sample and SampleMut handle the data a bit different. When calling Publisher::loan_custom_payload(123) and 123 corresponds to the number of elements, this number is stored in the samples header but Sample::payload().len() will return 123 * MessageTypeDetails::payload.size, the bytes used by the sample. When the MessageTypeDetails::payload.size is not overridden, Sample::payload().len() == Header::number_of_elements().
The publish subscribe header contains now the number_of_elements that are contained in the sample. The payload layout was removed. In the C API one can now easily obtain the underlying number of elements by just accessing this number directly from the header - no more payload.len() / sizeof(Payload) stuff.
Pre-Review Checklist for the PR Author
[x] Add sensible notes for the reviewer
[x] PR title is short, expressive and meaningful
[x] Relevant issues are linked in the References section
[x] Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
[x] Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
[x] Commits messages are according to this guideline
[x] Commit messages have the issue ID ([#123] Add posix ipc example)
Notes for Reviewer
In this PR the API used when overriding the
MessageTypeDetails
is strictly separated from the end user API.MessageTypeDetails
you must use[CustomPayloadMarker]
as message typePublisher::loan_custom_payload()
Subscriber::receive_custom_payload()
.The reason is, that in those cases the
Sample
andSampleMut
handle the data a bit different. When callingPublisher::loan_custom_payload(123)
and 123 corresponds to the number of elements, this number is stored in the samples header butSample::payload().len()
will return123 * MessageTypeDetails::payload.size
, the bytes used by the sample. When theMessageTypeDetails::payload.size
is not overridden,Sample::payload().len() == Header::number_of_elements()
.The publish subscribe header contains now the
number_of_elements
that are contained in the sample. The payload layout was removed. In the C API one can now easily obtain the underlying number of elements by just accessing this number directly from the header - no morepayload.len() / sizeof(Payload)
stuff.Pre-Review Checklist for the PR Author
SPDX-License-Identifier: Apache-2.0 OR MIT
iox2-123-introduce-posix-ipc-example
)[#123] Add posix ipc example
)task-list-completed
)Checklist for the PR Reviewer
Post-review Checklist for the PR Author
References
Closes #498