iceoryx_doc  1.0.1
iceoryx_posh_types.hpp
1 // Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved.
2 // Copyright (c) 2020 - 2021 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_posh/iceoryx_posh_deployment.hpp"
21 #include "iceoryx_utils/cxx/method_callback.hpp"
22 #include "iceoryx_utils/cxx/string.hpp"
23 #include "iceoryx_utils/cxx/variant_queue.hpp"
24 #include "iceoryx_utils/cxx/vector.hpp"
25 #include "iceoryx_utils/internal/posix_wrapper/ipc_channel.hpp"
26 #include "iceoryx_utils/internal/units/duration.hpp"
27 #include "iceoryx_utils/log/logstream.hpp"
28 
29 #include <cstdint>
30 
31 namespace iox
32 {
33 namespace popo
34 {
35 template <typename>
36 class TypedUniqueId;
37 struct BasePortData;
38 
39 class PublisherPortRouDi;
40 class PublisherPortUser;
41 class SubscriberPortRouDi;
42 class SubscriberPortUser;
43 } // namespace popo
44 namespace posix
45 {
46 class UnixDomainSocket;
47 } // namespace posix
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 using UniquePortId = popo::TypedUniqueId<popo::BasePortData>;
54 
55 using SubscriberPortType = iox::build::CommunicationPolicy;
56 
60 using IpcChannelType = iox::posix::UnixDomainSocket;
61 
63 constexpr uint32_t MAX_RECEIVERS_PER_SENDERPORT = build::IOX_MAX_SUBSCRIBERS_PER_PUBLISHER;
64 
65 //--------- Communication Resources Start---------------------
66 // Publisher
67 constexpr uint32_t MAX_PUBLISHERS = build::IOX_MAX_PUBLISHERS;
68 constexpr uint32_t MAX_SUBSCRIBERS_PER_PUBLISHER = build::IOX_MAX_SUBSCRIBERS_PER_PUBLISHER;
69 constexpr uint32_t MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY =
70  build::IOX_MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY;
71 constexpr uint64_t MAX_PUBLISHER_HISTORY = build::IOX_MAX_PUBLISHER_HISTORY;
72 // Subscriber
73 constexpr uint32_t MAX_SUBSCRIBERS = build::IOX_MAX_SUBSCRIBERS;
74 constexpr uint32_t MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY =
75  build::IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY;
76 constexpr uint32_t MAX_SUBSCRIBER_QUEUE_CAPACITY = MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY;
77 // Introspection is using the following publisherPorts, which reduced the number of ports available for the user
78 // 1x publisherPort mempool introspection
79 // 1x publisherPort process introspection
80 // 3x publisherPort port introspection
81 constexpr uint32_t PUBLISHERS_RESERVED_FOR_INTROSPECTION = 5;
87 // Gateway
88 constexpr uint32_t MAX_INTERFACE_NUMBER = build::IOX_MAX_INTERFACE_NUMBER;
89 constexpr uint32_t MAX_INTERFACE_CAPRO_FIFO_SIZE = MAX_PUBLISHERS;
90 constexpr uint32_t MAX_CHANNEL_NUMBER = MAX_PUBLISHERS + MAX_SUBSCRIBERS;
91 constexpr uint32_t MAX_GATEWAY_SERVICES = 2 * MAX_CHANNEL_NUMBER;
92 // Client
93 constexpr uint32_t MAX_CLIENTS = build::IOX_MAX_SUBSCRIBERS;
94 constexpr uint32_t MAX_REQUESTS_ALLOCATED_SIMULTANEOUSLY = 4U;
95 constexpr uint32_t MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY = 16U;
96 constexpr uint32_t MAX_RESPONSE_QUEUE_CAPACITY = 16U;
97 // Server
98 constexpr uint32_t MAX_SERVERS = build::IOX_MAX_PUBLISHERS;
99 constexpr uint32_t MAX_CLIENTS_PER_SERVER = 256U;
100 constexpr uint32_t MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY = 4U;
101 constexpr uint32_t MAX_RESPONSES_ALLOCATED_SIMULTANEOUSLY = MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY;
102 constexpr uint32_t MAX_REQUEST_QUEUE_CAPACITY = 1024;
103 // Waitset
104 namespace popo
105 {
106 using WaitSetIsConditionSatisfiedCallback = cxx::ConstMethodCallback<bool>;
107 }
108 constexpr uint32_t MAX_NUMBER_OF_CONDITION_VARIABLES = 1024U;
109 constexpr uint32_t MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE = 128U;
110 constexpr uint32_t MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET = 128U;
111 static_assert(MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET <= MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE,
112  "The WaitSet capacity is restricted by the maximum amount of notifiers per condition variable.");
113 // Listener
114 constexpr uint8_t MAX_NUMBER_OF_EVENT_VARIABLES = 128U;
115 constexpr uint8_t MAX_NUMBER_OF_EVENTS_PER_LISTENER = 128U;
116 static_assert(MAX_NUMBER_OF_EVENTS_PER_LISTENER <= MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE,
117  "The Listener capacity is restricted by the maximum amount of notifiers per condition variable.");
118 //--------- Communication Resources End---------------------
119 
120 constexpr uint32_t MAX_APPLICATION_CAPRO_FIFO_SIZE = 128U;
121 
122 // Memory
123 constexpr uint32_t MAX_NUMBER_OF_MEMPOOLS = 32U;
124 constexpr uint32_t MAX_SHM_SEGMENTS = 100U;
125 
126 constexpr uint32_t MAX_NUMBER_OF_MEMORY_PROVIDER = 8U;
127 constexpr uint32_t MAX_NUMBER_OF_MEMORY_BLOCKS_PER_MEMORY_PROVIDER = 64U;
128 
129 constexpr uint32_t CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT{8U};
130 constexpr uint32_t CHUNK_NO_USER_HEADER_SIZE{0U};
131 constexpr uint32_t CHUNK_NO_USER_HEADER_ALIGNMENT{1U};
132 
133 // Message Queue
134 constexpr uint32_t ROUDI_MAX_MESSAGES = 5U;
135 constexpr uint32_t ROUDI_MESSAGE_SIZE = 512U;
136 constexpr uint32_t APP_MAX_MESSAGES = 5U;
137 constexpr uint32_t APP_MESSAGE_SIZE = 512U;
138 
139 
140 // Processes
141 constexpr uint32_t MAX_PROCESS_NUMBER = 300U;
145 constexpr uint32_t MAX_NUMBER_OF_INSTANCES = 50U;
146 
147 // Nodes
148 constexpr uint32_t MAX_NODE_NUMBER = 1000U;
149 constexpr uint32_t MAX_NODE_PER_PROCESS = 50U;
150 
151 constexpr uint32_t MAX_RUNTIME_NAME_LENGTH = MAX_IPC_CHANNEL_NAME_LENGTH;
152 
153 
154 static_assert(MAX_PROCESS_NUMBER * MAX_NODE_PER_PROCESS > MAX_NODE_NUMBER, "Invalid configuration for nodes");
155 
156 enum class SubscribeState : uint32_t
157 {
158  NOT_SUBSCRIBED = 0,
159  SUBSCRIBE_REQUESTED,
160  SUBSCRIBED,
161  UNSUBSCRIBE_REQUESTED,
162  WAIT_FOR_OFFER
163 };
164 
165 enum class ConnectionState : uint32_t
166 {
167  NOT_CONNECTED = 0,
168  CONNECT_REQUESTED,
169  CONNNECTED,
170  DISCONNECT_REQUESTED,
171  WAIT_FOR_OFFER
172 };
173 
174 // Default properties of ChunkDistributorData
176 {
177  static constexpr uint32_t MAX_QUEUES = MAX_SUBSCRIBERS_PER_PUBLISHER;
178  static constexpr uint64_t MAX_HISTORY_CAPACITY = MAX_PUBLISHER_HISTORY;
179 };
180 
181 // Default properties of ChunkQueueData
183 {
184  static constexpr uint64_t MAX_QUEUE_CAPACITY = MAX_SUBSCRIBER_QUEUE_CAPACITY;
185 };
186 
187 // alias for cxx::string
188 using RuntimeName_t = cxx::string<MAX_RUNTIME_NAME_LENGTH>;
189 using NodeName_t = cxx::string<100>;
190 using ShmName_t = cxx::string<128>;
191 
192 namespace capro
193 {
194 using IdString_t = cxx::string<100>;
195 }
196 
198 namespace roudi
199 {
200 using ConfigFilePathString_t = cxx::string<1024>;
201 
202 constexpr const char ROUDI_LOCK_NAME[] = "iox-unique-roudi";
203 constexpr const char IPC_CHANNEL_ROUDI_NAME[] = "roudi";
204 
206 constexpr const char SHM_NAME[] = "/iceoryx_mgmt";
207 
208 // Timeout
209 using namespace units::duration_literals;
210 constexpr units::Duration PROCESS_DEFAULT_KILL_DELAY = 45_s;
211 constexpr units::Duration PROCESS_TERMINATED_CHECK_INTERVAL = 250_ms;
212 constexpr units::Duration DISCOVERY_INTERVAL = 100_ms;
213 
220 enum class MonitoringMode
221 {
222  ON,
223  OFF
224 };
225 
226 iox::log::LogStream& operator<<(iox::log::LogStream& logstream, const MonitoringMode& mode);
227 } // namespace roudi
228 
229 namespace mepoo
230 {
231 using SequenceNumber_t = std::uint64_t;
232 using BaseClock_t = std::chrono::steady_clock;
233 
234 // use signed integer for duration;
235 // there is a bug in gcc 4.8 which leads to a wrong calcutated time
236 // when sleep_until() is used with a timepoint in the past
237 using DurationNs_t = std::chrono::duration<std::int64_t, std::nano>;
238 using TimePointNs_t = std::chrono::time_point<BaseClock_t, DurationNs_t>;
239 } // namespace mepoo
240 
241 namespace runtime
242 {
243 using InstanceContainer = iox::cxx::vector<capro::IdString_t, MAX_NUMBER_OF_INSTANCES>;
244 using namespace units::duration_literals;
245 constexpr units::Duration PROCESS_WAITING_FOR_ROUDI_TIMEOUT = 60_s;
246 constexpr units::Duration PROCESS_KEEP_ALIVE_INTERVAL = 3 * roudi::DISCOVERY_INTERVAL; // > DISCOVERY_INTERVAL
247 constexpr units::Duration PROCESS_KEEP_ALIVE_TIMEOUT = 5 * PROCESS_KEEP_ALIVE_INTERVAL; // > PROCESS_KEEP_ALIVE_INTERVAL
248 } // namespace runtime
249 
250 namespace version
251 {
252 static const uint64_t COMMIT_ID_STRING_SIZE = 12u;
253 using CommitIdString_t = cxx::string<COMMIT_ID_STRING_SIZE>;
254 static const uint64_t BUILD_DATE_STRING_SIZE = 36u;
255 using BuildDateString_t = cxx::string<BUILD_DATE_STRING_SIZE>;
256 } // namespace version
257 
258 } // namespace iox
259 
260 #include "iceoryx_posh/iceoryx_posh_types.inl"
261 
262 #endif // IOX_POSH_ICEORYX_POSH_TYPES_HPP
The PublisherPortRouDi provides the API for accessing a publisher port from the RouDi middleware daem...
Definition: publisher_port_roudi.hpp:36
The PublisherPortUser provides the API for accessing a publisher port from the user side....
Definition: publisher_port_user.hpp:39
The SubscriberPortRouDi provides the API for accessing a subscriber port from the RouDi middleware da...
Definition: subscriber_port_roudi.hpp:36
The SubscriberPortUser provides the API for accessing a subscriber port from the user side....
Definition: subscriber_port_user.hpp:41
MonitoringMode
Controls process alive monitoring. Upon timeout, a monitored process is removed and its resources are...
Definition: iceoryx_posh_types.hpp:221
constexpr const char SHM_NAME[]
shared memmory segment for the iceoryx managment data
Definition: iceoryx_posh_types.hpp:206
Definition: service_description.hpp:29
constexpr uint32_t MAX_CLIENTS_PER_SERVER
Definition: iceoryx_posh_types.hpp:99
iox::posix::UnixDomainSocket IpcChannelType
The socket is created in the current path if no absolute path is given hence we need an absolut path ...
Definition: iceoryx_posh_types.hpp:60
constexpr uint32_t MAX_NUMBER_OF_INSTANCES
Definition: iceoryx_posh_types.hpp:145
constexpr uint32_t MAX_INTERFACE_NUMBER
Definition: iceoryx_posh_types.hpp:88
constexpr uint32_t MAX_RECEIVERS_PER_SENDERPORT
Definition: iceoryx_posh_types.hpp:63
constexpr uint32_t MAX_REQUESTS_ALLOCATED_SIMULTANEOUSLY
Definition: iceoryx_posh_types.hpp:94
Definition: iceoryx_posh_types.hpp:176
Definition: iceoryx_posh_types.hpp:183