iceoryx2
C++ Language 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
35namespace iox2 {
40template <ServiceType T>
41class Node {
42 public:
43 Node(Node&&) noexcept;
44 auto operator=(Node&&) noexcept -> Node&;
45 Node(const Node&) = delete;
46 auto operator=(const Node&) -> Node& = delete;
47 ~Node();
48
50 auto config() const -> ConfigView;
51
53 auto name() const -> NodeNameView;
54
56 auto id() const -> UniqueNodeId;
57
61
63 auto wait(iox2::bb::Duration cycle_time) const -> bb::Expected<void, NodeWaitFailure>;
64
69 static auto list(ConfigView config, const iox2::bb::StaticFunction<CallbackProgression(NodeState<T>)>& callback)
70 -> bb::Expected<void, NodeListFailure>;
71
74
81
90 auto blocking_cleanup_dead_nodes(iox2::bb::Duration timeout) -> CleanupState;
91
100 auto force_remove_service(const iox2::ServiceName& name, iox2::MessagingPattern messaging_pattern) const
101 -> iox2::bb::Expected<bool, ServiceRemoveError>;
102
103 private:
104 explicit Node(iox2_node_h handle);
105 void drop();
106
107 friend class NodeBuilder;
108
109 iox2_node_h m_handle = nullptr;
110};
111
114 public:
118#ifdef DOXYGEN_MACRO_FIX
119 auto name(const NodeName value) -> decltype(auto);
120#else
122#endif
123
126#ifdef DOXYGEN_MACRO_FIX
127 auto config(const Config value) -> decltype(auto);
128#else
130#endif
131
134#ifdef DOXYGEN_MACRO_FIX
135 auto signal_handling_mode(const SignalHandlingMode value) -> decltype(auto);
136#else
138#endif
139
140 public:
143 auto operator=(NodeBuilder&&) -> NodeBuilder& = default;
144 ~NodeBuilder() = default;
145
146 NodeBuilder(const NodeBuilder&) = delete;
147 auto operator=(const NodeBuilder&) -> NodeBuilder& = delete;
148
150 template <ServiceType T>
151 auto create() const&& -> bb::Expected<Node<T>, NodeCreationFailure>;
152
153 private:
154 iox2_node_builder_h m_handle = nullptr;
155};
156} // namespace iox2
157
158#endif
#define IOX2_BUILDER_OPTIONAL(type, name)
Definition builder.hpp:47
Non-owning view of a [Config].
Definition config.hpp:417
Creates a new [Node].
Definition node.hpp:113
auto operator=(const NodeBuilder &) -> NodeBuilder &=delete
NodeBuilder(const NodeBuilder &)=delete
auto create() const &&-> bb::Expected< Node< T >, NodeCreationFailure >
Creates a new [Node] for a specified [ServiceType].
~NodeBuilder()=default
auto name(const NodeName value) -> decltype(auto)
auto config(const Config value) -> decltype(auto)
NodeBuilder(NodeBuilder &&)=default
auto operator=(NodeBuilder &&) -> NodeBuilder &=default
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
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.
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].
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).