cpp-common/bt2: add `SelfComponent::createTraceClass`
[babeltrace.git] / src / cpp-common / bt2 / self-component-port.hpp
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_PORT_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_PORT_HPP
9
10 #include <cstdint>
11
12 #include <babeltrace2/babeltrace.h>
13
14 #include "logging.hpp"
15
16 #include "common/assert.h"
17 #include "cpp-common/bt2c/c-string-view.hpp"
18
19 #include "borrowed-object-iterator.hpp"
20 #include "borrowed-object.hpp"
21 #include "component-port.hpp"
22 #include "message-iterator.hpp"
23
24 namespace bt2 {
25
26 class SelfSourceComponent;
27 class SelfFilterComponent;
28 class SelfSinkComponent;
29
30 class SelfComponent final : public BorrowedObject<bt_self_component>
31 {
32 public:
33 explicit SelfComponent(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
34 {
35 }
36
37 explicit SelfComponent(bt_self_component_source * const libObjPtr) noexcept :
38 _ThisBorrowedObject {bt_self_component_source_as_self_component(libObjPtr)}
39 {
40 }
41
42 explicit SelfComponent(bt_self_component_filter * const libObjPtr) noexcept :
43 _ThisBorrowedObject {bt_self_component_filter_as_self_component(libObjPtr)}
44 {
45 }
46
47 explicit SelfComponent(bt_self_component_sink * const libObjPtr) noexcept :
48 _ThisBorrowedObject {bt_self_component_sink_as_self_component(libObjPtr)}
49 {
50 }
51
52 /* Not `explicit` to make them behave like copy constructors */
53 SelfComponent(SelfSourceComponent other) noexcept;
54 SelfComponent(SelfFilterComponent other) noexcept;
55 SelfComponent(SelfSinkComponent other) noexcept;
56
57 SelfComponent operator=(SelfSourceComponent other) noexcept;
58 SelfComponent operator=(SelfFilterComponent other) noexcept;
59 SelfComponent operator=(SelfSinkComponent other) noexcept;
60
61 ConstComponent asConstComponent() const noexcept
62 {
63 return ConstComponent {bt_self_component_as_component(this->libObjPtr())};
64 }
65
66 bool isSource() const noexcept
67 {
68 return this->asConstComponent().isSource();
69 }
70
71 bool isFilter() const noexcept
72 {
73 return this->asConstComponent().isFilter();
74 }
75
76 bool isSink() const noexcept
77 {
78 return this->asConstComponent().isSink();
79 }
80
81 bt2c::CStringView name() const noexcept
82 {
83 return this->asConstComponent().name();
84 }
85
86 LoggingLevel loggingLevel() const noexcept
87 {
88 return this->asConstComponent().loggingLevel();
89 }
90
91 std::uint64_t graphMipVersion() const noexcept
92 {
93 return bt_self_component_get_graph_mip_version(this->libObjPtr());
94 }
95
96 template <typename T>
97 T& data() const noexcept
98 {
99 return *static_cast<T *>(bt_self_component_get_data(this->libObjPtr()));
100 }
101
102 template <typename T>
103 void data(T& obj) const noexcept
104 {
105 bt_self_component_set_data(this->libObjPtr(), static_cast<void *>(&obj));
106 }
107
108 bt2::TraceClass::Shared createTraceClass() const
109 {
110 const auto libObjPtr = bt_trace_class_create(this->libObjPtr());
111
112 if (!libObjPtr) {
113 throw MemoryError {};
114 }
115
116 return bt2::TraceClass::Shared::createWithoutRef(libObjPtr);
117 }
118 };
119
120 template <typename LibObjT>
121 class SelfSpecificComponent : public BorrowedObject<LibObjT>
122 {
123 private:
124 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
125
126 public:
127 using typename BorrowedObject<LibObjT>::LibObjPtr;
128
129 protected:
130 explicit SelfSpecificComponent(const LibObjPtr libObjPtr) noexcept :
131 _ThisBorrowedObject {libObjPtr}
132 {
133 }
134
135 template <typename PortT, typename LibPortT, typename AddPortFuncT, typename DataT>
136 PortT _addPort(const char * const name, DataT * const data, AddPortFuncT&& func) const
137 {
138 LibPortT *libPortPtr;
139
140 const auto status = func(this->libObjPtr(), name, static_cast<void *>(data), &libPortPtr);
141
142 switch (status) {
143 case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK:
144 return PortT {libPortPtr};
145 case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
146 throw MemoryError {};
147 case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
148 throw Error {};
149 default:
150 bt_common_abort();
151 }
152 }
153
154 public:
155 bt2c::CStringView name() const noexcept
156 {
157 return this->_selfComponent().name();
158 }
159
160 LoggingLevel loggingLevel() const noexcept
161 {
162 return this->_selfComponent().loggingLevel();
163 }
164
165 std::uint64_t graphMipVersion() const noexcept
166 {
167 return this->_selfComponent().graphMipVersion();
168 }
169
170 template <typename T>
171 T& data() const noexcept
172 {
173 return this->_selfComponent().template data<T>();
174 }
175
176 template <typename T>
177 void data(T& obj) const noexcept
178 {
179 this->_selfComponent().data(obj);
180 }
181
182 private:
183 SelfComponent _selfComponent() const noexcept
184 {
185 return SelfComponent {this->libObjPtr()};
186 }
187 };
188
189 namespace internal {
190
191 template <typename LibSelfCompT, typename LibSelfCompPortPtrT>
192 struct SelfComponentPortsSpec;
193
194 template <>
195 struct SelfComponentPortsSpec<bt_self_component_source, bt_self_component_port_output> final
196 {
197 static std::uint64_t portCount(bt_self_component_source * const libCompPtr) noexcept
198 {
199 return bt_component_source_get_output_port_count(
200 bt_self_component_source_as_component_source(libCompPtr));
201 }
202
203 static bt_self_component_port_output *portByIndex(bt_self_component_source * const libCompPtr,
204 const std::uint64_t index) noexcept
205 {
206 return bt_self_component_source_borrow_output_port_by_index(libCompPtr, index);
207 }
208
209 static bt_self_component_port_output *portByName(bt_self_component_source * const libCompPtr,
210 const char * const name) noexcept
211 {
212 return bt_self_component_source_borrow_output_port_by_name(libCompPtr, name);
213 }
214 };
215
216 template <>
217 struct SelfComponentPortsSpec<bt_self_component_filter, bt_self_component_port_output> final
218 {
219 static std::uint64_t portCount(bt_self_component_filter * const libCompPtr) noexcept
220 {
221 return bt_component_filter_get_output_port_count(
222 bt_self_component_filter_as_component_filter(libCompPtr));
223 }
224
225 static bt_self_component_port_output *portByIndex(bt_self_component_filter * const libCompPtr,
226 const std::uint64_t index) noexcept
227 {
228 return bt_self_component_filter_borrow_output_port_by_index(libCompPtr, index);
229 }
230
231 static bt_self_component_port_output *portByName(bt_self_component_filter * const libCompPtr,
232 const char * const name) noexcept
233 {
234 return bt_self_component_filter_borrow_output_port_by_name(libCompPtr, name);
235 }
236 };
237
238 template <>
239 struct SelfComponentPortsSpec<bt_self_component_filter, bt_self_component_port_input> final
240 {
241 static std::uint64_t portCount(bt_self_component_filter * const libCompPtr) noexcept
242 {
243 return bt_component_filter_get_input_port_count(
244 bt_self_component_filter_as_component_filter(libCompPtr));
245 }
246
247 static bt_self_component_port_input *portByIndex(bt_self_component_filter * const libCompPtr,
248 const std::uint64_t index) noexcept
249 {
250 return bt_self_component_filter_borrow_input_port_by_index(libCompPtr, index);
251 }
252
253 static bt_self_component_port_input *portByName(bt_self_component_filter * const libCompPtr,
254 const char * const name) noexcept
255 {
256 return bt_self_component_filter_borrow_input_port_by_name(libCompPtr, name);
257 }
258 };
259
260 template <>
261 struct SelfComponentPortsSpec<bt_self_component_sink, bt_self_component_port_input> final
262 {
263 static std::uint64_t portCount(bt_self_component_sink * const libCompPtr) noexcept
264 {
265 return bt_component_sink_get_input_port_count(
266 bt_self_component_sink_as_component_sink(libCompPtr));
267 }
268
269 static bt_self_component_port_input *portByIndex(bt_self_component_sink * const libCompPtr,
270 const std::uint64_t index) noexcept
271 {
272 return bt_self_component_sink_borrow_input_port_by_index(libCompPtr, index);
273 }
274
275 static bt_self_component_port_input *portByName(bt_self_component_sink * const libCompPtr,
276 const char * const name) noexcept
277 {
278 return bt_self_component_sink_borrow_input_port_by_name(libCompPtr, name);
279 }
280 };
281
282 } /* namespace internal */
283
284 template <typename LibSelfCompPortT, typename LibPortT>
285 class SelfComponentPort;
286
287 template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
288 class SelfComponentPorts final : public BorrowedObject<LibSelfCompT>
289 {
290 private:
291 using typename BorrowedObject<LibSelfCompT>::_ThisBorrowedObject;
292 using _Spec = internal::SelfComponentPortsSpec<LibSelfCompT, LibSelfCompPortT>;
293
294 public:
295 using typename BorrowedObject<LibSelfCompT>::LibObjPtr;
296 using Port = SelfComponentPort<LibSelfCompPortT, LibPortT>;
297 using Iterator = BorrowedObjectIterator<SelfComponentPorts>;
298
299 explicit SelfComponentPorts(const LibObjPtr libObjPtr) noexcept :
300 _ThisBorrowedObject {libObjPtr}
301 {
302 }
303
304 std::uint64_t length() const noexcept
305 {
306 return _Spec::portCount(this->libObjPtr());
307 }
308
309 Port operator[](std::uint64_t index) const noexcept;
310 Port operator[](bt2c::CStringView name) const noexcept;
311 Iterator begin() const noexcept;
312 Iterator end() const noexcept;
313 Port front() const noexcept;
314 Port back() const noexcept;
315 };
316
317 class SelfSourceComponent final : public SelfSpecificComponent<bt_self_component_source>
318 {
319 public:
320 using OutputPorts = SelfComponentPorts<bt_self_component_source, bt_self_component_port_output,
321 const bt_port_output>;
322
323 explicit SelfSourceComponent(bt_self_component_source * const libObjPtr) noexcept :
324 SelfSpecificComponent {libObjPtr}
325 {
326 }
327
328 ConstSourceComponent asConstComponent() const noexcept
329 {
330 return ConstSourceComponent {
331 bt_self_component_source_as_component_source(this->libObjPtr())};
332 }
333
334 template <typename DataT>
335 OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const;
336
337 OutputPorts::Port addOutputPort(bt2c::CStringView name) const;
338
339 OutputPorts outputPorts() const noexcept;
340
341 private:
342 template <typename DataT>
343 OutputPorts::Port _addOutputPort(const char *name, DataT *data) const;
344 };
345
346 class SelfFilterComponent final : public SelfSpecificComponent<bt_self_component_filter>
347 {
348 public:
349 using InputPorts = SelfComponentPorts<bt_self_component_filter, bt_self_component_port_input,
350 const bt_port_input>;
351 using OutputPorts = SelfComponentPorts<bt_self_component_filter, bt_self_component_port_output,
352 const bt_port_output>;
353
354 explicit SelfFilterComponent(bt_self_component_filter * const libObjPtr) noexcept :
355 SelfSpecificComponent {libObjPtr}
356 {
357 }
358
359 ConstFilterComponent asConstComponent() const noexcept
360 {
361 return ConstFilterComponent {
362 bt_self_component_filter_as_component_filter(this->libObjPtr())};
363 }
364
365 template <typename DataT>
366 InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const;
367
368 InputPorts::Port addInputPort(bt2c::CStringView name) const;
369
370 InputPorts inputPorts() const noexcept;
371
372 template <typename DataT>
373 OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const;
374
375 OutputPorts::Port addOutputPort(bt2c::CStringView name) const;
376
377 OutputPorts outputPorts() const noexcept;
378
379 private:
380 template <typename DataT>
381 InputPorts::Port _addInputPort(const char *name, DataT *data) const;
382
383 template <typename DataT>
384 OutputPorts::Port _addOutputPort(const char *name, DataT *data) const;
385 };
386
387 class SelfSinkComponent final : public SelfSpecificComponent<bt_self_component_sink>
388 {
389 public:
390 using InputPorts = SelfComponentPorts<bt_self_component_sink, bt_self_component_port_input,
391 const bt_port_input>;
392
393 explicit SelfSinkComponent(bt_self_component_sink * const libObjPtr) noexcept :
394 SelfSpecificComponent {libObjPtr}
395 {
396 }
397
398 ConstSinkComponent asConstComponent() const noexcept
399 {
400 return ConstSinkComponent {bt_self_component_sink_as_component_sink(this->libObjPtr())};
401 }
402
403 MessageIterator::Shared createMessageIterator(InputPorts::Port port) const;
404
405 bool isInterrupted() const noexcept
406 {
407 return static_cast<bool>(bt_self_component_sink_is_interrupted(this->libObjPtr()));
408 }
409
410 template <typename DataT>
411 InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const;
412
413 InputPorts::Port addInputPort(bt2c::CStringView name) const;
414
415 InputPorts inputPorts() const noexcept;
416
417 private:
418 template <typename DataT>
419 InputPorts::Port _addInputPort(const char *name, DataT *data) const;
420 };
421
422 inline SelfComponent::SelfComponent(const SelfSourceComponent other) noexcept :
423 SelfComponent {other.libObjPtr()}
424 {
425 }
426
427 inline SelfComponent::SelfComponent(const SelfFilterComponent other) noexcept :
428 SelfComponent {other.libObjPtr()}
429 {
430 }
431
432 inline SelfComponent::SelfComponent(const SelfSinkComponent other) noexcept :
433 SelfComponent {other.libObjPtr()}
434 {
435 }
436
437 inline SelfComponent SelfComponent::operator=(const SelfSourceComponent other) noexcept
438 {
439 *this = SelfComponent {other.libObjPtr()};
440 return *this;
441 }
442
443 inline SelfComponent SelfComponent::operator=(const SelfFilterComponent other) noexcept
444 {
445 *this = SelfComponent {other.libObjPtr()};
446 return *this;
447 }
448
449 inline SelfComponent SelfComponent::operator=(const SelfSinkComponent other) noexcept
450 {
451 *this = SelfComponent {other.libObjPtr()};
452 return *this;
453 }
454
455 namespace internal {
456
457 template <typename LibObjT>
458 struct SelfComponentPortSpec;
459
460 /* Functions specific to self component input ports */
461 template <>
462 struct SelfComponentPortSpec<bt_self_component_port_input> final
463 {
464 static bt_self_component_port *
465 asSelfCompPort(bt_self_component_port_input * const libObjPtr) noexcept
466 {
467 return bt_self_component_port_input_as_self_component_port(libObjPtr);
468 }
469
470 static const bt_port_input *
471 asConstPort(const bt_self_component_port_input * const libObjPtr) noexcept
472 {
473 return bt_self_component_port_input_as_port_input(libObjPtr);
474 }
475 };
476
477 /* Functions specific to self component output ports */
478 template <>
479 struct SelfComponentPortSpec<bt_self_component_port_output> final
480 {
481 static bt_self_component_port *
482 asSelfCompPort(bt_self_component_port_output * const libObjPtr) noexcept
483 {
484 return bt_self_component_port_output_as_self_component_port(libObjPtr);
485 }
486
487 static const bt_port_output *
488 asConstPort(bt_self_component_port_output * const libObjPtr) noexcept
489 {
490 return bt_self_component_port_output_as_port_output(libObjPtr);
491 }
492 };
493
494 } /* namespace internal */
495
496 template <typename LibSelfCompPortT, typename LibPortT>
497 class SelfComponentPort final : public BorrowedObject<LibSelfCompPortT>
498 {
499 public:
500 using typename BorrowedObject<LibSelfCompPortT>::LibObjPtr;
501
502 explicit SelfComponentPort(const LibObjPtr libObjPtr) noexcept :
503 BorrowedObject<LibSelfCompPortT> {libObjPtr}
504 {
505 }
506
507 ConstPort<LibPortT> asConstPort() const noexcept
508 {
509 return ConstPort<LibPortT> {
510 internal::SelfComponentPortSpec<LibSelfCompPortT>::asConstPort(this->libObjPtr())};
511 }
512
513 bt2c::CStringView name() const noexcept
514 {
515 return this->asConstPort().name();
516 }
517
518 bool isConnected() const noexcept
519 {
520 return this->asConstPort().isConnected();
521 }
522
523 SelfComponent component() const noexcept
524 {
525 return SelfComponent {bt_self_component_port_borrow_component(this->_libSelfCompPortPtr())};
526 }
527
528 template <typename T>
529 T& data() const noexcept
530 {
531 *static_cast<T *>(bt_self_component_port_get_data(this->_libSelfCompPortPtr()));
532 }
533
534 private:
535 bt_self_component_port *_libSelfCompPortPtr() const noexcept
536 {
537 return internal::SelfComponentPortSpec<LibSelfCompPortT>::asSelfCompPort(this->libObjPtr());
538 }
539 };
540
541 template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
542 typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Port
543 SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::operator[](
544 const std::uint64_t index) const noexcept
545 {
546 return Port {_Spec::portByIndex(this->libObjPtr(), index)};
547 }
548
549 template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
550 typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Port
551 SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::operator[](
552 const bt2c::CStringView name) const noexcept
553 {
554 return Port {_Spec::portByName(this->libObjPtr(), name)};
555 }
556
557 template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
558 typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Iterator
559 SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::begin() const noexcept
560 {
561 return Iterator {*this, 0};
562 }
563
564 template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
565 typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Iterator
566 SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::end() const noexcept
567 {
568 return Iterator {*this, this->length()};
569 }
570
571 template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
572 typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Port
573 SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::front() const noexcept
574 {
575 return (*this)[0];
576 }
577
578 template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
579 typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Port
580 SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::back() const noexcept
581 {
582 return (*this)[this->length() - 1];
583 }
584
585 using SelfComponentInputPort = SelfComponentPort<bt_self_component_port_input, const bt_port_input>;
586
587 using SelfComponentOutputPort =
588 SelfComponentPort<bt_self_component_port_output, const bt_port_output>;
589
590 template <typename DataT>
591 SelfSourceComponent::OutputPorts::Port SelfSourceComponent::_addOutputPort(const char * const name,
592 DataT * const data) const
593 {
594 return this->_addPort<SelfSourceComponent::OutputPorts::Port, bt_self_component_port_output>(
595 name, data, bt_self_component_source_add_output_port);
596 }
597
598 template <typename DataT>
599 SelfSourceComponent::OutputPorts::Port
600 SelfSourceComponent::addOutputPort(const bt2c::CStringView name, DataT& data) const
601 {
602 return this->_addOutputPort(name, &data);
603 }
604
605 inline SelfSourceComponent::OutputPorts::Port
606 SelfSourceComponent::addOutputPort(const bt2c::CStringView name) const
607 {
608 return this->_addOutputPort<void>(name, nullptr);
609 }
610
611 inline SelfSourceComponent::OutputPorts SelfSourceComponent::outputPorts() const noexcept
612 {
613 return OutputPorts {this->libObjPtr()};
614 }
615
616 template <typename DataT>
617 SelfFilterComponent::OutputPorts::Port SelfFilterComponent::_addOutputPort(const char * const name,
618 DataT * const data) const
619 {
620 return this->_addPort<SelfFilterComponent::OutputPorts::Port, bt_self_component_port_output>(
621 name, data, bt_self_component_filter_add_output_port);
622 }
623
624 template <typename DataT>
625 SelfFilterComponent::OutputPorts::Port
626 SelfFilterComponent::addOutputPort(const bt2c::CStringView name, DataT& data) const
627 {
628 return this->_addOutputPort(name, &data);
629 }
630
631 inline SelfFilterComponent::OutputPorts::Port
632 SelfFilterComponent::addOutputPort(const bt2c::CStringView name) const
633 {
634 return this->_addOutputPort<void>(name, nullptr);
635 }
636
637 inline SelfFilterComponent::OutputPorts SelfFilterComponent::outputPorts() const noexcept
638 {
639 return OutputPorts {this->libObjPtr()};
640 }
641
642 template <typename DataT>
643 SelfFilterComponent::InputPorts::Port SelfFilterComponent::_addInputPort(const char * const name,
644 DataT * const data) const
645 {
646 return this->_addPort<SelfFilterComponent::InputPorts::Port, bt_self_component_port_input>(
647 name, data, bt_self_component_filter_add_input_port);
648 }
649
650 template <typename DataT>
651 SelfFilterComponent::InputPorts::Port
652 SelfFilterComponent::addInputPort(const bt2c::CStringView name, DataT& data) const
653 {
654 return this->_addInputPort(name, &data);
655 }
656
657 inline SelfFilterComponent::InputPorts::Port
658 SelfFilterComponent::addInputPort(const bt2c::CStringView name) const
659 {
660 return this->_addInputPort<void>(name, nullptr);
661 }
662
663 inline SelfFilterComponent::InputPorts SelfFilterComponent::inputPorts() const noexcept
664 {
665 return InputPorts {this->libObjPtr()};
666 }
667
668 inline MessageIterator::Shared
669 SelfSinkComponent::createMessageIterator(const InputPorts::Port port) const
670 {
671 bt_message_iterator *libMsgIterPtr = nullptr;
672
673 const auto status = bt_message_iterator_create_from_sink_component(
674 this->libObjPtr(), port.libObjPtr(), &libMsgIterPtr);
675
676 switch (status) {
677 case BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK:
678 BT_ASSERT(libMsgIterPtr);
679 return MessageIterator::Shared::createWithoutRef(libMsgIterPtr);
680 case BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_MEMORY_ERROR:
681 throw MemoryError {};
682 case BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_ERROR:
683 throw Error {};
684 default:
685 bt_common_abort();
686 }
687 }
688
689 template <typename DataT>
690 SelfSinkComponent::InputPorts::Port SelfSinkComponent::_addInputPort(const char * const name,
691 DataT * const data) const
692 {
693 return this->_addPort<SelfSinkComponent::InputPorts::Port, bt_self_component_port_input>(
694 name, data, bt_self_component_sink_add_input_port);
695 }
696
697 template <typename DataT>
698 SelfSinkComponent::InputPorts::Port SelfSinkComponent::addInputPort(const bt2c::CStringView name,
699 DataT& data) const
700 {
701 return this->_addInputPort(name, &data);
702 }
703
704 inline SelfSinkComponent::InputPorts::Port
705 SelfSinkComponent::addInputPort(const bt2c::CStringView name) const
706 {
707 return this->_addInputPort<void>(name, nullptr);
708 }
709
710 inline SelfSinkComponent::InputPorts SelfSinkComponent::inputPorts() const noexcept
711 {
712 return InputPorts {this->libObjPtr()};
713 }
714
715 } /* namespace bt2 */
716
717 #endif /* BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_PORT_HPP */
This page took 0.079798 seconds and 5 git commands to generate.