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}
55 bt2c::CStringView _name() const noexcept
57 return _mSelfComp.name();
60 LoggingLevel _loggingLevel() const noexcept
62 return _mSelfComp.loggingLevel();
65 std::uint64_t _graphMipVersion() const noexcept
67 return _mSelfComp.graphMipVersion();
70 SelfCompT _selfComp() noexcept
75 bt2c::Logger _mLogger;
82 * Base class of a user source component `UserComponentT` (CRTP).
84 * `UserComponentT` must define a static member `name` of type
85 * `const char *` to provide the name of the component class.
87 * `UserComponentT` may define the static members `description` and/or
88 * `help` of type `const char *` to provide the description and/or help
89 * of the component class.
91 * UserComponentT::UserComponentT() must accept, in this order:
93 * 1. A `bt2::SelfSourceComponent` parameter, which it needs to forward
94 * to bt2::UserSourceComponent::UserSourceComponent().
96 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
98 * 3. An `InitDataT *` parameter (the initialization method data).
100 * `UserMessageIteratorT`, the message iterator class to use, must inherit
101 * `UserMessageIterator`.
103 * UserComponentT::_query() receives a query method data pointer of type
104 * `QueryDataT *` as its last parameter.
106 template <typename UserComponentT, typename UserMessageIteratorT, typename InitDataT = void,
107 typename QueryDataT = void>
108 class UserSourceComponent : public UserComponent<SelfSourceComponent, InitDataT, QueryDataT>
110 static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
111 UserMessageIteratorT>::value,
112 "`UserMessageIteratorT` inherits `UserMessageIterator`");
115 using MessageIterator = UserMessageIteratorT;
118 using _OutputPorts = SelfSourceComponent::OutputPorts;
120 explicit UserSourceComponent(const SelfSourceComponent selfComp, const std::string& logTag) :
121 UserComponent<SelfSourceComponent, InitDataT, QueryDataT> {selfComp, logTag}
126 static Value::Shared query(const SelfComponentClass selfCompCls,
127 const PrivateQueryExecutor privQueryExec,
128 const bt2c::CStringView obj, const ConstValue params,
129 QueryDataT * const data)
131 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
134 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
135 const ConstValue params, const LoggingLevel loggingLevel,
136 const UnsignedIntegerRangeSet ranges)
138 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
141 void outputPortConnected(const SelfComponentOutputPort outputPort,
142 const ConstInputPort inputPort)
144 static_cast<UserComponentT&>(*this)._outputPortConnected(outputPort, inputPort);
149 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
150 ConstValue, QueryDataT *)
152 throw UnknownObject {};
156 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
157 const UnsignedIntegerRangeSet ranges)
159 ranges.addRange(0, 0);
163 void _outputPortConnected(SelfComponentOutputPort, ConstInputPort)
167 template <typename DataT>
168 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
170 return this->_selfComp().addOutputPort(name, data);
173 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
175 return this->_selfComp().addOutputPort(name);
178 _OutputPorts _outputPorts() noexcept
180 return this->_selfComp().outputPorts();
185 * Base class of a user filter component `UserComponentT` (CRTP).
187 * `UserComponentT` must define a static member `name` of type
188 * `const char *` to provide the name of the component class.
190 * `UserComponentT` may define the static members `description` and/or
191 * `help` of type `const char *` to provide the description and/or help
192 * of the component class.
194 * UserComponentT::UserComponentT() must accept, in this order:
196 * 1. A `bt2::SelfFilterComponent` parameter, which it needs to forward
197 * to bt2::UserFilterComponent::UserFilterComponent().
199 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
201 * 3. An `InitDataT *` parameter (the initialization method data).
203 * `UserMessageIteratorT`, the message iterator class to use, must inherit
204 * `UserMessageIterator`.
206 * UserComponentT::_query() receives a query method data pointer of type
207 * `QueryDataT *` as its last parameter.
209 template <typename UserComponentT, typename UserMessageIteratorT, typename InitDataT = void,
210 typename QueryDataT = void>
211 class UserFilterComponent : public UserComponent<SelfFilterComponent, InitDataT, QueryDataT>
213 static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
214 UserMessageIteratorT>::value,
215 "`UserMessageIteratorT` inherits `UserMessageIterator`");
218 using MessageIterator = UserMessageIteratorT;
221 using _InputPorts = SelfFilterComponent::InputPorts;
222 using _OutputPorts = SelfFilterComponent::OutputPorts;
224 explicit UserFilterComponent(const SelfFilterComponent selfComp, const std::string& logTag) :
225 UserComponent<SelfFilterComponent, InitDataT, QueryDataT> {selfComp, logTag}
230 static Value::Shared query(const SelfComponentClass selfCompCls,
231 const PrivateQueryExecutor privQueryExec,
232 const bt2c::CStringView obj, const ConstValue params,
233 QueryDataT * const data)
235 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
238 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
239 const ConstValue params, const LoggingLevel loggingLevel,
240 const UnsignedIntegerRangeSet ranges)
242 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
245 void inputPortConnected(const SelfComponentInputPort inputPort,
246 const ConstOutputPort outputPort)
248 static_cast<UserComponentT&>(*this)._inputPortConnected(inputPort, outputPort);
251 void outputPortConnected(const SelfComponentOutputPort outputPort,
252 const ConstInputPort inputPort)
254 static_cast<UserComponentT&>(*this)._outputPortConnected(outputPort, inputPort);
259 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
260 ConstValue, QueryDataT *)
262 throw UnknownObject {};
266 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
267 const UnsignedIntegerRangeSet ranges)
269 ranges.addRange(0, 0);
273 void _inputPortConnected(SelfComponentInputPort, ConstOutputPort)
278 void _outputPortConnected(SelfComponentOutputPort, ConstInputPort)
282 template <typename DataT>
283 _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
285 return this->_selfComp().addInputPort(name, data);
288 _InputPorts::Port _addInputPort(const bt2c::CStringView name)
290 return this->_selfComp().addInputPort(name);
293 _InputPorts _inputPorts() noexcept
295 return this->_selfComp().inputPorts();
298 template <typename DataT>
299 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
301 return this->_selfComp().addOutputPort(name, data);
304 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
306 return this->_selfComp().addOutputPort(name);
309 _OutputPorts _outputPorts() noexcept
311 return this->_selfComp().outputPorts();
316 * Base class of a user sink component `UserComponentT` (CRTP).
318 * `UserComponentT` must define a static member `name` of type
319 * `const char *` to provide the name of the component class.
321 * `UserComponentT` may define the static members `description` and/or
322 * `help` of type `const char *` to provide the description and/or help
323 * of the component class.
325 * UserComponentT::UserComponentT() must accept, in this order:
327 * 1. A `bt2::SelfSinkComponent` parameter, which it needs to forward
328 * to bt2::UserSinkComponent::UserSinkComponent().
330 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
332 * 3. An `InitDataT *` parameter (the initialization method data).
334 * `UserComponentT` must implement:
338 * This method returns `true` if the sink component still needs to
339 * consume, or `false` if it's finished.
341 * UserComponentT::_query() receives a query method data pointer of type
342 * `QueryDataT *` as its last parameter.
345 template <typename UserComponentT, typename InitDataT = void, typename QueryDataT = void>
346 class UserSinkComponent : public UserComponent<SelfSinkComponent, InitDataT, QueryDataT>
349 using _InputPorts = SelfSinkComponent::InputPorts;
351 explicit UserSinkComponent(const SelfSinkComponent selfComp, const std::string& logTag) :
352 UserComponent<SelfSinkComponent, InitDataT, QueryDataT> {selfComp, logTag}
357 static Value::Shared query(const SelfComponentClass selfCompCls,
358 const PrivateQueryExecutor privQueryExec,
359 const bt2c::CStringView obj, const ConstValue params,
360 QueryDataT * const data)
362 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
365 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
366 const ConstValue params, const LoggingLevel loggingLevel,
367 const UnsignedIntegerRangeSet ranges)
369 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
372 void graphIsConfigured()
374 static_cast<UserComponentT&>(*this)._graphIsConfigured();
377 void inputPortConnected(const SelfComponentInputPort inputPort,
378 const ConstOutputPort outputPort)
380 static_cast<UserComponentT&>(*this)._inputPortConnected(inputPort, outputPort);
385 return static_cast<UserComponentT&>(*this)._consume();
390 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
391 ConstValue, QueryDataT *)
393 throw UnknownObject {};
397 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
398 const UnsignedIntegerRangeSet ranges)
400 ranges.addRange(0, 0);
404 void _graphIsConfigured()
409 void _inputPortConnected(SelfComponentInputPort, ConstOutputPort)
413 MessageIterator::Shared _createMessageIterator(const _InputPorts::Port port)
415 return this->_selfComp().createMessageIterator(port);
418 template <typename DataT>
419 _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
421 return this->_selfComp().addInputPort(name, data);
424 _InputPorts::Port _addInputPort(const bt2c::CStringView name)
426 return this->_selfComp().addInputPort(name);
429 _InputPorts _inputPorts() noexcept
431 return this->_selfComp().inputPorts();
436 * Base class of a user message iterator `UserMessageIteratorT` (CRTP)
437 * of which the parent user component class is `UserComponentT`.
439 * `UserMessageIteratorT::UserMessageIteratorT()` must accept a
440 * `bt2::SelfMessageIterator` parameter, which it needs to forward to
441 * bt2::UserMessageIterator::UserMessageIterator().
443 * The public next() method below (called by the bridge) implements the
444 * very common pattern of appending messages into the output array, and,
447 * If it catches a `bt2::TryAgain` exception:
448 * If the message array isn't empty, transform this into a success
453 * If it catches an error:
454 * If the message array isn't empty, transform this into a success
455 * (don't throw), but save the error of the current thread and the
456 * type of error to throw the next time the user calls next().
460 * `UserMessageIteratorT` must implement:
462 * void _next(bt2::ConstMessageArray& messages);
464 * This method fills `messages` with at most `messages.capacity()`
465 * messages and may throw `bt2::TryAgain` or a valid error whenever.
466 * Leaving an empty `messages` means the end of iteration.
468 template <typename UserMessageIteratorT, typename UserComponentT>
469 class UserMessageIterator
472 /* Type of `_mExcToThrowType` */
473 enum class _ExcToThrowType
481 explicit UserMessageIterator(const SelfMessageIterator selfMsgIter,
482 const std::string& logTagSuffix) :
483 _mSelfMsgIter {selfMsgIter},
484 _mLogger {selfMsgIter,
485 fmt::format("{}/{}", this->_component()._mLogger.tag(), logTagSuffix)}
490 ~UserMessageIterator()
495 void next(bt2::ConstMessageArray& messages)
497 /* Any saved error? Now is the time to throw */
498 if (G_UNLIKELY(_mExcToThrowType != _ExcToThrowType::NONE)) {
499 /* Move `_mSavedLibError`, if any, as current thread error */
500 if (_mSavedLibError) {
501 BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(_mSavedLibError);
504 /* Throw the corresponding exception */
505 if (_mExcToThrowType == _ExcToThrowType::ERROR) {
508 BT_ASSERT(_mExcToThrowType == _ExcToThrowType::MEM_ERROR);
509 throw bt2::MemoryError {};
514 * When catching some exception below, if our message array
515 * isn't empty, then return immediately before throwing to
516 * provide those messages to downstream.
518 * When catching an error, also save the current thread error,
519 * if any, so that we can restore it later (see the beginning of
522 BT_ASSERT_DBG(_mExcToThrowType == _ExcToThrowType::NONE);
525 this->_userObj()._next(messages);
527 /* We're done: everything below is exception handling */
529 } catch (const bt2::TryAgain&) {
530 if (messages.isEmpty()) {
533 } catch (const std::bad_alloc&) {
534 if (messages.isEmpty()) {
538 _mExcToThrowType = _ExcToThrowType::MEM_ERROR;
539 } catch (const bt2::Error&) {
540 if (messages.isEmpty()) {
544 _mExcToThrowType = _ExcToThrowType::ERROR;
547 if (_mExcToThrowType != _ExcToThrowType::NONE) {
549 "An error occurred, but there are {} messages to return: delaying the error reporting.",
551 BT_ASSERT(!_mSavedLibError);
552 _mSavedLibError = bt_current_thread_take_error();
556 bool canSeekBeginning()
559 return this->_userObj()._canSeekBeginning();
565 return this->_userObj()._seekBeginning();
568 bool canSeekNsFromOrigin(const std::int64_t nsFromOrigin)
571 return this->_userObj()._canSeekNsFromOrigin(nsFromOrigin);
574 void seekNsFromOrigin(const std::int64_t nsFromOrigin)
577 this->_userObj()._seekNsFromOrigin(nsFromOrigin);
582 bool _canSeekBeginning() noexcept
588 void _seekBeginning() noexcept
593 bool _canSeekNsFromOrigin(std::int64_t) noexcept
599 void _seekNsFromOrigin(std::int64_t) noexcept
603 MessageIterator::Shared _createMessageIterator(const SelfComponentInputPort port)
605 return _mSelfMsgIter.createMessageIterator(port);
608 UserComponentT& _component() noexcept
610 return _mSelfMsgIter.component().template data<UserComponentT>();
613 SelfComponentOutputPort _port() noexcept
615 return _mSelfMsgIter.port();
618 bool _isInterrupted() const noexcept
620 return _mSelfMsgIter.isInterrupted();
624 UserMessageIteratorT& _userObj() noexcept
626 return static_cast<UserMessageIteratorT&>(*this);
629 void _resetError() noexcept
631 _mExcToThrowType = _ExcToThrowType::NONE;
633 if (_mSavedLibError) {
634 bt_error_release(_mSavedLibError);
638 SelfMessageIterator _mSelfMsgIter;
641 * next() may accumulate messages, and then catch an error before
642 * returning. In that case, it saves the error of the current thread
643 * here so that it can return its accumulated messages and throw the
646 * It also saves the type of the exception to throw the next time.
648 _ExcToThrowType _mExcToThrowType = _ExcToThrowType::NONE;
649 const bt_error *_mSavedLibError = nullptr;
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 */