18 #ifndef IOX_POSH_POPO_SAMPLE_HPP
19 #define IOX_POSH_POPO_SAMPLE_HPP
21 #include "iceoryx_posh/mepoo/chunk_header.hpp"
22 #include "iceoryx_utils/cxx/type_traits.hpp"
23 #include "iceoryx_utils/cxx/unique_ptr.hpp"
29 template <
typename T,
typename H>
30 class PublisherInterface;
35 template <
typename T,
typename H>
46 cxx::unique_ptr<T> sampleUniquePtr;
47 std::reference_wrapper<PublisherInterface<T, H>> publisherRef;
51 template <
typename T,
typename H>
62 cxx::unique_ptr<const T> sampleUniquePtr;
70 template <
typename T,
typename H = cxx::add_const_conditionally_t<mepoo::NoUserHeader, T>>
73 static_assert(std::is_const<T>::value == std::is_const<H>::value,
74 "The type `T` and the user-header `H` must be equal in their const qualifier to ensure the same "
75 "access restrictions for the user-header as for the sample data!");
78 template <
typename S,
typename TT>
79 using ForPublisherOnly = std::enable_if_t<std::is_same<S, TT>::value && !std::is_const<TT>::value, S>;
82 template <
typename S,
typename TT>
83 using ForSubscriberOnly = std::enable_if_t<std::is_same<S, TT>::value && std::is_const<TT>::value, S>;
86 template <
typename R,
typename HH>
88 std::enable_if_t<std::is_same<R, HH>::value && !std::is_same<R, mepoo::NoUserHeader>::value, R>;
95 template <
typename S = T,
typename = ForPublisherOnly<S, T>>
101 template <
typename S = T,
typename = ForSubscriberOnly<S, T>>
102 Sample(cxx::unique_ptr<T>&& sampleUniquePtr) noexcept;
104 ~
Sample() noexcept =
default;
140 operator bool()
const noexcept;
152 const T*
get()
const noexcept;
173 template <typename R = H, typename = HasUserHeader<R, H>>
180 template <typename R = H, typename = HasUserHeader<R, H>>
188 template <typename S = T, typename = ForPublisherOnly<S, T>>
192 template <typename, typename, typename>
197 T* release() noexcept;
200 internal::SamplePrivateData<T, H> m_members;
206 #include "iceoryx_posh/internal/popo/sample.inl"
Definition: publisher.hpp:47
The PublisherInterface class defines the publisher interface used by the Sample class to make it gene...
Definition: publisher.hpp:36
The Sample class is a mutable abstraction over types which are written to loaned shared memory....
Definition: sample.hpp:72
T * operator->() noexcept
Transparent access to the encapsulated type.
Definition: sample.inl:57
void publish() noexcept
Publish the sample via the publisher from which it was loaned and automatically release ownership to ...
Definition: sample.inl:126
T * get() noexcept
Mutable access to the encapsulated type loaned to the sample.
Definition: sample.inl:87
R & getUserHeader() noexcept
Retrieve the user-header of the underlying memory chunk loaned to the sample.
Definition: sample.inl:112
T & operator*() noexcept
Provides a reference to the encapsulated type.
Definition: sample.inl:69
Sample(cxx::unique_ptr< T > &&sampleUniquePtr, PublisherInterface< T, H > &publisher) noexcept
Constructor for a Sample used by the Publisher.
Definition: sample.inl:44
ConditionalConstChunkHeader_t * getChunkHeader() noexcept
Retrieve the ChunkHeader of the underlying memory chunk loaned to the sample.
Definition: sample.inl:99
cxx::add_const_conditionally_t< mepoo::ChunkHeader, T > ConditionalConstChunkHeader_t
Helper type to ensure the access to the ChunkHeader has the same const qualifier as the access to the...
Definition: sample.hpp:156
Definition: service_description.hpp:29
helper struct for sample
Definition: sample.hpp:37