Skip to content

iox::popo::ServerPortUser🔗

The ServerPortUser provides the API for accessing a server port from the user side. The server port is divided in the three parts ServerPortData, ServerPortRouDi and ServerPortUser. The ServerPortUser uses the functionality of a ChunkSender and ChunReceiver for receiving requests and sending responses. Additionally it provides the offer / stopOffer API which controls whether the server is discoverable for client ports.

#include <server_port_user.hpp>

Inherits from iox::popo::BasePort

Public Types🔗

Name
using ServerPortData MemberType_t

Public Functions🔗

Name
ServerPortUser(cxx::not_null< MemberType_t *const > serverPortDataPtr)
ServerPortUser(const ServerPortUser & other)
ServerPortUser & operator=(const ServerPortUser & )
ServerPortUser(ServerPortUser && rhs) =default
ServerPortUser & operator=(ServerPortUser && rhs) =default
~ServerPortUser() =default
cxx::expected< cxx::optional< const RequestHeader * >, ChunkReceiveResult > getRequest()
Tries to get the next request from the queue. If there is a new one, the ChunkHeader of the oldest request in the queue is returned (FiFo queue)
void releaseRequest(const RequestHeader *const requestHeader)
Release a request that was obtained with getRequest.
bool hasNewRequests() const
check if there are requests in the queue
bool hasLostRequestsSinceLastCall()
check if there was a queue overflow since the last call of hasLostRequestsSinceLastCall
cxx::expected< ResponseHeader *, AllocationError > allocateResponse(const uint32_t userPayloadSize)
Allocate a response, the ownerhip of the SharedChunk remains in the ServerPortUser for being able to cleanup if the user process disappears.
void freeResponse(ResponseHeader *const responseHeader)
Free an allocated response without sending it.
void sendResponse(ResponseHeader *const responseHeader)
Send an allocated request chunk to the server port.
void offer()
offer this server port in the system
void stopOffer()
stop offering this server port, all clients will be disconnected from this server
bool isOffered() const
Checks whether the server port is currently offered.
bool hasClients() const
Checks whether there are currently clients connected to this server.
void setConditionVariable(ConditionVariableData & conditionVariableData, const uint64_t notificationIndex)
set a condition variable (via its pointer) to the client
void unsetConditionVariable()
unset a condition variable from the client
bool isConditionVariableSet() const
check if there's a condition variable set

Additional inherited members🔗

Public Functions inherited from iox::popo::BasePort

Name
BasePort(MemberType_t *const basePortDataPtr)
BasePort(const BasePort & other)
BasePort(BasePort && )
virtual ~BasePort() =default
operator bool() const
a port can be constructed from a nullptr, additionally it also can be moved and in these cases the member methods would work on a nullptr. to circumvent this problem
capro::ServiceDescription getCaProServiceDescription() const
Reads Type of actual CaPro Port (publisher/subscriber...)
RuntimeName_t getRuntimeName() const
Gets name of the application's runtime for the active port.
UniquePortId getUniqueID() const
Gets Id of the active port.
NodeName_t getNodeName() const
returns node name for the active port
void destroy()
Indicate that this port can be destroyed.
bool toBeDestroyed() const
Checks whether port can be destroyed.

Public Types Documentation🔗

using MemberType_t🔗

using iox::popo::ServerPortUser::MemberType_t =  ServerPortData;

Public Functions Documentation🔗

function ServerPortUser🔗

explicit ServerPortUser(
    cxx::not_null< MemberType_t *const > serverPortDataPtr
)

function ServerPortUser🔗

ServerPortUser(
    const ServerPortUser & other
)

function operator=🔗

ServerPortUser & operator=(
    const ServerPortUser & 
)

function ServerPortUser🔗

ServerPortUser(
    ServerPortUser && rhs
) =default

function operator=🔗

ServerPortUser & operator=(
    ServerPortUser && rhs
) =default

function ~ServerPortUser🔗

~ServerPortUser() =default

function getRequest🔗

cxx::expected< cxx::optional< const RequestHeader * >, ChunkReceiveResult > getRequest()

Tries to get the next request from the queue. If there is a new one, the ChunkHeader of the oldest request in the queue is returned (FiFo queue)

Return: optional that has a new chunk header or no value if there are no new requests in the underlying queue, ChunkReceiveResult on error

function releaseRequest🔗

void releaseRequest(
    const RequestHeader *const requestHeader
)

Release a request that was obtained with getRequest.

Parameters:

  • chunkHeaderpointer to the ChunkHeader to release

function hasNewRequests🔗

bool hasNewRequests() const

check if there are requests in the queue

Return: if there are requests in the queue return true, otherwise false

function hasLostRequestsSinceLastCall🔗

bool hasLostRequestsSinceLastCall()

check if there was a queue overflow since the last call of hasLostRequestsSinceLastCall

Return: true if the underlying queue overflowed since last call of this method, otherwise false

function allocateResponse🔗

cxx::expected< ResponseHeader *, AllocationError > allocateResponse(
    const uint32_t userPayloadSize
)

Allocate a response, the ownerhip of the SharedChunk remains in the ServerPortUser for being able to cleanup if the user process disappears.

Parameters:

  • userPayloadSizesize of the user user-paylaod without additional headers

Return: on success pointer to a ChunkHeader which can be used to access the chunk-header, user-header and user-payload fields, error if not

function freeResponse🔗

void freeResponse(
    ResponseHeader *const responseHeader
)

Free an allocated response without sending it.

Parameters:

  • chunkHeaderpointer to the ChunkHeader to free

function sendResponse🔗

void sendResponse(
    ResponseHeader *const responseHeader
)

Send an allocated request chunk to the server port.

Parameters:

  • chunkHeaderpointer to the ChunkHeader to send

function offer🔗

void offer()

offer this server port in the system

function stopOffer🔗

void stopOffer()

stop offering this server port, all clients will be disconnected from this server

function isOffered🔗

bool isOffered() const

Checks whether the server port is currently offered.

Return: true if currently offered otherwise false

function hasClients🔗

bool hasClients() const

Checks whether there are currently clients connected to this server.

Return: true if there are clients otherwise false

function setConditionVariable🔗

void setConditionVariable(
    ConditionVariableData & conditionVariableData,
    const uint64_t notificationIndex
)

set a condition variable (via its pointer) to the client

Return: true if attachment worked, otherwise false

function unsetConditionVariable🔗

void unsetConditionVariable()

unset a condition variable from the client

function isConditionVariableSet🔗

bool isConditionVariableSet() const

check if there's a condition variable set

Return: true if a condition variable attached, otherwise false


Updated on 31 May 2022 at 15:29:16 CEST