cpp-common: add `bt2s::optional`, alias of `nonstd::optional`
[babeltrace.git] / src / cpp-common / bt2 / trace-ir.hpp
1 /*
2 * Copyright (c) 2020-2021 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP
9
10 #include <cstdint>
11 #include <type_traits>
12
13 #include <babeltrace2/babeltrace.h>
14
15 #include "cpp-common/bt2s/optional.hpp"
16
17 #include "borrowed-object.hpp"
18 #include "clock-class.hpp"
19 #include "field-class.hpp"
20 #include "field.hpp"
21 #include "internal/utils.hpp"
22 #include "shared-object.hpp"
23 #include "value.hpp"
24
25 namespace bt2 {
26
27 template <typename LibObjT>
28 class CommonEvent;
29
30 template <typename LibObjT>
31 class CommonPacket;
32
33 template <typename LibObjT>
34 class CommonStream;
35
36 template <typename LibObjT>
37 class CommonTrace;
38
39 template <typename LibObjT>
40 class CommonEventClass;
41
42 template <typename LibObjT>
43 class CommonStreamClass;
44
45 template <typename LibObjT>
46 class CommonTraceClass;
47
48 namespace internal {
49
50 template <typename LibObjT>
51 struct CommonEventSpec;
52
53 /* Functions specific to mutable events */
54 template <>
55 struct CommonEventSpec<bt_event> final
56 {
57 static bt_event_class *cls(bt_event * const libObjPtr) noexcept
58 {
59 return bt_event_borrow_class(libObjPtr);
60 }
61
62 static bt_stream *stream(bt_event * const libObjPtr) noexcept
63 {
64 return bt_event_borrow_stream(libObjPtr);
65 }
66
67 static bt_packet *packet(bt_event * const libObjPtr) noexcept
68 {
69 return bt_event_borrow_packet(libObjPtr);
70 }
71
72 static bt_field *payloadField(bt_event * const libObjPtr) noexcept
73 {
74 return bt_event_borrow_payload_field(libObjPtr);
75 }
76
77 static bt_field *specificContextField(bt_event * const libObjPtr) noexcept
78 {
79 return bt_event_borrow_specific_context_field(libObjPtr);
80 }
81
82 static bt_field *commonContextField(bt_event * const libObjPtr) noexcept
83 {
84 return bt_event_borrow_common_context_field(libObjPtr);
85 }
86 };
87
88 /* Functions specific to constant events */
89 template <>
90 struct CommonEventSpec<const bt_event> final
91 {
92 static const bt_event_class *cls(const bt_event * const libObjPtr) noexcept
93 {
94 return bt_event_borrow_class_const(libObjPtr);
95 }
96
97 static const bt_stream *stream(const bt_event * const libObjPtr) noexcept
98 {
99 return bt_event_borrow_stream_const(libObjPtr);
100 }
101
102 static const bt_packet *packet(const bt_event * const libObjPtr) noexcept
103 {
104 return bt_event_borrow_packet_const(libObjPtr);
105 }
106
107 static const bt_field *payloadField(const bt_event * const libObjPtr) noexcept
108 {
109 return bt_event_borrow_payload_field_const(libObjPtr);
110 }
111
112 static const bt_field *specificContextField(const bt_event * const libObjPtr) noexcept
113 {
114 return bt_event_borrow_specific_context_field_const(libObjPtr);
115 }
116
117 static const bt_field *commonContextField(const bt_event * const libObjPtr) noexcept
118 {
119 return bt_event_borrow_common_context_field_const(libObjPtr);
120 }
121 };
122
123 template <typename LibObjT>
124 using DepStructField = DepType<LibObjT, StructureField, ConstStructureField>;
125
126 } /* namespace internal */
127
128 template <typename LibObjT>
129 class CommonEvent final : public BorrowedObject<LibObjT>
130 {
131 private:
132 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
133 using typename BorrowedObject<LibObjT>::_LibObjPtr;
134 using _Spec = internal::CommonEventSpec<LibObjT>;
135 using _Packet = internal::DepPacket<LibObjT>;
136 using _Stream = internal::DepStream<LibObjT>;
137 using _StructureField = internal::DepStructField<LibObjT>;
138
139 public:
140 using Class = internal::DepType<LibObjT, CommonEventClass<bt_event_class>,
141 CommonEventClass<const bt_event_class>>;
142
143 explicit CommonEvent(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
144 {
145 }
146
147 template <typename OtherLibObjT>
148 CommonEvent(const CommonEvent<OtherLibObjT> event) noexcept : _ThisBorrowedObject {event}
149 {
150 }
151
152 template <typename OtherLibObjT>
153 CommonEvent<LibObjT> operator=(const CommonEvent<OtherLibObjT> event) noexcept
154 {
155 _ThisBorrowedObject::operator=(event);
156 return *this;
157 }
158
159 CommonEvent<const bt_event> asConst() const noexcept
160 {
161 return CommonEvent<const bt_event> {*this};
162 }
163
164 Class cls() const noexcept;
165 _Stream stream() const noexcept;
166 bt2s::optional<_Packet> packet() const noexcept;
167
168 bt2s::optional<_StructureField> payloadField() const noexcept
169 {
170 const auto libObjPtr = _Spec::payloadField(this->libObjPtr());
171
172 if (libObjPtr) {
173 return _StructureField {libObjPtr};
174 }
175
176 return bt2s::nullopt;
177 }
178
179 bt2s::optional<_StructureField> specificContextField() const noexcept
180 {
181 const auto libObjPtr = _Spec::specificContextField(this->libObjPtr());
182
183 if (libObjPtr) {
184 return _StructureField {libObjPtr};
185 }
186
187 return bt2s::nullopt;
188 }
189
190 bt2s::optional<_StructureField> commonContextField() const noexcept
191 {
192 const auto libObjPtr = _Spec::commonContextField(this->libObjPtr());
193
194 if (libObjPtr) {
195 return _StructureField {libObjPtr};
196 }
197
198 return bt2s::nullopt;
199 }
200 };
201
202 using Event = CommonEvent<bt_event>;
203 using ConstEvent = CommonEvent<const bt_event>;
204
205 namespace internal {
206
207 struct EventTypeDescr
208 {
209 using Const = ConstEvent;
210 using NonConst = Event;
211 };
212
213 template <>
214 struct TypeDescr<Event> : public EventTypeDescr
215 {
216 };
217
218 template <>
219 struct TypeDescr<ConstEvent> : public EventTypeDescr
220 {
221 };
222
223 struct PacketRefFuncs final
224 {
225 static void get(const bt_packet * const libObjPtr) noexcept
226 {
227 bt_packet_get_ref(libObjPtr);
228 }
229
230 static void put(const bt_packet * const libObjPtr) noexcept
231 {
232 bt_packet_put_ref(libObjPtr);
233 }
234 };
235
236 template <typename LibObjT>
237 struct CommonPacketSpec;
238
239 /* Functions specific to mutable packets */
240 template <>
241 struct CommonPacketSpec<bt_packet> final
242 {
243 static bt_stream *stream(bt_packet * const libObjPtr) noexcept
244 {
245 return bt_packet_borrow_stream(libObjPtr);
246 }
247
248 static bt_field *contextField(bt_packet * const libObjPtr) noexcept
249 {
250 return bt_packet_borrow_context_field(libObjPtr);
251 }
252 };
253
254 /* Functions specific to constant packets */
255 template <>
256 struct CommonPacketSpec<const bt_packet> final
257 {
258 static const bt_stream *stream(const bt_packet * const libObjPtr) noexcept
259 {
260 return bt_packet_borrow_stream_const(libObjPtr);
261 }
262
263 static const bt_field *contextField(const bt_packet * const libObjPtr) noexcept
264 {
265 return bt_packet_borrow_context_field_const(libObjPtr);
266 }
267 };
268
269 } /* namespace internal */
270
271 template <typename LibObjT>
272 class CommonPacket final : public BorrowedObject<LibObjT>
273 {
274 private:
275 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
276 using typename BorrowedObject<LibObjT>::_LibObjPtr;
277 using _Spec = internal::CommonPacketSpec<LibObjT>;
278 using _Stream = internal::DepStream<LibObjT>;
279 using _StructureField = internal::DepStructField<LibObjT>;
280
281 public:
282 using Shared = SharedObject<CommonPacket, LibObjT, internal::PacketRefFuncs>;
283
284 explicit CommonPacket(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
285 {
286 }
287
288 template <typename OtherLibObjT>
289 CommonPacket(const CommonPacket<OtherLibObjT> packet) noexcept : _ThisBorrowedObject {packet}
290 {
291 }
292
293 template <typename OtherLibObjT>
294 CommonPacket operator=(const CommonPacket<OtherLibObjT> packet) noexcept
295 {
296 _ThisBorrowedObject::operator=(packet);
297 return *this;
298 }
299
300 CommonPacket<const bt_packet> asConst() const noexcept
301 {
302 return CommonPacket<const bt_packet> {*this};
303 }
304
305 _Stream stream() const noexcept;
306
307 bt2s::optional<_StructureField> contextField() const noexcept
308 {
309 const auto libObjPtr = _Spec::contextField(this->libObjPtr());
310
311 if (libObjPtr) {
312 return _StructureField {libObjPtr};
313 }
314
315 return bt2s::nullopt;
316 }
317
318 Shared shared() const noexcept
319 {
320 return Shared::createWithRef(*this);
321 }
322 };
323
324 using Packet = CommonPacket<bt_packet>;
325 using ConstPacket = CommonPacket<const bt_packet>;
326
327 namespace internal {
328
329 struct PacketTypeDescr
330 {
331 using Const = ConstPacket;
332 using NonConst = Packet;
333 };
334
335 template <>
336 struct TypeDescr<Packet> : public PacketTypeDescr
337 {
338 };
339
340 template <>
341 struct TypeDescr<ConstPacket> : public PacketTypeDescr
342 {
343 };
344
345 } /* namespace internal */
346
347 template <typename LibObjT>
348 bt2s::optional<typename CommonEvent<LibObjT>::_Packet> CommonEvent<LibObjT>::packet() const noexcept
349 {
350 const auto libObjPtr = _Spec::packet(this->libObjPtr());
351
352 if (libObjPtr) {
353 return _Packet {libObjPtr};
354 }
355
356 return bt2s::nullopt;
357 }
358
359 namespace internal {
360
361 struct StreamRefFuncs final
362 {
363 static void get(const bt_stream * const libObjPtr) noexcept
364 {
365 bt_stream_get_ref(libObjPtr);
366 }
367
368 static void put(const bt_stream * const libObjPtr) noexcept
369 {
370 bt_stream_put_ref(libObjPtr);
371 }
372 };
373
374 template <typename LibObjT>
375 struct CommonStreamSpec;
376
377 /* Functions specific to mutable streams */
378 template <>
379 struct CommonStreamSpec<bt_stream> final
380 {
381 static bt_stream_class *cls(bt_stream * const libObjPtr) noexcept
382 {
383 return bt_stream_borrow_class(libObjPtr);
384 }
385
386 static bt_trace *trace(bt_stream * const libObjPtr) noexcept
387 {
388 return bt_stream_borrow_trace(libObjPtr);
389 }
390
391 static bt_value *userAttributes(bt_stream * const libObjPtr) noexcept
392 {
393 return bt_stream_borrow_user_attributes(libObjPtr);
394 }
395 };
396
397 /* Functions specific to constant streams */
398 template <>
399 struct CommonStreamSpec<const bt_stream> final
400 {
401 static const bt_stream_class *cls(const bt_stream * const libObjPtr) noexcept
402 {
403 return bt_stream_borrow_class_const(libObjPtr);
404 }
405
406 static const bt_trace *trace(const bt_stream * const libObjPtr) noexcept
407 {
408 return bt_stream_borrow_trace_const(libObjPtr);
409 }
410
411 static const bt_value *userAttributes(const bt_stream * const libObjPtr) noexcept
412 {
413 return bt_stream_borrow_user_attributes_const(libObjPtr);
414 }
415 };
416
417 } /* namespace internal */
418
419 template <typename LibObjT>
420 class CommonStream final : public BorrowedObject<LibObjT>
421 {
422 private:
423 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
424 using typename BorrowedObject<LibObjT>::_LibObjPtr;
425 using _Spec = internal::CommonStreamSpec<LibObjT>;
426 using _Trace = internal::DepType<LibObjT, CommonTrace<bt_trace>, CommonTrace<const bt_trace>>;
427
428 public:
429 using Shared = SharedObject<CommonStream, LibObjT, internal::StreamRefFuncs>;
430 using UserAttributes = internal::DepUserAttrs<LibObjT>;
431
432 using Class = internal::DepType<LibObjT, CommonStreamClass<bt_stream_class>,
433 CommonStreamClass<const bt_stream_class>>;
434
435 explicit CommonStream(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
436 {
437 }
438
439 template <typename OtherLibObjT>
440 CommonStream(const CommonStream<OtherLibObjT> stream) noexcept : _ThisBorrowedObject {stream}
441 {
442 }
443
444 template <typename OtherLibObjT>
445 CommonStream operator=(const CommonStream<OtherLibObjT> stream) noexcept
446 {
447 _ThisBorrowedObject::operator=(stream);
448 return *this;
449 }
450
451 CommonStream<const bt_stream> asConst() const noexcept
452 {
453 return CommonStream<const bt_stream> {*this};
454 }
455
456 Packet::Shared createPacket() const
457 {
458 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
459
460 const auto libObjPtr = bt_packet_create(this->libObjPtr());
461
462 internal::validateCreatedObjPtr(libObjPtr);
463 return Packet::Shared::createWithoutRef(libObjPtr);
464 }
465
466 Class cls() const noexcept;
467 _Trace trace() const noexcept;
468
469 std::uint64_t id() const noexcept
470 {
471 return bt_stream_get_id(this->libObjPtr());
472 }
473
474 void name(const char * const name) const
475 {
476 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
477
478 const auto status = bt_stream_set_name(this->libObjPtr(), name);
479
480 if (status == BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR) {
481 throw MemoryError {};
482 }
483 }
484
485 void name(const std::string& name) const
486 {
487 this->name(name.data());
488 }
489
490 const char *name() const noexcept
491 {
492 return bt_stream_get_name(this->libObjPtr());
493 }
494
495 template <typename LibValT>
496 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
497 {
498 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
499
500 bt_stream_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
501 }
502
503 UserAttributes userAttributes() const noexcept
504 {
505 return UserAttributes {_Spec::userAttributes(this->libObjPtr())};
506 }
507
508 Shared shared() const noexcept
509 {
510 return Shared::createWithRef(*this);
511 }
512 };
513
514 using Stream = CommonStream<bt_stream>;
515 using ConstStream = CommonStream<const bt_stream>;
516
517 namespace internal {
518
519 struct StreamTypeDescr
520 {
521 using Const = ConstStream;
522 using NonConst = Stream;
523 };
524
525 template <>
526 struct TypeDescr<Stream> : public StreamTypeDescr
527 {
528 };
529
530 template <>
531 struct TypeDescr<ConstStream> : public StreamTypeDescr
532 {
533 };
534
535 } /* namespace internal */
536
537 template <typename LibObjT>
538 typename CommonEvent<LibObjT>::_Stream CommonEvent<LibObjT>::stream() const noexcept
539 {
540 return _Stream {_Spec::stream(this->libObjPtr())};
541 }
542
543 template <typename LibObjT>
544 typename CommonPacket<LibObjT>::_Stream CommonPacket<LibObjT>::stream() const noexcept
545 {
546 return _Stream {_Spec::stream(this->libObjPtr())};
547 }
548
549 namespace internal {
550
551 struct TraceRefFuncs final
552 {
553 static void get(const bt_trace * const libObjPtr) noexcept
554 {
555 bt_trace_get_ref(libObjPtr);
556 }
557
558 static void put(const bt_trace * const libObjPtr) noexcept
559 {
560 bt_trace_put_ref(libObjPtr);
561 }
562 };
563
564 template <typename LibObjT>
565 struct CommonTraceSpec;
566
567 /* Functions specific to mutable traces */
568 template <>
569 struct CommonTraceSpec<bt_trace> final
570 {
571 static bt_trace_class *cls(bt_trace * const libObjPtr) noexcept
572 {
573 return bt_trace_borrow_class(libObjPtr);
574 }
575
576 static bt_stream *streamByIndex(bt_trace * const libObjPtr, const std::uint64_t index) noexcept
577 {
578 return bt_trace_borrow_stream_by_index(libObjPtr, index);
579 }
580
581 static bt_stream *streamById(bt_trace * const libObjPtr, const std::uint64_t id) noexcept
582 {
583 return bt_trace_borrow_stream_by_id(libObjPtr, id);
584 }
585
586 static bt_value *userAttributes(bt_trace * const libObjPtr) noexcept
587 {
588 return bt_trace_borrow_user_attributes(libObjPtr);
589 }
590 };
591
592 /* Functions specific to constant traces */
593 template <>
594 struct CommonTraceSpec<const bt_trace> final
595 {
596 static const bt_trace_class *cls(const bt_trace * const libObjPtr) noexcept
597 {
598 return bt_trace_borrow_class_const(libObjPtr);
599 }
600
601 static const bt_stream *streamByIndex(const bt_trace * const libObjPtr,
602 const std::uint64_t index) noexcept
603 {
604 return bt_trace_borrow_stream_by_index_const(libObjPtr, index);
605 }
606
607 static const bt_stream *streamById(const bt_trace * const libObjPtr,
608 const std::uint64_t id) noexcept
609 {
610 return bt_trace_borrow_stream_by_id_const(libObjPtr, id);
611 }
612
613 static const bt_value *userAttributes(const bt_trace * const libObjPtr) noexcept
614 {
615 return bt_trace_borrow_user_attributes_const(libObjPtr);
616 }
617 };
618
619 } /* namespace internal */
620
621 template <typename LibObjT>
622 class CommonTrace final : public BorrowedObject<LibObjT>
623 {
624 private:
625 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
626 using typename BorrowedObject<LibObjT>::_LibObjPtr;
627 using _Spec = internal::CommonTraceSpec<LibObjT>;
628 using _Stream = internal::DepStream<LibObjT>;
629
630 public:
631 using Shared = SharedObject<CommonTrace, LibObjT, internal::TraceRefFuncs>;
632 using UserAttributes = internal::DepUserAttrs<LibObjT>;
633
634 using Class = internal::DepType<LibObjT, CommonTraceClass<bt_trace_class>,
635 CommonTraceClass<const bt_trace_class>>;
636
637 struct ConstEnvironmentEntry
638 {
639 const char *name;
640 ConstValue value;
641 };
642
643 explicit CommonTrace(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
644 {
645 }
646
647 template <typename OtherLibObjT>
648 CommonTrace(const CommonTrace<OtherLibObjT> trace) noexcept : _ThisBorrowedObject {trace}
649 {
650 }
651
652 template <typename OtherLibObjT>
653 CommonTrace operator=(const CommonTrace<OtherLibObjT> trace) noexcept
654 {
655 _ThisBorrowedObject::operator=(trace);
656 return *this;
657 }
658
659 CommonTrace<const bt_trace> asConst() const noexcept
660 {
661 return CommonTrace<const bt_trace> {*this};
662 }
663
664 Class cls() const noexcept;
665
666 void name(const char * const name) const
667 {
668 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
669
670 const auto status = bt_trace_set_name(this->libObjPtr(), name);
671
672 if (status == BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR) {
673 throw MemoryError {};
674 }
675 }
676
677 void name(const std::string& name) const
678 {
679 this->name(name.data());
680 }
681
682 const char *name() const noexcept
683 {
684 return bt_trace_get_name(this->libObjPtr());
685 }
686
687 void uuid(const bt2c::UuidView& uuid) const noexcept
688 {
689 bt_trace_set_uuid(this->libObjPtr(), uuid.begin());
690 }
691
692 bt2s::optional<bt2c::UuidView> uuid() const noexcept
693 {
694 const auto uuid = bt_trace_get_uuid(this->libObjPtr());
695
696 if (uuid) {
697 return bt2c::UuidView {uuid};
698 }
699
700 return bt2s::nullopt;
701 }
702
703 std::uint64_t length() const noexcept
704 {
705 return bt_trace_get_stream_count(this->libObjPtr());
706 }
707
708 _Stream operator[](const std::uint64_t index) const noexcept
709 {
710 return _Stream {_Spec::streamByIndex(this->libObjPtr(), index)};
711 }
712
713 bt2s::optional<_Stream> streamById(const std::uint64_t id) const noexcept
714 {
715 const auto libObjPtr = _Spec::streamById(this->libObjPtr(), id);
716
717 if (libObjPtr) {
718 return _Stream {libObjPtr};
719 }
720
721 return bt2s::nullopt;
722 }
723
724 void environmentEntry(const char * const name, const std::int64_t val) const
725 {
726 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
727
728 const auto status = bt_trace_set_environment_entry_integer(this->libObjPtr(), name, val);
729
730 if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
731 throw MemoryError {};
732 }
733 }
734
735 void environmentEntry(const std::string& name, const std::int64_t val) const
736 {
737 this->environmentEntry(name.data(), val);
738 }
739
740 void environmentEntry(const char * const name, const char * const val) const
741 {
742 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
743
744 const auto status = bt_trace_set_environment_entry_string(this->libObjPtr(), name, val);
745
746 if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
747 throw MemoryError {};
748 }
749 }
750
751 void environmentEntry(const std::string& name, const char * const val) const
752 {
753 this->environmentEntry(name.data(), val);
754 }
755
756 void environmentEntry(const char * const name, const std::string& val) const
757 {
758 this->environmentEntry(name, val.data());
759 }
760
761 void environmentEntry(const std::string& name, const std::string& val) const
762 {
763 this->environmentEntry(name.data(), val.data());
764 }
765
766 std::uint64_t environmentSize() const noexcept
767 {
768 return bt_trace_get_environment_entry_count(this->libObjPtr());
769 }
770
771 ConstEnvironmentEntry environmentEntry(const std::uint64_t index) const noexcept
772 {
773 const char *name;
774 const bt_value *libObjPtr;
775
776 bt_trace_borrow_environment_entry_by_index_const(this->libObjPtr(), index, &name,
777 &libObjPtr);
778 return ConstEnvironmentEntry {name, ConstValue {libObjPtr}};
779 }
780
781 bt2s::optional<ConstValue> environmentEntry(const char * const name) const noexcept
782 {
783 const auto libObjPtr =
784 bt_trace_borrow_environment_entry_value_by_name_const(this->libObjPtr(), name);
785
786 if (libObjPtr) {
787 return ConstValue {libObjPtr};
788 }
789
790 return bt2s::nullopt;
791 }
792
793 bt2s::optional<ConstValue> environmentEntry(const std::string& name) const noexcept
794 {
795 return this->environmentEntry(name.data());
796 }
797
798 template <typename LibValT>
799 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
800 {
801 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
802
803 bt_trace_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
804 }
805
806 UserAttributes userAttributes() const noexcept
807 {
808 return UserAttributes {_Spec::userAttributes(this->libObjPtr())};
809 }
810
811 Shared shared() const noexcept
812 {
813 return Shared::createWithRef(*this);
814 }
815 };
816
817 using Trace = CommonTrace<bt_trace>;
818 using ConstTrace = CommonTrace<const bt_trace>;
819
820 namespace internal {
821
822 struct TraceTypeDescr
823 {
824 using Const = ConstTrace;
825 using NonConst = Trace;
826 };
827
828 template <>
829 struct TypeDescr<Trace> : public TraceTypeDescr
830 {
831 };
832
833 template <>
834 struct TypeDescr<ConstTrace> : public TraceTypeDescr
835 {
836 };
837
838 } /* namespace internal */
839
840 template <typename LibObjT>
841 typename CommonStream<LibObjT>::_Trace CommonStream<LibObjT>::trace() const noexcept
842 {
843 return _Trace {_Spec::trace(this->libObjPtr())};
844 }
845
846 namespace internal {
847
848 struct EventClassRefFuncs final
849 {
850 static void get(const bt_event_class * const libObjPtr) noexcept
851 {
852 bt_event_class_get_ref(libObjPtr);
853 }
854
855 static void put(const bt_event_class * const libObjPtr) noexcept
856 {
857 bt_event_class_put_ref(libObjPtr);
858 }
859 };
860
861 template <typename LibObjT>
862 struct CommonEventClassSpec;
863
864 /* Functions specific to mutable event classes */
865 template <>
866 struct CommonEventClassSpec<bt_event_class> final
867 {
868 static bt_stream_class *streamClass(bt_event_class * const libObjPtr) noexcept
869 {
870 return bt_event_class_borrow_stream_class(libObjPtr);
871 }
872
873 static bt_field_class *payloadFieldClass(bt_event_class * const libObjPtr) noexcept
874 {
875 return bt_event_class_borrow_payload_field_class(libObjPtr);
876 }
877
878 static bt_field_class *specificContextFieldClass(bt_event_class * const libObjPtr) noexcept
879 {
880 return bt_event_class_borrow_specific_context_field_class(libObjPtr);
881 }
882
883 static bt_value *userAttributes(bt_event_class * const libObjPtr) noexcept
884 {
885 return bt_event_class_borrow_user_attributes(libObjPtr);
886 }
887 };
888
889 /* Functions specific to constant event classes */
890 template <>
891 struct CommonEventClassSpec<const bt_event_class> final
892 {
893 static const bt_stream_class *streamClass(const bt_event_class * const libObjPtr) noexcept
894 {
895 return bt_event_class_borrow_stream_class_const(libObjPtr);
896 }
897
898 static const bt_field_class *payloadFieldClass(const bt_event_class * const libObjPtr) noexcept
899 {
900 return bt_event_class_borrow_payload_field_class_const(libObjPtr);
901 }
902
903 static const bt_field_class *
904 specificContextFieldClass(const bt_event_class * const libObjPtr) noexcept
905 {
906 return bt_event_class_borrow_specific_context_field_class_const(libObjPtr);
907 }
908
909 static const bt_value *userAttributes(const bt_event_class * const libObjPtr) noexcept
910 {
911 return bt_event_class_borrow_user_attributes_const(libObjPtr);
912 }
913 };
914
915 template <typename LibObjT>
916 using DepStructFc = DepType<LibObjT, StructureFieldClass, ConstStructureFieldClass>;
917
918 } /* namespace internal */
919
920 template <typename LibObjT>
921 class CommonEventClass final : public BorrowedObject<LibObjT>
922 {
923 private:
924 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
925 using typename BorrowedObject<LibObjT>::_LibObjPtr;
926 using _Spec = internal::CommonEventClassSpec<LibObjT>;
927 using _StructureFieldClass = internal::DepStructFc<LibObjT>;
928
929 using _StreamClass = internal::DepType<LibObjT, CommonStreamClass<bt_stream_class>,
930 CommonStreamClass<const bt_stream_class>>;
931
932 public:
933 using Shared = SharedObject<CommonEventClass, LibObjT, internal::EventClassRefFuncs>;
934 using UserAttributes = internal::DepUserAttrs<LibObjT>;
935
936 enum class LogLevel
937 {
938 EMERGENCY = BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY,
939 ALERT = BT_EVENT_CLASS_LOG_LEVEL_ALERT,
940 CRITICAL = BT_EVENT_CLASS_LOG_LEVEL_CRITICAL,
941 ERR = BT_EVENT_CLASS_LOG_LEVEL_ERROR,
942 WARNING = BT_EVENT_CLASS_LOG_LEVEL_WARNING,
943 NOTICE = BT_EVENT_CLASS_LOG_LEVEL_NOTICE,
944 INFO = BT_EVENT_CLASS_LOG_LEVEL_INFO,
945 DEBUG_SYSTEM = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM,
946 DEBUG_PROGRAM = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM,
947 DEBUG_PROC = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS,
948 DEBUG_MODULE = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE,
949 DEBUG_UNIT = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT,
950 DEBUG_FUNCTION = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION,
951 DEBUG_LINE = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE,
952 DEBUG = BT_EVENT_CLASS_LOG_LEVEL_DEBUG,
953 };
954
955 explicit CommonEventClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
956 {
957 }
958
959 template <typename OtherLibObjT>
960 CommonEventClass(const CommonEventClass<OtherLibObjT> eventClass) noexcept :
961 _ThisBorrowedObject {eventClass}
962 {
963 }
964
965 template <typename OtherLibObjT>
966 CommonEventClass operator=(const CommonEventClass<OtherLibObjT> eventClass) noexcept
967 {
968 _ThisBorrowedObject::operator=(eventClass);
969 return *this;
970 }
971
972 CommonEventClass<const bt_event_class> asConst() const noexcept
973 {
974 return CommonEventClass<const bt_event_class> {*this};
975 }
976
977 _StreamClass streamClass() const noexcept;
978
979 std::uint64_t id() const noexcept
980 {
981 return bt_event_class_get_id(this->libObjPtr());
982 }
983
984 void name(const char * const name) const
985 {
986 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
987
988 const auto status = bt_event_class_set_name(this->libObjPtr(), name);
989
990 if (status == BT_EVENT_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
991 throw MemoryError {};
992 }
993 }
994
995 void name(const std::string& name) const
996 {
997 this->name(name.data());
998 }
999
1000 const char *name() const noexcept
1001 {
1002 return bt_event_class_get_name(this->libObjPtr());
1003 }
1004
1005 void logLevel(const LogLevel logLevel) const noexcept
1006 {
1007 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
1008
1009 bt_event_class_set_log_level(this->libObjPtr(),
1010 static_cast<bt_event_class_log_level>(logLevel));
1011 }
1012
1013 bt2s::optional<LogLevel> logLevel() const noexcept
1014 {
1015 bt_event_class_log_level libLogLevel;
1016 const auto avail = bt_event_class_get_log_level(this->libObjPtr(), &libLogLevel);
1017
1018 if (avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
1019 return static_cast<LogLevel>(libLogLevel);
1020 }
1021
1022 return bt2s::nullopt;
1023 }
1024
1025 void emfUri(const char * const emfUri) const
1026 {
1027 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
1028
1029 const auto status = bt_event_class_set_emf_uri(this->libObjPtr(), emfUri);
1030
1031 if (status == BT_EVENT_CLASS_SET_EMF_URI_STATUS_MEMORY_ERROR) {
1032 throw MemoryError {};
1033 }
1034 }
1035
1036 void emfUri(const std::string& emfUri) const
1037 {
1038 this->emfUri(emfUri.data());
1039 }
1040
1041 const char *emfUri() const noexcept
1042 {
1043 return bt_event_class_get_emf_uri(this->libObjPtr());
1044 }
1045
1046 void payloadFieldClass(const StructureFieldClass fc) const
1047 {
1048 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
1049
1050 const auto status =
1051 bt_event_class_set_payload_field_class(this->libObjPtr(), fc.libObjPtr());
1052
1053 if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
1054 throw MemoryError {};
1055 }
1056 }
1057
1058 bt2s::optional<_StructureFieldClass> payloadFieldClass() const noexcept
1059 {
1060 const auto libObjPtr = _Spec::payloadFieldClass(this->libObjPtr());
1061
1062 if (libObjPtr) {
1063 return _StructureFieldClass {libObjPtr};
1064 }
1065
1066 return bt2s::nullopt;
1067 }
1068
1069 void specificContextFieldClass(const StructureFieldClass fc) const
1070 {
1071 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
1072
1073 const auto status =
1074 bt_event_class_set_specific_context_field_class(this->libObjPtr(), fc.libObjPtr());
1075
1076 if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
1077 throw MemoryError {};
1078 }
1079 }
1080
1081 bt2s::optional<_StructureFieldClass> specificContextFieldClass() const noexcept
1082 {
1083 const auto libObjPtr = _Spec::specificContextFieldClass(this->libObjPtr());
1084
1085 if (libObjPtr) {
1086 return _StructureFieldClass {libObjPtr};
1087 }
1088
1089 return bt2s::nullopt;
1090 }
1091
1092 template <typename LibValT>
1093 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
1094 {
1095 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
1096
1097 bt_event_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
1098 }
1099
1100 UserAttributes userAttributes() const noexcept
1101 {
1102 return UserAttributes {_Spec::userAttributes(this->libObjPtr())};
1103 }
1104
1105 Shared shared() const noexcept
1106 {
1107 return Shared::createWithRef(*this);
1108 }
1109 };
1110
1111 using EventClass = CommonEventClass<bt_event_class>;
1112 using ConstEventClass = CommonEventClass<const bt_event_class>;
1113
1114 namespace internal {
1115
1116 struct EventClassTypeDescr
1117 {
1118 using Const = ConstEventClass;
1119 using NonConst = EventClass;
1120 };
1121
1122 template <>
1123 struct TypeDescr<EventClass> : public EventClassTypeDescr
1124 {
1125 };
1126
1127 template <>
1128 struct TypeDescr<ConstEventClass> : public EventClassTypeDescr
1129 {
1130 };
1131
1132 } /* namespace internal */
1133
1134 template <typename LibObjT>
1135 typename CommonEvent<LibObjT>::Class CommonEvent<LibObjT>::cls() const noexcept
1136 {
1137 return Class {_Spec::cls(this->libObjPtr())};
1138 }
1139
1140 namespace internal {
1141
1142 struct StreamClassRefFuncs final
1143 {
1144 static void get(const bt_stream_class * const libObjPtr) noexcept
1145 {
1146 bt_stream_class_get_ref(libObjPtr);
1147 }
1148
1149 static void put(const bt_stream_class * const libObjPtr) noexcept
1150 {
1151 bt_stream_class_put_ref(libObjPtr);
1152 }
1153 };
1154
1155 template <typename LibObjT>
1156 struct CommonStreamClassSpec;
1157
1158 /* Functions specific to mutable stream classes */
1159 template <>
1160 struct CommonStreamClassSpec<bt_stream_class> final
1161 {
1162 static bt_trace_class *traceClass(bt_stream_class * const libObjPtr) noexcept
1163 {
1164 return bt_stream_class_borrow_trace_class(libObjPtr);
1165 }
1166
1167 static bt_event_class *eventClassByIndex(bt_stream_class * const libObjPtr,
1168 const std::uint64_t index) noexcept
1169 {
1170 return bt_stream_class_borrow_event_class_by_index(libObjPtr, index);
1171 }
1172
1173 static bt_event_class *eventClassById(bt_stream_class * const libObjPtr,
1174 const std::uint64_t id) noexcept
1175 {
1176 return bt_stream_class_borrow_event_class_by_id(libObjPtr, id);
1177 }
1178
1179 static bt_clock_class *defaultClockClass(bt_stream_class * const libObjPtr) noexcept
1180 {
1181 return bt_stream_class_borrow_default_clock_class(libObjPtr);
1182 }
1183
1184 static bt_field_class *packetContextFieldClass(bt_stream_class * const libObjPtr) noexcept
1185 {
1186 return bt_stream_class_borrow_packet_context_field_class(libObjPtr);
1187 }
1188
1189 static bt_field_class *eventCommonContextFieldClass(bt_stream_class * const libObjPtr) noexcept
1190 {
1191 return bt_stream_class_borrow_event_common_context_field_class(libObjPtr);
1192 }
1193
1194 static bt_value *userAttributes(bt_stream_class * const libObjPtr) noexcept
1195 {
1196 return bt_stream_class_borrow_user_attributes(libObjPtr);
1197 }
1198 };
1199
1200 /* Functions specific to constant stream classes */
1201 template <>
1202 struct CommonStreamClassSpec<const bt_stream_class> final
1203 {
1204 static const bt_trace_class *traceClass(const bt_stream_class * const libObjPtr) noexcept
1205 {
1206 return bt_stream_class_borrow_trace_class_const(libObjPtr);
1207 }
1208
1209 static const bt_event_class *eventClassByIndex(const bt_stream_class * const libObjPtr,
1210 const std::uint64_t index) noexcept
1211 {
1212 return bt_stream_class_borrow_event_class_by_index_const(libObjPtr, index);
1213 }
1214
1215 static const bt_event_class *eventClassById(const bt_stream_class * const libObjPtr,
1216 const std::uint64_t id) noexcept
1217 {
1218 return bt_stream_class_borrow_event_class_by_id_const(libObjPtr, id);
1219 }
1220
1221 static const bt_clock_class *defaultClockClass(const bt_stream_class * const libObjPtr) noexcept
1222 {
1223 return bt_stream_class_borrow_default_clock_class_const(libObjPtr);
1224 }
1225
1226 static const bt_field_class *
1227 packetContextFieldClass(const bt_stream_class * const libObjPtr) noexcept
1228 {
1229 return bt_stream_class_borrow_packet_context_field_class_const(libObjPtr);
1230 }
1231
1232 static const bt_field_class *
1233 eventCommonContextFieldClass(const bt_stream_class * const libObjPtr) noexcept
1234 {
1235 return bt_stream_class_borrow_event_common_context_field_class_const(libObjPtr);
1236 }
1237
1238 static const bt_value *userAttributes(const bt_stream_class * const libObjPtr) noexcept
1239 {
1240 return bt_stream_class_borrow_user_attributes_const(libObjPtr);
1241 }
1242 };
1243
1244 } /* namespace internal */
1245
1246 template <typename LibObjT>
1247 class CommonStreamClass final : public BorrowedObject<LibObjT>
1248 {
1249 private:
1250 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
1251 using typename BorrowedObject<LibObjT>::_LibObjPtr;
1252 using _Spec = internal::CommonStreamClassSpec<LibObjT>;
1253 using _StructureFieldClass = internal::DepStructFc<LibObjT>;
1254
1255 using _TraceClass = internal::DepType<LibObjT, CommonTraceClass<bt_trace_class>,
1256 CommonTraceClass<const bt_trace_class>>;
1257
1258 using _EventClass = internal::DepType<LibObjT, CommonEventClass<bt_event_class>,
1259 CommonEventClass<const bt_event_class>>;
1260
1261 using _ClockClass = internal::DepType<LibObjT, ClockClass, ConstClockClass>;
1262
1263 public:
1264 using Shared = SharedObject<CommonStreamClass, LibObjT, internal::StreamClassRefFuncs>;
1265 using UserAttributes = internal::DepUserAttrs<LibObjT>;
1266
1267 explicit CommonStreamClass(const _LibObjPtr libObjPtr) noexcept :
1268 _ThisBorrowedObject {libObjPtr}
1269 {
1270 }
1271
1272 template <typename OtherLibObjT>
1273 CommonStreamClass(const CommonStreamClass<OtherLibObjT> streamClass) noexcept :
1274 _ThisBorrowedObject {streamClass}
1275 {
1276 }
1277
1278 template <typename OtherLibObjT>
1279 CommonStreamClass operator=(const CommonStreamClass<OtherLibObjT> streamClass) noexcept
1280 {
1281 _ThisBorrowedObject::operator=(streamClass);
1282 return *this;
1283 }
1284
1285 CommonStreamClass<const bt_stream_class> asConst() const noexcept
1286 {
1287 return CommonStreamClass<const bt_stream_class> {*this};
1288 }
1289
1290 Stream::Shared instantiate(const Trace trace) const
1291 {
1292 static_assert(!std::is_const<LibObjT>::value,
1293 "Not available with `bt2::ConstStreamClass`.");
1294
1295 const auto libObjPtr = bt_stream_create(this->libObjPtr(), trace.libObjPtr());
1296
1297 internal::validateCreatedObjPtr(libObjPtr);
1298 return Stream::Shared::createWithoutRef(libObjPtr);
1299 }
1300
1301 Stream::Shared instantiate(const Trace trace, const std::uint64_t id) const
1302 {
1303 static_assert(!std::is_const<LibObjT>::value,
1304 "Not available with `bt2::ConstStreamClass`.");
1305
1306 const auto libObjPtr = bt_stream_create_with_id(this->libObjPtr(), trace.libObjPtr(), id);
1307
1308 internal::validateCreatedObjPtr(libObjPtr);
1309 return Stream::Shared::createWithoutRef(libObjPtr);
1310 }
1311
1312 EventClass::Shared createEventClass() const
1313 {
1314 static_assert(!std::is_const<LibObjT>::value,
1315 "Not available with `bt2::ConstStreamClass`.");
1316
1317 const auto libObjPtr = bt_event_class_create(this->libObjPtr());
1318
1319 internal::validateCreatedObjPtr(libObjPtr);
1320 return EventClass::Shared::createWithoutRef(libObjPtr);
1321 }
1322
1323 EventClass::Shared createEventClass(const std::uint64_t id) const
1324 {
1325 static_assert(!std::is_const<LibObjT>::value,
1326 "Not available with `bt2::ConstStreamClass`.");
1327
1328 const auto libObjPtr = bt_event_class_create_with_id(this->libObjPtr(), id);
1329
1330 internal::validateCreatedObjPtr(libObjPtr);
1331 return EventClass::Shared::createWithoutRef(libObjPtr);
1332 }
1333
1334 _TraceClass traceClass() const noexcept;
1335
1336 std::uint64_t id() const noexcept
1337 {
1338 return bt_stream_class_get_id(this->libObjPtr());
1339 }
1340
1341 void name(const char * const name) const
1342 {
1343 static_assert(!std::is_const<LibObjT>::value,
1344 "Not available with `bt2::ConstStreamClass`.");
1345
1346 const auto status = bt_stream_class_set_name(this->libObjPtr(), name);
1347
1348 if (status == BT_STREAM_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
1349 throw MemoryError {};
1350 }
1351 }
1352
1353 void name(const std::string& name) const
1354 {
1355 this->name(name.data());
1356 }
1357
1358 const char *name() const noexcept
1359 {
1360 return bt_stream_class_get_name(this->libObjPtr());
1361 }
1362
1363 void assignsAutomaticEventClassId(const bool val) const noexcept
1364 {
1365 static_assert(!std::is_const<LibObjT>::value,
1366 "Not available with `bt2::ConstStreamClass`.");
1367
1368 bt_stream_class_set_assigns_automatic_event_class_id(this->libObjPtr(),
1369 static_cast<bt_bool>(val));
1370 }
1371
1372 bool assignsAutomaticEventClassId() const noexcept
1373 {
1374 return static_cast<bool>(
1375 bt_stream_class_assigns_automatic_event_class_id(this->libObjPtr()));
1376 }
1377
1378 void assignsAutomaticStreamId(const bool val) const noexcept
1379 {
1380 static_assert(!std::is_const<LibObjT>::value,
1381 "Not available with `bt2::ConstStreamClass`.");
1382
1383 bt_stream_class_set_assigns_automatic_stream_id(this->libObjPtr(),
1384 static_cast<bt_bool>(val));
1385 }
1386
1387 bool assignsAutomaticStreamId() const noexcept
1388 {
1389 return static_cast<bool>(bt_stream_class_assigns_automatic_stream_id(this->libObjPtr()));
1390 }
1391
1392 void supportsPackets(const bool supportsPackets, const bool withBeginningDefaultClkSnapshot,
1393 const bool withEndDefaultClkSnapshot) const noexcept
1394 {
1395 static_assert(!std::is_const<LibObjT>::value,
1396 "Not available with `bt2::ConstStreamClass`.");
1397
1398 bt_stream_class_set_supports_packets(this->libObjPtr(),
1399 static_cast<bt_bool>(supportsPackets),
1400 static_cast<bt_bool>(withBeginningDefaultClkSnapshot),
1401 static_cast<bt_bool>(withEndDefaultClkSnapshot));
1402 }
1403
1404 bool supportsPackets() const noexcept
1405 {
1406 return static_cast<bool>(bt_stream_class_supports_packets(this->libObjPtr()));
1407 }
1408
1409 bool packetsHaveBeginningClockSnapshot() const noexcept
1410 {
1411 return static_cast<bool>(
1412 bt_stream_class_packets_have_beginning_default_clock_snapshot(this->libObjPtr()));
1413 }
1414
1415 bool packetsHaveEndClockSnapshot() const noexcept
1416 {
1417 return static_cast<bool>(
1418 bt_stream_class_packets_have_end_default_clock_snapshot(this->libObjPtr()));
1419 }
1420
1421 void supportsDiscardedEvents(const bool supportsDiscardedEvents,
1422 const bool withDefaultClkSnapshots) const noexcept
1423 {
1424 static_assert(!std::is_const<LibObjT>::value,
1425 "Not available with `bt2::ConstStreamClass`.");
1426
1427 bt_stream_class_set_supports_discarded_events(
1428 this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedEvents),
1429 static_cast<bt_bool>(withDefaultClkSnapshots));
1430 }
1431
1432 bool supportsDiscardedEvents() const noexcept
1433 {
1434 return static_cast<bool>(bt_stream_class_supports_discarded_events(this->libObjPtr()));
1435 }
1436
1437 bool discardedEventsHaveDefaultClockSnapshots() const noexcept
1438 {
1439 return static_cast<bool>(
1440 bt_stream_class_discarded_events_have_default_clock_snapshots(this->libObjPtr()));
1441 }
1442
1443 void supportsDiscardedPackets(const bool supportsDiscardedPackets,
1444 const bool withDefaultClkSnapshots) const noexcept
1445 {
1446 static_assert(!std::is_const<LibObjT>::value,
1447 "Not available with `bt2::ConstStreamClass`.");
1448
1449 bt_stream_class_set_supports_discarded_packets(
1450 this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedPackets),
1451 static_cast<bt_bool>(withDefaultClkSnapshots));
1452 }
1453
1454 bool supportsDiscardedPackets() const noexcept
1455 {
1456 return static_cast<bool>(bt_stream_class_supports_discarded_packets(this->libObjPtr()));
1457 }
1458
1459 bool discardedPacketsHaveDefaultClockSnapshots() const noexcept
1460 {
1461 return static_cast<bool>(
1462 bt_stream_class_discarded_packets_have_default_clock_snapshots(this->libObjPtr()));
1463 }
1464
1465 void defaultClockClass(const ClockClass clkCls) const
1466 {
1467 static_assert(!std::is_const<LibObjT>::value,
1468 "Not available with `bt2::ConstStreamClass`.");
1469
1470 const auto status =
1471 bt_stream_class_set_default_clock_class(this->libObjPtr(), clkCls.libObjPtr());
1472
1473 BT_ASSERT(status == BT_STREAM_CLASS_SET_DEFAULT_CLOCK_CLASS_STATUS_OK);
1474 }
1475
1476 bt2s::optional<_ClockClass> defaultClockClass() const noexcept
1477 {
1478 const auto libObjPtr = _Spec::defaultClockClass(this->libObjPtr());
1479
1480 if (libObjPtr) {
1481 return _ClockClass {libObjPtr};
1482 }
1483
1484 return bt2s::nullopt;
1485 }
1486
1487 std::uint64_t length() const noexcept
1488 {
1489 return bt_stream_class_get_event_class_count(this->libObjPtr());
1490 }
1491
1492 _EventClass operator[](const std::uint64_t index) const noexcept
1493 {
1494 return _EventClass {_Spec::eventClassByIndex(this->libObjPtr(), index)};
1495 }
1496
1497 bt2s::optional<_EventClass> eventClassById(const std::uint64_t id) const noexcept
1498 {
1499 const auto libObjPtr = _Spec::eventClassById(this->libObjPtr(), id);
1500
1501 if (libObjPtr) {
1502 return _EventClass {libObjPtr};
1503 }
1504
1505 return bt2s::nullopt;
1506 }
1507
1508 void packetContextFieldClass(const StructureFieldClass fc) const
1509 {
1510 static_assert(!std::is_const<LibObjT>::value,
1511 "Not available with `bt2::ConstStreamClass`.");
1512
1513 const auto status =
1514 bt_stream_class_set_packet_context_field_class(this->libObjPtr(), fc.libObjPtr());
1515
1516 if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
1517 throw MemoryError {};
1518 }
1519 }
1520
1521 bt2s::optional<_StructureFieldClass> packetContextFieldClass() const noexcept
1522 {
1523 const auto libObjPtr = _Spec::packetContextFieldClass(this->libObjPtr());
1524
1525 if (libObjPtr) {
1526 return _StructureFieldClass {libObjPtr};
1527 }
1528
1529 return bt2s::nullopt;
1530 }
1531
1532 void eventCommonContextFieldClass(const StructureFieldClass fc) const
1533 {
1534 static_assert(!std::is_const<LibObjT>::value,
1535 "Not available with `bt2::ConstStreamClass`.");
1536
1537 const auto status =
1538 bt_stream_class_set_event_common_context_field_class(this->libObjPtr(), fc.libObjPtr());
1539
1540 if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
1541 throw MemoryError {};
1542 }
1543 }
1544
1545 bt2s::optional<_StructureFieldClass> eventCommonContextFieldClass() const noexcept
1546 {
1547 const auto libObjPtr = _Spec::eventCommonContextFieldClass(this->libObjPtr());
1548
1549 if (libObjPtr) {
1550 return _StructureFieldClass {libObjPtr};
1551 }
1552
1553 return bt2s::nullopt;
1554 }
1555
1556 template <typename LibValT>
1557 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
1558 {
1559 static_assert(!std::is_const<LibObjT>::value,
1560 "Not available with `bt2::ConstStreamClass`.");
1561
1562 bt_stream_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
1563 }
1564
1565 UserAttributes userAttributes() const noexcept
1566 {
1567 return UserAttributes {_Spec::userAttributes(this->libObjPtr())};
1568 }
1569
1570 Shared shared() const noexcept
1571 {
1572 return Shared::createWithRef(*this);
1573 }
1574 };
1575
1576 using StreamClass = CommonStreamClass<bt_stream_class>;
1577 using ConstStreamClass = CommonStreamClass<const bt_stream_class>;
1578
1579 namespace internal {
1580
1581 struct StreamClassTypeDescr
1582 {
1583 using Const = ConstStreamClass;
1584 using NonConst = StreamClass;
1585 };
1586
1587 template <>
1588 struct TypeDescr<StreamClass> : public StreamClassTypeDescr
1589 {
1590 };
1591
1592 template <>
1593 struct TypeDescr<ConstStreamClass> : public StreamClassTypeDescr
1594 {
1595 };
1596
1597 } /* namespace internal */
1598
1599 template <typename LibObjT>
1600 typename CommonEventClass<LibObjT>::_StreamClass
1601 CommonEventClass<LibObjT>::streamClass() const noexcept
1602 {
1603 return _StreamClass {_Spec::streamClass(this->libObjPtr())};
1604 }
1605
1606 template <typename LibObjT>
1607 typename CommonStream<LibObjT>::Class CommonStream<LibObjT>::cls() const noexcept
1608 {
1609 return Class {_Spec::cls(this->libObjPtr())};
1610 }
1611
1612 namespace internal {
1613
1614 struct TraceClassRefFuncs final
1615 {
1616 static void get(const bt_trace_class * const libObjPtr) noexcept
1617 {
1618 bt_trace_class_get_ref(libObjPtr);
1619 }
1620
1621 static void put(const bt_trace_class * const libObjPtr) noexcept
1622 {
1623 bt_trace_class_put_ref(libObjPtr);
1624 }
1625 };
1626
1627 template <typename LibObjT>
1628 struct CommonTraceClassSpec;
1629
1630 /* Functions specific to mutable stream classes */
1631 template <>
1632 struct CommonTraceClassSpec<bt_trace_class> final
1633 {
1634 static bt_stream_class *streamClassByIndex(bt_trace_class * const libObjPtr,
1635 const std::uint64_t index) noexcept
1636 {
1637 return bt_trace_class_borrow_stream_class_by_index(libObjPtr, index);
1638 }
1639
1640 static bt_stream_class *streamClassById(bt_trace_class * const libObjPtr,
1641 const std::uint64_t id) noexcept
1642 {
1643 return bt_trace_class_borrow_stream_class_by_id(libObjPtr, id);
1644 }
1645
1646 static bt_value *userAttributes(bt_trace_class * const libObjPtr) noexcept
1647 {
1648 return bt_trace_class_borrow_user_attributes(libObjPtr);
1649 }
1650 };
1651
1652 /* Functions specific to constant stream classes */
1653 template <>
1654 struct CommonTraceClassSpec<const bt_trace_class> final
1655 {
1656 static const bt_stream_class *streamClassByIndex(const bt_trace_class * const libObjPtr,
1657 const std::uint64_t index) noexcept
1658 {
1659 return bt_trace_class_borrow_stream_class_by_index_const(libObjPtr, index);
1660 }
1661
1662 static const bt_stream_class *streamClassById(const bt_trace_class * const libObjPtr,
1663 const std::uint64_t id) noexcept
1664 {
1665 return bt_trace_class_borrow_stream_class_by_id_const(libObjPtr, id);
1666 }
1667
1668 static const bt_value *userAttributes(const bt_trace_class * const libObjPtr) noexcept
1669 {
1670 return bt_trace_class_borrow_user_attributes_const(libObjPtr);
1671 }
1672 };
1673
1674 } /* namespace internal */
1675
1676 template <typename LibObjT>
1677 class CommonTraceClass final : public BorrowedObject<LibObjT>
1678 {
1679 private:
1680 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
1681 using typename BorrowedObject<LibObjT>::_LibObjPtr;
1682 using _Spec = internal::CommonTraceClassSpec<LibObjT>;
1683
1684 using _StreamClass = internal::DepType<LibObjT, CommonStreamClass<bt_stream_class>,
1685 CommonStreamClass<const bt_stream_class>>;
1686
1687 public:
1688 using Shared = SharedObject<CommonTraceClass, LibObjT, internal::TraceClassRefFuncs>;
1689 using UserAttributes = internal::DepUserAttrs<LibObjT>;
1690
1691 explicit CommonTraceClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
1692 {
1693 }
1694
1695 template <typename OtherLibObjT>
1696 CommonTraceClass(const CommonTraceClass<OtherLibObjT> traceClass) noexcept :
1697 _ThisBorrowedObject {traceClass}
1698 {
1699 }
1700
1701 template <typename OtherLibObjT>
1702 CommonTraceClass operator=(const CommonTraceClass<OtherLibObjT> traceClass) noexcept
1703 {
1704 _ThisBorrowedObject::operator=(traceClass);
1705 return *this;
1706 }
1707
1708 CommonTraceClass<const bt_trace_class> asConst() const noexcept
1709 {
1710 return CommonTraceClass<const bt_trace_class> {*this};
1711 }
1712
1713 Trace::Shared instantiate() const
1714 {
1715 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1716
1717 const auto libObjPtr = bt_trace_create(this->libObjPtr());
1718
1719 internal::validateCreatedObjPtr(libObjPtr);
1720 return Trace::Shared::createWithoutRef(libObjPtr);
1721 }
1722
1723 StreamClass::Shared createStreamClass() const
1724 {
1725 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1726
1727 const auto libObjPtr = bt_stream_class_create(this->libObjPtr());
1728
1729 internal::validateCreatedObjPtr(libObjPtr);
1730 return StreamClass::Shared::createWithoutRef(libObjPtr);
1731 }
1732
1733 StreamClass::Shared createStreamClass(const std::uint64_t id) const
1734 {
1735 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1736
1737 const auto libObjPtr = bt_stream_class_create_with_id(this->libObjPtr(), id);
1738
1739 internal::validateCreatedObjPtr(libObjPtr);
1740 return StreamClass::Shared::createWithoutRef(libObjPtr);
1741 }
1742
1743 FieldClass::Shared createBoolFieldClass() const
1744 {
1745 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1746
1747 const auto libObjPtr = bt_field_class_bool_create(this->libObjPtr());
1748
1749 internal::validateCreatedObjPtr(libObjPtr);
1750 return FieldClass::Shared::createWithoutRef(libObjPtr);
1751 }
1752
1753 BitArrayFieldClass::Shared createBitArrayFieldClass(const std::uint64_t length) const
1754 {
1755 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1756
1757 const auto libObjPtr = bt_field_class_bit_array_create(this->libObjPtr(), length);
1758
1759 internal::validateCreatedObjPtr(libObjPtr);
1760 return BitArrayFieldClass::Shared::createWithoutRef(libObjPtr);
1761 }
1762
1763 IntegerFieldClass::Shared createUnsignedIntegerFieldClass() const
1764 {
1765 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1766
1767 const auto libObjPtr = bt_field_class_integer_unsigned_create(this->libObjPtr());
1768
1769 internal::validateCreatedObjPtr(libObjPtr);
1770 return IntegerFieldClass::Shared::createWithoutRef(libObjPtr);
1771 }
1772
1773 IntegerFieldClass::Shared createSignedIntegerFieldClass() const
1774 {
1775 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1776
1777 const auto libObjPtr = bt_field_class_integer_signed_create(this->libObjPtr());
1778
1779 internal::validateCreatedObjPtr(libObjPtr);
1780 return IntegerFieldClass::Shared::createWithoutRef(libObjPtr);
1781 }
1782
1783 UnsignedEnumerationFieldClass::Shared createUnsignedEnumerationFieldClass() const
1784 {
1785 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1786
1787 const auto libObjPtr = bt_field_class_enumeration_unsigned_create(this->libObjPtr());
1788
1789 internal::validateCreatedObjPtr(libObjPtr);
1790 return UnsignedEnumerationFieldClass::Shared::createWithoutRef(libObjPtr);
1791 }
1792
1793 SignedEnumerationFieldClass::Shared createSignedEnumerationFieldClass() const
1794 {
1795 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1796
1797 const auto libObjPtr = bt_field_class_enumeration_signed_create(this->libObjPtr());
1798
1799 internal::validateCreatedObjPtr(libObjPtr);
1800 return SignedEnumerationFieldClass::Shared::createWithoutRef(libObjPtr);
1801 }
1802
1803 FieldClass::Shared createSinglePrecisionRealFieldClass() const
1804 {
1805 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1806
1807 const auto libObjPtr = bt_field_class_real_single_precision_create(this->libObjPtr());
1808
1809 internal::validateCreatedObjPtr(libObjPtr);
1810 return FieldClass::Shared::createWithoutRef(libObjPtr);
1811 }
1812
1813 FieldClass::Shared createDoublePrecisionRealFieldClass() const
1814 {
1815 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1816
1817 const auto libObjPtr = bt_field_class_real_double_precision_create(this->libObjPtr());
1818
1819 internal::validateCreatedObjPtr(libObjPtr);
1820 return FieldClass::Shared::createWithoutRef(libObjPtr);
1821 }
1822
1823 FieldClass::Shared createStringFieldClass() const
1824 {
1825 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1826
1827 const auto libObjPtr = bt_field_class_string_create(this->libObjPtr());
1828
1829 internal::validateCreatedObjPtr(libObjPtr);
1830 return FieldClass::Shared::createWithoutRef(libObjPtr);
1831 }
1832
1833 StaticArrayFieldClass::Shared createStaticArrayFieldClass(const FieldClass elementFieldClass,
1834 const std::uint64_t length) const
1835 {
1836 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1837
1838 const auto libObjPtr = bt_field_class_array_static_create(
1839 this->libObjPtr(), elementFieldClass.libObjPtr(), length);
1840
1841 internal::validateCreatedObjPtr(libObjPtr);
1842 return StaticArrayFieldClass::Shared::createWithoutRef(libObjPtr);
1843 }
1844
1845 ArrayFieldClass::Shared createDynamicArrayFieldClass(const FieldClass elementFieldClass) const
1846 {
1847 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1848
1849 const auto libObjPtr = bt_field_class_array_dynamic_create(
1850 this->libObjPtr(), elementFieldClass.libObjPtr(), nullptr);
1851
1852 internal::validateCreatedObjPtr(libObjPtr);
1853 return ArrayFieldClass::Shared::createWithoutRef(libObjPtr);
1854 }
1855
1856 DynamicArrayWithLengthFieldClass::Shared
1857 createDynamicArrayFieldClass(const FieldClass elementFieldClass,
1858 const IntegerFieldClass lengthFieldClass) const
1859 {
1860 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1861
1862 const auto libObjPtr = bt_field_class_array_dynamic_create(
1863 this->libObjPtr(), elementFieldClass.libObjPtr(), lengthFieldClass.libObjPtr());
1864
1865 internal::validateCreatedObjPtr(libObjPtr);
1866 return DynamicArrayWithLengthFieldClass::Shared::createWithoutRef(libObjPtr);
1867 }
1868
1869 StructureFieldClass::Shared createStructureFieldClass() const
1870 {
1871 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1872
1873 const auto libObjPtr = bt_field_class_structure_create(this->libObjPtr());
1874
1875 internal::validateCreatedObjPtr(libObjPtr);
1876 return StructureFieldClass::Shared::createWithoutRef(libObjPtr);
1877 }
1878
1879 OptionFieldClass::Shared createOptionFieldClass(const FieldClass optionalFieldClass) const
1880 {
1881 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1882
1883 const auto libObjPtr = bt_field_class_option_without_selector_create(
1884 this->libObjPtr(), optionalFieldClass.libObjPtr());
1885
1886 internal::validateCreatedObjPtr(libObjPtr);
1887 return OptionFieldClass::Shared::createWithoutRef(libObjPtr);
1888 }
1889
1890 OptionWithBoolSelectorFieldClass::Shared
1891 createOptionWithBoolSelectorFieldClass(const FieldClass optionalFieldClass,
1892 const FieldClass selectorFieldClass) const
1893 {
1894 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1895
1896 const auto libObjPtr = bt_field_class_option_with_selector_field_bool_create(
1897 this->libObjPtr(), optionalFieldClass.libObjPtr(), selectorFieldClass.libObjPtr());
1898
1899 internal::validateCreatedObjPtr(libObjPtr);
1900 return OptionWithBoolSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
1901 }
1902
1903 OptionWithUnsignedIntegerSelectorFieldClass::Shared
1904 createOptionWithUnsignedIntegerSelectorFieldClass(
1905 const FieldClass optionalFieldClass, const IntegerFieldClass selectorFieldClass,
1906 const ConstUnsignedIntegerRangeSet ranges) const
1907 {
1908 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1909
1910 const auto libObjPtr = bt_field_class_option_with_selector_field_integer_unsigned_create(
1911 this->libObjPtr(), optionalFieldClass.libObjPtr(), selectorFieldClass.libObjPtr(),
1912 ranges.libObjPtr());
1913
1914 internal::validateCreatedObjPtr(libObjPtr);
1915 return OptionWithUnsignedIntegerSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
1916 }
1917
1918 OptionWithSignedIntegerSelectorFieldClass::Shared
1919 createOptionWithSignedIntegerSelectorFieldClass(const FieldClass optionalFieldClass,
1920 const IntegerFieldClass selectorFieldClass,
1921 const ConstSignedIntegerRangeSet ranges) const
1922 {
1923 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1924
1925 const auto libObjPtr = bt_field_class_option_with_selector_field_integer_signed_create(
1926 this->libObjPtr(), optionalFieldClass.libObjPtr(), selectorFieldClass.libObjPtr(),
1927 ranges.libObjPtr());
1928
1929 internal::validateCreatedObjPtr(libObjPtr);
1930 return OptionWithSignedIntegerSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
1931 }
1932
1933 VariantWithoutSelectorFieldClass::Shared createVariantFieldClass() const
1934 {
1935 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1936
1937 const auto libObjPtr = bt_field_class_variant_create(this->libObjPtr(), nullptr);
1938
1939 internal::validateCreatedObjPtr(libObjPtr);
1940 return VariantWithoutSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
1941 }
1942
1943 VariantWithUnsignedIntegerSelectorFieldClass::Shared
1944 createVariantWithUnsignedIntegerSelectorFieldClass(
1945 const IntegerFieldClass selectorFieldClass) const
1946 {
1947 return this->_createVariantWithIntegerSelectorFieldClass<
1948 VariantWithUnsignedIntegerSelectorFieldClass>(selectorFieldClass);
1949 }
1950
1951 VariantWithSignedIntegerSelectorFieldClass::Shared
1952 createVariantWithSignedIntegerSelectorFieldClass(
1953 const IntegerFieldClass selectorFieldClass) const
1954 {
1955 return this->_createVariantWithIntegerSelectorFieldClass<
1956 VariantWithSignedIntegerSelectorFieldClass>(selectorFieldClass);
1957 }
1958
1959 void assignsAutomaticStreamClassId(const bool val) const noexcept
1960 {
1961 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1962
1963 bt_trace_class_set_assigns_automatic_stream_class_id(this->libObjPtr(),
1964 static_cast<bt_bool>(val));
1965 }
1966
1967 bool assignsAutomaticStreamClassId() const noexcept
1968 {
1969 return static_cast<bool>(
1970 bt_trace_class_assigns_automatic_stream_class_id(this->libObjPtr()));
1971 }
1972
1973 std::uint64_t length() const noexcept
1974 {
1975 return bt_trace_class_get_stream_class_count(this->libObjPtr());
1976 }
1977
1978 _StreamClass operator[](const std::uint64_t index) const noexcept
1979 {
1980 return _StreamClass {_Spec::streamClassByIndex(this->libObjPtr(), index)};
1981 }
1982
1983 bt2s::optional<_StreamClass> streamClassById(const std::uint64_t id) const noexcept
1984 {
1985 const auto libObjPtr = _Spec::streamClassById(this->libObjPtr(), id);
1986
1987 if (libObjPtr) {
1988 return _StreamClass {libObjPtr};
1989 }
1990
1991 return bt2s::nullopt;
1992 }
1993
1994 template <typename LibValT>
1995 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
1996 {
1997 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
1998
1999 bt_trace_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
2000 }
2001
2002 UserAttributes userAttributes() const noexcept
2003 {
2004 return UserAttributes {_Spec::userAttributes(this->libObjPtr())};
2005 }
2006
2007 Shared shared() const noexcept
2008 {
2009 return Shared::createWithRef(*this);
2010 }
2011
2012 private:
2013 template <typename ObjT>
2014 typename ObjT::Shared
2015 _createVariantWithIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass) const
2016 {
2017 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
2018
2019 const auto libObjPtr =
2020 bt_field_class_variant_create(this->libObjPtr(), selectorFieldClass.libObjPtr());
2021
2022 internal::validateCreatedObjPtr(libObjPtr);
2023 return ObjT::Shared::createWithoutRef(libObjPtr);
2024 }
2025 };
2026
2027 using TraceClass = CommonTraceClass<bt_trace_class>;
2028 using ConstTraceClass = CommonTraceClass<const bt_trace_class>;
2029
2030 namespace internal {
2031
2032 struct TraceClassTypeDescr
2033 {
2034 using Const = ConstTraceClass;
2035 using NonConst = TraceClass;
2036 };
2037
2038 template <>
2039 struct TypeDescr<TraceClass> : public TraceClassTypeDescr
2040 {
2041 };
2042
2043 template <>
2044 struct TypeDescr<ConstTraceClass> : public TraceClassTypeDescr
2045 {
2046 };
2047
2048 } /* namespace internal */
2049
2050 template <typename LibObjT>
2051 typename CommonStreamClass<LibObjT>::_TraceClass
2052 CommonStreamClass<LibObjT>::traceClass() const noexcept
2053 {
2054 return _TraceClass {_Spec::traceClass(this->libObjPtr())};
2055 }
2056
2057 template <typename LibObjT>
2058 typename CommonTrace<LibObjT>::Class CommonTrace<LibObjT>::cls() const noexcept
2059 {
2060 return Class {_Spec::cls(this->libObjPtr())};
2061 }
2062
2063 } /* namespace bt2 */
2064
2065 #endif /* BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP */
This page took 0.071104 seconds and 4 git commands to generate.