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

The ClientPortUser provides the API for accessing a client port from the user side. The client port is divided in the three parts ClientPortData, ClientPortRouDi and ClientPortUser. The ClientPortUser uses the functionality of a ChunkSender and ChunReceiver for sending requests and receiving responses. Additionally it provides the connect / disconnect API which controls whether the client port shall connect to the server. More...

#include <client_port_user.hpp>

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

Public Types

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

Public Member Functions

 ClientPortUser (cxx::not_null< MemberType_t *const > clientPortDataPtr) noexcept
 
 ClientPortUser (const ClientPortUser &other)=delete
 
ClientPortUseroperator= (const ClientPortUser &)=delete
 
 ClientPortUser (ClientPortUser &&rhs)=default
 
ClientPortUseroperator= (ClientPortUser &&rhs)=default
 
cxx::expected< RequestHeader *, AllocationError > allocateRequest (const uint32_t userPayloadSize) noexcept
 Allocate a chunk, the ownerhip of the SharedChunk remains in the ClientPortUser for being able to cleanup if the user process disappears. More...
 
void freeRequest (RequestHeader *const requestHeader) noexcept
 Free an allocated request without sending it. More...
 
void sendRequest (RequestHeader *const requestHeader) noexcept
 Send an allocated request chunk to the server port. More...
 
void connect () noexcept
 try to connect to the server Caution: There can be delays between calling connect and a change in the connection state More...
 
void disconnect () noexcept
 disconnect from the server
 
ConnectionState getConnectionState () const noexcept
 get the current connection state. Caution: There can be delays between calling connect and a change in the connection state. The connection state can also change without user interaction if the server comes and goes More...
 
cxx::expected< cxx::optional< const ResponseHeader * >, ChunkReceiveResult > getResponse () noexcept
 Tries to get the next response from the queue. If there is a new one, the ChunkHeader of the oldest response in the queue is returned (FiFo queue) More...
 
void releaseResponse (const ResponseHeader *const responseHeader) noexcept
 Release a response that was obtained with getResponseChunk. More...
 
bool hasNewResponses () const noexcept
 check if there are responses in the queue More...
 
bool hasLostResponsesSinceLastCall () noexcept
 check if there was a queue overflow since the last call of hasLostResponseChunks More...
 
void setConditionVariable (ConditionVariableData &conditionVariableData, const uint64_t notificationIndex) noexcept
 set a condition variable (via its pointer) to the client
 
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 ClientPortUser provides the API for accessing a client port from the user side. The client port is divided in the three parts ClientPortData, ClientPortRouDi and ClientPortUser. The ClientPortUser uses the functionality of a ChunkSender and ChunReceiver for sending requests and receiving responses. Additionally it provides the connect / disconnect API which controls whether the client port shall connect to the server.

Member Function Documentation

◆ allocateRequest()

cxx::expected<RequestHeader*, AllocationError> iox::popo::ClientPortUser::allocateRequest ( const uint32_t  userPayloadSize)
noexcept

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

Parameters
[in]userPayloadSize,sizeof the 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

◆ connect()

void iox::popo::ClientPortUser::connect ( )
noexcept

try to connect to the server Caution: There can be delays between calling connect and a change in the connection state

myPort.connect();
while(myPort.getConnectionState() != ConnectionState::CONNECTED)
sleep(1_s);

◆ freeRequest()

void iox::popo::ClientPortUser::freeRequest ( RequestHeader *const  requestHeader)
noexcept

Free an allocated request without sending it.

Parameters
[in]chunkHeader,pointerto the ChunkHeader to free

◆ getConnectionState()

ConnectionState iox::popo::ClientPortUser::getConnectionState ( ) const
noexcept

get the current connection state. Caution: There can be delays between calling connect and a change in the connection state. The connection state can also change without user interaction if the server comes and goes

Returns
ConnectionState

◆ getResponse()

cxx::expected<cxx::optional<const ResponseHeader*>, ChunkReceiveResult> iox::popo::ClientPortUser::getResponse ( )
noexcept

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

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

◆ hasLostResponsesSinceLastCall()

bool iox::popo::ClientPortUser::hasLostResponsesSinceLastCall ( )
noexcept

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

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

◆ hasNewResponses()

bool iox::popo::ClientPortUser::hasNewResponses ( ) const
noexcept

check if there are responses in the queue

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

◆ isConditionVariableSet()

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

check if there's a condition variable set

Returns
true if a condition variable attached, otherwise false

◆ releaseResponse()

void iox::popo::ClientPortUser::releaseResponse ( const ResponseHeader *const  responseHeader)
noexcept

Release a response that was obtained with getResponseChunk.

Parameters
[in]chunkHeader,pointerto the ChunkHeader to release

◆ sendRequest()

void iox::popo::ClientPortUser::sendRequest ( RequestHeader *const  requestHeader)
noexcept

Send an allocated request chunk to the server port.

Parameters
[in]chunkHeader,pointerto the ChunkHeader to send

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