2 * Copyright (c) 2024 EfficiOS, Inc.
4 * SPDX-License-Identifier: MIT
7 #ifndef BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_DEV_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_DEV_HPP
14 #include "cpp-common/bt2c/c-string-view.hpp"
15 #include "cpp-common/bt2c/logging.hpp"
16 #include "cpp-common/vendor/fmt/core.h"
19 #include "internal/comp-cls-bridge.hpp"
20 #include "private-query-executor.hpp"
21 #include "self-component-port.hpp"
25 template <typename UserMessageIteratorT, typename UserComponentT>
26 class UserMessageIterator;
29 * Base class of any user component.
31 * See the specific `bt2::UserSourceComponent`,
32 * `bt2::UserFilterComponent`, and `bt2::UserSinkComponent`.
34 template <typename SelfCompT, typename InitDataT, typename QueryDataT>
37 /* Give a related message iterator access to this logger */
38 template <typename, typename>
39 friend class UserMessageIterator;
42 using InitData = InitDataT;
43 using QueryData = QueryDataT;
45 static constexpr auto description = nullptr;
46 static constexpr auto help = nullptr;
49 explicit UserComponent(const SelfCompT selfComp, const std::string& logTag) :
50 _mLogger {selfComp, fmt::format("{}/[{}]", logTag, selfComp.name())}, _mSelfComp {selfComp}
54 bt2c::CStringView _name() const noexcept
56 return _mSelfComp.name();
59 LoggingLevel _loggingLevel() const noexcept
61 return _mSelfComp.loggingLevel();
64 std::uint64_t _graphMipVersion() const noexcept
66 return _mSelfComp.graphMipVersion();
69 SelfCompT _selfComp() noexcept
74 bt2c::Logger _mLogger;
81 * Base class of a user source component `UserComponentT` (CRTP).
83 * `UserComponentT` must define a static member `name` of type
84 * `const char *` to provide the name of the component class.
86 * `UserComponentT` may define the static members `description` and/or
87 * `help` of type `const char *` to provide the description and/or help
88 * of the component class.
90 * UserComponentT::UserComponentT() must accept, in this order:
92 * 1. A `bt2::SelfSourceComponent` parameter, which it needs to forward
93 * to bt2::UserSourceComponent::UserSourceComponent().
95 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
97 * 3. An `InitDataT *` parameter (the initialization method data).
99 * `UserMessageIteratorT`, the message iterator class to use, must inherit
100 * `UserMessageIterator`.
102 * UserComponentT::_query() receives a query method data pointer of type
103 * `QueryDataT *` as its last parameter.
105 template <typename UserComponentT, typename UserMessageIteratorT, typename InitDataT = void,
106 typename QueryDataT = void>
107 class UserSourceComponent : public UserComponent<SelfSourceComponent, InitDataT, QueryDataT>
109 static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
110 UserMessageIteratorT>::value,
111 "`UserMessageIteratorT` inherits `UserMessageIterator`");
114 using MessageIterator = UserMessageIteratorT;
117 using _OutputPorts = SelfSourceComponent::OutputPorts;
119 explicit UserSourceComponent(const SelfSourceComponent selfComp, const std::string& logTag) :
120 UserComponent<SelfSourceComponent, InitDataT, QueryDataT> {selfComp, logTag}
125 static Value::Shared query(const SelfComponentClass selfCompCls,
126 const PrivateQueryExecutor privQueryExec,
127 const bt2c::CStringView obj, const ConstValue params,
128 QueryDataT * const data)
130 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
133 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
134 const ConstValue params, const LoggingLevel loggingLevel,
135 const UnsignedIntegerRangeSet ranges)
137 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
140 void outputPortConnected(const SelfComponentOutputPort outputPort,
141 const ConstInputPort inputPort)
143 static_cast<UserComponentT&>(*this)._outputPortConnected(outputPort, inputPort);
148 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
149 ConstValue, QueryDataT *)
151 throw UnknownObject {};
155 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
156 const UnsignedIntegerRangeSet ranges)
158 ranges.addRange(0, 0);
162 void _outputPortConnected(SelfComponentOutputPort, ConstInputPort)
166 template <typename DataT>
167 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
169 return this->_selfComp().addOutputPort(name, data);
172 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
174 return this->_selfComp().addOutputPort(name);
177 _OutputPorts _outputPorts() noexcept
179 return this->_selfComp().outputPorts();
184 * Base class of a user filter component `UserComponentT` (CRTP).
186 * `UserComponentT` must define a static member `name` of type
187 * `const char *` to provide the name of the component class.
189 * `UserComponentT` may define the static members `description` and/or
190 * `help` of type `const char *` to provide the description and/or help
191 * of the component class.
193 * UserComponentT::UserComponentT() must accept, in this order:
195 * 1. A `bt2::SelfFilterComponent` parameter, which it needs to forward
196 * to bt2::UserFilterComponent::UserFilterComponent().
198 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
200 * 3. An `InitDataT *` parameter (the initialization method data).
202 * `UserMessageIteratorT`, the message iterator class to use, must inherit
203 * `UserMessageIterator`.
205 * UserComponentT::_query() receives a query method data pointer of type
206 * `QueryDataT *` as its last parameter.
208 template <typename UserComponentT, typename UserMessageIteratorT, typename InitDataT = void,
209 typename QueryDataT = void>
210 class UserFilterComponent : public UserComponent<SelfFilterComponent, InitDataT, QueryDataT>
212 static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
213 UserMessageIteratorT>::value,
214 "`UserMessageIteratorT` inherits `UserMessageIterator`");
217 using MessageIterator = UserMessageIteratorT;
220 using _InputPorts = SelfFilterComponent::InputPorts;
221 using _OutputPorts = SelfFilterComponent::OutputPorts;
223 explicit UserFilterComponent(const SelfFilterComponent selfComp, const std::string& logTag) :
224 UserComponent<SelfFilterComponent, InitDataT, QueryDataT> {selfComp, logTag}
229 static Value::Shared query(const SelfComponentClass selfCompCls,
230 const PrivateQueryExecutor privQueryExec,
231 const bt2c::CStringView obj, const ConstValue params,
232 QueryDataT * const data)
234 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
237 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
238 const ConstValue params, const LoggingLevel loggingLevel,
239 const UnsignedIntegerRangeSet ranges)
241 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
244 void inputPortConnected(const SelfComponentInputPort inputPort,
245 const ConstOutputPort outputPort)
247 static_cast<UserComponentT&>(*this)._inputPortConnected(inputPort, outputPort);
250 void outputPortConnected(const SelfComponentOutputPort outputPort,
251 const ConstInputPort inputPort)
253 static_cast<UserComponentT&>(*this)._outputPortConnected(outputPort, inputPort);
258 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
259 ConstValue, QueryDataT *)
261 throw UnknownObject {};
265 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
266 const UnsignedIntegerRangeSet ranges)
268 ranges.addRange(0, 0);
272 void _inputPortConnected(SelfComponentInputPort, ConstOutputPort)
277 void _outputPortConnected(SelfComponentOutputPort, ConstInputPort)
281 template <typename DataT>
282 _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
284 return this->_selfComp().addInputPort(name, data);
287 _InputPorts::Port _addInputPort(const bt2c::CStringView name)
289 return this->_selfComp().addInputPort(name);
292 _InputPorts _inputPorts() noexcept
294 return this->_selfComp().inputPorts();
297 template <typename DataT>
298 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
300 return this->_selfComp().addOutputPort(name, data);
303 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
305 return this->_selfComp().addOutputPort(name);
308 _OutputPorts _outputPorts() noexcept
310 return this->_selfComp().outputPorts();
315 * Base class of a user sink component `UserComponentT` (CRTP).
317 * `UserComponentT` must define a static member `name` of type
318 * `const char *` to provide the name of the component class.
320 * `UserComponentT` may define the static members `description` and/or
321 * `help` of type `const char *` to provide the description and/or help
322 * of the component class.
324 * UserComponentT::UserComponentT() must accept, in this order:
326 * 1. A `bt2::SelfSinkComponent` parameter, which it needs to forward
327 * to bt2::UserSinkComponent::UserSinkComponent().
329 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
331 * 3. An `InitDataT *` parameter (the initialization method data).
333 * `UserComponentT` must implement:
337 * This method returns `true` if the sink component still needs to
338 * consume, or `false` if it's finished.
340 * UserComponentT::_query() receives a query method data pointer of type
341 * `QueryDataT *` as its last parameter.
344 template <typename UserComponentT, typename InitDataT = void, typename QueryDataT = void>
345 class UserSinkComponent : public UserComponent<SelfSinkComponent, InitDataT, QueryDataT>
348 using _InputPorts = SelfSinkComponent::InputPorts;
350 explicit UserSinkComponent(const SelfSinkComponent selfComp, const std::string& logTag) :
351 UserComponent<SelfSinkComponent, InitDataT, QueryDataT> {selfComp, logTag}
356 static Value::Shared query(const SelfComponentClass selfCompCls,
357 const PrivateQueryExecutor privQueryExec,
358 const bt2c::CStringView obj, const ConstValue params,
359 QueryDataT * const data)
361 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
364 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
365 const ConstValue params, const LoggingLevel loggingLevel,
366 const UnsignedIntegerRangeSet ranges)
368 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
371 void graphIsConfigured()
373 static_cast<UserComponentT&>(*this)._graphIsConfigured();
376 void inputPortConnected(const SelfComponentInputPort inputPort,
377 const ConstOutputPort outputPort)
379 static_cast<UserComponentT&>(*this)._inputPortConnected(inputPort, outputPort);
384 return static_cast<UserComponentT&>(*this)._consume();
389 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
390 ConstValue, QueryDataT *)
392 throw UnknownObject {};
396 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
397 const UnsignedIntegerRangeSet ranges)
399 ranges.addRange(0, 0);
403 void _graphIsConfigured()
408 void _inputPortConnected(SelfComponentInputPort, ConstOutputPort)
412 MessageIterator::Shared _createMessageIterator(const _InputPorts::Port port)
414 return this->_selfComp().createMessageIterator(port);
417 template <typename DataT>
418 _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
420 return this->_selfComp().addInputPort(name, data);
423 _InputPorts::Port _addInputPort(const bt2c::CStringView name)
425 return this->_selfComp().addInputPort(name);
428 _InputPorts _inputPorts() noexcept
430 return this->_selfComp().inputPorts();
435 * Base class of a user message iterator `UserMessageIteratorT` (CRTP)
436 * of which the parent user component class is `UserComponentT`.
438 * `UserMessageIteratorT::UserMessageIteratorT()` must accept a
439 * `bt2::SelfMessageIterator` parameter, which it needs to forward to
440 * bt2::UserMessageIterator::UserMessageIterator().
442 * The public next() method below (called by the bridge) implements the
443 * very common pattern of appending messages into the output array, and,
446 * If it catches a `bt2::TryAgain` exception:
447 * If the message array isn't empty, transform this into a success
452 * If it catches an error:
453 * If the message array isn't empty, transform this into a success
454 * (don't throw), but save the error of the current thread and the
455 * type of error to throw the next time the user calls next().
459 * `UserMessageIteratorT` must implement:
461 * void _next(bt2::ConstMessageArray& messages);
463 * This method fills `messages` with at most `messages.capacity()`
464 * messages and may throw `bt2::TryAgain` or a valid error whenever.
465 * Leaving an empty `messages` means the end of iteration.
467 template <typename UserMessageIteratorT, typename UserComponentT>
468 class UserMessageIterator
471 /* Type of `_mExcToThrowType` */
472 enum class _ExcToThrowType
480 explicit UserMessageIterator(const SelfMessageIterator selfMsgIter,
481 const std::string& logTagSuffix) :
482 _mSelfMsgIter {selfMsgIter},
483 _mLogger {selfMsgIter,
484 fmt::format("{}/{}", this->_component()._mLogger.tag(), logTagSuffix)}
489 void next(bt2::ConstMessageArray& messages)
491 /* Any saved error? Now is the time to throw */
492 if (G_UNLIKELY(_mExcToThrowType != _ExcToThrowType::NONE)) {
493 /* Move `_mSavedLibError`, if any, as current thread error */
494 if (_mSavedLibError) {
495 bt_current_thread_move_error(_mSavedLibError.release());
498 /* Throw the corresponding exception */
499 if (_mExcToThrowType == _ExcToThrowType::ERROR) {
502 BT_ASSERT(_mExcToThrowType == _ExcToThrowType::MEM_ERROR);
503 throw bt2::MemoryError {};
508 * When catching some exception below, if our message array
509 * isn't empty, then return immediately before throwing to
510 * provide those messages to downstream.
512 * When catching an error, also save the current thread error,
513 * if any, so that we can restore it later (see the beginning of
516 BT_ASSERT_DBG(_mExcToThrowType == _ExcToThrowType::NONE);
519 this->_userObj()._next(messages);
521 /* We're done: everything below is exception handling */
523 } catch (const bt2::TryAgain&) {
524 if (messages.isEmpty()) {
527 } catch (const std::bad_alloc&) {
528 if (messages.isEmpty()) {
532 _mExcToThrowType = _ExcToThrowType::MEM_ERROR;
533 } catch (const bt2::Error&) {
534 if (messages.isEmpty()) {
538 _mExcToThrowType = _ExcToThrowType::ERROR;
541 if (_mExcToThrowType != _ExcToThrowType::NONE) {
543 "An error occurred, but there are {} messages to return: delaying the error reporting.",
545 BT_ASSERT(!_mSavedLibError);
546 _mSavedLibError.reset(bt_current_thread_take_error());
550 bool canSeekBeginning()
553 return this->_userObj()._canSeekBeginning();
559 return this->_userObj()._seekBeginning();
562 bool canSeekNsFromOrigin(const std::int64_t nsFromOrigin)
565 return this->_userObj()._canSeekNsFromOrigin(nsFromOrigin);
568 void seekNsFromOrigin(const std::int64_t nsFromOrigin)
571 this->_userObj()._seekNsFromOrigin(nsFromOrigin);
576 bool _canSeekBeginning() noexcept
582 void _seekBeginning() noexcept
587 bool _canSeekNsFromOrigin(std::int64_t) noexcept
593 void _seekNsFromOrigin(std::int64_t) noexcept
597 MessageIterator::Shared _createMessageIterator(const SelfComponentInputPort port)
599 return _mSelfMsgIter.createMessageIterator(port);
602 UserComponentT& _component() noexcept
604 return _mSelfMsgIter.component().template data<UserComponentT>();
607 SelfComponentOutputPort _port() noexcept
609 return _mSelfMsgIter.port();
612 bool _isInterrupted() const noexcept
614 return _mSelfMsgIter.isInterrupted();
618 UserMessageIteratorT& _userObj() noexcept
620 return static_cast<UserMessageIteratorT&>(*this);
623 void _resetError() noexcept
625 _mExcToThrowType = _ExcToThrowType::NONE;
626 _mSavedLibError.reset();
629 SelfMessageIterator _mSelfMsgIter;
632 * next() may accumulate messages, and then catch an error before
633 * returning. In that case, it saves the error of the current thread
634 * here so that it can return its accumulated messages and throw the
637 * It also saves the type of the exception to throw the next time.
639 _ExcToThrowType _mExcToThrowType = _ExcToThrowType::NONE;
641 struct LibErrorDeleter final
643 void operator()(const bt_error * const error) const noexcept
645 bt_error_release(error);
649 std::unique_ptr<const bt_error, LibErrorDeleter> _mSavedLibError;
652 bt2c::Logger _mLogger;
657 template <typename UserComponentT, typename CompClsBridgeT, typename LibSpecCompClsPtrT,
658 typename AsCompClsFuncT, typename SetInitMethodFuncT, typename SetFinalizeMethodFuncT,
659 typename SetGetSupportedMipVersionsMethodFuncT, typename SetQueryMethodFuncT>
660 void setCompClsCommonProps(
661 LibSpecCompClsPtrT * const libSpecCompClsPtr, AsCompClsFuncT&& asCompClsFunc,
662 SetInitMethodFuncT&& setInitMethodFunc, SetFinalizeMethodFuncT&& setFinalizeMethodFunc,
663 SetGetSupportedMipVersionsMethodFuncT&& setGetSupportedMipVersionsMethodFunc,
664 SetQueryMethodFuncT&& setQueryMethodFunc)
666 const auto libCompClsPtr = asCompClsFunc(libSpecCompClsPtr);
668 if (UserComponentT::description != nullptr) {
670 bt_component_class_set_description(libCompClsPtr, UserComponentT::description);
672 if (status == BT_COMPONENT_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR) {
673 throw MemoryError {};
677 if (UserComponentT::help != nullptr) {
678 const auto status = bt_component_class_set_help(libCompClsPtr, UserComponentT::help);
680 if (status == BT_COMPONENT_CLASS_SET_HELP_STATUS_MEMORY_ERROR) {
681 throw MemoryError {};
686 const auto status = setInitMethodFunc(libSpecCompClsPtr, CompClsBridgeT::init);
688 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
692 const auto status = setFinalizeMethodFunc(libSpecCompClsPtr, CompClsBridgeT::finalize);
694 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
698 const auto status = setGetSupportedMipVersionsMethodFunc(
699 libSpecCompClsPtr, CompClsBridgeT::getSupportedMipVersions);
701 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
705 const auto status = setQueryMethodFunc(libSpecCompClsPtr, CompClsBridgeT::query);
707 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
711 template <typename MsgIterClsBridgeT>
712 bt_message_iterator_class *createLibMsgIterCls()
714 const auto libMsgIterClsPtr = bt_message_iterator_class_create(MsgIterClsBridgeT::next);
716 if (!libMsgIterClsPtr) {
717 throw MemoryError {};
721 const auto status = bt_message_iterator_class_set_initialize_method(
722 libMsgIterClsPtr, MsgIterClsBridgeT::init);
724 BT_ASSERT(status == BT_MESSAGE_ITERATOR_CLASS_SET_METHOD_STATUS_OK);
728 const auto status = bt_message_iterator_class_set_finalize_method(
729 libMsgIterClsPtr, MsgIterClsBridgeT::finalize);
731 BT_ASSERT(status == BT_MESSAGE_ITERATOR_CLASS_SET_METHOD_STATUS_OK);
734 return libMsgIterClsPtr;
737 template <typename UserComponentT>
738 bt_component_class_source *createSourceCompCls()
741 std::is_base_of<UserSourceComponent<
742 UserComponentT, typename UserComponentT::MessageIterator,
743 typename UserComponentT::InitData, typename UserComponentT::QueryData>,
744 UserComponentT>::value,
745 "`UserComponentT` inherits `UserSourceComponent`");
747 using CompClsBridge = internal::SrcCompClsBridge<UserComponentT>;
748 using MsgIterClsBridge = internal::MsgIterClsBridge<typename UserComponentT::MessageIterator>;
750 const auto libMsgIterClsPtr = createLibMsgIterCls<MsgIterClsBridge>();
751 const auto libCompClsPtr =
752 bt_component_class_source_create(UserComponentT::name, libMsgIterClsPtr);
754 bt_message_iterator_class_put_ref(libMsgIterClsPtr);
756 if (!libCompClsPtr) {
757 throw MemoryError {};
760 setCompClsCommonProps<UserComponentT, CompClsBridge>(
761 libCompClsPtr, bt_component_class_source_as_component_class,
762 bt_component_class_source_set_initialize_method,
763 bt_component_class_source_set_finalize_method,
764 bt_component_class_source_set_get_supported_mip_versions_method,
765 bt_component_class_source_set_query_method);
768 const auto status = bt_component_class_source_set_output_port_connected_method(
769 libCompClsPtr, CompClsBridge::outputPortConnected);
771 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
774 return libCompClsPtr;
777 template <typename UserComponentT>
778 bt_component_class_filter *createFilterCompCls()
781 std::is_base_of<UserFilterComponent<
782 UserComponentT, typename UserComponentT::MessageIterator,
783 typename UserComponentT::InitData, typename UserComponentT::QueryData>,
784 UserComponentT>::value,
785 "`UserComponentT` inherits `UserFilterComponent`");
787 using CompClsBridge = internal::FltCompClsBridge<UserComponentT>;
788 using MsgIterClsBridge = internal::MsgIterClsBridge<typename UserComponentT::MessageIterator>;
790 const auto libMsgIterClsPtr = createLibMsgIterCls<MsgIterClsBridge>();
791 const auto libCompClsPtr =
792 bt_component_class_filter_create(UserComponentT::name, libMsgIterClsPtr);
794 bt_message_iterator_class_put_ref(libMsgIterClsPtr);
796 if (!libCompClsPtr) {
797 throw MemoryError {};
800 setCompClsCommonProps<UserComponentT, CompClsBridge>(
801 libCompClsPtr, bt_component_class_filter_as_component_class,
802 bt_component_class_filter_set_initialize_method,
803 bt_component_class_filter_set_finalize_method,
804 bt_component_class_filter_set_get_supported_mip_versions_method,
805 bt_component_class_filter_set_query_method);
808 const auto status = bt_component_class_filter_set_input_port_connected_method(
809 libCompClsPtr, CompClsBridge::inputPortConnected);
811 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
815 const auto status = bt_component_class_filter_set_output_port_connected_method(
816 libCompClsPtr, CompClsBridge::outputPortConnected);
818 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
821 return libCompClsPtr;
824 template <typename UserComponentT>
825 bt_component_class_sink *createSinkCompCls()
828 std::is_base_of<UserSinkComponent<UserComponentT, typename UserComponentT::InitData,
829 typename UserComponentT::QueryData>,
830 UserComponentT>::value,
831 "`UserComponentT` inherits `UserSinkComponent`");
833 using CompClsBridge = internal::SinkCompClsBridge<UserComponentT>;
835 const auto libCompClsPtr =
836 bt_component_class_sink_create(UserComponentT::name, CompClsBridge::consume);
838 if (!libCompClsPtr) {
839 throw MemoryError {};
842 setCompClsCommonProps<UserComponentT, CompClsBridge>(
843 libCompClsPtr, bt_component_class_sink_as_component_class,
844 bt_component_class_sink_set_initialize_method, bt_component_class_sink_set_finalize_method,
845 bt_component_class_sink_set_get_supported_mip_versions_method,
846 bt_component_class_sink_set_query_method);
849 const auto status = bt_component_class_sink_set_graph_is_configured_method(
850 libCompClsPtr, CompClsBridge::graphIsConfigured);
852 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
856 const auto status = bt_component_class_sink_set_input_port_connected_method(
857 libCompClsPtr, CompClsBridge::inputPortConnected);
859 BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
862 return libCompClsPtr;
865 } /* namespace internal */
866 } /* namespace bt2 */
868 #endif /* BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_DEV_HPP */