916ff1aeaa6bdfa269ba96c1ed0732c08e58a4c2
[babeltrace.git] / src / cpp-common / bt2 / plugin-dev.hpp
1 /*
2 * Copyright (c) 2023 Simon Marchi <simon.marchi@efficios.com>
3 * Copyright (c) 2023 Philippe Proulx <pproulx@efficios.com>
4 *
5 * SPDX-License-Identifier: MIT
6 */
7
8 #ifndef BABELTRACE_CPP_COMMON_BT2_PLUGIN_DEV_HPP
9 #define BABELTRACE_CPP_COMMON_BT2_PLUGIN_DEV_HPP
10
11 #include <cstdint>
12
13 #include <glib.h>
14
15 #include <babeltrace2/babeltrace.h>
16
17 #include "cpp-common/bt2c/c-string-view.hpp"
18 #include "cpp-common/bt2c/logging.hpp"
19 #include "cpp-common/vendor/fmt/core.h"
20
21 #include "exc.hpp"
22 #include "wrap.hpp"
23
24 namespace bt2 {
25 namespace internal {
26
27 constexpr bt2c::CStringView unhandledExcLogStr() noexcept
28 {
29 return "Unhandled exception.";
30 }
31
32 constexpr bt2c::CStringView unhandledExcLogTag() noexcept
33 {
34 return "PLUGIN-DEV-HPP";
35 }
36
37 /*
38 * Base class of any component class bridge.
39 *
40 * `UserCompClsT` is the actual C++ user component class and `LibTypesT`
41 * is a structure offering the following specific library types:
42 *
43 * `SelfCompCls`:
44 * Self component class.
45 *
46 * `SelfComp`:
47 * Self component.
48 *
49 * `SelfCompCfg`:
50 * Self component configuration.
51 */
52 template <typename UserCompClsT, typename LibTypesT>
53 class CompClsBridge
54 {
55 private:
56 using _LibSelfCompPtr = typename LibTypesT::SelfComp *;
57
58 public:
59 static UserCompClsT& userCompFromLibSelfCompPtr(const _LibSelfCompPtr libSelfCompPtr) noexcept
60 {
61 return wrap(libSelfCompPtr).template data<UserCompClsT>();
62 }
63
64 static bt_component_class_initialize_method_status init(const _LibSelfCompPtr libSelfCompPtr,
65 typename LibTypesT::SelfCompCfg *,
66 const bt_value * const libParamsPtr,
67 void * const initData) noexcept
68 {
69 const auto selfComp = wrap(libSelfCompPtr);
70
71 try {
72 const auto comp =
73 new UserCompClsT {selfComp, wrap(libParamsPtr).asMap(),
74 static_cast<typename UserCompClsT::InitData *>(initData)};
75
76 selfComp.data(*comp);
77 } catch (const std::bad_alloc&) {
78 return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
79 } catch (const Error&) {
80 return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
81 } catch (...) {
82 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, static_cast<int>(selfComp.loggingLevel()),
83 unhandledExcLogTag(), unhandledExcLogStr());
84 return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
85 }
86
87 return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
88 }
89
90 static void finalize(const _LibSelfCompPtr libSelfCompPtr) noexcept
91 {
92 delete &userCompFromLibSelfCompPtr(libSelfCompPtr);
93 }
94
95 static bt_component_class_get_supported_mip_versions_method_status
96 getSupportedMipVersions(typename LibTypesT::SelfCompCls * const libSelfCompClsPtr,
97 const bt_value * const libParamsPtr, void *,
98 const bt_logging_level logLevel,
99 bt_integer_range_set_unsigned * const libSupportedVersionsPtr) noexcept
100 {
101 try {
102 UserCompClsT::getSupportedMipVersions(wrap(libSelfCompClsPtr), wrap(libParamsPtr),
103 static_cast<LoggingLevel>(logLevel),
104 wrap(libSupportedVersionsPtr));
105 return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_OK;
106 } catch (const std::bad_alloc&) {
107 return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_MEMORY_ERROR;
108 } catch (const Error&) {
109 return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_ERROR;
110 } catch (...) {
111 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, static_cast<int>(logLevel), unhandledExcLogTag(),
112 unhandledExcLogStr());
113 return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_ERROR;
114 }
115 }
116
117 static bt_component_class_query_method_status
118 query(typename LibTypesT::SelfCompCls * const libSelfCompClsPtr,
119 bt_private_query_executor * const libPrivQueryExecPtr, const char * const object,
120 const bt_value * const libParamsPtr, void * const data,
121 const bt_value ** const libResultPtr) noexcept
122 {
123 const auto privQueryExec = wrap(libPrivQueryExecPtr);
124
125 try {
126 auto result = UserCompClsT::query(
127 wrap(libSelfCompClsPtr), privQueryExec, object, wrap(libParamsPtr),
128 static_cast<typename UserCompClsT::QueryData *>(data));
129
130 *libResultPtr = result.release().libObjPtr();
131 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK;
132 } catch (const TryAgain&) {
133 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_AGAIN;
134 } catch (const UnknownObject&) {
135 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_UNKNOWN_OBJECT;
136 } catch (const std::bad_alloc&) {
137 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR;
138 } catch (const Error&) {
139 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
140 } catch (...) {
141 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, static_cast<int>(privQueryExec.loggingLevel()),
142 unhandledExcLogTag(), unhandledExcLogStr());
143 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
144 }
145 }
146 };
147
148 template <typename SpecCompClsBridgeT, typename LibTypesT>
149 struct CompClsBridgeWithInputPorts
150 {
151 static bt_component_class_port_connected_method_status
152 inputPortConnected(typename LibTypesT::SelfComp * const libSelfCompPtr,
153 bt_self_component_port_input * const libSelfCompPortPtr,
154 const bt_port_output * const libOtherPortPtr) noexcept
155 {
156 try {
157 SpecCompClsBridgeT::userCompFromLibSelfCompPtr(libSelfCompPtr)
158 .inputPortConnected(wrap(libSelfCompPortPtr), wrap(libOtherPortPtr));
159 } catch (const std::bad_alloc&) {
160 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_MEMORY_ERROR;
161 } catch (const Error&) {
162 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_ERROR;
163 } catch (...) {
164 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING,
165 static_cast<int>(wrap(libSelfCompPtr).loggingLevel()),
166 unhandledExcLogTag(), unhandledExcLogStr());
167 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_ERROR;
168 }
169
170 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_OK;
171 }
172 };
173
174 template <typename SpecCompClsBridgeT, typename LibTypesT>
175 struct CompClsBridgeWithOutputPorts
176 {
177 static bt_component_class_port_connected_method_status
178 outputPortConnected(typename LibTypesT::SelfComp * const libSelfCompPtr,
179 bt_self_component_port_output * const libSelfCompPortPtr,
180 const bt_port_input * const libOtherPortPtr) noexcept
181 {
182 try {
183 SpecCompClsBridgeT::userCompFromLibSelfCompPtr(libSelfCompPtr)
184 .outputPortConnected(wrap(libSelfCompPortPtr), wrap(libOtherPortPtr));
185 } catch (const std::bad_alloc&) {
186 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_MEMORY_ERROR;
187 } catch (const Error&) {
188 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_ERROR;
189 } catch (...) {
190 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING,
191 static_cast<int>(wrap(libSelfCompPtr).loggingLevel()),
192 unhandledExcLogTag(), unhandledExcLogStr());
193 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_ERROR;
194 }
195
196 return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_OK;
197 }
198 };
199
200 struct SrcCompClsLibTypes final
201 {
202 using SelfCompCls = bt_self_component_class_source;
203 using SelfComp = bt_self_component_source;
204 using SelfCompCfg = bt_self_component_source_configuration;
205 };
206
207 template <typename UserCompClsT>
208 class SrcCompClsBridge final :
209 public CompClsBridge<UserCompClsT, SrcCompClsLibTypes>,
210 public CompClsBridgeWithOutputPorts<SrcCompClsBridge<UserCompClsT>, SrcCompClsLibTypes>
211 {
212 };
213
214 struct FltCompClsLibTypes final
215 {
216 using SelfCompCls = bt_self_component_class_filter;
217 using SelfComp = bt_self_component_filter;
218 using SelfCompCfg = bt_self_component_filter_configuration;
219 };
220
221 template <typename UserCompClsT>
222 class FltCompClsBridge final :
223 public CompClsBridge<UserCompClsT, FltCompClsLibTypes>,
224 public CompClsBridgeWithInputPorts<FltCompClsBridge<UserCompClsT>, FltCompClsLibTypes>,
225 public CompClsBridgeWithOutputPorts<FltCompClsBridge<UserCompClsT>, FltCompClsLibTypes>
226 {
227 };
228
229 struct SinkCompClsLibTypes final
230 {
231 using SelfCompCls = bt_self_component_class_sink;
232 using SelfComp = bt_self_component_sink;
233 using SelfCompCfg = bt_self_component_sink_configuration;
234 };
235
236 template <typename UserCompClsT>
237 class SinkCompClsBridge final :
238 public CompClsBridge<UserCompClsT, SinkCompClsLibTypes>,
239 public CompClsBridgeWithInputPorts<SinkCompClsBridge<UserCompClsT>, SinkCompClsLibTypes>
240 {
241 private:
242 using CompClsBridge<UserCompClsT, SinkCompClsLibTypes>::userCompFromLibSelfCompPtr;
243
244 public:
245 static bt_component_class_sink_consume_method_status
246 consume(bt_self_component_sink * const libSelfCompPtr) noexcept
247 {
248 try {
249 if (userCompFromLibSelfCompPtr(libSelfCompPtr).consume()) {
250 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
251 } else {
252 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
253 }
254 } catch (const TryAgain&) {
255 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN;
256 } catch (const std::bad_alloc&) {
257 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR;
258 } catch (const Error&) {
259 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
260 } catch (...) {
261 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING,
262 static_cast<int>(wrap(libSelfCompPtr).loggingLevel()),
263 unhandledExcLogTag(), unhandledExcLogStr());
264 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
265 }
266 }
267
268 static bt_component_class_sink_graph_is_configured_method_status
269 graphIsConfigured(bt_self_component_sink * const libSelfCompPtr) noexcept
270 {
271 try {
272 userCompFromLibSelfCompPtr(libSelfCompPtr).graphIsConfigured();
273 return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
274 } catch (const std::bad_alloc&) {
275 return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR;
276 } catch (const Error&) {
277 return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_ERROR;
278 } catch (...) {
279 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING,
280 static_cast<int>(wrap(libSelfCompPtr).loggingLevel()),
281 unhandledExcLogTag(), unhandledExcLogStr());
282 return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_ERROR;
283 }
284 }
285 };
286
287 template <typename UserMsgIterT>
288 class MsgIterClsBridge final
289 {
290 public:
291 static UserMsgIterT&
292 userMsgIterFromLibSelfMsgIterPtr(bt_self_message_iterator * const libSelfMsgIterPtr) noexcept
293 {
294 return bt2::wrap(libSelfMsgIterPtr).data<UserMsgIterT>();
295 }
296
297 static bt_message_iterator_class_initialize_method_status
298 init(bt_self_message_iterator * const libSelfMsgIterPtr,
299 bt_self_message_iterator_configuration * const libSelfMsgIterConfigPtr,
300 bt_self_component_port_output * const libSelfCompPortPtr) noexcept
301 {
302 const auto selfMsgIter = bt2::wrap(libSelfMsgIterPtr);
303
304 try {
305 const auto msgIter = new UserMsgIterT {selfMsgIter, bt2::wrap(libSelfMsgIterConfigPtr),
306 bt2::wrap(libSelfCompPortPtr)};
307
308 selfMsgIter.data(*msgIter);
309 } catch (const std::bad_alloc&) {
310 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
311 } catch (const bt2::Error&) {
312 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
313 } catch (...) {
314 BT_LOG_WRITE_CUR_LVL(
315 BT_LOG_WARNING,
316 static_cast<int>(wrap(libSelfMsgIterPtr).component().loggingLevel()),
317 unhandledExcLogTag(), unhandledExcLogStr());
318 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
319 }
320
321 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
322 }
323
324 static void finalize(bt_self_message_iterator * const libSelfMsgIterPtr) noexcept
325 {
326 delete &userMsgIterFromLibSelfMsgIterPtr(libSelfMsgIterPtr);
327 }
328
329 static bt_message_iterator_class_next_method_status
330 next(bt_self_message_iterator * const libSelfMsgIterPtr, bt_message_array_const libMsgsPtr,
331 const uint64_t capacity, uint64_t * const count) noexcept
332 {
333 try {
334 auto msgArray = bt2::ConstMessageArray::wrapEmpty(libMsgsPtr, capacity);
335 auto& msgIter = userMsgIterFromLibSelfMsgIterPtr(libSelfMsgIterPtr);
336
337 msgIter.next(msgArray);
338 *count = msgArray.release();
339
340 if (G_LIKELY(*count > 0)) {
341 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
342 } else {
343 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
344 }
345 } catch (const bt2::TryAgain&) {
346 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
347 } catch (const std::bad_alloc&) {
348 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
349 } catch (const bt2::Error&) {
350 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
351 } catch (...) {
352 BT_LOG_WRITE_CUR_LVL(
353 BT_LOG_WARNING,
354 static_cast<int>(wrap(libSelfMsgIterPtr).component().loggingLevel()),
355 unhandledExcLogTag(), unhandledExcLogStr());
356 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
357 }
358 }
359
360 static bt_message_iterator_class_can_seek_beginning_method_status
361 canSeekBeginning(bt_self_message_iterator * const libSelfMsgIterPtr,
362 bt_bool * const canSeek) noexcept
363 {
364 try {
365 *canSeek = static_cast<bt_bool>(
366 userMsgIterFromLibSelfMsgIterPtr(libSelfMsgIterPtr).canSeekBeginning());
367 } catch (const bt2::TryAgain&) {
368 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_AGAIN;
369 } catch (const std::bad_alloc&) {
370 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR;
371 } catch (const bt2::Error&) {
372 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_ERROR;
373 } catch (...) {
374 BT_LOG_WRITE_CUR_LVL(
375 BT_LOG_WARNING,
376 static_cast<int>(wrap(libSelfMsgIterPtr).component().loggingLevel()),
377 unhandledExcLogTag(), unhandledExcLogStr());
378 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_ERROR;
379 }
380
381 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
382 }
383
384 static bt_message_iterator_class_seek_beginning_method_status
385 seekBeginning(bt_self_message_iterator * const libSelfMsgIterPtr) noexcept
386 {
387 try {
388 userMsgIterFromLibSelfMsgIterPtr(libSelfMsgIterPtr).seekBeginning();
389 } catch (const bt2::TryAgain&) {
390 return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_AGAIN;
391 } catch (const std::bad_alloc&) {
392 return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR;
393 } catch (const bt2::Error&) {
394 return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_ERROR;
395 } catch (...) {
396 BT_LOG_WRITE_CUR_LVL(
397 BT_LOG_WARNING,
398 static_cast<int>(wrap(libSelfMsgIterPtr).component().loggingLevel()),
399 unhandledExcLogTag(), unhandledExcLogStr());
400 return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_ERROR;
401 }
402
403 return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
404 }
405
406 static bt_message_iterator_class_can_seek_ns_from_origin_method_status
407 canSeekNsFromOrigin(bt_self_message_iterator * const libSelfMsgIterPtr,
408 const std::int64_t nsFromOrigin, bt_bool * const canSeek) noexcept
409 {
410 try {
411 *canSeek = static_cast<bt_bool>(userMsgIterFromLibSelfMsgIterPtr(libSelfMsgIterPtr)
412 .canSeekNsFromOrigin(nsFromOrigin));
413 } catch (const bt2::TryAgain&) {
414 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN;
415 } catch (const std::bad_alloc&) {
416 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR;
417 } catch (const bt2::Error&) {
418 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR;
419 } catch (...) {
420 BT_LOG_WRITE_CUR_LVL(
421 BT_LOG_WARNING,
422 static_cast<int>(wrap(libSelfMsgIterPtr).component().loggingLevel()),
423 unhandledExcLogTag(), unhandledExcLogStr());
424 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR;
425 }
426
427 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
428 }
429
430 static bt_message_iterator_class_seek_ns_from_origin_method_status
431 seekNsFromOrigin(bt_self_message_iterator * const libSelfMsgIterPtr,
432 const std::int64_t nsFromOrigin) noexcept
433 {
434 try {
435 userMsgIterFromLibSelfMsgIterPtr(libSelfMsgIterPtr).seekNsFromOrigin(nsFromOrigin);
436 } catch (const bt2::TryAgain&) {
437 return BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN;
438 } catch (const std::bad_alloc&) {
439 return BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR;
440 } catch (const bt2::Error&) {
441 return BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR;
442 } catch (...) {
443 BT_LOG_WRITE_CUR_LVL(
444 BT_LOG_WARNING,
445 static_cast<int>(wrap(libSelfMsgIterPtr).component().loggingLevel()),
446 unhandledExcLogTag(), unhandledExcLogStr());
447 return BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR;
448 }
449
450 return BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
451 }
452 };
453
454 } /* namespace internal */
455
456 template <typename UserMessageIteratorT, typename UserComponentT>
457 class UserMessageIterator;
458
459 /*
460 * Base class of any user component.
461 *
462 * See the specific `bt2::UserSourceComponent`,
463 * `bt2::UserFilterComponent`, and `bt2::UserSinkComponent`.
464 */
465 template <typename SelfCompT, typename InitDataT, typename QueryDataT>
466 class UserComponent
467 {
468 /* Give a related message iterator access to this logger */
469 template <typename, typename>
470 friend class UserMessageIterator;
471
472 public:
473 using InitData = InitDataT;
474 using QueryData = QueryDataT;
475
476 protected:
477 explicit UserComponent(const SelfCompT selfComp, const std::string& logTag) :
478 _mLogger {selfComp, fmt::format("{}/[{}]", logTag, selfComp.name())}, _mSelfComp {selfComp}
479 {
480 }
481
482 protected:
483 bt2c::CStringView _name() const noexcept
484 {
485 return _mSelfComp.name();
486 }
487
488 LoggingLevel _loggingLevel() const noexcept
489 {
490 return _mSelfComp.loggingLevel();
491 }
492
493 std::uint64_t _graphMipVersion() const noexcept
494 {
495 return _mSelfComp.graphMipVersion();
496 }
497
498 SelfCompT _selfComp() noexcept
499 {
500 return _mSelfComp;
501 }
502
503 bt2c::Logger _mLogger;
504
505 private:
506 SelfCompT _mSelfComp;
507 };
508
509 /*
510 * Base class of a user source component `UserComponentT` (CRTP).
511 *
512 * UserComponentT::UserComponentT() must accept, in this order:
513 *
514 * 1. A `bt2::SelfSourceComponent` parameter, which it needs to forward
515 * to bt2::UserSourceComponent::UserSourceComponent().
516 *
517 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
518 *
519 * 3. An `InitDataT *` parameter (the initialization method data).
520 *
521 * `UserMessageIteratorT`, the message iterator class to use, must inherit
522 * `UserMessageIterator`.
523 *
524 * UserComponentT::_query() receives a query method data pointer of type
525 * `QueryDataT *` as its last parameter.
526 */
527 template <typename UserComponentT, typename UserMessageIteratorT, typename InitDataT = void,
528 typename QueryDataT = void>
529 class UserSourceComponent : public UserComponent<SelfSourceComponent, InitDataT, QueryDataT>
530 {
531 static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
532 UserMessageIteratorT>::value,
533 "`UserMessageIteratorT` inherits `UserMessageIterator`");
534
535 public:
536 using MessageIterator = UserMessageIteratorT;
537
538 protected:
539 using _OutputPorts = SelfSourceComponent::OutputPorts;
540
541 explicit UserSourceComponent(const SelfSourceComponent selfComp, const std::string& logTag) :
542 UserComponent<SelfSourceComponent, InitDataT, QueryDataT> {selfComp, logTag}
543 {
544 }
545
546 public:
547 static Value::Shared query(const SelfComponentClass selfCompCls,
548 const PrivateQueryExecutor privQueryExec,
549 const bt2c::CStringView obj, const ConstValue params,
550 QueryDataT * const data)
551 {
552 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
553 }
554
555 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
556 const ConstValue params, const LoggingLevel loggingLevel,
557 const UnsignedIntegerRangeSet ranges)
558 {
559 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
560 }
561
562 void outputPortConnected(const SelfComponentOutputPort outputPort,
563 const ConstInputPort inputPort)
564 {
565 static_cast<UserComponentT&>(*this)._outputPortConnected(outputPort, inputPort);
566 }
567
568 protected:
569 /* Overloadable */
570 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
571 ConstValue, QueryDataT *)
572 {
573 throw UnknownObject {};
574 }
575
576 /* Overloadable */
577 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
578 const UnsignedIntegerRangeSet ranges)
579 {
580 ranges.addRange(0, 0);
581 }
582
583 /* Overloadable */
584 void _outputPortConnected(SelfComponentOutputPort, ConstInputPort)
585 {
586 }
587
588 template <typename DataT>
589 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
590 {
591 return this->_selfComp().addOutputPort(name, data);
592 }
593
594 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
595 {
596 return this->_selfComp().addOutputPort(name);
597 }
598
599 _OutputPorts _outputPorts() noexcept
600 {
601 return this->_selfComp().outputPorts();
602 }
603 };
604
605 /*
606 * Base class of a user filter component `UserComponentT` (CRTP).
607 *
608 * UserComponentT::UserComponentT() must accept, in this order:
609 *
610 * 1. A `bt2::SelfFilterComponent` parameter, which it needs to forward
611 * to bt2::UserFilterComponent::UserFilterComponent().
612 *
613 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
614 *
615 * 3. An `InitDataT *` parameter (the initialization method data).
616 *
617 * `UserMessageIteratorT`, the message iterator class to use, must inherit
618 * `UserMessageIterator`.
619 *
620 * UserComponentT::_query() receives a query method data pointer of type
621 * `QueryDataT *` as its last parameter.
622 */
623 template <typename UserComponentT, typename UserMessageIteratorT, typename InitDataT = void,
624 typename QueryDataT = void>
625 class UserFilterComponent : public UserComponent<SelfFilterComponent, InitDataT, QueryDataT>
626 {
627 static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
628 UserMessageIteratorT>::value,
629 "`UserMessageIteratorT` inherits `UserMessageIterator`");
630
631 public:
632 using MessageIterator = UserMessageIteratorT;
633
634 protected:
635 using _InputPorts = SelfFilterComponent::InputPorts;
636 using _OutputPorts = SelfFilterComponent::OutputPorts;
637
638 explicit UserFilterComponent(const SelfFilterComponent selfComp, const std::string& logTag) :
639 UserComponent<SelfFilterComponent, InitDataT, QueryDataT> {selfComp, logTag}
640 {
641 }
642
643 public:
644 static Value::Shared query(const SelfComponentClass selfCompCls,
645 const PrivateQueryExecutor privQueryExec,
646 const bt2c::CStringView obj, const ConstValue params,
647 QueryDataT * const data)
648 {
649 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
650 }
651
652 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
653 const ConstValue params, const LoggingLevel loggingLevel,
654 const UnsignedIntegerRangeSet ranges)
655 {
656 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
657 }
658
659 void inputPortConnected(const SelfComponentInputPort inputPort,
660 const ConstOutputPort outputPort)
661 {
662 static_cast<UserComponentT&>(*this)._inputPortConnected(inputPort, outputPort);
663 }
664
665 void outputPortConnected(const SelfComponentOutputPort outputPort,
666 const ConstInputPort inputPort)
667 {
668 static_cast<UserComponentT&>(*this)._outputPortConnected(outputPort, inputPort);
669 }
670
671 protected:
672 /* Overloadable */
673 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
674 ConstValue, QueryDataT *)
675 {
676 throw UnknownObject {};
677 }
678
679 /* Overloadable */
680 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
681 const UnsignedIntegerRangeSet ranges)
682 {
683 ranges.addRange(0, 0);
684 }
685
686 /* Overloadable */
687 void _inputPortConnected(SelfComponentInputPort, ConstOutputPort)
688 {
689 }
690
691 /* Overloadable */
692 void _outputPortConnected(SelfComponentOutputPort, ConstInputPort)
693 {
694 }
695
696 template <typename DataT>
697 _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
698 {
699 return this->_selfComp().addInputPort(name, data);
700 }
701
702 _InputPorts::Port _addInputPort(const bt2c::CStringView name)
703 {
704 return this->_selfComp().addInputPort(name);
705 }
706
707 _InputPorts _inputPorts() noexcept
708 {
709 return this->_selfComp().inputPorts();
710 }
711
712 template <typename DataT>
713 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
714 {
715 return this->_selfComp().addOutputPort(name, data);
716 }
717
718 _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
719 {
720 return this->_selfComp().addOutputPort(name);
721 }
722
723 _OutputPorts _outputPorts() noexcept
724 {
725 return this->_selfComp().outputPorts();
726 }
727 };
728
729 /*
730 * Base class of a user sink component `UserComponentT` (CRTP).
731 *
732 * UserComponentT::UserComponentT() must accept, in this order:
733 *
734 * 1. A `bt2::SelfSinkComponent` parameter, which it needs to forward
735 * to bt2::UserSinkComponent::UserSinkComponent().
736 *
737 * 2. A `bt2::ConstValue` parameter (the initialization parameters).
738 *
739 * 3. An `InitDataT *` parameter (the initialization method data).
740 *
741 * `UserComponentT` must implement:
742 *
743 * bool _consume();
744 *
745 * This method returns `true` if the sink component still needs to
746 * consume, or `false` if it's finished.
747 *
748 * UserComponentT::_query() receives a query method data pointer of type
749 * `QueryDataT *` as its last parameter.
750
751 */
752 template <typename UserComponentT, typename InitDataT = void, typename QueryDataT = void>
753 class UserSinkComponent : public UserComponent<SelfSinkComponent, InitDataT, QueryDataT>
754 {
755 protected:
756 using _InputPorts = SelfSinkComponent::InputPorts;
757
758 explicit UserSinkComponent(const SelfSinkComponent selfComp, const std::string& logTag) :
759 UserComponent<SelfSinkComponent, InitDataT, QueryDataT> {selfComp, logTag}
760 {
761 }
762
763 public:
764 static Value::Shared query(const SelfComponentClass selfCompCls,
765 const PrivateQueryExecutor privQueryExec,
766 const bt2c::CStringView obj, const ConstValue params,
767 QueryDataT * const data)
768 {
769 return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data);
770 }
771
772 static void getSupportedMipVersions(const SelfComponentClass selfCompCls,
773 const ConstValue params, const LoggingLevel loggingLevel,
774 const UnsignedIntegerRangeSet ranges)
775 {
776 UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges);
777 }
778
779 void graphIsConfigured()
780 {
781 static_cast<UserComponentT&>(*this)._graphIsConfigured();
782 }
783
784 void inputPortConnected(const SelfComponentInputPort inputPort,
785 const ConstOutputPort outputPort)
786 {
787 static_cast<UserComponentT&>(*this)._inputPortConnected(inputPort, outputPort);
788 }
789
790 bool consume()
791 {
792 return static_cast<UserComponentT&>(*this)._consume();
793 }
794
795 protected:
796 /* Overloadable */
797 static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
798 ConstValue, QueryDataT *)
799 {
800 throw UnknownObject {};
801 }
802
803 /* Overloadable */
804 static void _getSupportedMipVersions(SelfComponentClass, ConstValue, LoggingLevel,
805 const UnsignedIntegerRangeSet ranges)
806 {
807 ranges.addRange(0, 0);
808 }
809
810 /* Overloadable */
811 void _graphIsConfigured()
812 {
813 }
814
815 /* Overloadable */
816 void _inputPortConnected(SelfComponentInputPort, ConstOutputPort)
817 {
818 }
819
820 MessageIterator::Shared _createMessageIterator(const _InputPorts::Port port)
821 {
822 return this->_selfComp().createMessageIterator(port);
823 }
824
825 template <typename DataT>
826 _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
827 {
828 return this->_selfComp().addInputPort(name, data);
829 }
830
831 _InputPorts::Port _addInputPort(const bt2c::CStringView name)
832 {
833 return this->_selfComp().addInputPort(name);
834 }
835
836 _InputPorts _inputPorts() noexcept
837 {
838 return this->_selfComp().inputPorts();
839 }
840 };
841
842 /*
843 * Base class of a user message iterator `UserMessageIteratorT` (CRTP)
844 * of which the parent user component class is `UserComponentT`.
845 *
846 * `UserMessageIteratorT::UserMessageIteratorT()` must accept a
847 * `bt2::SelfMessageIterator` parameter, which it needs to forward to
848 * bt2::UserMessageIterator::UserMessageIterator().
849 *
850 * The public next() method below (called by the bridge) implements the
851 * very common pattern of appending messages into the output array, and,
852 * meanwhile:
853 *
854 * If it catches a `bt2::TryAgain` exception:
855 * If the message array isn't empty, transform this into a success
856 * (don't throw).
857 *
858 * Otherwise rethrow.
859 *
860 * If it catches an error:
861 * If the message array isn't empty, transform this into a success
862 * (don't throw), but save the error of the current thread and the
863 * type of error to throw the next time the user calls next().
864 *
865 * Otherwise rethrow.
866 *
867 * `UserMessageIteratorT` must implement:
868 *
869 * void _next(bt2::ConstMessageArray& messages);
870 *
871 * This method fills `messages` with at most `messages.capacity()`
872 * messages and may throw `bt2::TryAgain` or a valid error whenever.
873 * Leaving an empty `messages` means the end of iteration.
874 */
875 template <typename UserMessageIteratorT, typename UserComponentT>
876 class UserMessageIterator
877 {
878 private:
879 /* Type of `_mExcToThrowType` */
880 enum class _ExcToThrowType
881 {
882 NONE,
883 ERROR,
884 MEM_ERROR,
885 };
886
887 protected:
888 explicit UserMessageIterator(const SelfMessageIterator selfMsgIter,
889 const std::string& logTagSuffix) :
890 _mSelfMsgIter {selfMsgIter},
891 _mLogger {selfMsgIter,
892 fmt::format("{}/{}", this->_component()._mLogger.tag(), logTagSuffix)}
893 {
894 }
895
896 public:
897 ~UserMessageIterator()
898 {
899 this->_resetError();
900 }
901
902 void next(bt2::ConstMessageArray& messages)
903 {
904 /* Any saved error? Now is the time to throw */
905 if (G_UNLIKELY(_mExcToThrowType != _ExcToThrowType::NONE)) {
906 /* Move `_mSavedLibError`, if any, as current thread error */
907 if (_mSavedLibError) {
908 BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(_mSavedLibError);
909 }
910
911 /* Throw the corresponding exception */
912 if (_mExcToThrowType == _ExcToThrowType::ERROR) {
913 throw bt2::Error {};
914 } else {
915 BT_ASSERT(_mExcToThrowType == _ExcToThrowType::MEM_ERROR);
916 throw bt2::MemoryError {};
917 }
918 }
919
920 /*
921 * When catching some exception below, if our message array
922 * isn't empty, then return immediately before throwing to
923 * provide those messages to downstream.
924 *
925 * When catching an error, also save the current thread error,
926 * if any, so that we can restore it later (see the beginning of
927 * this method).
928 */
929 BT_ASSERT_DBG(_mExcToThrowType == _ExcToThrowType::NONE);
930
931 try {
932 this->_userObj()._next(messages);
933
934 /* We're done: everything below is exception handling */
935 return;
936 } catch (const bt2::TryAgain&) {
937 if (messages.isEmpty()) {
938 throw;
939 }
940 } catch (const std::bad_alloc&) {
941 if (messages.isEmpty()) {
942 throw;
943 }
944
945 _mExcToThrowType = _ExcToThrowType::MEM_ERROR;
946 } catch (const bt2::Error&) {
947 if (messages.isEmpty()) {
948 throw;
949 }
950
951 _mExcToThrowType = _ExcToThrowType::ERROR;
952 }
953
954 if (_mExcToThrowType != _ExcToThrowType::NONE) {
955 BT_CPPLOGE(
956 "An error occurred, but there are {} messages to return: delaying the error reporting.",
957 messages.length());
958 BT_ASSERT(!_mSavedLibError);
959 _mSavedLibError = bt_current_thread_take_error();
960 }
961 }
962
963 bool canSeekBeginning()
964 {
965 this->_resetError();
966 return this->_userObj()._canSeekBeginning();
967 }
968
969 void seekBeginning()
970 {
971 this->_resetError();
972 return this->_userObj()._seekBeginning();
973 }
974
975 bool canSeekNsFromOrigin(const std::int64_t nsFromOrigin)
976 {
977 this->_resetError();
978 return this->_userObj()._canSeekNsFromOrigin(nsFromOrigin);
979 }
980
981 void seekNsFromOrigin(const std::int64_t nsFromOrigin)
982 {
983 this->_resetError();
984 this->_userObj()._seekNsFromOrigin(nsFromOrigin);
985 }
986
987 protected:
988 /* Overloadable */
989 bool _canSeekBeginning() noexcept
990 {
991 return false;
992 }
993
994 /* Overloadable */
995 void _seekBeginning() noexcept
996 {
997 }
998
999 /* Overloadable */
1000 bool _canSeekNsFromOrigin(std::int64_t) noexcept
1001 {
1002 return false;
1003 }
1004
1005 /* Overloadable */
1006 void _seekNsFromOrigin(std::int64_t) noexcept
1007 {
1008 }
1009
1010 MessageIterator::Shared _createMessageIterator(const SelfComponentInputPort port)
1011 {
1012 return _mSelfMsgIter.createMessageIterator(port);
1013 }
1014
1015 UserComponentT& _component() noexcept
1016 {
1017 return _mSelfMsgIter.component().template data<UserComponentT>();
1018 }
1019
1020 SelfComponentOutputPort _port() noexcept
1021 {
1022 return _mSelfMsgIter.port();
1023 }
1024
1025 bool _isInterrupted() const noexcept
1026 {
1027 return _mSelfMsgIter.isInterrupted();
1028 }
1029
1030 private:
1031 UserMessageIteratorT& _userObj() noexcept
1032 {
1033 return static_cast<UserMessageIteratorT&>(*this);
1034 }
1035
1036 void _resetError() noexcept
1037 {
1038 _mExcToThrowType = _ExcToThrowType::NONE;
1039
1040 if (_mSavedLibError) {
1041 bt_error_release(_mSavedLibError);
1042 }
1043 }
1044
1045 SelfMessageIterator _mSelfMsgIter;
1046
1047 /*
1048 * next() may accumulate messages, and then catch an error before
1049 * returning. In that case, it saves the error of the current thread
1050 * here so that it can return its accumulated messages and throw the
1051 * next time.
1052 *
1053 * It also saves the type of the exception to throw the next time.
1054 */
1055 _ExcToThrowType _mExcToThrowType = _ExcToThrowType::NONE;
1056 const bt_error *_mSavedLibError = nullptr;
1057
1058 protected:
1059 bt2c::Logger _mLogger;
1060 };
1061
1062 } /* namespace bt2 */
1063
1064 #define BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_pluginId, _componentClassId, _name, \
1065 _userComponentClass) \
1066 BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID( \
1067 _pluginId, _componentClassId, _name, \
1068 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::next); \
1069 BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID( \
1070 _pluginId, _componentClassId, bt2::internal::SrcCompClsBridge<_userComponentClass>::init); \
1071 BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID( \
1072 _pluginId, _componentClassId, \
1073 bt2::internal::SrcCompClsBridge<_userComponentClass>::finalize); \
1074 BT_PLUGIN_SOURCE_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID( \
1075 _pluginId, _componentClassId, \
1076 bt2::internal::SrcCompClsBridge<_userComponentClass>::getSupportedMipVersions); \
1077 BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID( \
1078 _pluginId, _componentClassId, \
1079 bt2::internal::SrcCompClsBridge<_userComponentClass>::outputPortConnected); \
1080 BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID( \
1081 _pluginId, _componentClassId, \
1082 bt2::internal::SrcCompClsBridge<_userComponentClass>::query); \
1083 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_WITH_ID( \
1084 _pluginId, _componentClassId, \
1085 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::init); \
1086 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD_WITH_ID( \
1087 _pluginId, _componentClassId, \
1088 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::finalize); \
1089 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHODS_WITH_ID( \
1090 _pluginId, _componentClassId, \
1091 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekBeginning, \
1092 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::canSeekBeginning); \
1093 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID( \
1094 _pluginId, _componentClassId, \
1095 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekNsFromOrigin, \
1096 bt2::internal::MsgIterClsBridge< \
1097 _userComponentClass::MessageIterator>::canSeekNsFromOrigin);
1098
1099 #define BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_pluginId, _componentClassId, _name, \
1100 _userComponentClass) \
1101 BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID( \
1102 _pluginId, _componentClassId, _name, \
1103 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::next); \
1104 BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID( \
1105 _pluginId, _componentClassId, bt2::internal::FltCompClsBridge<_userComponentClass>::init); \
1106 BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID( \
1107 _pluginId, _componentClassId, \
1108 bt2::internal::FltCompClsBridge<_userComponentClass>::finalize); \
1109 BT_PLUGIN_FILTER_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID( \
1110 _pluginId, _componentClassId, \
1111 bt2::internal::FltCompClsBridge<_userComponentClass>::getSupportedMipVersions); \
1112 BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID( \
1113 _pluginId, _componentClassId, \
1114 bt2::internal::FltCompClsBridge<_userComponentClass>::inputPortConnected); \
1115 BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID( \
1116 _pluginId, _componentClassId, \
1117 bt2::internal::FltCompClsBridge<_userComponentClass>::outputPortConnected); \
1118 BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID( \
1119 _pluginId, _componentClassId, \
1120 bt2::internal::FltCompClsBridge<_userComponentClass>::query); \
1121 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_WITH_ID( \
1122 _pluginId, _componentClassId, \
1123 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::init); \
1124 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD_WITH_ID( \
1125 _pluginId, _componentClassId, \
1126 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::finalize); \
1127 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHODS_WITH_ID( \
1128 _pluginId, _componentClassId, \
1129 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekBeginning, \
1130 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::canSeekBeginning); \
1131 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID( \
1132 _pluginId, _componentClassId, \
1133 bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekNsFromOrigin, \
1134 bt2::internal::MsgIterClsBridge< \
1135 _userComponentClass::MessageIterator>::canSeekNsFromOrigin);
1136
1137 #define BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_pluginId, _componentClassId, _name, \
1138 _userComponentClass) \
1139 BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID( \
1140 _pluginId, _componentClassId, _name, \
1141 bt2::internal::SinkCompClsBridge<_userComponentClass>::consume); \
1142 BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID( \
1143 _pluginId, _componentClassId, \
1144 bt2::internal::SinkCompClsBridge<_userComponentClass>::init); \
1145 BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID( \
1146 _pluginId, _componentClassId, \
1147 bt2::internal::SinkCompClsBridge<_userComponentClass>::finalize); \
1148 BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID( \
1149 _pluginId, _componentClassId, \
1150 bt2::internal::SinkCompClsBridge<_userComponentClass>::getSupportedMipVersions); \
1151 BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID( \
1152 _pluginId, _componentClassId, \
1153 bt2::internal::SinkCompClsBridge<_userComponentClass>::inputPortConnected); \
1154 BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD_WITH_ID( \
1155 _pluginId, _componentClassId, \
1156 bt2::internal::SinkCompClsBridge<_userComponentClass>::graphIsConfigured); \
1157 BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID( \
1158 _pluginId, _componentClassId, \
1159 bt2::internal::SinkCompClsBridge<_userComponentClass>::query);
1160
1161 #define BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _userComponentClass) \
1162 BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass)
1163
1164 #define BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS(_name, _userComponentClass) \
1165 BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass)
1166
1167 #define BT_CPP_PLUGIN_SINK_COMPONENT_CLASS(_name, _userComponentClass) \
1168 BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass)
1169
1170 #endif /* BABELTRACE_CPP_COMMON_BT2_PLUGIN_DEV_HPP */
This page took 0.053484 seconds and 3 git commands to generate.