iceoryx_posh 2.0.3
iceoryx_posh_types.hpp
1// Copyright (c) 2019 - 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#ifndef IOX_POSH_ICEORYX_POSH_TYPES_HPP
18#define IOX_POSH_ICEORYX_POSH_TYPES_HPP
19
20#include "iceoryx_hoofs/cxx/method_callback.hpp"
21#include "iceoryx_hoofs/cxx/string.hpp"
22#include "iceoryx_hoofs/cxx/variant_queue.hpp"
23#include "iceoryx_hoofs/cxx/vector.hpp"
24#include "iceoryx_hoofs/internal/posix_wrapper/ipc_channel.hpp"
25#include "iceoryx_hoofs/internal/units/duration.hpp"
26#include "iceoryx_hoofs/log/logstream.hpp"
27#include "iceoryx_hoofs/platform/platform_settings.hpp"
28#include "iceoryx_posh/iceoryx_posh_deployment.hpp"
29
30#include <cstdint>
31
32namespace iox
33{
34namespace popo
35{
36class UniquePortId;
37struct BasePortData;
38
39class PublisherPortRouDi;
40class PublisherPortUser;
41class SubscriberPortRouDi;
42class SubscriberPortUser;
43} // namespace popo
44namespace capro
45{
46class ServiceDescription;
47}
48
49using PublisherPortRouDiType = iox::popo::PublisherPortRouDi;
50using PublisherPortUserType = iox::popo::PublisherPortUser;
51using SubscriberPortRouDiType = iox::popo::SubscriberPortRouDi;
52using SubscriberPortUserType = iox::popo::SubscriberPortUser;
53
54using SubscriberPortType = iox::build::CommunicationPolicy;
55
56//--------- Communication Resources Start---------------------
57// Publisher
58constexpr uint32_t MAX_PUBLISHERS = build::IOX_MAX_PUBLISHERS;
59constexpr uint32_t MAX_SUBSCRIBERS_PER_PUBLISHER = build::IOX_MAX_SUBSCRIBERS_PER_PUBLISHER;
60constexpr uint32_t MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY =
61 build::IOX_MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY;
62constexpr uint64_t MAX_PUBLISHER_HISTORY = build::IOX_MAX_PUBLISHER_HISTORY;
63// Subscriber
64constexpr uint32_t MAX_SUBSCRIBERS = build::IOX_MAX_SUBSCRIBERS;
65constexpr uint32_t MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY =
66 build::IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY;
67constexpr uint32_t MAX_SUBSCRIBER_QUEUE_CAPACITY = MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY;
68// Introspection is using the following publisherPorts, which reduced the number of ports available for the user
69// 1x publisherPort mempool introspection
70// 1x publisherPort process introspection
71// 3x publisherPort port introspection
72constexpr uint32_t PUBLISHERS_RESERVED_FOR_INTROSPECTION = 5;
73constexpr uint32_t PUBLISHERS_RESERVED_FOR_SERVICE_REGISTRY = 1;
74constexpr uint32_t NUMBER_OF_INTERNAL_PUBLISHERS =
75 PUBLISHERS_RESERVED_FOR_INTROSPECTION + PUBLISHERS_RESERVED_FOR_SERVICE_REGISTRY;
81// Gateway
82constexpr uint32_t MAX_INTERFACE_NUMBER = build::IOX_MAX_INTERFACE_NUMBER;
83constexpr uint32_t MAX_INTERFACE_CAPRO_FIFO_SIZE = MAX_PUBLISHERS;
84constexpr uint32_t MAX_CHANNEL_NUMBER = MAX_PUBLISHERS + MAX_SUBSCRIBERS;
85constexpr uint32_t MAX_GATEWAY_SERVICES = 2 * MAX_CHANNEL_NUMBER;
86// Client
87constexpr uint32_t MAX_CLIENTS = build::IOX_MAX_SUBSCRIBERS;
88constexpr uint32_t MAX_REQUESTS_ALLOCATED_SIMULTANEOUSLY = 4U;
89constexpr uint32_t MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY = 16U;
90constexpr uint32_t MAX_RESPONSE_QUEUE_CAPACITY = 16U;
91// Server
92constexpr uint32_t MAX_SERVERS = build::IOX_MAX_PUBLISHERS;
93constexpr uint32_t MAX_CLIENTS_PER_SERVER = 256U;
94constexpr uint32_t MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY = 4U;
95constexpr uint32_t MAX_RESPONSES_ALLOCATED_SIMULTANEOUSLY = MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY;
96constexpr uint32_t MAX_REQUEST_QUEUE_CAPACITY = 1024;
97// Waitset
98namespace popo
99{
100using WaitSetIsConditionSatisfiedCallback = cxx::ConstMethodCallback<bool>;
101}
102constexpr uint32_t MAX_NUMBER_OF_CONDITION_VARIABLES = 1024U;
103
104constexpr uint32_t MAX_NUMBER_OF_NOTIFIERS = build::IOX_MAX_NUMBER_OF_NOTIFIERS;
107constexpr uint32_t MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET = MAX_NUMBER_OF_NOTIFIERS;
108constexpr uint32_t MAX_NUMBER_OF_EVENTS_PER_LISTENER = MAX_NUMBER_OF_NOTIFIERS;
109//--------- Communication Resources End---------------------
110
111// Memory
112constexpr uint32_t MAX_NUMBER_OF_MEMPOOLS = 32U;
113constexpr uint32_t MAX_SHM_SEGMENTS = 100U;
114
115constexpr uint32_t MAX_NUMBER_OF_MEMORY_PROVIDER = 8U;
116constexpr uint32_t MAX_NUMBER_OF_MEMORY_BLOCKS_PER_MEMORY_PROVIDER = 64U;
117
118constexpr uint32_t CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT{8U};
119constexpr uint32_t CHUNK_NO_USER_HEADER_SIZE{0U};
120constexpr uint32_t CHUNK_NO_USER_HEADER_ALIGNMENT{1U};
121
122// Message Queue
123constexpr uint32_t ROUDI_MAX_MESSAGES = 5U;
124constexpr uint32_t ROUDI_MESSAGE_SIZE = 512U;
125constexpr uint32_t APP_MAX_MESSAGES = 5U;
126constexpr uint32_t APP_MESSAGE_SIZE = 512U;
127
128
129// Processes
130constexpr uint32_t MAX_PROCESS_NUMBER = 300U;
131
132// Service Discovery
133constexpr uint32_t SERVICE_REGISTRY_CAPACITY = MAX_PUBLISHERS + MAX_SERVERS;
134constexpr uint32_t MAX_FINDSERVICE_RESULT_SIZE = SERVICE_REGISTRY_CAPACITY;
135
136constexpr const char SERVICE_DISCOVERY_SERVICE_NAME[] = "ServiceDiscovery";
137constexpr const char SERVICE_DISCOVERY_INSTANCE_NAME[] = "RouDi_ID";
138constexpr const char SERVICE_DISCOVERY_EVENT_NAME[] = "ServiceRegistry";
139
140namespace runtime
141{
142using ServiceContainer = iox::cxx::vector<capro::ServiceDescription, MAX_FINDSERVICE_RESULT_SIZE>;
143}
144
145// Nodes
146constexpr uint32_t MAX_NODE_NUMBER = 1000U;
147constexpr uint32_t MAX_NODE_PER_PROCESS = 50U;
148
149constexpr uint32_t MAX_RUNTIME_NAME_LENGTH = MAX_IPC_CHANNEL_NAME_LENGTH;
150
151
152static_assert(MAX_PROCESS_NUMBER * MAX_NODE_PER_PROCESS > MAX_NODE_NUMBER, "Invalid configuration for nodes");
153
154enum class SubscribeState : uint32_t
155{
156 NOT_SUBSCRIBED = 0,
157 SUBSCRIBE_REQUESTED,
158 SUBSCRIBED,
159 UNSUBSCRIBE_REQUESTED,
160 WAIT_FOR_OFFER
161};
162
163enum class ConnectionState : uint32_t
164{
165 NOT_CONNECTED = 0,
166 CONNECT_REQUESTED,
167 CONNECTED,
168 DISCONNECT_REQUESTED,
169 WAIT_FOR_OFFER
170};
171
175inline constexpr const char* asStringLiteral(ConnectionState value) noexcept;
176
181inline std::ostream& operator<<(std::ostream& stream, ConnectionState value) noexcept;
182
187inline log::LogStream& operator<<(log::LogStream& stream, ConnectionState value) noexcept;
188
189// Default properties of ChunkDistributorData
191{
192 static constexpr uint32_t MAX_QUEUES = MAX_SUBSCRIBERS_PER_PUBLISHER;
193 static constexpr uint64_t MAX_HISTORY_CAPACITY = MAX_PUBLISHER_HISTORY;
194};
195
196// Default properties of ChunkQueueData
198{
199 static constexpr uint64_t MAX_QUEUE_CAPACITY = MAX_SUBSCRIBER_QUEUE_CAPACITY;
200};
201
202// alias for cxx::string
203using RuntimeName_t = cxx::string<MAX_RUNTIME_NAME_LENGTH>;
204// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
205using NodeName_t = cxx::string<100>;
206// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
207using ShmName_t = cxx::string<128>;
208
209namespace capro
210{
211// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
212using IdString_t = cxx::string<100>;
213} // namespace capro
214
216namespace roudi
217{
218// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
219using ConfigFilePathString_t = cxx::string<1024>;
220
221constexpr const char ROUDI_LOCK_NAME[] = "iox-unique-roudi";
222constexpr const char IPC_CHANNEL_ROUDI_NAME[] = "roudi";
223
225constexpr const char SHM_NAME[] = "iceoryx_mgmt";
226
227// this is used by the UniquePortId
228constexpr uint16_t DEFAULT_UNIQUE_ROUDI_ID{0U};
229
230// Timeout
231using namespace units::duration_literals;
232constexpr units::Duration PROCESS_DEFAULT_KILL_DELAY = 45_s;
233constexpr units::Duration PROCESS_TERMINATED_CHECK_INTERVAL = 250_ms;
234constexpr units::Duration DISCOVERY_INTERVAL = 100_ms;
235
243{
244 ON,
245 OFF
246};
247
248iox::log::LogStream& operator<<(iox::log::LogStream& logstream, const MonitoringMode& mode) noexcept;
249} // namespace roudi
250
251namespace mepoo
252{
253using SequenceNumber_t = std::uint64_t;
254using BaseClock_t = std::chrono::steady_clock;
255
256// use signed integer for duration;
257// there is a bug in gcc 4.8 which leads to a wrong calculated time
258// when sleep_until() is used with a timepoint in the past
259using DurationNs_t = std::chrono::duration<std::int64_t, std::nano>;
260using TimePointNs_t = std::chrono::time_point<BaseClock_t, DurationNs_t>;
261} // namespace mepoo
262
263namespace runtime
264{
265using namespace units::duration_literals;
266constexpr units::Duration PROCESS_WAITING_FOR_ROUDI_TIMEOUT = 60_s;
267constexpr units::Duration PROCESS_KEEP_ALIVE_INTERVAL = 3 * roudi::DISCOVERY_INTERVAL; // > DISCOVERY_INTERVAL
268constexpr units::Duration PROCESS_KEEP_ALIVE_TIMEOUT = 5 * PROCESS_KEEP_ALIVE_INTERVAL; // > PROCESS_KEEP_ALIVE_INTERVAL
269} // namespace runtime
270
271namespace version
272{
273static const uint64_t COMMIT_ID_STRING_SIZE = 12U;
274using CommitIdString_t = cxx::string<COMMIT_ID_STRING_SIZE>;
275static const uint64_t BUILD_DATE_STRING_SIZE = 36U;
276using BuildDateString_t = cxx::string<BUILD_DATE_STRING_SIZE>;
277} // namespace version
278
279} // namespace iox
280
281#include "iceoryx_posh/iceoryx_posh_types.inl"
282
283#endif // IOX_POSH_ICEORYX_POSH_TYPES_HPP
MonitoringMode
Controls process alive monitoring. Upon timeout, a monitored process is removed and its resources are...
Definition: iceoryx_posh_types.hpp:243
constexpr const char SHM_NAME[]
shared memory segment for the iceoryx management data
Definition: iceoryx_posh_types.hpp:225
Definition: iceoryx_posh_types.hpp:191
Definition: iceoryx_posh_types.hpp:198