iceoryx_posh 2.0.8
Loading...
Searching...
No Matches
base_client.hpp
1// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16// SPDX-License-Identifier: Apache-2.0
17
18#ifndef IOX_POSH_POPO_BASE_CLIENT_HPP
19#define IOX_POSH_POPO_BASE_CLIENT_HPP
20
21#include "iceoryx_hoofs/cxx/expected.hpp"
22#include "iceoryx_posh/capro/service_description.hpp"
23#include "iceoryx_posh/internal/popo/ports/client_port_user.hpp"
24#include "iceoryx_posh/popo/client_options.hpp"
25#include "iceoryx_posh/popo/trigger_handle.hpp"
26#include "iceoryx_posh/runtime/posh_runtime.hpp"
27
28namespace iox
29{
30namespace popo
31{
32using uid_t = UniquePortId;
33
38template <typename PortT = ClientPortUser, typename TriggerHandleT = TriggerHandle>
39class BaseClient
40{
41 public:
42 virtual ~BaseClient() noexcept;
43
44 BaseClient(const BaseClient& other) = delete;
45 BaseClient& operator=(const BaseClient&) = delete;
46 BaseClient(BaseClient&& rhs) = delete;
47 BaseClient& operator=(BaseClient&& rhs) = delete;
48
53 uid_t getUid() const noexcept;
54
59 const capro::ServiceDescription& getServiceDescription() const noexcept;
60
64 void connect() noexcept;
65
70 ConnectionState getConnectionState() const noexcept;
71
75 void disconnect() noexcept;
76
81 bool hasResponses() const noexcept;
82
88 bool hasMissedResponses() noexcept;
89
91 void releaseQueuedResponses() noexcept;
92
93 friend class NotificationAttorney;
94
95 protected:
96 using SelfType = BaseClient<PortT, TriggerHandleT>;
97 using PortType = PortT;
98
99 BaseClient(const capro::ServiceDescription& service, const ClientOptions& clientOptions) noexcept;
100
103 void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept;
104
109 void enableState(TriggerHandleT&& triggerHandle, const ClientState clientState) noexcept;
110
114 WaitSetIsConditionSatisfiedCallback
115 getCallbackForIsStateConditionSatisfied(const ClientState clientState) const noexcept;
116
119 void disableState(const ClientState clientState) noexcept;
120
125 void enableEvent(TriggerHandleT&& triggerHandle, const ClientEvent clientEvent) noexcept;
126
129 void disableEvent(const ClientEvent clientEvent) noexcept;
130
134 const PortT& port() const noexcept;
135
139 PortT& port() noexcept;
140
141 protected:
142 PortT m_port; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
143 TriggerHandleT m_trigger; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
144};
145} // namespace popo
146} // namespace iox
147
148#include "iceoryx_posh/internal/popo/base_client.inl"
149
150#endif // IOX_POSH_POPO_BASE_CLIENT_HPP
void enableState(TriggerHandleT &&triggerHandle, const ClientState clientState) noexcept
void enableEvent(TriggerHandleT &&triggerHandle, const ClientEvent clientEvent) noexcept
ConnectionState getConnectionState() const noexcept
const PortT & port() const noexcept
void disableState(const ClientState clientState) noexcept
void disableEvent(const ClientEvent clientEvent) noexcept
const capro::ServiceDescription & getServiceDescription() const noexcept
uid_t getUid() const noexcept
Get the unique ID of the client.
void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept
WaitSetIsConditionSatisfiedCallback getCallbackForIsStateConditionSatisfied(const ClientState clientState) const noexcept
This struct is used to configure the client.
Definition client_options.hpp:33