13#ifndef IOX2_ENTRY_VALUE_UNINIT_HPP
14#define IOX2_ENTRY_VALUE_UNINIT_HPP
18#include "iox2/iceoryx2.h"
22template <ServiceType,
typename,
typename>
26template <ServiceType S,
typename KeyType,
typename ValueType>
38 template <ServiceType ST,
typename KeyT,
typename ValueT>
43 template <ServiceType ST,
typename KeyT,
typename ValueT>
52 template <ServiceType ST,
typename KeyT,
typename ValueT>
56 template <ServiceType,
typename,
typename>
59 template <ServiceType ST,
typename KeyT,
typename ValueT>
66 auto take_handle_ownership() -> iox2_entry_value_uninit_h;
69 iox2_entry_value_uninit_t m_entry_value_uninit;
70 iox2_entry_value_uninit_h m_handle =
nullptr;
74template <ServiceType S,
typename KeyType,
typename ValueType>
76 iox2_entry_handle_mut_loan_uninit(
77 entry_handle, &m_entry_value_uninit, &m_handle,
sizeof(ValueType),
alignof(ValueType));
81template <ServiceType S,
typename KeyType,
typename ValueType>
83 *
this = std::move(rhs);
88void iox2_entry_value_uninit_move(iox2_entry_value_uninit_t*, iox2_entry_value_uninit_t*, iox2_entry_value_uninit_h*);
92template <ServiceType S,
typename KeyType,
typename ValueType>
97 internal::iox2_entry_value_uninit_move(&rhs.m_entry_value_uninit, &m_entry_value_uninit, &m_handle);
98 rhs.m_handle =
nullptr;
104template <ServiceType S,
typename KeyType,
typename ValueType>
109template <ServiceType S,
typename KeyType,
typename ValueType>
112 new (&self.value_mut()) ValueType(std::forward<ValueType>(value));
114 iox2_entry_handle_mut_h entry_handle_mut_handle =
nullptr;
115 iox2_entry_value_uninit_update(self.take_handle_ownership(),
nullptr, &entry_handle_mut_handle);
118 return entry_handle_mut;
121template <ServiceType S,
typename KeyType,
typename ValueType>
123 iox2_entry_handle_mut_h entry_handle_mut_handle =
nullptr;
125 iox2_entry_value_uninit_discard(self.take_handle_ownership(),
nullptr, &entry_handle_mut_handle);
128 return entry_handle_mut;
131template <ServiceType S,
typename KeyType,
typename ValueType>
133 void* value_ptr =
nullptr;
134 iox2_entry_value_uninit_value_mut(&m_handle, &value_ptr);
135 return *
static_cast<ValueType*
>(value_ptr);
138template <ServiceType S,
typename KeyType,
typename ValueType>
141 iox2_entry_handle_mut_h entry_handle_mut_handle =
nullptr;
142 iox2_entry_value_uninit_update(self.take_handle_ownership(),
nullptr, &entry_handle_mut_handle);
145 return entry_handle_mut;
148template <ServiceType S,
typename KeyType,
typename ValueType>
149inline void EntryValueUninit<S, KeyType, ValueType>::drop() {
150 if (m_handle !=
nullptr) {
151 iox2_entry_value_uninit_drop(m_handle);
156template <ServiceType S,
typename KeyType,
typename ValueType>
157inline auto EntryValueUninit<S, KeyType, ValueType>::take_handle_ownership() -> iox2_entry_value_uninit_h {
158 auto* result = m_handle;
A handle for direct write access to a specific blackboard value.
Wrapper around an uninitialized entry value that can be used for a zero-copy update.
auto value_mut() -> ValueType &
~EntryValueUninit() noexcept
EntryValueUninit(EntryValueUninit &&rhs) noexcept
EntryValueUninit(const EntryValueUninit &)=delete
friend auto update_with_copy(EntryValueUninit< ST, KeyT, ValueT > &&self, ValueT value) -> EntryHandleMut< ST, KeyT, ValueT >
auto operator=(EntryValueUninit &&rhs) noexcept -> EntryValueUninit &
friend auto discard(EntryValueUninit< ST, KeyT, ValueT > &&self) -> EntryHandleMut< ST, KeyT, ValueT >
Discard the [EntryValueUninit] and returns the original [EntryHandleMut].
friend auto assume_init_and_update(EntryValueUninit< ST, KeyT, ValueT > &&self) -> EntryHandleMut< ST, KeyT, ValueT >
auto operator=(const EntryValueUninit &) -> EntryValueUninit &=delete
friend auto loan_uninit(EntryHandleMut< ST, KeyT, ValueT > &&) -> EntryValueUninit< ST, KeyT, ValueT >
auto assume_init_and_update(EntryValueUninit< S, KeyType, ValueType > &&self) -> EntryHandleMut< S, KeyType, ValueType >
auto update_with_copy(EntryValueUninit< S, KeyType, ValueType > &&self, ValueType value) -> EntryHandleMut< S, KeyType, ValueType >
auto discard(EntryValueUninit< S, KeyType, ValueType > &&self) -> EntryHandleMut< S, KeyType, ValueType >