iceoryx_doc  1.0.1
Public Types | Public Member Functions | List of all members
iox::popo::ServerPortUser Class Reference

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. More...

#include <server_port_user.hpp>

Inheritance diagram for iox::popo::ServerPortUser:
Inheritance graph
[legend]
Collaboration diagram for iox::popo::ServerPortUser:
Collaboration graph
[legend]

Public Types

using MemberType_t = ServerPortData
 
- Public Types inherited from iox::popo::BasePort
using MemberType_t = BasePortData
 

Public Member Functions

 ServerPortUser (cxx::not_null< MemberType_t *const > serverPortDataPtr) noexcept
 
 ServerPortUser (const ServerPortUser &other)=delete
 
ServerPortUseroperator= (const ServerPortUser &)=delete
 
 ServerPortUser (ServerPortUser &&rhs)=default
 
ServerPortUseroperator= (ServerPortUser &&rhs)=default
 
cxx::expected< cxx::optional< const RequestHeader * >, ChunkReceiveResult > getRequest () noexcept
 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) More...
 
void releaseRequest (const RequestHeader *const requestHeader) noexcept
 Release a request that was obtained with getRequest. More...
 
bool hasNewRequests () const noexcept
 check if there are requests in the queue More...
 
bool hasLostRequestsSinceLastCall () noexcept
 check if there was a queue overflow since the last call of hasLostRequestsSinceLastCall More...
 
cxx::expected< ResponseHeader *, AllocationError > allocateResponse (const uint32_t userPayloadSize) noexcept
 Allocate a response, the ownerhip of the SharedChunk remains in the ServerPortUser for being able to cleanup if the user process disappears. More...
 
void freeResponse (ResponseHeader *const responseHeader) noexcept
 Free an allocated response without sending it. More...
 
void sendResponse (ResponseHeader *const responseHeader) noexcept
 Send an allocated request chunk to the server port. More...
 
void offer () noexcept
 offer this server port in the system
 
void stopOffer () noexcept
 stop offering this server port, all clients will be disconnected from this server
 
bool isOffered () const noexcept
 Checks whether the server port is currently offered. More...
 
bool hasClients () const noexcept
 Checks whether there are currently clients connected to this server. More...
 
void setConditionVariable (ConditionVariableData &conditionVariableData, const uint64_t notificationIndex) noexcept
 set a condition variable (via its pointer) to the client More...
 
void unsetConditionVariable () noexcept
 unset a condition variable from the client
 
bool isConditionVariableSet () const noexcept
 check if there's a condition variable set More...
 
- Public Member Functions inherited from iox::popo::BasePort
 BasePort (MemberType_t *const basePortDataPtr) noexcept
 
 BasePort (const BasePort &other)=delete
 
BasePortoperator= (const BasePort &)=delete
 
 BasePort (BasePort &&) noexcept
 
BasePortoperator= (BasePort &&) noexcept
 
 operator bool () const noexcept
 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 More...
 
capro::ServiceDescription getCaProServiceDescription () const noexcept
 Reads Type of actual CaPro Port (publisher/subscriber...) More...
 
RuntimeName_t getRuntimeName () const noexcept
 Gets name of the application's runtime for the active port. More...
 
UniquePortId getUniqueID () const noexcept
 Gets Id of the active port. More...
 
NodeName_t getNodeName () const noexcept
 returns node name for the active port More...
 
void destroy () noexcept
 Indicate that this port can be destroyed.
 
bool toBeDestroyed () const noexcept
 Checks whether port can be destroyed. More...
 

Additional Inherited Members

- Protected Member Functions inherited from iox::popo::BasePort
const MemberType_tgetMembers () const noexcept
 
MemberType_tgetMembers () noexcept
 

Detailed Description

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.

Member Function Documentation

◆ allocateResponse()

cxx::expected<ResponseHeader*, AllocationError> iox::popo::ServerPortUser::allocateResponse ( const uint32_t  userPayloadSize)
noexcept

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

Parameters
[in]userPayloadSize,sizeof the user user-paylaod without additional headers
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

◆ freeResponse()

void iox::popo::ServerPortUser::freeResponse ( ResponseHeader *const  responseHeader)
noexcept

Free an allocated response without sending it.

Parameters
[in]chunkHeader,pointerto the ChunkHeader to free

◆ getRequest()

cxx::expected<cxx::optional<const RequestHeader*>, ChunkReceiveResult> iox::popo::ServerPortUser::getRequest ( )
noexcept

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)

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

◆ hasClients()

bool iox::popo::ServerPortUser::hasClients ( ) const
noexcept

Checks whether there are currently clients connected to this server.

Returns
true if there are clients otherwise false

◆ hasLostRequestsSinceLastCall()

bool iox::popo::ServerPortUser::hasLostRequestsSinceLastCall ( )
noexcept

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

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

◆ hasNewRequests()

bool iox::popo::ServerPortUser::hasNewRequests ( ) const
noexcept

check if there are requests in the queue

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

◆ isConditionVariableSet()

bool iox::popo::ServerPortUser::isConditionVariableSet ( ) const
noexcept

check if there's a condition variable set

Returns
true if a condition variable attached, otherwise false

◆ isOffered()

bool iox::popo::ServerPortUser::isOffered ( ) const
noexcept

Checks whether the server port is currently offered.

Returns
true if currently offered otherwise false

◆ releaseRequest()

void iox::popo::ServerPortUser::releaseRequest ( const RequestHeader *const  requestHeader)
noexcept

Release a request that was obtained with getRequest.

Parameters
[in]chunkHeader,pointerto the ChunkHeader to release

◆ sendResponse()

void iox::popo::ServerPortUser::sendResponse ( ResponseHeader *const  responseHeader)
noexcept

Send an allocated request chunk to the server port.

Parameters
[in]chunkHeader,pointerto the ChunkHeader to send

◆ setConditionVariable()

void iox::popo::ServerPortUser::setConditionVariable ( ConditionVariableData conditionVariableData,
const uint64_t  notificationIndex 
)
noexcept

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

Returns
true if attachment worked, otherwise false

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