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:
89 auto directory() && -> const char*;
91 void set_directory(const iox2::bb::Path& value) &&;
93 auto data_segment_suffix() && -> const char*;
97 auto static_config_storage_suffix() && -> const char*;
101 auto dynamic_config_storage_suffix() && -> const char*;
105 auto connection_suffix() && -> const char*;
109 auto event_connection_suffix() && -> const char*;
114 auto cleanup_dead_nodes_on_open() && -> bool;
118
119 private:
120 friend class Global;
121 explicit Service(iox2_config_h* config);
122
123 iox2_config_h* m_config = nullptr;
124};
125
127class Global {
128 public:
130 auto prefix() && -> const char*;
132 void set_prefix(const iox2::bb::FileName& value) &&;
134 auto root_path() && -> const char*;
136 void set_root_path(const iox2::bb::Path& value) &&;
142
144 auto service() -> Service;
145
147 auto node() -> Node;
148
149 private:
150 friend class ::iox2::Config;
151 explicit Global(iox2_config_h* config);
152
153 iox2_config_h* m_config = nullptr;
154};
155
159 public:
161 auto max_subscribers() && -> size_t;
163 void set_max_subscribers(size_t value) &&;
165 auto max_publishers() && -> size_t;
167 void set_max_publishers(size_t value) &&;
170 auto max_nodes() && -> size_t;
172 void set_max_nodes(size_t value) &&;
174 auto subscriber_max_buffer_size() && -> size_t;
176 void set_subscriber_max_buffer_size(size_t value) &&;
182 auto publisher_max_loaned_samples() && -> size_t;
184 void set_publisher_max_loaned_samples(size_t value) &&;
186 auto publisher_history_size() && -> size_t;
188 void set_publisher_history_size(size_t value) &&;
192 auto enable_safe_overflow() && -> bool;
194 void set_enable_safe_overflow(bool value) &&;
208
209 private:
210 friend class Defaults;
211 explicit PublishSubscribe(iox2_config_h* config);
212
213 iox2_config_h* m_config = nullptr;
214};
215
218class Event {
219 public:
221 auto max_listeners() && -> size_t;
223 void set_max_listeners(size_t value) &&;
225 auto max_notifiers() && -> size_t;
227 void set_max_notifiers(size_t value) &&;
230 auto max_nodes() && -> size_t;
232 void set_max_nodes(size_t value) &&;
234 auto event_id_max_value() && -> size_t;
236 void set_event_id_max_value(size_t value) &&;
255
256 private:
257 friend class Defaults;
258 explicit Event(iox2_config_h* config);
259
260 iox2_config_h* m_config = nullptr;
261};
262
266 public:
283 auto max_response_buffer_size() && -> size_t;
286 void set_max_response_buffer_size(size_t value) &&;
288 auto max_servers() && -> size_t;
290 void set_max_servers(size_t value) &&;
292 auto max_clients() && -> size_t;
294 void set_max_clients(size_t value) &&;
297 auto max_nodes() && -> size_t;
300 void set_max_nodes(size_t value) &&;
309 auto max_loaned_requests() && -> size_t;
312 void set_max_loaned_requests(size_t value) &&;
372
373 private:
374 friend class Defaults;
375 explicit RequestResponse(iox2_config_h* config);
376
377 iox2_config_h* m_config = nullptr;
378};
379
383 public:
385 auto max_readers() && -> size_t;
387 void set_max_readers(size_t value) &&;
390 auto max_nodes() && -> size_t;
392 void set_max_nodes(size_t value) &&;
393
394 private:
395 friend class Defaults;
396 explicit Blackboard(iox2_config_h* config);
397
398 iox2_config_h* m_config = nullptr;
399};
400
403class Defaults {
404 public:
408 auto event() && -> Event;
412 auto blackboard() && -> Blackboard;
413
414 private:
415 friend class ::iox2::Config;
416 explicit Defaults(iox2_config_h* config);
417
418 iox2_config_h* m_config = nullptr;
419};
420} // namespace config
421
424 public:
425 ConfigView(const ConfigView&) = default;
426 ConfigView(ConfigView&&) = default;
427 auto operator=(const ConfigView&) -> ConfigView& = default;
428 auto operator=(ConfigView&&) -> ConfigView& = default;
429 ~ConfigView() = default;
430
432 auto to_owned() const -> Config;
433
434 private:
435 friend class Config;
436 template <ServiceType>
437 friend class Node;
438 template <typename, typename, ServiceType>
440
441 template <ServiceType>
442 friend class Service;
443
444 explicit ConfigView(iox2_config_ptr ptr);
445 iox2_config_ptr m_ptr = nullptr;
446};
447
452class Config {
453 public:
455 Config(const Config& rhs);
456 Config(Config&& rhs) noexcept;
458
459 auto operator=(const Config& rhs) -> Config&;
460 auto operator=(Config&& rhs) noexcept -> Config&;
461
465
470
475
477 static auto global_config() -> ConfigView;
478
480 auto view() -> ConfigView;
481
482 private:
483 friend class ConfigView;
484 friend class config::Global;
485 friend class NodeBuilder;
486 template <ServiceType>
487 friend class DeadNodeView;
488
489 explicit Config(iox2_config_h handle);
490 void drop();
491
492 iox2_config_h m_handle = nullptr;
493};
494} // namespace iox2
495
496#endif
Non-owning view of a [Config].
Definition config.hpp:423
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:435
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
Builder to create new [MessagingPattern::PublishSubscribe] based [Service]s.
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:127
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_flatbuffer_schema_path(bb::Optional< bb::Path > value) &&
Set the flatbuffer schema lookup path.
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.
auto flatbuffer_schema_path() &&-> bb::Optional< const char * >
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