Class PublisherPortUser
Defined in File publisher_port_user.hpp
Inheritance Relationships
Base Type
public iox::popo::BasePort(Class BasePort)
Class Documentation
-
class PublisherPortUser : public iox::popo::BasePort
The PublisherPortUser provides the API for accessing a publisher port from the user side. The publisher port is divided in the three parts PublisherPortData, PublisherPortRouDi and PublisherPortUser. The PublisherPortUser uses the functionality of a ChunkSender for sending shared memory chunks. Additionally it provides the offer / stopOffer API which controls whether the publisher port is discoverable for subscriber ports.
Public Types
-
using MemberType_t = PublisherPortData
Public Functions
-
explicit PublisherPortUser(cxx::not_null<MemberType_t*const> publisherPortDataPtr) noexcept
-
PublisherPortUser(const PublisherPortUser &other) = delete
-
PublisherPortUser &operator=(const PublisherPortUser&) = delete
-
PublisherPortUser(PublisherPortUser &&rhs) noexcept = default
-
PublisherPortUser &operator=(PublisherPortUser &&rhs) noexcept = default
-
~PublisherPortUser() = default
-
cxx::expected<mepoo::ChunkHeader*, AllocationError> tryAllocateChunk(const uint32_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize = 0U, const uint32_t userHeaderAlignment = 1U) noexcept
Allocate a chunk, the ownership of the SharedChunk remains in the PublisherPortUser for being able to cleanup if the user process disappears.
- Parameters:
userPayloadSize, size – [in] of the user-payload without additional headers
userPayloadAlignment, alignment – [in] of the user-payload
userHeaderSize, size – [in] of the user-header; use iox::CHUNK_NO_USER_HEADER_SIZE to omit a user-header
userHeaderAlignment, alignment – [in] of the user-header; use iox::CHUNK_NO_USER_HEADER_ALIGNMENT to omit a user-header
- Returns:
on success pointer to a ChunkHeader which can be used to access the chunk-header, user-header and user-payload fields, error if not
-
void releaseChunk(mepoo::ChunkHeader *const chunkHeader) noexcept
Free an allocated chunk without sending it.
- Parameters:
chunkHeader, pointer – [in] to the ChunkHeader to free
-
void sendChunk(mepoo::ChunkHeader *const chunkHeader) noexcept
Send an allocated chunk to all connected subscriber ports.
- Parameters:
chunkHeader, pointer – [in] to the ChunkHeader to send
-
cxx::optional<const mepoo::ChunkHeader*> tryGetPreviousChunk() const noexcept
Returns the last sent chunk if there is one.
- Returns:
pointer to the ChunkHeader of the last sent Chunk if there is one, empty optional if not
-
void offer() noexcept
offer this publiher port in the system
-
void stopOffer() noexcept
stop offering this publisher port, all subscribers will be removed from this publisher
-
bool isOffered() const noexcept
Checks whether the publisher port is currently offered.
- Returns:
true if currently offered otherwise false
-
bool hasSubscribers() const noexcept
Checks whether there are currently subscribers connected to this publisher.
- Returns:
true if there are subscribers otherwise false
-
using MemberType_t = PublisherPortData