iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
attribute_set.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_ATTRIBUTE_SET_HPP
14#define IOX2_ATTRIBUTE_SET_HPP
15
16#include "iox2/attribute.hpp"
17#include "iox2/bb/optional.hpp"
20
21#include <iostream>
22
23namespace iox2 {
24class AttributeSet;
25
31 public:
33 auto number_of_attributes() const -> uint64_t;
34
37 auto operator[](uint64_t index) const -> AttributeView;
38
41 auto number_of_key_values(const Attribute::Key& key) const -> uint64_t;
42
49 auto key_value(const Attribute::Key& key, uint64_t idx) -> bb::Optional<Attribute::Value>;
50
52 void iter_key_values(const Attribute::Key& key,
53 const iox2::bb::StaticFunction<CallbackProgression(const Attribute::Value&)>& callback) const;
54
56 auto to_owned() const -> AttributeSet;
57
58 private:
59 template <ServiceType, typename, typename>
61 template <ServiceType, typename, typename, typename, typename>
63 template <ServiceType>
64 friend class PortFactoryEvent;
65 template <ServiceType, typename>
67 friend class AttributeVerifier;
68 friend class AttributeSpecifier;
69 friend class StaticConfig;
70 friend class AttributeSet;
71
72 explicit AttributeSetView(iox2_attribute_set_ptr handle);
73
74 iox2_attribute_set_ptr m_handle = nullptr;
75};
76
79 public:
80 AttributeSet(const AttributeSet&) = delete;
81 AttributeSet(AttributeSet&& rhs) noexcept;
82 auto operator=(const AttributeSet&) -> AttributeSet& = delete;
83 auto operator=(AttributeSet&& rhs) noexcept -> AttributeSet&;
85
87 auto number_of_attributes() const -> uint64_t;
88
91 auto operator[](uint64_t index) const -> AttributeView;
92
95 auto number_of_key_values(const Attribute::Key& key) const -> uint64_t;
96
103 auto key_value(const Attribute::Key& key, uint64_t idx) -> bb::Optional<Attribute::Value>;
104
106 void iter_key_values(const Attribute::Key& key,
107 const iox2::bb::StaticFunction<CallbackProgression(const Attribute::Value&)>& callback) const;
108
109 private:
110 friend class AttributeSetView;
111
112 explicit AttributeSet(iox2_attribute_set_h handle);
113 void drop();
114
115 iox2_attribute_set_h m_handle = nullptr;
116 AttributeSetView m_view;
117};
118
119} // namespace iox2
120
121auto operator<<(std::ostream& stream, const iox2::AttributeSetView& value) -> std::ostream&;
122auto operator<<(std::ostream& stream, const iox2::AttributeSet& value) -> std::ostream&;
123
124#endif
auto number_of_key_values(const Attribute::Key &key) const -> uint64_t
auto number_of_attributes() const -> uint64_t
Returns the number of [Attribute]s stored inside the [AttributeSet].
void iter_key_values(const Attribute::Key &key, const iox2::bb::StaticFunction< CallbackProgression(const Attribute::Value &)> &callback) const
Returns all values to a specific key.
auto to_owned() const -> AttributeSet
Creates a copy of the [AttributeSetView] that owns the attributes.
auto key_value(const Attribute::Key &key, uint64_t idx) -> bb::Optional< Attribute::Value >
Represents all service attributes. They can be set when the service is created.
auto operator=(const AttributeSet &) -> AttributeSet &=delete
AttributeSet(AttributeSet &&rhs) noexcept
auto operator=(AttributeSet &&rhs) noexcept -> AttributeSet &
AttributeSet(const AttributeSet &)=delete
auto number_of_attributes() const -> uint64_t
Returns the number of [Attribute]s stored inside the [AttributeSet].
Represents the port factory of a [Service] with [MessagingPattern::Blackboard].
Represents the port factory of a [Service] with [MessagingPattern::Event].
Defines a common set of static service configuration details every service shares.