iceoryx_posh 2.0.3
Public Member Functions | List of all members
iox::popo::PublisherImpl< T, H, BasePublisherType > Class Template Reference

The PublisherImpl class implements the typed publisher API. More...

#include <iceoryx_posh/internal/popo/publisher_impl.hpp>

Inheritance diagram for iox::popo::PublisherImpl< T, H, BasePublisherType >:
Inheritance graph
[legend]
Collaboration diagram for iox::popo::PublisherImpl< T, H, BasePublisherType >:
Collaboration graph
[legend]

Public Member Functions

 PublisherImpl (const capro::ServiceDescription &service, const PublisherOptions &publisherOptions=PublisherOptions())
 
 PublisherImpl (const PublisherImpl &other)=delete
 
PublisherImploperator= (const PublisherImpl &)=delete
 
 PublisherImpl (PublisherImpl &&rhs)=delete
 
PublisherImploperator= (PublisherImpl &&rhs)=delete
 
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. More...
 
void publish (Sample< T, H > &&sample) noexcept override
 publish Publishes the given sample and then releases its loan. More...
 
cxx::expected< AllocationError > publishCopyOf (const T &val) noexcept
 publishCopyOf Copy the provided value into a loaned shared memory chunk and publish it. More...
 
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. More...
 
- Public Member Functions inherited from iox::popo::BasePublisher< port_t >
 BasePublisher (const BasePublisher &other)=delete
 
BasePublisheroperator= (const BasePublisher &)=delete
 
 BasePublisher (BasePublisher &&rhs)=delete
 
BasePublisheroperator= (BasePublisher &&rhs)=delete
 
uid_t getUid () const noexcept
 uid Get the UID of the publisher. More...
 
capro::ServiceDescription getServiceDescription () const noexcept
 getServiceDescription Get the service description of the publisher. More...
 
void offer () noexcept
 offer Offer the service to be subscribed to.
 
void stopOffer () noexcept
 stopOffer Stop offering the service.
 
bool isOffered () const noexcept
 isOffered More...
 
bool hasSubscribers () const noexcept
 hasSubscribers More...
 

Additional Inherited Members

- Public Types inherited from iox::popo::BasePublisher< port_t >
using PortType = port_t
 
- Protected Member Functions inherited from iox::popo::BasePublisher< port_t >
 BasePublisher (const capro::ServiceDescription &service, const PublisherOptions &publisherOptions)
 
const port_t & port () const noexcept
 port More...
 
port_t & port () noexcept
 port More...
 
- Protected Attributes inherited from iox::popo::BasePublisher< port_t >
port_t m_port {nullptr}
 

Detailed Description

template<typename T, typename H = mepoo::NoUserHeader, typename BasePublisherType = BasePublisher<>>
class iox::popo::PublisherImpl< T, H, BasePublisherType >

The PublisherImpl class implements the typed publisher API.

Note
Not intended for public usage! Use the Publisher instead!

Member Function Documentation

◆ loan()

template<typename T , typename H = mepoo::NoUserHeader, typename BasePublisherType = BasePublisher<>>
template<typename... Args>
cxx::expected< Sample< T, H >, AllocationError > iox::popo::PublisherImpl< T, H, BasePublisherType >::loan ( Args &&...  args)
noexcept

loan Get a sample from loaned shared memory and consctruct the data with the given arguments.

Parameters
argsArguments 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.

The loaned sample is automatically released when it goes out of scope.

◆ publish()

template<typename T , typename H = mepoo::NoUserHeader, typename BasePublisherType = BasePublisher<>>
void iox::popo::PublisherImpl< T, H, BasePublisherType >::publish ( Sample< T, H > &&  sample)
overridenoexcept

publish Publishes the given sample and then releases its loan.

Parameters
sampleThe sample to publish.

◆ publishCopyOf()

template<typename T , typename H = mepoo::NoUserHeader, typename BasePublisherType = BasePublisher<>>
cxx::expected< AllocationError > iox::popo::PublisherImpl< T, H, BasePublisherType >::publishCopyOf ( const T &  val)
noexcept

publishCopyOf Copy the provided value into a loaned shared memory chunk and publish it.

Parameters
valValue to copy.
Returns
Error if unable to allocate memory to loan.

◆ publishResultOf()

template<typename T , typename H = mepoo::NoUserHeader, typename BasePublisherType = BasePublisher<>>
template<typename Callable , typename... ArgTypes>
cxx::expected< AllocationError > iox::popo::PublisherImpl< T, H, BasePublisherType >::publishResultOf ( Callable  c,
ArgTypes...  args 
)
noexcept

publishResultOf Loan a sample from memory, execute the provided callable to write to it, then publish it.

Parameters
cCallable with the signature void(T*, ArgTypes...) that write's it's result to T*.
argsThe arguments of the callable.
Returns
Error if unable to allocate memory to loan.

The documentation for this class was generated from the following file: