iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
degradation_handler.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 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_DEGRADATION_HANDLER_HPP
14#define IOX2_DEGRADATION_HANDLER_HPP
15
21
22namespace iox2 {
23namespace detail {
24// forward declaration in order to make it a friend in DegradationInfo
25inline auto degradation_handler_delegate(iox2_degradation_cause_e degradation_cause,
26 iox2_degradation_info_h_ref info_handle,
27 iox2_callback_context callback_cxt) -> iox2_degradation_action_e;
28} // namespace detail
29
32 private:
33 iox2_degradation_info_h_ref m_info;
34
35 explicit DegradationInfo(iox2_degradation_info_h_ref info)
36 : m_info(info) {
37 }
38
39 friend auto iox2::detail::degradation_handler_delegate(iox2_degradation_cause_e degradation_cause,
40 iox2_degradation_info_h_ref info_handle,
41 iox2_callback_context callback_cxt)
42 -> iox2_degradation_action_e;
43
44 static_assert(sizeof(iox2_buffer_16_align_4_t::data) == RawIdType::capacity(),
45 "RawIdType capacity must match iox2_buffer_16_align_4_t capacity");
46
47 public:
49 auto service_id() const -> RawIdType {
50 iox2_buffer_16_align_4_t buf;
51 iox2_degradation_info_service_id(m_info, &buf);
52 return RawIdType::from_range_unchecked(buf.data).value();
53 }
55 auto receiver_port_id() const -> RawIdType {
56 iox2_buffer_16_align_4_t buf;
57 iox2_degradation_info_receiver_port_id(m_info, &buf);
58 return RawIdType::from_range_unchecked(buf.data).value();
59 }
61 auto sender_port_id() const -> RawIdType {
62 iox2_buffer_16_align_4_t buf;
63 iox2_degradation_info_sender_port_id(m_info, &buf);
64 return RawIdType::from_range_unchecked(buf.data).value();
65 }
66};
67
76
77namespace detail {
78inline auto degradation_handler_delegate(iox2_degradation_cause_e degradation_cause,
79 iox2_degradation_info_h_ref info_handle,
80 iox2_callback_context callback_cxt) -> iox2_degradation_action_e {
81 auto* handler = static_cast<DegradationHandler*>(callback_cxt);
82
83 auto cause = bb::into<DegradationCause>(degradation_cause);
84 auto info = DegradationInfo(info_handle);
85
86 return bb::into<iox2_degradation_action_e>((*handler)(cause, info));
87}
88} // namespace detail
89
90} // namespace iox2
91
92#endif // IOX2_DEGRADATION_HANDLER_HPP
The degradation info passed to the [DegradationHandler].
auto service_id() const -> RawIdType
Returns the ServiceId of the involved ports.
auto sender_port_id() const -> RawIdType
Returns the ReceiverPortId of the involved ports.
auto receiver_port_id() const -> RawIdType
Returns the ReceiverPortId of the involved ports.
A resizable container with compile-time fixed static capacity and contiguous inplace storage.
static constexpr auto capacity() noexcept -> SizeType
Retrieves the static capacity of the vector.
static constexpr auto from_range_unchecked(Iter it_begin, Sentinel it_end) -> bb::Optional< StaticVector >
auto degradation_handler_delegate(iox2_degradation_cause_e degradation_cause, iox2_degradation_info_h_ref info_handle, iox2_callback_context callback_cxt) -> iox2_degradation_action_e
DegradationCause
Defines the cause of a degradation and is a parameter of the [DegradationHandler].