iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
node_name.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_NAME_HPP
14#define IOX2_NODE_NAME_HPP
15
16#include "iox2/bb/expected.hpp"
19
20namespace iox2 {
21namespace internal {
22template <ServiceType>
23auto list_callback(iox2_node_state_e,
24 iox2_unique_node_id_ptr,
25 const char* executable,
26 iox2_node_name_ptr,
27 iox2_config_ptr,
28 iox2_callback_context) -> iox2_callback_progression_e;
29}
30class NodeName;
31
34 public:
36 NodeNameView(const NodeNameView&) = default;
37 auto operator=(NodeNameView&&) -> NodeNameView& = default;
38 auto operator=(const NodeNameView&) -> NodeNameView& = default;
39 ~NodeNameView() = default;
40
42 auto to_string() const -> iox2::bb::StaticString<IOX2_NODE_NAME_LENGTH>;
43
45 auto to_owned() const -> NodeName;
46
47 private:
48 template <ServiceType>
49 friend class Node;
50 friend class NodeName;
51 template <ServiceType>
52 friend auto internal::list_callback(iox2_node_state_e,
53 iox2_unique_node_id_ptr,
54 const char* executable,
55 iox2_node_name_ptr,
56 iox2_config_ptr,
57 iox2_callback_context) -> iox2_callback_progression_e;
58
59 explicit NodeNameView(iox2_node_name_ptr ptr);
60 iox2_node_name_ptr m_ptr = nullptr;
61};
62
64class NodeName {
65 public:
66 NodeName(NodeName&&) noexcept;
67 auto operator=(NodeName&&) noexcept -> NodeName&;
69 auto operator=(const NodeName&) -> NodeName&;
71
73 auto as_view() const -> NodeNameView;
74
78 static auto create(const char* value) -> iox2::bb::Expected<NodeName, bb::SemanticStringError>;
79
81 auto to_string() const -> iox2::bb::StaticString<IOX2_NODE_NAME_LENGTH>;
82
83 private:
84 friend class NodeBuilder;
85 friend class NodeNameView;
86
87 explicit NodeName(iox2_node_name_h handle);
88 void drop() noexcept;
89 static auto create_impl(const char* value, size_t value_len)
90 -> iox2::bb::Expected<NodeName, bb::SemanticStringError>;
91
92 iox2_node_name_h m_handle = nullptr;
93};
94} // namespace iox2
95
96#endif
Creates a new [Node].
Definition node.hpp:113
Non-owning view of a [NodeName].
Definition node_name.hpp:33
NodeNameView(const NodeNameView &)=default
auto to_owned() const -> NodeName
Creates a copy of the corresponding [NodeName] and returns it.
NodeNameView(NodeNameView &&)=default
friend auto internal::list_callback(iox2_node_state_e, iox2_unique_node_id_ptr, const char *executable, iox2_node_name_ptr, iox2_config_ptr, iox2_callback_context) -> iox2_callback_progression_e
~NodeNameView()=default
auto operator=(const NodeNameView &) -> NodeNameView &=default
auto operator=(NodeNameView &&) -> NodeNameView &=default
auto to_string() const -> iox2::bb::StaticString< IOX2_NODE_NAME_LENGTH >
Returns a [iox2::bb::StaticString] containing the [NodeName].
Represent the name for a [Node].
Definition node_name.hpp:64
NodeName(NodeName &&) noexcept
auto list_callback(iox2_node_state_e node_state, iox2_unique_node_id_ptr node_id_ptr, const char *executable, iox2_node_name_ptr node_name, iox2_config_ptr config, iox2_callback_context context) -> iox2_callback_progression_e