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