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