Skip to content

Commit

Permalink
[#490] Consistent use of ValueType when retrieving Payload
Browse files Browse the repository at this point in the history
  • Loading branch information
orecham committed Nov 7, 2024
1 parent 1a8a87e commit 9a25cbc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions iceoryx2-ffi/cxx/include/iox2/sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Sample {

/// Returns a reference to the payload of the [`Sample`]
template <typename T = Payload, typename = std::enable_if_t<!iox::IsSlice<T>::VALUE, void>>
auto payload() const -> const Payload&;
auto payload() const -> const ValueType&;

/// Returns a slice to navigate the payload of the [`Sample`]
template <typename T = Payload, typename = std::enable_if_t<iox::IsSlice<T>::VALUE, void>>
Expand Down Expand Up @@ -132,12 +132,12 @@ inline auto Sample<S, Payload, UserHeader>::operator->() const -> const Payload*

template <ServiceType S, typename Payload, typename UserHeader>
template <typename T, typename>
inline auto Sample<S, Payload, UserHeader>::payload() const -> const Payload& {
inline auto Sample<S, Payload, UserHeader>::payload() const -> const ValueType& {
const void* ptr = nullptr;

iox2_sample_payload(&m_handle, &ptr, nullptr);

return *static_cast<const Payload*>(ptr);
return *static_cast<const ValueType*>(ptr);
}

template <ServiceType S, typename Payload, typename UserHeader>
Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-ffi/cxx/include/iox2/sample_mut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class SampleMut {

/// Returns a reference to the const payload of the sample.
template <typename T = Payload, typename = std::enable_if_t<!iox::IsSlice<T>::VALUE, void>>
auto payload() const -> const Payload&;
auto payload() const -> const ValueType&;

/// Returns a reference to the payload of the sample.
template <typename T = Payload, typename = std::enable_if_t<!iox::IsSlice<T>::VALUE, void>>
auto payload_mut() -> Payload&;
auto payload_mut() -> ValueType&;

template <typename T = Payload, typename = std::enable_if_t<iox::IsSlice<T>::VALUE, void>>
auto payload() const -> iox::ImmutableSlice<ValueType>;
Expand Down Expand Up @@ -199,22 +199,22 @@ inline auto SampleMut<S, Payload, UserHeader>::user_header_mut() -> T& {

template <ServiceType S, typename Payload, typename UserHeader>
template <typename T, typename>
inline auto SampleMut<S, Payload, UserHeader>::payload() const -> const Payload& {
inline auto SampleMut<S, Payload, UserHeader>::payload() const -> const ValueType& {
const void* ptr = nullptr;

iox2_sample_mut_payload(&m_handle, &ptr, nullptr);

return *static_cast<const Payload*>(ptr);
return *static_cast<const ValueType*>(ptr);
}

template <ServiceType S, typename Payload, typename UserHeader>
template <typename T, typename>
inline auto SampleMut<S, Payload, UserHeader>::payload_mut() -> Payload& {
inline auto SampleMut<S, Payload, UserHeader>::payload_mut() -> ValueType& {
void* ptr = nullptr;

iox2_sample_mut_payload_mut(&m_handle, &ptr, nullptr);

return *static_cast<Payload*>(ptr);
return *static_cast<ValueType*>(ptr);
}

template <ServiceType S, typename Payload, typename UserHeader>
Expand Down
8 changes: 4 additions & 4 deletions iceoryx2-ffi/cxx/include/iox2/sample_mut_uninit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class SampleMutUninit {

/// Returns a reference to the const payload of the sample.
template <typename T = Payload, typename = std::enable_if_t<!iox::IsSlice<T>::VALUE, void>>
auto payload() const -> const Payload&;
auto payload() const -> const ValueType&;

/// Returns a reference to the payload of the sample.
template <typename T = Payload, typename = std::enable_if_t<!iox::IsSlice<T>::VALUE, void>>
auto payload_mut() -> Payload&;
auto payload_mut() -> ValueType&;

template <typename T = Payload, typename = std::enable_if_t<iox::IsSlice<T>::VALUE, void>>
auto payload() const -> iox::ImmutableSlice<ValueType>;
Expand Down Expand Up @@ -143,13 +143,13 @@ inline auto SampleMutUninit<S, Payload, UserHeader>::user_header_mut() -> T& {

template <ServiceType S, typename Payload, typename UserHeader>
template <typename T, typename>
inline auto SampleMutUninit<S, Payload, UserHeader>::payload() const -> const Payload& {
inline auto SampleMutUninit<S, Payload, UserHeader>::payload() const -> const ValueType& {
return m_sample.payload();
}

template <ServiceType S, typename Payload, typename UserHeader>
template <typename T, typename>
inline auto SampleMutUninit<S, Payload, UserHeader>::payload_mut() -> Payload& {
inline auto SampleMutUninit<S, Payload, UserHeader>::payload_mut() -> ValueType& {
return m_sample.payload_mut();
}

Expand Down

0 comments on commit 9a25cbc

Please sign in to comment.