iceoryx_posh 2.0.8
Loading...
Searching...
No Matches
base_server.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_SERVER_HPP
19#define IOX_POSH_POPO_BASE_SERVER_HPP
20
21#include "iceoryx_hoofs/cxx/expected.hpp"
22#include "iceoryx_posh/capro/service_description.hpp"
23#include "iceoryx_posh/internal/popo/ports/server_port_user.hpp"
24#include "iceoryx_posh/popo/server_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 = ServerPortUser, typename TriggerHandleT = TriggerHandle>
39class BaseServer
40{
41 public:
42 virtual ~BaseServer() noexcept;
43
44 BaseServer(const BaseServer& other) = delete;
45 BaseServer& operator=(const BaseServer&) = delete;
46 BaseServer(BaseServer&& rhs) = delete;
47 BaseServer& operator=(BaseServer&& rhs) = delete;
48
53 uid_t getUid() const noexcept;
54
59 const capro::ServiceDescription& getServiceDescription() const noexcept;
60
64 void offer() noexcept;
65
69 void stopOffer() noexcept;
70
75 bool isOffered() const noexcept;
76
81 bool hasClients() const noexcept;
82
87 bool hasRequests() const noexcept;
88
94 bool hasMissedRequests() noexcept;
95
97 void releaseQueuedRequests() noexcept;
98
99 friend class NotificationAttorney;
100
101 protected:
102 using SelfType = BaseServer<PortT, TriggerHandleT>;
103 using PortType = PortT;
104
105 BaseServer(const capro::ServiceDescription& service, const ServerOptions& serverOptions) noexcept;
106
109 void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept;
110
115 void enableState(TriggerHandleT&& triggerHandle, const ServerState serverState) noexcept;
116
120 WaitSetIsConditionSatisfiedCallback
121 getCallbackForIsStateConditionSatisfied(const ServerState serverState) const noexcept;
122
125 void disableState(const ServerState serverState) noexcept;
126
131 void enableEvent(TriggerHandleT&& triggerHandle, const ServerEvent serverEvent) noexcept;
132
135 void disableEvent(const ServerEvent serverEvent) noexcept;
136
141 const PortT& port() const noexcept;
142
147 PortT& port() noexcept;
148
149 PortT m_port; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
150 TriggerHandleT m_trigger; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
151};
152
153} // namespace popo
154} // namespace iox
155
156#include "iceoryx_posh/internal/popo/base_server.inl"
157
158#endif // IOX_POSH_POPO_BASE_SERVER_HPP
WaitSetIsConditionSatisfiedCallback getCallbackForIsStateConditionSatisfied(const ServerState serverState) const noexcept
void disableState(const ServerState serverState) noexcept
void disableEvent(const ServerEvent serverEvent) noexcept
void enableEvent(TriggerHandleT &&triggerHandle, const ServerEvent serverEvent) noexcept
void enableState(TriggerHandleT &&triggerHandle, const ServerState serverState) noexcept
void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept
const capro::ServiceDescription & getServiceDescription() const noexcept
const PortT & port() const noexcept
uid_t getUid() const noexcept
Get the UID of the server.
This struct is used to configure the server.
Definition server_options.hpp:33