13#ifndef IOX2_READER_HPP
14#define IOX2_READER_HPP
27template <ServiceType S,
typename KeyType>
44 template <typename ValueType>
51 explicit
Reader(iox2_reader_h handle);
54 iox2_reader_h m_handle =
nullptr;
59 : m_handle { handle } {
62template <ServiceType S,
typename KeyType>
63inline void Reader<S, KeyType>::drop() {
64 if (m_handle !=
nullptr) {
66#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__))
67#pragma GCC diagnostic push
68#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
70 iox2_reader_drop(m_handle);
71#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__))
72#pragma GCC diagnostic pop
78template <ServiceType S,
typename KeyType>
80 *
this = std::move(rhs);
83template <ServiceType S,
typename KeyType>
87 m_handle = rhs.m_handle;
88 rhs.m_handle =
nullptr;
94template <ServiceType S,
typename KeyType>
99template <ServiceType S,
typename KeyType>
101 iox2_unique_reader_id_h id_handle =
nullptr;
103 iox2_reader_id(&m_handle,
nullptr, &id_handle);
107template <ServiceType S,
typename KeyType>
109 const auto* port_name_ptr = iox2_reader_name(&m_handle);
113template <ServiceType S,
typename KeyType>
114template <
typename ValueType>
117 iox2_entry_handle_h entry_handle {};
118 const auto type_name = internal::get_type_name<ValueType>();
120 auto result = iox2_reader_entry(&m_handle,
124 type_name.unchecked_access().c_str(),
129 if (result == IOX2_OK) {
133 return bb::err(bb::into<EntryHandleError>(result));
A handle for direct read access to a specific blackboard value.
Non-owning view of a [PortName].
static auto from_native_ptr(iox2_port_name_ptr m_ptr) -> PortNameView
Creates a [PortNameView] from a native [iox2_port_name_ptr].
Reading endpoint of a blackboard based communication.
auto id() const -> UniqueReaderId
Returns the [UniqueReaderId] of the [Reader].
auto name() const -> PortNameView
Returns the [PortNameView] of the [Reader].
auto operator=(const Reader &) -> Reader &=delete
auto operator=(Reader &&rhs) noexcept -> Reader &
Reader(const Reader &)=delete
Reader(Reader &&rhs) noexcept
auto entry(const KeyType &key) -> bb::Expected< EntryHandle< S, KeyType, ValueType >, EntryHandleError >
Creates an [EntryHandle] for direct read access to the value.
The system-wide unique id of a [Reader].
constexpr auto err(const E &error) -> Unexpected< E >
iox2::bb::variation::Expected< T, E > Expected
EntryHandleError
Defines a failure that can occur when a [EntryHandle] is created with [Reader::entry()].