Skip to content

iceoryx_posh/internal/popo/ports/client_port_user.hpp🔗

Namespaces🔗

Name
iox
iox::popo

Classes🔗

Name
class 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.

Source code🔗

// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_POSH_POPO_PORTS_CLIENT_PORT_USER_HPP
#define IOX_POSH_POPO_PORTS_CLIENT_PORT_USER_HPP

#include "iceoryx_posh/internal/popo/building_blocks/chunk_receiver.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/chunk_sender.hpp"
#include "iceoryx_posh/internal/popo/ports/base_port.hpp"
#include "iceoryx_posh/internal/popo/ports/client_port_data.hpp"
#include "iceoryx_posh/mepoo/chunk_header.hpp"
#include "iceoryx_utils/cxx/expected.hpp"
#include "iceoryx_utils/cxx/helplets.hpp"
#include "iceoryx_utils/cxx/optional.hpp"
#include "iceoryx_utils/error_handling/error_handling.hpp"

namespace iox
{
namespace popo
{
class ClientPortUser : public BasePort
{
  public:
    using MemberType_t = ClientPortData;

    explicit ClientPortUser(cxx::not_null<MemberType_t* const> clientPortDataPtr) noexcept;

    ClientPortUser(const ClientPortUser& other) = delete;
    ClientPortUser& operator=(const ClientPortUser&) = delete;
    ClientPortUser(ClientPortUser&& rhs) = default;
    ClientPortUser& operator=(ClientPortUser&& rhs) = default;
    ~ClientPortUser() = default;

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

    void freeRequest(RequestHeader* const requestHeader) noexcept;

    void sendRequest(RequestHeader* const requestHeader) noexcept;

    void connect() noexcept;

    void disconnect() noexcept;

    ConnectionState getConnectionState() const noexcept;

    cxx::expected<cxx::optional<const ResponseHeader*>, ChunkReceiveResult> getResponse() noexcept;

    void releaseResponse(const ResponseHeader* const responseHeader) noexcept;

    bool hasNewResponses() const noexcept;

    bool hasLostResponsesSinceLastCall() noexcept;

    void setConditionVariable(ConditionVariableData& conditionVariableData, const uint64_t notificationIndex) noexcept;

    void unsetConditionVariable() noexcept;

    bool isConditionVariableSet() const noexcept;

  private:
    const MemberType_t* getMembers() const noexcept;
    MemberType_t* getMembers() noexcept;

    ChunkSender<ClientChunkSenderData_t> m_chunkSender;
    ChunkReceiver<ClientChunkReceiverData_t> m_chunkReceiver;
};

} // namespace popo
} // namespace iox

#endif // IOX_POSH_POPO_PORTS_PUBLISHER_PORT_USER_HPP

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