Template Class PublisherImpl
Defined in File publisher_impl.hpp
Inheritance Relationships
Base Types
public iox::popo::BasePublisher<>(Template Class BasePublisher)private iox::popo::PublisherInterface< T, mepoo::NoUserHeader >(Template Class PublisherInterface)
Class Documentation
-
template<typename T, typename H = mepoo::NoUserHeader, typename BasePublisherType = BasePublisher<>>
class PublisherImpl : public iox::popo::BasePublisher<>, private iox::popo::PublisherInterface<T, mepoo::NoUserHeader> The PublisherImpl class implements the typed publisher API.
Note
Not intended for public usage! Use the
Publisherinstead!Public Functions
-
explicit PublisherImpl(const capro::ServiceDescription &service, const PublisherOptions &publisherOptions = PublisherOptions())
-
PublisherImpl(const PublisherImpl &other) = delete
-
PublisherImpl &operator=(const PublisherImpl&) = delete
-
PublisherImpl(PublisherImpl &&rhs) = delete
-
PublisherImpl &operator=(PublisherImpl &&rhs) = delete
-
virtual ~PublisherImpl() = default
-
template<typename ...Args>
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.
The loaned sample is automatically released when it goes out of scope.
- Parameters:
args – Arguments used to construct the data.
- Returns:
An instance of the sample that resides in shared memory or an error if unable ot allocate memory to loan.
-
void publish(Sample<T, H> &&sample) noexcept override
publish Publishes the given sample and then releases its loan.
- Parameters:
sample – The sample to publish.
-
cxx::expected<AllocationError> publishCopyOf(const T &val) noexcept
publishCopyOf Copy the provided value into a loaned shared memory chunk and publish it.
- Parameters:
val – Value to copy.
- Returns:
Error if unable to allocate memory to loan.
-
template<typename Callable, typename ...ArgTypes>
cxx::expected<AllocationError> publishResultOf(Callable c, ArgTypes... args) noexcept publishResultOf Loan a sample from memory, execute the provided callable to write to it, then publish it.
- Parameters:
c – Callable with the signature void(T*, ArgTypes…) that write’s it’s result to T*.
args – The arguments of the callable.
- Returns:
Error if unable to allocate memory to loan.
-
explicit PublisherImpl(const capro::ServiceDescription &service, const PublisherOptions &publisherOptions = PublisherOptions())