Skip to content

iceoryx_posh/internal/popo/base_client.hpp🔗

Namespaces🔗

Name
iox
iox::popo

Classes🔗

Name
class iox::popo::BaseClient
The BaseClient class contains the common implementation for the different clients.

Source code🔗

// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2022 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_BASE_CLIENT_HPP
#define IOX_POSH_POPO_BASE_CLIENT_HPP

#include "iceoryx_hoofs/cxx/expected.hpp"
#include "iceoryx_posh/capro/service_description.hpp"
#include "iceoryx_posh/internal/popo/ports/client_port_user.hpp"
#include "iceoryx_posh/popo/client_options.hpp"
#include "iceoryx_posh/popo/trigger_handle.hpp"
#include "iceoryx_posh/runtime/posh_runtime.hpp"

namespace iox
{
namespace popo
{
using uid_t = UniquePortId;

template <typename PortT = ClientPortUser, typename TriggerHandleT = TriggerHandle>
class BaseClient
{
  public:
    virtual ~BaseClient() noexcept;

    BaseClient(const BaseClient& other) = delete;
    BaseClient& operator=(const BaseClient&) = delete;
    BaseClient(BaseClient&& rhs) = delete;
    BaseClient& operator=(BaseClient&& rhs) = delete;

    uid_t getUid() const noexcept;

    const capro::ServiceDescription& getServiceDescription() const noexcept;

    void connect() noexcept;

    ConnectionState getConnectionState() const noexcept;

    void disconnect() noexcept;

    bool hasResponses() const noexcept;

    bool hasMissedResponses() noexcept;

    void releaseQueuedResponses() noexcept;

    friend class NotificationAttorney;

  protected:
    using SelfType = BaseClient<PortT, TriggerHandleT>;
    using PortType = PortT;

    BaseClient(const capro::ServiceDescription& service, const ClientOptions& clientOptions) noexcept;

    void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept;

    void enableState(TriggerHandleT&& triggerHandle, const ClientState clientState) noexcept;

    WaitSetIsConditionSatisfiedCallback
    getCallbackForIsStateConditionSatisfied(const ClientState clientState) const noexcept;

    void disableState(const ClientState clientState) noexcept;

    void enableEvent(TriggerHandleT&& triggerHandle, const ClientEvent clientEvent) noexcept;

    void disableEvent(const ClientEvent clientEvent) noexcept;

    const PortT& port() const noexcept;

    PortT& port() noexcept;

  protected:
    PortT m_port;             // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
    TriggerHandleT m_trigger; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
};
} // namespace popo
} // namespace iox

#include "iceoryx_posh/internal/popo/base_client.inl"

#endif // IOX_POSH_POPO_BASE_CLIENT_HPP

Updated on 2 April 2022 at 16:37:47 CEST