18 #ifndef IOX_POSH_POPO_TYPED_PUBLISHER_HPP
19 #define IOX_POSH_POPO_TYPED_PUBLISHER_HPP
21 #include "iceoryx_posh/popo/base_publisher.hpp"
22 #include "iceoryx_posh/popo/sample.hpp"
23 #include "iceoryx_utils/cxx/type_traits.hpp"
34 template <
typename T,
typename H>
38 virtual void publish(
Sample<T, H>&& sample) noexcept = 0;
45 template <
typename T,
typename H = mepoo::NoUserHeader,
typename BasePublisher_t = BasePublisher<>>
48 static_assert(!std::is_void<T>::value,
"The type `T` must not be void. Use the UntypedPublisher for void types.");
49 static_assert(!std::is_void<H>::value,
"The user-header `H` must not be void.");
51 static_assert(!std::is_const<T>::value,
"The type `T` must not be const.");
52 static_assert(!std::is_reference<T>::value,
"The type `T` must not be a reference.");
53 static_assert(!std::is_pointer<T>::value,
"The type `T` must not be a pointer.");
55 static_assert(!std::is_const<H>::value,
"The user-header `H` must not be const.");
56 static_assert(!std::is_reference<H>::value,
"The user-header `H` must not be a reference.");
57 static_assert(!std::is_pointer<H>::value,
"The user-header must `H` not be a pointer.");
75 template <
typename... Args>
76 cxx::expected<Sample<T, H>, AllocationError>
loan(Args&&... args) noexcept;
89 cxx::expected<AllocationError>
publishCopyOf(
const T& val) noexcept;
96 template <
typename Callable,
typename... ArgTypes>
97 cxx::expected<AllocationError>
publishResultOf(Callable c, ArgTypes... args) noexcept;
100 using BasePublisher_t::port;
105 cxx::expected<Sample<T, H>, AllocationError> loanSample() noexcept;
111 template <
typename T,
typename H = mepoo::NoUserHeader>
117 #include "iceoryx_posh/internal/popo/publisher.inl"
class for the identification of a communication event including information on the service,...
Definition: service_description.hpp:86
const port_t & port() const noexcept
port
Definition: base_publisher.inl:77
Definition: publisher.hpp:47
void publish(Sample< T, H > &&sample) noexcept override
publish Publishes the given sample and then releases its loan.
Definition: publisher.inl:84
cxx::expected< AllocationError > publishCopyOf(const T &val) noexcept
publishCopyOf Copy the provided value into a loaned shared memory chunk and publish it.
Definition: publisher.inl:59
cxx::expected< Sample< T, H >, AllocationError > loan(Args &&... args) noexcept
loan Get a sample from loaned shared memory and consctruct the data with the given arguments.
Definition: publisher.inl:36
cxx::expected< AllocationError > publishResultOf(Callable c, ArgTypes... args) noexcept
publishResultOf Loan a sample from memory, execute the provided callable to write to it,...
Definition: publisher.inl:43
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
Definition: service_description.hpp:29
This struct is used to configure the publisher.
Definition: publisher_options.hpp:30