iceoryx_posh  2.0.2
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 
32 namespace iox
33 {
34 namespace popo
35 {
36 class UniquePortId;
37 struct BasePortData;
38 
39 class PublisherPortRouDi;
40 class PublisherPortUser;
41 class SubscriberPortRouDi;
42 class SubscriberPortUser;
43 } // namespace popo
44 namespace capro
45 {
46 class ServiceDescription;
47 }
48 
49 using PublisherPortRouDiType = iox::popo::PublisherPortRouDi;
50 using PublisherPortUserType = iox::popo::PublisherPortUser;
51 using SubscriberPortRouDiType = iox::popo::SubscriberPortRouDi;
52 using SubscriberPortUserType = iox::popo::SubscriberPortUser;
53 
54 using SubscriberPortType = iox::build::CommunicationPolicy;
55 
56 //--------- Communication Resources Start---------------------
57 // Publisher
58 constexpr uint32_t MAX_PUBLISHERS = build::IOX_MAX_PUBLISHERS;
59 constexpr uint32_t MAX_SUBSCRIBERS_PER_PUBLISHER = build::IOX_MAX_SUBSCRIBERS_PER_PUBLISHER;
60 constexpr uint32_t MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY =
61  build::IOX_MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY;
62 constexpr uint64_t MAX_PUBLISHER_HISTORY = build::IOX_MAX_PUBLISHER_HISTORY;
63 // Subscriber
64 constexpr uint32_t MAX_SUBSCRIBERS = build::IOX_MAX_SUBSCRIBERS;
65 constexpr uint32_t MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY =
66  build::IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY;
67 constexpr 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
72 constexpr uint32_t PUBLISHERS_RESERVED_FOR_INTROSPECTION = 5;
73 constexpr uint32_t PUBLISHERS_RESERVED_FOR_SERVICE_REGISTRY = 1;
74 constexpr uint32_t NUMBER_OF_INTERNAL_PUBLISHERS =
75  PUBLISHERS_RESERVED_FOR_INTROSPECTION + PUBLISHERS_RESERVED_FOR_SERVICE_REGISTRY;
81 // Gateway
82 constexpr uint32_t MAX_INTERFACE_NUMBER = build::IOX_MAX_INTERFACE_NUMBER;
83 constexpr uint32_t MAX_INTERFACE_CAPRO_FIFO_SIZE = MAX_PUBLISHERS;
84 constexpr uint32_t MAX_CHANNEL_NUMBER = MAX_PUBLISHERS + MAX_SUBSCRIBERS;
85 constexpr uint32_t MAX_GATEWAY_SERVICES = 2 * MAX_CHANNEL_NUMBER;
86 // Client
87 constexpr uint32_t MAX_CLIENTS = build::IOX_MAX_SUBSCRIBERS;
88 constexpr uint32_t MAX_REQUESTS_ALLOCATED_SIMULTANEOUSLY = 4U;
89 constexpr uint32_t MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY = 16U;
90 constexpr uint32_t MAX_RESPONSE_QUEUE_CAPACITY = 16U;
91 // Server
92 constexpr uint32_t MAX_SERVERS = build::IOX_MAX_PUBLISHERS;
93 constexpr uint32_t MAX_CLIENTS_PER_SERVER = 256U;
94 constexpr uint32_t MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY = 4U;
95 constexpr uint32_t MAX_RESPONSES_ALLOCATED_SIMULTANEOUSLY = MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY;
96 constexpr uint32_t MAX_REQUEST_QUEUE_CAPACITY = 1024;
97 // Waitset
98 namespace popo
99 {
100 using WaitSetIsConditionSatisfiedCallback = cxx::ConstMethodCallback<bool>;
101 }
102 constexpr uint32_t MAX_NUMBER_OF_CONDITION_VARIABLES = 1024U;
103 
104 constexpr uint32_t MAX_NUMBER_OF_NOTIFIERS = build::IOX_MAX_NUMBER_OF_NOTIFIERS;
107 constexpr uint32_t MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET = MAX_NUMBER_OF_NOTIFIERS;
108 constexpr uint32_t MAX_NUMBER_OF_EVENTS_PER_LISTENER = MAX_NUMBER_OF_NOTIFIERS;
109 //--------- Communication Resources End---------------------
110 
111 // Memory
112 constexpr uint32_t MAX_NUMBER_OF_MEMPOOLS = 32U;
113 constexpr uint32_t MAX_SHM_SEGMENTS = 100U;
114 
115 constexpr uint32_t MAX_NUMBER_OF_MEMORY_PROVIDER = 8U;
116 constexpr uint32_t MAX_NUMBER_OF_MEMORY_BLOCKS_PER_MEMORY_PROVIDER = 64U;
117 
118 constexpr uint32_t CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT{8U};
119 constexpr uint32_t CHUNK_NO_USER_HEADER_SIZE{0U};
120 constexpr uint32_t CHUNK_NO_USER_HEADER_ALIGNMENT{1U};
121 
122 // Message Queue
123 constexpr uint32_t ROUDI_MAX_MESSAGES = 5U;
124 constexpr uint32_t ROUDI_MESSAGE_SIZE = 512U;
125 constexpr uint32_t APP_MAX_MESSAGES = 5U;
126 constexpr uint32_t APP_MESSAGE_SIZE = 512U;
127 
128 
129 // Processes
130 constexpr uint32_t MAX_PROCESS_NUMBER = 300U;
131 
132 // Service Discovery
133 constexpr uint32_t SERVICE_REGISTRY_CAPACITY = MAX_PUBLISHERS + MAX_SERVERS;
134 constexpr uint32_t MAX_FINDSERVICE_RESULT_SIZE = SERVICE_REGISTRY_CAPACITY;
135 
136 constexpr const char SERVICE_DISCOVERY_SERVICE_NAME[] = "ServiceDiscovery";
137 constexpr const char SERVICE_DISCOVERY_INSTANCE_NAME[] = "RouDi_ID";
138 constexpr const char SERVICE_DISCOVERY_EVENT_NAME[] = "ServiceRegistry";
139 
140 namespace runtime
141 {
142 using ServiceContainer = iox::cxx::vector<capro::ServiceDescription, MAX_FINDSERVICE_RESULT_SIZE>;
143 }
144 
145 // Nodes
146 constexpr uint32_t MAX_NODE_NUMBER = 1000U;
147 constexpr uint32_t MAX_NODE_PER_PROCESS = 50U;
148 
149 constexpr uint32_t MAX_RUNTIME_NAME_LENGTH = MAX_IPC_CHANNEL_NAME_LENGTH;
150 
151 
152 static_assert(MAX_PROCESS_NUMBER * MAX_NODE_PER_PROCESS > MAX_NODE_NUMBER, "Invalid configuration for nodes");
153 
154 enum class SubscribeState : uint32_t
155 {
156  NOT_SUBSCRIBED = 0,
157  SUBSCRIBE_REQUESTED,
158  SUBSCRIBED,
159  UNSUBSCRIBE_REQUESTED,
160  WAIT_FOR_OFFER
161 };
162 
163 enum class ConnectionState : uint32_t
164 {
165  NOT_CONNECTED = 0,
166  CONNECT_REQUESTED,
167  CONNECTED,
168  DISCONNECT_REQUESTED,
169  WAIT_FOR_OFFER
170 };
171 
175 inline constexpr const char* asStringLiteral(ConnectionState value) noexcept;
176 
181 inline std::ostream& operator<<(std::ostream& stream, ConnectionState value) noexcept;
182 
187 inline 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
203 using RuntimeName_t = cxx::string<MAX_RUNTIME_NAME_LENGTH>;
204 // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
205 using NodeName_t = cxx::string<100>;
206 // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
207 using ShmName_t = cxx::string<128>;
208 
209 namespace capro
210 {
211 // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
212 using IdString_t = cxx::string<100>;
213 } // namespace capro
214 
216 namespace roudi
217 {
218 // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
219 using ConfigFilePathString_t = cxx::string<1024>;
220 
221 constexpr const char ROUDI_LOCK_NAME[] = "iox-unique-roudi";
222 constexpr const char IPC_CHANNEL_ROUDI_NAME[] = "roudi";
223 
225 constexpr const char SHM_NAME[] = "iceoryx_mgmt";
226 
227 // this is used by the UniquePortId
228 constexpr uint16_t DEFAULT_UNIQUE_ROUDI_ID{0U};
229 
230 // Timeout
231 using namespace units::duration_literals;
232 constexpr units::Duration PROCESS_DEFAULT_KILL_DELAY = 45_s;
233 constexpr units::Duration PROCESS_TERMINATED_CHECK_INTERVAL = 250_ms;
234 constexpr units::Duration DISCOVERY_INTERVAL = 100_ms;
235 
242 enum class MonitoringMode
243 {
244  ON,
245  OFF
246 };
247 
248 iox::log::LogStream& operator<<(iox::log::LogStream& logstream, const MonitoringMode& mode) noexcept;
249 } // namespace roudi
250 
251 namespace mepoo
252 {
253 using SequenceNumber_t = std::uint64_t;
254 using 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
259 using DurationNs_t = std::chrono::duration<std::int64_t, std::nano>;
260 using TimePointNs_t = std::chrono::time_point<BaseClock_t, DurationNs_t>;
261 } // namespace mepoo
262 
263 namespace runtime
264 {
265 using namespace units::duration_literals;
266 constexpr units::Duration PROCESS_WAITING_FOR_ROUDI_TIMEOUT = 60_s;
267 constexpr units::Duration PROCESS_KEEP_ALIVE_INTERVAL = 3 * roudi::DISCOVERY_INTERVAL; // > DISCOVERY_INTERVAL
268 constexpr units::Duration PROCESS_KEEP_ALIVE_TIMEOUT = 5 * PROCESS_KEEP_ALIVE_INTERVAL; // > PROCESS_KEEP_ALIVE_INTERVAL
269 } // namespace runtime
270 
271 namespace version
272 {
273 static const uint64_t COMMIT_ID_STRING_SIZE = 12U;
274 using CommitIdString_t = cxx::string<COMMIT_ID_STRING_SIZE>;
275 static const uint64_t BUILD_DATE_STRING_SIZE = 36U;
276 using 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