13#ifndef IOX2_INTERNAL_CALLBACK_CONTEXT_HPP
14#define IOX2_INTERNAL_CALLBACK_CONTEXT_HPP
53 auto value() const -> const T& {
73 auto* context = ctx_cast<OverridePreallocationCallback>(
ctx);
74 auto ret_val = context->value()(value);
76 delete &context->value();
82template <
typename T,
typename ViewType>
83inline auto list_ports_callback(
void* context,
const T port_details_view) -> iox2_callback_progression_e {
85 return iox2::bb::into<iox2_callback_progression_e>(callback->value()(ViewType(port_details_view)));
88template <ServiceType T>
91 iox2_unique_node_id_ptr node_id_ptr,
92 const char* executable,
93 iox2_node_name_ptr node_name,
94 iox2_config_ptr config,
95 iox2_callback_context context) -> iox2_callback_progression_e {
96 auto node_details = [&]() ->
auto {
97 if (node_id_ptr ==
nullptr || config ==
nullptr) {
103 if (!str.has_value()) {
107 if (!file_name.has_value()) {
108 IOX2_PANIC(
"The executable file name should always be valid.");
114 iox2_unique_node_id_h node_id_handle =
nullptr;
115 iox2_unique_node_id_clone_from_ptr(
nullptr, node_id_ptr, &node_id_handle);
118 auto node_state_object = [&]() ->
auto {
119 switch (node_state) {
120 case iox2_node_state_e_ALIVE:
122 case iox2_node_state_e_DEAD:
124 case iox2_node_state_e_UNDEFINED:
125 return NodeState<T> { iox2_node_state_e_UNDEFINED, node_id };
126 case iox2_node_state_e_INACCESSIBLE:
127 return NodeState<T> { iox2_node_state_e_INACCESSIBLE, node_id };
134 return iox2::bb::into<iox2_callback_progression_e>(callback->value()(node_state_object));
#define IOX2_UNREACHABLE()
panic if control flow reaches this code at runtime
#define IOX2_PANIC(message)
calls panic handler and does not return
Contains all details of a [Node] that is alive.
Contains all details of a [Node] that is dead.
Contains details of a [Node].
Non-owning view of a [NodeName].
auto to_owned() const -> NodeName
Creates a copy of the corresponding [NodeName] and returns it.
Describes the state of a [Node].
The system-wide unique id of a [Node].
static constexpr auto capacity() noexcept -> uint64_t
Returns the capacity of the string.
static auto create(const char(&value)[N]) noexcept -> bb::Expected< FileName, SemanticStringError >
Creates a new SemanticString from the provided string literal. If the value contains invalid characte...
CallbackContext(const T &ptr)
auto value() const -> const T &
iox2::bb::variation::Optional< T > Optional
auto override_callback(size_t value, iox2_callback_context ctx) -> size_t
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
auto list_ports_callback(void *context, const T port_details_view) -> iox2_callback_progression_e
auto ctx(const T &ptr) -> CallbackContext< T >
auto ctx_cast(void *ptr) -> CallbackContext< T > *