iox::popo::ClientPortUser🔗
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.
#include <client_port_user.hpp>
Inherits from iox::popo::BasePort
Public Types🔗
Name | |
---|---|
using ClientPortData | MemberType_t |
Public Functions🔗
Name | |
---|---|
ClientPortUser(cxx::not_null< MemberType_t *const > clientPortDataPtr) | |
ClientPortUser(const ClientPortUser & other) | |
ClientPortUser & | operator=(const ClientPortUser & ) |
ClientPortUser(ClientPortUser && rhs) =default | |
ClientPortUser & | operator=(ClientPortUser && rhs) =default |
~ClientPortUser() =default | |
cxx::expected< RequestHeader *, AllocationError > | allocateRequest(const uint32_t userPayloadSize) Allocate a chunk, the ownerhip of the SharedChunk remains in the ClientPortUser for being able to cleanup if the user process disappears. |
void | freeRequest(RequestHeader *const requestHeader) Free an allocated request without sending it. |
void | sendRequest(RequestHeader *const requestHeader) Send an allocated request chunk to the server port. |
void | connect() try to connect to the server Caution: There can be delays between calling connect and a change in the connection state |
void | disconnect() disconnect from the server |
ConnectionState | getConnectionState() const 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 |
cxx::expected< cxx::optional< const ResponseHeader * >, ChunkReceiveResult > | getResponse() 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) |
void | releaseResponse(const ResponseHeader *const responseHeader) Release a response that was obtained with getResponseChunk. |
bool | hasNewResponses() const check if there are responses in the queue |
bool | hasLostResponsesSinceLastCall() check if there was a queue overflow since the last call of hasLostResponseChunks |
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::ClientPortUser::MemberType_t = ClientPortData;
Public Functions Documentation🔗
function ClientPortUser🔗
explicit ClientPortUser(
cxx::not_null< MemberType_t *const > clientPortDataPtr
)
function ClientPortUser🔗
ClientPortUser(
const ClientPortUser & other
)
function operator=🔗
ClientPortUser & operator=(
const ClientPortUser &
)
function ClientPortUser🔗
ClientPortUser(
ClientPortUser && rhs
) =default
function operator=🔗
ClientPortUser & operator=(
ClientPortUser && rhs
) =default
function ~ClientPortUser🔗
~ClientPortUser() =default
function allocateRequest🔗
cxx::expected< RequestHeader *, AllocationError > allocateRequest(
const uint32_t userPayloadSize
)
Allocate a chunk, the ownerhip of the SharedChunk remains in the ClientPortUser for being able to cleanup if the user process disappears.
Parameters:
- userPayloadSizesize of the 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 freeRequest🔗
void freeRequest(
RequestHeader *const requestHeader
)
Free an allocated request without sending it.
Parameters:
- chunkHeaderpointer to the ChunkHeader to free
function sendRequest🔗
void sendRequest(
RequestHeader *const requestHeader
)
Send an allocated request chunk to the server port.
Parameters:
- chunkHeaderpointer to the ChunkHeader to send
function connect🔗
void connect()
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);
function disconnect🔗
void disconnect()
disconnect from the server
function getConnectionState🔗
ConnectionState getConnectionState() const
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
Return: ConnectionState
function getResponse🔗
cxx::expected< cxx::optional< const ResponseHeader * >, ChunkReceiveResult > getResponse()
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)
Return: optional that has a new chunk header or no value if there are no new responses in the underlying queue, ChunkReceiveResult on error
function releaseResponse🔗
void releaseResponse(
const ResponseHeader *const responseHeader
)
Release a response that was obtained with getResponseChunk.
Parameters:
- chunkHeaderpointer to the ChunkHeader to release
function hasNewResponses🔗
bool hasNewResponses() const
check if there are responses in the queue
Return: if there are responses in the queue return true, otherwise false
function hasLostResponsesSinceLastCall🔗
bool hasLostResponsesSinceLastCall()
check if there was a queue overflow since the last call of hasLostResponseChunks
Return: true if the underlying queue overflowed since last call of this method, otherwise false
function setConditionVariable🔗
void setConditionVariable(
ConditionVariableData & conditionVariableData,
const uint64_t notificationIndex
)
set a condition variable (via its pointer) to the client
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