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