iceoryx_posh 2.0.5
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>
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
The BaseClient class contains the common implementation for the different clients.
Definition base_client.hpp:40
void enableState(TriggerHandleT &&triggerHandle, const ClientState clientState) noexcept
Only usable by the WaitSet/Listener, not for public use. Attaches the triggerHandle to the internal t...
void connect() noexcept
Initiate connection to server when not already connected, otherwise nothing.
void enableEvent(TriggerHandleT &&triggerHandle, const ClientEvent clientEvent) noexcept
Only usable by the WaitSet/Listener, not for public use. Attaches the triggerHandle to the internal t...
bool hasResponses() const noexcept
Check if response are available.
ConnectionState getConnectionState() const noexcept
Get current connection state.
const PortT & port() const noexcept
const accessor of the underlying port
void disableState(const ClientState clientState) noexcept
Only usable by the WaitSet/Listener, not for public use. Resets the internal triggerHandle.
void disableEvent(const ClientEvent clientEvent) noexcept
Only usable by the WaitSet/Listener, not for public use. Resets the internal triggerHandle.
void disconnect() noexcept
Disconnects when already connected, otherwise nothing.
const capro::ServiceDescription & getServiceDescription() const noexcept
Get the service description of the client.
void releaseQueuedResponses() noexcept
Releases any unread queued response.
bool hasMissedResponses() noexcept
Check if response has been missed since the last call of this method.
uid_t getUid() const noexcept
Get the unique ID of the client.
void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept
Only usable by the WaitSet/Listener, not for public use. Invalidates the internal triggerHandle.
WaitSetIsConditionSatisfiedCallback getCallbackForIsStateConditionSatisfied(const ClientState clientState) const noexcept
Only usable by the WaitSet/Listener, not for public use. Returns method pointer to the event correspo...
Class which allows accessing private methods to friends of NotificationAttorney. Used for example by ...
Definition notification_attorney.hpp:33
This struct is used to configure the client.
Definition client_options.hpp:33