iceoryx2
C++ Bindings
Loading...
Searching...
No Matches
node.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_NODE_HPP
14#define IOX2_NODE_HPP
15
17#include "iox2/bb/duration.hpp"
18#include "iox2/bb/expected.hpp"
22#include "iox2/config.hpp"
26#include "iox2/node_name.hpp"
27#include "iox2/node_state.hpp"
30#include "iox2/service_name.hpp"
31#include "iox2/service_type.hpp"
34#include "iox2/waitset.hpp"
35
36namespace iox2 {
41template <ServiceType T>
42class Node {
43 public:
44 Node(Node&&) noexcept;
45 auto operator=(Node&&) noexcept -> Node&;
46 Node(const Node&) = delete;
47 auto operator=(const Node&) -> Node& = delete;
48 ~Node();
49
51 auto config() const -> ConfigView;
52
54 auto name() const -> NodeNameView;
55
57 auto id() const -> UniqueNodeId;
58
62
64 auto waitset_builder() const -> WaitSetBuilder<T>;
65
67 auto wait(iox2::bb::Duration cycle_time) const -> bb::Expected<void, NodeWaitFailure>;
68
73 static auto list(ConfigView config, const iox2::bb::StaticFunction<CallbackProgression(NodeState<T>)>& callback)
74 -> bb::Expected<void, NodeListFailure>;
75
78
85
94 auto blocking_cleanup_dead_nodes(iox2::bb::Duration timeout) -> CleanupState;
95
104 auto force_remove_service(const iox2::ServiceName& name, iox2::MessagingPattern messaging_pattern) const
105 -> iox2::bb::Expected<bool, ServiceRemoveError>;
106
107 private:
108 explicit Node(iox2_node_h handle);
109 void drop();
110
111 friend class NodeBuilder;
112
113 iox2_node_h m_handle = nullptr;
114};
115
118 public:
122#ifdef DOXYGEN_MACRO_FIX
123 auto name(const NodeName value) -> decltype(auto);
124#else
126#endif
127
130#ifdef DOXYGEN_MACRO_FIX
131 auto config(const Config value) -> decltype(auto);
132#else
134#endif
135
138#ifdef DOXYGEN_MACRO_FIX
139 auto signal_handling_mode(const SignalHandlingMode value) -> decltype(auto);
140#else
142#endif
143
144 public:
146 NodeBuilder(NodeBuilder&& rhs) noexcept;
147 auto operator=(NodeBuilder&& rhs) noexcept -> NodeBuilder&;
149
150 NodeBuilder(const NodeBuilder&) = delete;
151 auto operator=(const NodeBuilder&) -> NodeBuilder& = delete;
152
154 template <ServiceType T>
156
157 private:
158 void drop();
159
160 iox2_node_builder_h m_handle = nullptr;
161};
162} // namespace iox2
163
164#endif
#define IOX2_BUILDER_OPTIONAL(type, name)
Definition builder.hpp:47
Non-owning view of a [Config].
Definition config.hpp:423
auto operator=(const NodeBuilder &) -> NodeBuilder &=delete
NodeBuilder(NodeBuilder &&rhs) noexcept
NodeBuilder(const NodeBuilder &)=delete
auto name(const NodeName value) -> decltype(auto)
auto config(const Config value) -> decltype(auto)
auto create() &&-> bb::Expected< Node< T >, NodeCreationFailure >
Creates a new [Node] for a specified [ServiceType].
auto operator=(NodeBuilder &&rhs) noexcept -> NodeBuilder &
auto signal_handling_mode(const SignalHandlingMode value) -> decltype(auto)
Non-owning view of a [NodeName].
Definition node_name.hpp:33
Represent the name for a [Node].
Definition node_name.hpp:64
Describes the state of a [Node].
auto blocking_cleanup_dead_nodes(iox2::bb::Duration timeout) -> CleanupState
friend class NodeBuilder
Definition node.hpp:111
auto force_remove_service(const iox2::ServiceName &name, iox2::MessagingPattern messaging_pattern) const -> iox2::bb::Expected< bool, ServiceRemoveError >
auto config() const -> ConfigView
Returns the [Config] that the [Node] will use to create any iceoryx2 entity.
auto service_builder(const ServiceName &name) const -> ServiceBuilder< T >
Node(Node &&) noexcept
auto signal_handling_mode() const -> SignalHandlingMode
Returns the [SignalHandlingMode] with which the [Node] was created.
auto waitset_builder() const -> WaitSetBuilder< T >
Returns the [WaitSetBuilder] to create a new [WaitSet].
static auto list(ConfigView config, const iox2::bb::StaticFunction< CallbackProgression(NodeState< T >)> &callback) -> bb::Expected< void, NodeListFailure >
auto wait(iox2::bb::Duration cycle_time) const -> bb::Expected< void, NodeWaitFailure >
Waits for a given cycle_time.
auto name() const -> NodeNameView
Returns the name of the node inside a [NodeNameView].
auto try_cleanup_dead_nodes() -> CleanupState
Builder to create or open [Service]s.
The name of a [Service].
The system-wide unique id of a [Node].
The builder for the [WaitSet].
Definition waitset.hpp:293
iox2::bb::variation::Expected< T, E > Expected
Definition expected.hpp:22
NodeCreationFailure
All failures that can occur in [NodeBuilder::create()].
NodeListFailure
All failures that can occur in [Node::list()].
NodeWaitFailure
Defines all possible errors that can occur during [Node::wait()].
ServiceRemoveError
Error that can be reported when removing a [Node](crate::node::Node).