iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1// Copyright (c) 2024 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13#ifndef IOX2_CONFIG_HPP
14#define IOX2_CONFIG_HPP
15
17#include "iox2/bb/duration.hpp"
18#include "iox2/bb/expected.hpp"
19#include "iox2/bb/file_name.hpp"
20#include "iox2/bb/optional.hpp"
21#include "iox2/bb/path.hpp"
24
25namespace iox2 {
26class Config;
27class NodeBuilder;
28
29namespace config {
30class Global;
31
33class Node {
34 public:
36 auto directory() && -> const char*;
38 void set_directory(const iox2::bb::Path& value) &&;
40 auto monitor_suffix() && -> const char*;
44 auto global_mgmt_suffix() && -> const char*;
48 auto static_config_suffix() && -> const char*;
52 auto port_tag_suffix() && -> const char*;
56 auto service_tag_suffix() && -> const char*;
71
72 private:
73 friend class Global;
74 explicit Node(iox2_config_h* config);
75
76 iox2_config_h* m_config = nullptr;
77};
78
80class Service {
81 public:
83 auto directory() && -> const char*;
85 void set_directory(const iox2::bb::Path& value) &&;
87 auto data_segment_suffix() && -> const char*;
91 auto static_config_storage_suffix() && -> const char*;
95 auto dynamic_config_storage_suffix() && -> const char*;
99 auto connection_suffix() && -> const char*;
103 auto event_connection_suffix() && -> const char*;
108 auto cleanup_dead_nodes_on_open() && -> bool;
112
113 private:
114 friend class Global;
115 explicit Service(iox2_config_h* config);
116
117 iox2_config_h* m_config = nullptr;
118};
119
121class Global {
122 public:
124 auto prefix() && -> const char*;
126 void set_prefix(const iox2::bb::FileName& value) &&;
128 auto root_path() && -> const char*;
130 void set_root_path(const iox2::bb::Path& value) &&;
136
138 auto service() -> Service;
139
141 auto node() -> Node;
142
143 private:
144 friend class ::iox2::Config;
145 explicit Global(iox2_config_h* config);
146
147 iox2_config_h* m_config = nullptr;
148};
149
153 public:
155 auto max_subscribers() && -> size_t;
157 void set_max_subscribers(size_t value) &&;
159 auto max_publishers() && -> size_t;
161 void set_max_publishers(size_t value) &&;
164 auto max_nodes() && -> size_t;
166 void set_max_nodes(size_t value) &&;
168 auto subscriber_max_buffer_size() && -> size_t;
170 void set_subscriber_max_buffer_size(size_t value) &&;
176 auto publisher_max_loaned_samples() && -> size_t;
178 void set_publisher_max_loaned_samples(size_t value) &&;
180 auto publisher_history_size() && -> size_t;
182 void set_publisher_history_size(size_t value) &&;
186 auto enable_safe_overflow() && -> bool;
188 void set_enable_safe_overflow(bool value) &&;
202
203 private:
204 friend class Defaults;
205 explicit PublishSubscribe(iox2_config_h* config);
206
207 iox2_config_h* m_config = nullptr;
208};
209
212class Event {
213 public:
215 auto max_listeners() && -> size_t;
217 void set_max_listeners(size_t value) &&;
219 auto max_notifiers() && -> size_t;
221 void set_max_notifiers(size_t value) &&;
224 auto max_nodes() && -> size_t;
226 void set_max_nodes(size_t value) &&;
228 auto event_id_max_value() && -> size_t;
230 void set_event_id_max_value(size_t value) &&;
249
250 private:
251 friend class Defaults;
252 explicit Event(iox2_config_h* config);
253
254 iox2_config_h* m_config = nullptr;
255};
256
260 public:
277 auto max_response_buffer_size() && -> size_t;
280 void set_max_response_buffer_size(size_t value) &&;
282 auto max_servers() && -> size_t;
284 void set_max_servers(size_t value) &&;
286 auto max_clients() && -> size_t;
288 void set_max_clients(size_t value) &&;
291 auto max_nodes() && -> size_t;
294 void set_max_nodes(size_t value) &&;
303 auto max_loaned_requests() && -> size_t;
306 void set_max_loaned_requests(size_t value) &&;
366
367 private:
368 friend class Defaults;
369 explicit RequestResponse(iox2_config_h* config);
370
371 iox2_config_h* m_config = nullptr;
372};
373
377 public:
379 auto max_readers() && -> size_t;
381 void set_max_readers(size_t value) &&;
384 auto max_nodes() && -> size_t;
386 void set_max_nodes(size_t value) &&;
387
388 private:
389 friend class Defaults;
390 explicit Blackboard(iox2_config_h* config);
391
392 iox2_config_h* m_config = nullptr;
393};
394
397class Defaults {
398 public:
402 auto event() && -> Event;
406 auto blackboard() && -> Blackboard;
407
408 private:
409 friend class ::iox2::Config;
410 explicit Defaults(iox2_config_h* config);
411
412 iox2_config_h* m_config = nullptr;
413};
414} // namespace config
415
418 public:
419 ConfigView(const ConfigView&) = default;
420 ConfigView(ConfigView&&) = default;
421 auto operator=(const ConfigView&) -> ConfigView& = default;
422 auto operator=(ConfigView&&) -> ConfigView& = default;
423 ~ConfigView() = default;
424
426 auto to_owned() const -> Config;
427
428 private:
429 friend class Config;
430 template <ServiceType>
431 friend class Node;
432
433 template <ServiceType>
434 friend class Service;
435
436 explicit ConfigView(iox2_config_ptr ptr);
437 iox2_config_ptr m_ptr = nullptr;
438};
439
444class Config {
445 public:
447 Config(const Config& rhs);
448 Config(Config&& rhs) noexcept;
450
451 auto operator=(const Config& rhs) -> Config&;
452 auto operator=(Config&& rhs) noexcept -> Config&;
453
457
462
467
469 static auto global_config() -> ConfigView;
470
472 auto view() -> ConfigView;
473
474 private:
475 friend class ConfigView;
476 friend class config::Global;
477 friend class NodeBuilder;
478 template <ServiceType>
479 friend class DeadNodeView;
480
481 explicit Config(iox2_config_h handle);
482 void drop();
483
484 iox2_config_h m_handle = nullptr;
485};
486} // namespace iox2
487
488#endif
Non-owning view of a [Config].
Definition config.hpp:417
auto to_owned() const -> Config
Creates a copy of the corresponding [Config] and returns it.
ConfigView(const ConfigView &)=default
~ConfigView()=default
auto operator=(ConfigView &&) -> ConfigView &=default
ConfigView(ConfigView &&)=default
friend class Config
Definition config.hpp:429
auto operator=(const ConfigView &) -> ConfigView &=default
auto operator=(const Config &rhs) -> Config &
auto defaults() -> config::Defaults
Returns the [config::Defaults] part of the config.
auto global() -> config::Global
Returns the [config::Global] part of the config.
auto operator=(Config &&rhs) noexcept -> Config &
static auto setup_global_config_from_file(const iox2::bb::FilePath &file) -> iox2::bb::Expected< ConfigView, ConfigCreationError >
Config(Config &&rhs) noexcept
Config(const Config &rhs)
static auto from_file(const iox2::bb::FilePath &file) -> iox2::bb::Expected< Config, ConfigCreationError >
auto view() -> ConfigView
Returns the [ConfigView] to this [Config].
static auto global_config() -> ConfigView
Returns a [ConfigView] to the current global config.
Contains all details of a [Node] that is dead.
Creates a new [Node].
Definition node.hpp:113
Represents a single file name. It is not allowed to contain any path elements like "....
Definition file_name.hpp:43
Represents a path to a file. It is not allowed to end with a path separator since this would then be ...
Definition file_path.hpp:44
Represents a path to a file or a directory.
Definition path.hpp:34
void set_max_readers(size_t value) &&
Set the maximum amount of supported [Reader]s.
void set_max_nodes(size_t value) &&
Set the maximum amount of supported [Node]s.
auto max_readers() &&-> size_t
The maximum amount of supported [Reader]s.
auto max_nodes() &&-> size_t
auto blackboard() &&-> Blackboard
Returns the blackboard part of the default settings.
auto publish_subscribe() &&-> PublishSubscribe
Returns the publish_subscribe part of the default settings.
auto event() &&-> Event
Returns the event part of the default settings.
auto request_response() &&-> RequestResponse
Returns the request_response part of the default settings.
void set_notifier_dead_event(bb::Optional< size_t > value) &&
Sets the event id value that is emitted if a notifier was identified as dead.
void set_max_notifiers(size_t value) &&
Set the maximum amount of supported [Notifier].
void set_deadline(bb::Optional< iox2::bb::Duration > deadline) &&
Sets the deadline of the event service.
auto max_listeners() &&-> size_t
The maximum amount of supported [Listener].
void set_notifier_dropped_event(bb::Optional< size_t > value) &&
Sets the event id value that is emitted before a new notifier is dropped.
auto notifier_dead_event() &&-> bb::Optional< size_t >
Defines the event id value that is emitted if a notifier was identified as dead.
auto deadline() &&-> bb::Optional< iox2::bb::Duration >
auto notifier_dropped_event() &&-> bb::Optional< size_t >
Defines the event id value that is emitted before a new notifier is dropped.
void set_max_listeners(size_t value) &&
Set the maximum amount of supported [Listener].
void set_max_nodes(size_t value) &&
Set the maximum amount of supported [Node]s.
void set_event_id_max_value(size_t value) &&
Set the largest event id supported by the event service.
auto max_notifiers() &&-> size_t
The maximum amount of supported [Notifier].
void set_notifier_created_event(bb::Optional< size_t > value) &&
Sets the event id value that is emitted after a new notifier was created.
auto event_id_max_value() &&-> size_t
The largest event id supported by the event service.
auto max_nodes() &&-> size_t
auto notifier_created_event() &&-> bb::Optional< size_t >
Defines the event id value that is emitted after a new notifier was created.
The global settings.
Definition config.hpp:121
auto service() -> Service
Returns the service part of the global configuration.
auto node() -> Node
Returns the node part of the global configuration.
auto root_path() &&-> const char *
The path under which all other directories or files will be created.
void set_prefix(const iox2::bb::FileName &value) &&
Set the prefix used for all files created during runtime.
auto creation_timeout() &&-> iox2::bb::Duration
void set_root_path(const iox2::bb::Path &value) &&
Defines the path under which all other directories or files will be created.
auto prefix() &&-> const char *
Prefix used for all files created during runtime.
void set_creation_timeout(const iox2::bb::Duration &value) &&
Set the creation timeout.
All configurable settings of a [Node].
Definition config.hpp:33
void set_static_config_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the files where the node configuration is stored.
void set_service_tag_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the service tags.
auto monitor_suffix() &&-> const char *
The suffix of the monitor token.
void set_port_tag_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the service tags.
void set_monitor_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the monitor token.
void set_global_mgmt_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the files where the node configuration is stored.
auto directory() &&-> const char *
The directory in which all node files are stored.
auto cleanup_dead_nodes_on_destruction() &&-> bool
void set_directory(const iox2::bb::Path &value) &&
Set the directory in which all node files are stored.
auto service_tag_suffix() &&-> const char *
The suffix of the service tags.
void set_cleanup_dead_nodes_on_destruction(bool value) &&
Enable/disable the cleanup dead nodes on destruction.
auto port_tag_suffix() &&-> const char *
The suffix of the service tags.
void set_cleanup_dead_nodes_on_creation(bool value) &&
Enable/disable the cleanup dead nodes on creation.
auto global_mgmt_suffix() &&-> const char *
The suffix of the files where the node configuration is stored.
auto cleanup_dead_nodes_on_creation() &&-> bool
auto static_config_suffix() &&-> const char *
The suffix of the files where the node configuration is stored.
void set_enable_safe_overflow(bool value) &&
Enables/disables safe overflow.
auto subscriber_expired_connection_buffer() &&-> size_t
void set_publisher_history_size(size_t value) &&
Set the maximum history size a [Subscriber] can request from a [Publisher].
void set_max_publishers(size_t value) &&
Set the maximum amount of supported [Publisher]s.
void set_max_subscribers(size_t value) &&
Set the maximum amount of supported [Subscriber]s.
void set_max_nodes(size_t value) &&
Set the maximum amount of supported [Node]s.
void set_subscriber_max_borrowed_samples(size_t value) &&
Set the maximum amount of [Sample]s a [Subscriber] can hold at the same time.
auto max_subscribers() &&-> size_t
The maximum amount of supported [Subscriber]s.
void set_backpressure_strategy(BackpressureStrategy value) &&
Define the backpressure strategy.
auto backpressure_strategy() &&-> BackpressureStrategy
auto enable_safe_overflow() &&-> bool
void set_publisher_max_loaned_samples(size_t value) &&
The maximum amount of [SampleMut]s a [Publisher] can loan at the same time.
auto publisher_max_loaned_samples() &&-> size_t
The maximum amount of [SampleMut]s a [Publisher] can loan at the same time.
void set_subscriber_expired_connection_buffer(size_t value) &&
Set the expired connection buffer size.
auto subscriber_max_buffer_size() &&-> size_t
The maximum buffer size a [Subscriber] can have.
auto max_nodes() &&-> size_t
auto max_publishers() &&-> size_t
The maximum amount of supported [Publisher]s.
auto publisher_history_size() &&-> size_t
The maximum history size a [Subscriber] can request from a [Publisher].
void set_subscriber_max_buffer_size(size_t value) &&
Set the maximum buffer size a [Subscriber] can have.
auto subscriber_max_borrowed_samples() &&-> size_t
The maximum amount of [Sample]s a [Subscriber] can hold at the same time.
auto enable_safe_overflow_for_requests() &&-> bool
Defines if the request buffer of the [Service] safely overflows.
void set_max_loaned_requests(size_t value) &&
void set_max_response_buffer_size(size_t value) &&
auto server_backpressure_strategy() &&-> BackpressureStrategy
void set_server_backpressure_strategy(BackpressureStrategy value) &&
void set_client_expired_connection_buffer(size_t value) &&
void set_max_clients(size_t value) &&
Set the maximum amount of supported [crate::port::client::Client].
void set_enable_safe_overflow_for_responses(bool value) &&
Enables/disables safe overflow for the response buffer.
auto max_servers() &&-> size_t
The maximum amount of supported [crate::port::server::Server].
auto max_active_requests_per_client() &&-> size_t
auto client_expired_connection_buffer() &&-> size_t
void set_client_backpressure_strategy(BackpressureStrategy value) &&
void set_enable_fire_and_forget_requests(bool value) &&
Set if fire-and-forget feature is enabled.
void set_max_borrowed_responses_per_pending_response(size_t value) &&
void set_server_expired_connection_buffer(size_t value) &&
auto max_borrowed_responses_per_pending_response() &&-> size_t
auto enable_safe_overflow_for_responses() &&-> bool
Defines if the response buffer of the [Service] safely overflows.
void set_max_nodes(size_t value) &&
auto max_response_buffer_size() &&-> size_t
void set_max_servers(size_t value) &&
Set the maximum amount of supported [crate::port::server::Server].
void set_max_active_requests_per_client(size_t value) &&
auto max_nodes() &&-> size_t
void set_server_max_loaned_responses_per_request(size_t value) &&
auto max_loaned_requests() &&-> size_t
auto server_max_loaned_responses_per_request() &&-> size_t
auto max_clients() &&-> size_t
The maximum amount of supported [crate::port::client::Client].
auto server_expired_connection_buffer() &&-> size_t
auto client_backpressure_strategy() &&-> BackpressureStrategy
void set_enable_safe_overflow_for_requests(bool value) &&
Enables/disables safe overflow for the request buffer.
auto enable_fire_and_forget_requests() &&-> bool
All configurable settings of a [Service].
Definition config.hpp:80
auto directory() &&-> const char *
The directory in which all service files are stored.
void set_directory(const iox2::bb::Path &value) &&
Set the directory in which all service files are stored.
auto data_segment_suffix() &&-> const char *
The suffix of the ports data segment.
void set_event_connection_suffix(const iox2::bb::FileName &value) &&
Set the suffix of a one-to-one connection.
auto connection_suffix() &&-> const char *
The suffix of a one-to-one connection.
auto dynamic_config_storage_suffix() &&-> const char *
The suffix of the dynamic config file.
auto static_config_storage_suffix() &&-> const char *
The suffix of the static config file.
auto event_connection_suffix() &&-> const char *
The suffix of a one-to-one connection.
void set_data_segment_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the ports data segment.
void set_connection_suffix(const iox2::bb::FileName &value) &&
Set the suffix of a one-to-one connection.
void set_static_config_storage_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the static config file.
void set_dynamic_config_storage_suffix(const iox2::bb::FileName &value) &&
Set the suffix of the dynamic config file.
auto cleanup_dead_nodes_on_open() &&-> bool
void set_cleanup_dead_nodes_on_open(bool value) &&
iox2::bb::variation::Optional< T > Optional
Definition optional.hpp:25
iox2::bb::variation::Expected< T, E > Expected
Definition expected.hpp:22