From c83761b9ef60278016167607f09a06ff7b636a42 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 1 Dec 2023 14:50:32 -0500 Subject: [PATCH] cpp-common/bt2: add `bt2::SelfComponentClass` A very straightforward wrapper of `bt_self_component_class`. I didn't bother wrapping the individual `bt_self_component_class_source`, `bt_self_component_class_filter`, and `bt_self_component_class_sink` as they don't offer anything more. Signed-off-by: Philippe Proulx Change-Id: Ie96c61ba723d54ff720df9147279d7826dcf8fae Reviewed-on: https://review.lttng.org/c/babeltrace/+/11480 Reviewed-by: Simon Marchi CI-Build: Simon Marchi Tested-by: jenkins --- src/Makefile.am | 1 + src/cpp-common/bt2/self-component-class.hpp | 63 +++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/cpp-common/bt2/self-component-class.hpp diff --git a/src/Makefile.am b/src/Makefile.am index bab36f82..a3e07d0b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,6 +32,7 @@ noinst_HEADERS = \ cpp-common/bt2/shared-object.hpp \ cpp-common/bt2/raw-value-proxy.hpp \ cpp-common/bt2/private-query-executor.hpp \ + cpp-common/bt2/self-component-class.hpp \ cpp-common/bt2/self-component-port.hpp \ cpp-common/bt2/self-message-iterator-configuration.hpp \ cpp-common/bt2/self-message-iterator.hpp \ diff --git a/src/cpp-common/bt2/self-component-class.hpp b/src/cpp-common/bt2/self-component-class.hpp new file mode 100644 index 00000000..3aa28f2c --- /dev/null +++ b/src/cpp-common/bt2/self-component-class.hpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP +#define BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP + +#include + +#include "borrowed-object.hpp" + +namespace bt2 { + +class SelfComponentClass final : public BorrowedObject +{ +public: + explicit SelfComponentClass(const _LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} + { + } + + explicit SelfComponentClass(bt_self_component_class_source * const libObjPtr) noexcept : + _ThisBorrowedObject {bt_self_component_class_source_as_self_component_class(libObjPtr)} + { + } + + explicit SelfComponentClass(bt_self_component_class_filter * const libObjPtr) noexcept : + _ThisBorrowedObject {bt_self_component_class_filter_as_self_component_class(libObjPtr)} + { + } + + explicit SelfComponentClass(bt_self_component_class_sink * const libObjPtr) noexcept : + _ThisBorrowedObject {bt_self_component_class_sink_as_self_component_class(libObjPtr)} + { + } + + const char *name() const noexcept + { + return bt_component_class_get_name(this->_libCompClsPtr()); + } + + const char *description() const noexcept + { + return bt_component_class_get_description(this->_libCompClsPtr()); + } + + const char *help() const noexcept + { + return bt_component_class_get_help(this->_libCompClsPtr()); + } + +private: + const bt_component_class *_libCompClsPtr() const noexcept + { + return bt_self_component_class_as_component_class(this->libObjPtr()); + } +}; + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP */ -- 2.34.1