cpp-common/bt2: add `bt2::SelfComponentClass`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 1 Dec 2023 19:50:32 +0000 (14:50 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 14 Dec 2023 15:57:04 +0000 (10:57 -0500)
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 <eeppeliteloop@gmail.com>
Change-Id: Ie96c61ba723d54ff720df9147279d7826dcf8fae
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11480
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/Makefile.am
src/cpp-common/bt2/self-component-class.hpp [new file with mode: 0644]

index bab36f829f8576a4c1a2019c6979464a258ea1ec..a3e07d0bbd9b90b67d253ea620a7f042d3dd3c2f 100644 (file)
@@ -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 (file)
index 0000000..3aa28f2
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2023 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP
+#define BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP
+
+#include <babeltrace2/babeltrace.h>
+
+#include "borrowed-object.hpp"
+
+namespace bt2 {
+
+class SelfComponentClass final : public BorrowedObject<bt_self_component_class>
+{
+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 */
This page took 0.025099 seconds and 4 git commands to generate.