Commit | Line | Data |
---|---|---|
c83761b9 PP |
1 | /* |
2 | * Copyright (c) 2023 Philippe Proulx <pproulx@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: MIT | |
5 | */ | |
6 | ||
7 | #ifndef BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP | |
8 | #define BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP | |
9 | ||
10 | #include <babeltrace2/babeltrace.h> | |
11 | ||
e7f0f07b SM |
12 | #include "cpp-common/bt2c/c-string-view.hpp" |
13 | ||
c83761b9 PP |
14 | #include "borrowed-object.hpp" |
15 | ||
16 | namespace bt2 { | |
17 | ||
18 | class SelfComponentClass final : public BorrowedObject<bt_self_component_class> | |
19 | { | |
20 | public: | |
d246c457 | 21 | explicit SelfComponentClass(const LibObjPtr libObjPtr) noexcept : |
c83761b9 PP |
22 | _ThisBorrowedObject {libObjPtr} |
23 | { | |
24 | } | |
25 | ||
26 | explicit SelfComponentClass(bt_self_component_class_source * const libObjPtr) noexcept : | |
27 | _ThisBorrowedObject {bt_self_component_class_source_as_self_component_class(libObjPtr)} | |
28 | { | |
29 | } | |
30 | ||
31 | explicit SelfComponentClass(bt_self_component_class_filter * const libObjPtr) noexcept : | |
32 | _ThisBorrowedObject {bt_self_component_class_filter_as_self_component_class(libObjPtr)} | |
33 | { | |
34 | } | |
35 | ||
36 | explicit SelfComponentClass(bt_self_component_class_sink * const libObjPtr) noexcept : | |
37 | _ThisBorrowedObject {bt_self_component_class_sink_as_self_component_class(libObjPtr)} | |
38 | { | |
39 | } | |
40 | ||
e7f0f07b | 41 | bt2c::CStringView name() const noexcept |
c83761b9 PP |
42 | { |
43 | return bt_component_class_get_name(this->_libCompClsPtr()); | |
44 | } | |
45 | ||
e7f0f07b | 46 | bt2c::CStringView description() const noexcept |
c83761b9 PP |
47 | { |
48 | return bt_component_class_get_description(this->_libCompClsPtr()); | |
49 | } | |
50 | ||
e7f0f07b | 51 | bt2c::CStringView help() const noexcept |
c83761b9 PP |
52 | { |
53 | return bt_component_class_get_help(this->_libCompClsPtr()); | |
54 | } | |
55 | ||
56 | private: | |
57 | const bt_component_class *_libCompClsPtr() const noexcept | |
58 | { | |
59 | return bt_self_component_class_as_component_class(this->libObjPtr()); | |
60 | } | |
61 | }; | |
62 | ||
63 | } /* namespace bt2 */ | |
64 | ||
65 | #endif /* BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_CLASS_HPP */ |