| 1 | /* |
| 2 | * Copyright (C) 2024 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_TEST_UTILS_BT2_PLUGIN_UTILS_HPP |
| 9 | #define LTTNG_TEST_UTILS_BT2_PLUGIN_UTILS_HPP |
| 10 | |
| 11 | #include <common/make-unique-wrapper.hpp> |
| 12 | |
| 13 | #include <babeltrace2/babeltrace.h> |
| 14 | |
| 15 | namespace lttng { |
| 16 | namespace bt2 { |
| 17 | namespace internal { |
| 18 | static inline void bt_value_put_ref(bt_value *value) |
| 19 | { |
| 20 | bt_value_put_ref(static_cast<const bt_value *>(value)); |
| 21 | } |
| 22 | } /* namespace internal */ |
| 23 | |
| 24 | using value_ref = std::unique_ptr< |
| 25 | bt_value, |
| 26 | lttng::memory::create_deleter_class<bt_value, internal::bt_value_put_ref>::deleter>; |
| 27 | |
| 28 | using event_class_const_ref = std::unique_ptr< |
| 29 | const bt_event_class, |
| 30 | lttng::memory::create_deleter_class<const bt_event_class, bt_event_class_put_ref>::deleter>; |
| 31 | |
| 32 | static inline value_ref make_value_ref(bt_value *instance) |
| 33 | { |
| 34 | const memory::create_deleter_class<bt_value, internal::bt_value_put_ref> unique_deleter; |
| 35 | return unique_deleter(instance); |
| 36 | } |
| 37 | |
| 38 | using message_const_ref = std::unique_ptr< |
| 39 | const bt_message, |
| 40 | lttng::memory::create_deleter_class<const bt_message, bt_message_put_ref>::deleter>; |
| 41 | |
| 42 | using message_iterator_ref = |
| 43 | std::unique_ptr<bt_message_iterator, |
| 44 | lttng::memory::create_deleter_class<const bt_message_iterator, |
| 45 | bt_message_iterator_put_ref>::deleter>; |
| 46 | } /* namespace bt2 */ |
| 47 | } /* namespace lttng */ |
| 48 | |
| 49 | #endif /* LTTNG_TEST_UTILS_BT2_PLUGIN_UTILS_HPP */ |