Class ServerPortUser
Defined in File server_port_user.hpp
Inheritance Relationships
Base Type
public iox::popo::BasePort(Class BasePort)
Class Documentation
-
class ServerPortUser : public iox::popo::BasePort
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.
Public Types
-
using MemberType_t = ServerPortData
Public Functions
-
explicit ServerPortUser(MemberType_t &serverPortData) noexcept
-
ServerPortUser(const ServerPortUser &other) = delete
-
ServerPortUser &operator=(const ServerPortUser&) = delete
-
ServerPortUser(ServerPortUser &&rhs) noexcept = default
-
ServerPortUser &operator=(ServerPortUser &&rhs) noexcept = default
-
~ServerPortUser() = default
-
cxx::expected<const RequestHeader*, ServerRequestResult> 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:
cxx::expected that has a new RequestHeader if there are new requests in the underlying queue, ServerRequestResult on error
-
void releaseRequest(const RequestHeader *const requestHeader) noexcept
Release a request that was obtained with getRequest.
- Parameters:
chunkHeader, pointer – [in] to the ChunkHeader to release
-
void releaseQueuedRequests() noexcept
Release all the requests that are currently queued up.
-
bool hasNewRequests() const noexcept
check if there are requests in the queue
- Returns:
if there are requests in the queue return true, otherwise false
-
bool 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
-
cxx::expected<ResponseHeader*, AllocationError> allocateResponse(const RequestHeader *const requestHeader, const uint32_t userPayloadSize, const uint32_t userPayloadAlignment) noexcept
Allocate a response, the ownerhip of the SharedChunk remains in the ServerPortUser for being able to cleanup if the user process disappears.
- Parameters:
requestHeader, the – [in] request header for the corresponding response
userPayloadSize, size – [in] of the user user-paylaod without additional headers
userPayloadAlignment, alignment – [in] of 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
-
void releaseResponse(const ResponseHeader *const responseHeader) noexcept
Releases an allocated response without sending it.
- Parameters:
chunkHeader, pointer – [in] to the ChunkHeader to free
-
cxx::expected<ServerSendError> sendResponse(ResponseHeader *const responseHeader) noexcept
Send an allocated request chunk to the server port.
- Parameters:
chunkHeader, pointer – [in] to the ChunkHeader to send
- Returns:
ServerSendError if sending was not successful
-
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.
- Returns:
true if currently offered otherwise false
-
bool hasClients() const noexcept
Checks whether there are currently clients connected to this server.
- Returns:
true if there are clients otherwise false
-
void 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
-
void unsetConditionVariable() noexcept
unset a condition variable from the client
-
bool isConditionVariableSet() const noexcept
check if there’s a condition variable set
- Returns:
true if a condition variable attached, otherwise false
-
using MemberType_t = ServerPortData