a053da3d7081abe34de1455761ecf23ef10fd4da
[babeltrace.git] / src / cpp-common / bt2 / field-class.hpp
1 /*
2 * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP
9
10 #include <cstdint>
11 #include <type_traits>
12
13 #include <babeltrace2/babeltrace.h>
14
15 #include "common/assert.h"
16 #include "cpp-common/optional.hpp"
17 #include "cpp-common/string_view.hpp"
18
19 #include "borrowed-object.hpp"
20 #include "common-iterator.hpp"
21 #include "exc.hpp"
22 #include "field-path.hpp"
23 #include "integer-range-set.hpp"
24 #include "internal/utils.hpp"
25 #include "shared-object.hpp"
26 #include "value.hpp"
27
28 namespace bt2 {
29 namespace internal {
30
31 struct FieldClassRefFuncs final
32 {
33 static void get(const bt_field_class * const libObjPtr) noexcept
34 {
35 bt_field_class_get_ref(libObjPtr);
36 }
37
38 static void put(const bt_field_class * const libObjPtr) noexcept
39 {
40 bt_field_class_put_ref(libObjPtr);
41 }
42 };
43
44 template <typename LibObjT>
45 struct CommonFieldClassSpec;
46
47 /* Functions specific to mutable field classes */
48 template <>
49 struct CommonFieldClassSpec<bt_field_class> final
50 {
51 static bt_value *userAttributes(bt_field_class * const libObjPtr) noexcept
52 {
53 return bt_field_class_borrow_user_attributes(libObjPtr);
54 }
55 };
56
57 /* Functions specific to constant field classes */
58 template <>
59 struct CommonFieldClassSpec<const bt_field_class> final
60 {
61 static const bt_value *userAttributes(const bt_field_class * const libObjPtr) noexcept
62 {
63 return bt_field_class_borrow_user_attributes_const(libObjPtr);
64 }
65 };
66
67 } /* namespace internal */
68
69 template <typename ObjT, typename LibObjT>
70 using SharedFieldClass = SharedObject<ObjT, LibObjT, internal::FieldClassRefFuncs>;
71
72 template <typename LibObjT>
73 class CommonBitArrayFieldClass;
74
75 template <typename LibObjT>
76 class CommonIntegerFieldClass;
77
78 template <typename LibObjT>
79 class ConstEnumerationFieldClassMapping;
80
81 template <typename LibObjT>
82 class CommonBaseEnumerationFieldClass;
83
84 template <typename LibObjT, typename MappingT>
85 class CommonEnumerationFieldClass;
86
87 template <typename LibObjT>
88 class CommonStructureFieldClass;
89
90 template <typename LibObjT>
91 class CommonArrayFieldClass;
92
93 template <typename LibObjT>
94 class CommonStaticArrayFieldClass;
95
96 template <typename LibObjT>
97 class CommonDynamicArrayWithLengthFieldClass;
98
99 template <typename LibObjT>
100 class CommonOptionFieldClass;
101
102 template <typename LibObjT>
103 class CommonOptionWithSelectorFieldClass;
104
105 template <typename LibObjT>
106 class CommonOptionWithBoolSelectorFieldClass;
107
108 template <typename LibObjT>
109 class CommonVariantFieldClass;
110
111 template <typename LibObjT, typename RangeSetT>
112 class CommonOptionWithIntegerSelectorFieldClass;
113
114 template <typename LibObjT>
115 class CommonVariantWithoutSelectorFieldClass;
116
117 template <typename LibObjT>
118 class CommonVariantWithSelectorFieldClass;
119
120 template <typename LibObjT>
121 class ConstVariantWithIntegerSelectorFieldClassOption;
122
123 template <typename LibObjT, typename RangeSetT>
124 class CommonVariantWithIntegerSelectorFieldClass;
125
126 template <typename LibObjT>
127 class CommonEventClass;
128
129 template <typename LibObjT>
130 class CommonStreamClass;
131
132 template <typename LibObjT>
133 class CommonTraceClass;
134
135 enum class FieldClassType
136 {
137 BOOL = BT_FIELD_CLASS_TYPE_BOOL,
138 BIT_ARRAY = BT_FIELD_CLASS_TYPE_BIT_ARRAY,
139 UNSIGNED_INTEGER = BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
140 SIGNED_INTEGER = BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
141 UNSIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
142 SIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
143 SINGLE_PRECISION_REAL = BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL,
144 DOUBLE_PRECISION_REAL = BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL,
145 STRING = BT_FIELD_CLASS_TYPE_STRING,
146 STRUCTURE = BT_FIELD_CLASS_TYPE_STRUCTURE,
147 STATIC_ARRAY = BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
148 DYNAMIC_ARRAY_WITHOUT_LENGTH = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
149 DYNAMIC_ARRAY_WITH_LENGTH = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
150 OPTION_WITHOUT_SELECTOR = BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD,
151 OPTION_WITH_BOOL_SELECTOR = BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
152 OPTION_WITH_UNSIGNED_INTEGER_SELECTOR =
153 BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
154 OPTION_WITH_SIGNED_INTEGER_SELECTOR =
155 BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
156 VARIANT_WITHOUT_SELECTOR = BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD,
157 VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR =
158 BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
159 VARIANT_WITH_SIGNED_INTEGER_SELECTOR =
160 BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
161 };
162
163 template <typename LibObjT>
164 class CommonFieldClass : public BorrowedObject<LibObjT>
165 {
166 private:
167 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
168
169 protected:
170 using typename BorrowedObject<LibObjT>::_LibObjPtr;
171 using _ThisCommonFieldClass = CommonFieldClass<LibObjT>;
172
173 public:
174 using Shared = SharedFieldClass<CommonFieldClass<LibObjT>, LibObjT>;
175 using UserAttributes = internal::DepUserAttrs<LibObjT>;
176
177 explicit CommonFieldClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
178 {
179 }
180
181 template <typename OtherLibObjT>
182 CommonFieldClass(const CommonFieldClass<OtherLibObjT> fc) noexcept : _ThisBorrowedObject {fc}
183 {
184 }
185
186 template <typename OtherLibObjT>
187 CommonFieldClass& operator=(const CommonFieldClass<OtherLibObjT> fc) noexcept
188 {
189 _ThisBorrowedObject::operator=(fc);
190 return *this;
191 }
192
193 CommonFieldClass<const bt_field_class> asConst() const noexcept
194 {
195 return CommonFieldClass<const bt_field_class> {*this};
196 }
197
198 FieldClassType type() const noexcept
199 {
200 return static_cast<FieldClassType>(bt_field_class_get_type(this->libObjPtr()));
201 }
202
203 bool isBool() const noexcept
204 {
205 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_BOOL);
206 }
207
208 bool isBitArray() const noexcept
209 {
210 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_BIT_ARRAY);
211 }
212
213 bool isInteger() const noexcept
214 {
215 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_INTEGER);
216 }
217
218 bool isUnsignedInteger() const noexcept
219 {
220 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER);
221 }
222
223 bool isSignedInteger() const noexcept
224 {
225 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SIGNED_INTEGER);
226 }
227
228 bool isEnumeration() const noexcept
229 {
230 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_ENUMERATION);
231 }
232
233 bool isUnsignedEnumeration() const noexcept
234 {
235 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION);
236 }
237
238 bool isSignedEnumeration() const noexcept
239 {
240 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION);
241 }
242
243 bool isReal() const noexcept
244 {
245 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_REAL);
246 }
247
248 bool isSinglePrecisionReal() const noexcept
249 {
250 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL);
251 }
252
253 bool isDoublePrecisionReal() const noexcept
254 {
255 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL);
256 }
257
258 bool isString() const noexcept
259 {
260 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_STRING);
261 }
262
263 bool isStructure() const noexcept
264 {
265 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_STRUCTURE);
266 }
267
268 bool isArray() const noexcept
269 {
270 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_ARRAY);
271 }
272
273 bool isStaticArray() const noexcept
274 {
275 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_STATIC_ARRAY);
276 }
277
278 bool isDynamicArray() const noexcept
279 {
280 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
281 }
282
283 bool isDynamicArrayWithoutLength() const noexcept
284 {
285 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD);
286 }
287
288 bool isDynamicArrayWithLength() const noexcept
289 {
290 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
291 }
292
293 bool isOption() const noexcept
294 {
295 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION);
296 }
297
298 bool isOptionWithoutSelector() const noexcept
299 {
300 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD);
301 }
302
303 bool isOptionWithSelector() const noexcept
304 {
305 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD);
306 }
307
308 bool isOptionWithBoolSelector() const noexcept
309 {
310 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD);
311 }
312
313 bool isOptionWithIntegerSelector() const noexcept
314 {
315 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD);
316 }
317
318 bool isOptionWithUnsignedIntegerSelector() const noexcept
319 {
320 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD);
321 }
322
323 bool isOptionWithSignedIntegerSelector() const noexcept
324 {
325 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD);
326 }
327
328 bool isVariant() const noexcept
329 {
330 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT);
331 }
332
333 bool isVariantWithoutSelector() const noexcept
334 {
335 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD);
336 }
337
338 bool isVariantWithSelector() const noexcept
339 {
340 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD);
341 }
342
343 bool isVariantWithIntegerSelector() const noexcept
344 {
345 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD);
346 }
347
348 bool isVariantWithUnsignedIntegerSelector() const noexcept
349 {
350 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD);
351 }
352
353 bool isVariantWithSignedIntegerSelector() const noexcept
354 {
355 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD);
356 }
357
358 template <typename FieldClassT>
359 FieldClassT as() const noexcept
360 {
361 return FieldClassT {this->libObjPtr()};
362 }
363
364 CommonBitArrayFieldClass<LibObjT> asBitArray() const noexcept;
365 CommonIntegerFieldClass<LibObjT> asInteger() const noexcept;
366 CommonBaseEnumerationFieldClass<LibObjT> asEnumeration() const noexcept;
367 CommonEnumerationFieldClass<LibObjT, ConstEnumerationFieldClassMapping<
368 const bt_field_class_enumeration_unsigned_mapping>>
369 asUnsignedEnumeration() const noexcept;
370
371 CommonEnumerationFieldClass<
372 LibObjT, ConstEnumerationFieldClassMapping<const bt_field_class_enumeration_signed_mapping>>
373 asSignedEnumeration() const noexcept;
374
375 CommonStructureFieldClass<LibObjT> asStructure() const noexcept;
376 CommonArrayFieldClass<LibObjT> asArray() const noexcept;
377 CommonStaticArrayFieldClass<LibObjT> asStaticArray() const noexcept;
378 CommonDynamicArrayWithLengthFieldClass<LibObjT> asDynamicArrayWithLength() const noexcept;
379 CommonOptionFieldClass<LibObjT> asOption() const noexcept;
380 CommonOptionWithSelectorFieldClass<LibObjT> asOptionWithSelector() const noexcept;
381 CommonOptionWithBoolSelectorFieldClass<LibObjT> asOptionWithBoolSelector() const noexcept;
382
383 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstUnsignedIntegerRangeSet>
384 asOptionWithUnsignedIntegerSelector() const noexcept;
385
386 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstSignedIntegerRangeSet>
387 asOptionWithSignedIntegerSelector() const noexcept;
388
389 CommonVariantFieldClass<LibObjT> asVariant() const noexcept;
390 CommonVariantWithoutSelectorFieldClass<LibObjT> asVariantWithoutSelector() const noexcept;
391 CommonVariantWithSelectorFieldClass<LibObjT> asVariantWithSelector() const noexcept;
392
393 CommonVariantWithIntegerSelectorFieldClass<
394 LibObjT, ConstVariantWithIntegerSelectorFieldClassOption<
395 const bt_field_class_variant_with_selector_field_integer_unsigned_option>>
396 asVariantWithUnsignedIntegerSelector() const noexcept;
397
398 CommonVariantWithIntegerSelectorFieldClass<
399 LibObjT, ConstVariantWithIntegerSelectorFieldClassOption<
400 const bt_field_class_variant_with_selector_field_integer_signed_option>>
401 asVariantWithSignedIntegerSelector() const noexcept;
402
403 template <typename LibValT>
404 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
405 {
406 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstFieldClass`.");
407
408 bt_field_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
409 }
410
411 UserAttributes userAttributes() const noexcept
412 {
413 return UserAttributes {
414 internal::CommonFieldClassSpec<LibObjT>::userAttributes(this->libObjPtr())};
415 }
416
417 Shared shared() const noexcept
418 {
419 return Shared::createWithRef(*this);
420 }
421
422 protected:
423 bool _libTypeIs(const bt_field_class_type type) const noexcept
424 {
425 return bt_field_class_type_is(bt_field_class_get_type(this->libObjPtr()), type);
426 }
427 };
428
429 using FieldClass = CommonFieldClass<bt_field_class>;
430 using ConstFieldClass = CommonFieldClass<const bt_field_class>;
431
432 namespace internal {
433
434 struct FieldClassTypeDescr
435 {
436 using Const = ConstFieldClass;
437 using NonConst = FieldClass;
438 };
439
440 template <>
441 struct TypeDescr<FieldClass> : public FieldClassTypeDescr
442 {
443 };
444
445 template <>
446 struct TypeDescr<ConstFieldClass> : public FieldClassTypeDescr
447 {
448 };
449
450 } /* namespace internal */
451
452 template <typename LibObjT>
453 class CommonBitArrayFieldClass final : public CommonFieldClass<LibObjT>
454 {
455 private:
456 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
457 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
458
459 public:
460 using Shared = SharedFieldClass<CommonBitArrayFieldClass<LibObjT>, LibObjT>;
461
462 explicit CommonBitArrayFieldClass(const _LibObjPtr libObjPtr) noexcept :
463 _ThisCommonFieldClass {libObjPtr}
464 {
465 BT_ASSERT_DBG(this->isBitArray());
466 }
467
468 template <typename OtherLibObjT>
469 CommonBitArrayFieldClass(const CommonBitArrayFieldClass<OtherLibObjT> fc) noexcept :
470 _ThisCommonFieldClass {fc}
471 {
472 }
473
474 template <typename OtherLibObjT>
475 CommonBitArrayFieldClass<LibObjT>&
476 operator=(const CommonBitArrayFieldClass<OtherLibObjT> fc) noexcept
477 {
478 _ThisCommonFieldClass::operator=(fc);
479 return *this;
480 }
481
482 CommonBitArrayFieldClass<const bt_field_class> asConst() const noexcept
483 {
484 return CommonBitArrayFieldClass<const bt_field_class> {*this};
485 }
486
487 std::uint64_t length() const noexcept
488 {
489 return bt_field_class_bit_array_get_length(this->libObjPtr());
490 }
491
492 Shared shared() const noexcept
493 {
494 return Shared::createWithRef(*this);
495 }
496 };
497
498 using BitArrayFieldClass = CommonBitArrayFieldClass<bt_field_class>;
499 using ConstBitArrayFieldClass = CommonBitArrayFieldClass<const bt_field_class>;
500
501 namespace internal {
502
503 struct BitArrayFieldClassTypeDescr
504 {
505 using Const = ConstBitArrayFieldClass;
506 using NonConst = BitArrayFieldClass;
507 };
508
509 template <>
510 struct TypeDescr<BitArrayFieldClass> : public BitArrayFieldClassTypeDescr
511 {
512 };
513
514 template <>
515 struct TypeDescr<ConstBitArrayFieldClass> : public BitArrayFieldClassTypeDescr
516 {
517 };
518
519 } /* namespace internal */
520
521 enum class DisplayBase
522 {
523 BINARY = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
524 OCTAL = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
525 DECIMAL = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
526 HEXADECIMAL = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
527 };
528
529 template <typename LibObjT>
530 class CommonIntegerFieldClass : public CommonFieldClass<LibObjT>
531 {
532 private:
533 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
534
535 protected:
536 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
537 using _ThisCommonIntegerFieldClass = CommonIntegerFieldClass<LibObjT>;
538
539 public:
540 using Shared = SharedFieldClass<CommonIntegerFieldClass<LibObjT>, LibObjT>;
541
542 explicit CommonIntegerFieldClass(const _LibObjPtr libObjPtr) noexcept :
543 _ThisCommonFieldClass {libObjPtr}
544 {
545 BT_ASSERT_DBG(this->isInteger());
546 }
547
548 template <typename OtherLibObjT>
549 CommonIntegerFieldClass(const CommonIntegerFieldClass<OtherLibObjT> fc) noexcept :
550 _ThisCommonFieldClass {fc}
551 {
552 }
553
554 template <typename OtherLibObjT>
555 CommonIntegerFieldClass& operator=(const CommonIntegerFieldClass<OtherLibObjT> fc) noexcept
556 {
557 _ThisCommonFieldClass::operator=(fc);
558 return *this;
559 }
560
561 CommonIntegerFieldClass<const bt_field_class> asConst() const noexcept
562 {
563 return CommonIntegerFieldClass<const bt_field_class> {*this};
564 }
565
566 void fieldValueRange(const std::uint64_t n) const noexcept
567 {
568 static_assert(!std::is_const<LibObjT>::value,
569 "Not available with `bt2::ConstIntegerFieldClass`.");
570
571 bt_field_class_integer_set_field_value_range(this->libObjPtr(), n);
572 }
573
574 std::uint64_t fieldValueRange() const noexcept
575 {
576 return bt_field_class_integer_get_field_value_range(this->libObjPtr());
577 }
578
579 void preferredDisplayBase(const DisplayBase base) const noexcept
580 {
581 static_assert(!std::is_const<LibObjT>::value,
582 "Not available with `bt2::ConstIntegerFieldClass`.");
583
584 bt_field_class_integer_set_preferred_display_base(
585 this->libObjPtr(), static_cast<bt_field_class_integer_preferred_display_base>(base));
586 }
587
588 DisplayBase preferredDisplayBase() const noexcept
589 {
590 return static_cast<DisplayBase>(
591 bt_field_class_integer_get_preferred_display_base(this->libObjPtr()));
592 }
593
594 Shared shared() const noexcept
595 {
596 return Shared::createWithRef(*this);
597 }
598 };
599
600 using IntegerFieldClass = CommonIntegerFieldClass<bt_field_class>;
601 using ConstIntegerFieldClass = CommonIntegerFieldClass<const bt_field_class>;
602
603 namespace internal {
604
605 struct IntegerFieldClassTypeDescr
606 {
607 using Const = ConstIntegerFieldClass;
608 using NonConst = IntegerFieldClass;
609 };
610
611 template <>
612 struct TypeDescr<IntegerFieldClass> : public IntegerFieldClassTypeDescr
613 {
614 };
615
616 template <>
617 struct TypeDescr<ConstIntegerFieldClass> : public IntegerFieldClassTypeDescr
618 {
619 };
620
621 } /* namespace internal */
622
623 namespace internal {
624
625 template <typename LibObjT>
626 struct ConstEnumerationFieldClassMappingSpec;
627
628 /* Functions specific to unsigned enumeration field class mappings */
629 template <>
630 struct ConstEnumerationFieldClassMappingSpec<const bt_field_class_enumeration_unsigned_mapping>
631 final
632 {
633 static const bt_integer_range_set_unsigned *
634 ranges(const bt_field_class_enumeration_unsigned_mapping * const libObjPtr) noexcept
635 {
636 return bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(libObjPtr);
637 }
638
639 static const char *
640 label(const bt_field_class_enumeration_unsigned_mapping * const libObjPtr) noexcept
641 {
642 return bt_field_class_enumeration_mapping_get_label(
643 bt_field_class_enumeration_unsigned_mapping_as_mapping_const(libObjPtr));
644 }
645 };
646
647 /* Functions specific to signed enumeration field class mappings */
648 template <>
649 struct ConstEnumerationFieldClassMappingSpec<const bt_field_class_enumeration_signed_mapping> final
650 {
651 static const bt_integer_range_set_signed *
652 ranges(const bt_field_class_enumeration_signed_mapping * const libObjPtr) noexcept
653 {
654 return bt_field_class_enumeration_signed_mapping_borrow_ranges_const(libObjPtr);
655 }
656
657 static const char *
658 label(const bt_field_class_enumeration_signed_mapping * const libObjPtr) noexcept
659 {
660 return bt_field_class_enumeration_mapping_get_label(
661 bt_field_class_enumeration_signed_mapping_as_mapping_const(libObjPtr));
662 }
663 };
664
665 } /* namespace internal */
666
667 template <typename LibObjT>
668 class ConstEnumerationFieldClassMapping final : public BorrowedObject<LibObjT>
669 {
670 private:
671 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
672 using typename BorrowedObject<LibObjT>::_LibObjPtr;
673
674 public:
675 using RangeSet = typename std::conditional<
676 std::is_same<LibObjT, const bt_field_class_enumeration_unsigned_mapping>::value,
677 ConstUnsignedIntegerRangeSet, ConstSignedIntegerRangeSet>::type;
678
679 explicit ConstEnumerationFieldClassMapping(const _LibObjPtr libObjPtr) noexcept :
680 _ThisBorrowedObject {libObjPtr}
681 {
682 }
683
684 ConstEnumerationFieldClassMapping(const ConstEnumerationFieldClassMapping& mapping) noexcept :
685 _ThisBorrowedObject {mapping}
686 {
687 }
688
689 ConstEnumerationFieldClassMapping&
690 operator=(const ConstEnumerationFieldClassMapping& mapping) noexcept
691 {
692 _ThisBorrowedObject::operator=(mapping);
693 return *this;
694 }
695
696 RangeSet ranges() const noexcept
697 {
698 return RangeSet {
699 internal::ConstEnumerationFieldClassMappingSpec<LibObjT>::ranges(this->libObjPtr())};
700 }
701
702 bpstd::string_view label() const noexcept
703 {
704 return internal::ConstEnumerationFieldClassMappingSpec<LibObjT>::label(this->libObjPtr());
705 }
706 };
707
708 using ConstUnsignedEnumerationFieldClassMapping =
709 ConstEnumerationFieldClassMapping<const bt_field_class_enumeration_unsigned_mapping>;
710
711 using ConstSignedEnumerationFieldClassMapping =
712 ConstEnumerationFieldClassMapping<const bt_field_class_enumeration_signed_mapping>;
713
714 namespace internal {
715
716 template <typename MappingT>
717 struct CommonEnumerationFieldClassSpec;
718
719 /* Functions specific to unsigned enumeration field classes */
720 template <>
721 struct CommonEnumerationFieldClassSpec<ConstUnsignedEnumerationFieldClassMapping> final
722 {
723 static const bt_field_class_enumeration_unsigned_mapping *
724 mappingByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
725 {
726 return bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(libObjPtr, index);
727 }
728
729 static const bt_field_class_enumeration_unsigned_mapping *
730 mappingByLabel(const bt_field_class * const libObjPtr, const char * const label) noexcept
731 {
732 return bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(libObjPtr, label);
733 }
734
735 static bt_field_class_enumeration_add_mapping_status
736 addMapping(bt_field_class * const libObjPtr, const char * const label,
737 const bt_integer_range_set_unsigned * const libRanges) noexcept
738 {
739 return bt_field_class_enumeration_unsigned_add_mapping(libObjPtr, label, libRanges);
740 }
741 };
742
743 /* Functions specific to signed enumeration field classes */
744 template <>
745 struct CommonEnumerationFieldClassSpec<ConstSignedEnumerationFieldClassMapping> final
746 {
747 static const bt_field_class_enumeration_signed_mapping *
748 mappingByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
749 {
750 return bt_field_class_enumeration_signed_borrow_mapping_by_index_const(libObjPtr, index);
751 }
752
753 static const bt_field_class_enumeration_signed_mapping *
754 mappingByLabel(const bt_field_class * const libObjPtr, const char * const label) noexcept
755 {
756 return bt_field_class_enumeration_signed_borrow_mapping_by_label_const(libObjPtr, label);
757 }
758
759 static bt_field_class_enumeration_add_mapping_status
760 addMapping(bt_field_class * const libObjPtr, const char * const label,
761 const bt_integer_range_set_signed * const libRanges) noexcept
762 {
763 return bt_field_class_enumeration_signed_add_mapping(libObjPtr, label, libRanges);
764 }
765 };
766
767 } /* namespace internal */
768
769 template <typename LibObjT>
770 class CommonBaseEnumerationFieldClass : public CommonIntegerFieldClass<LibObjT>
771 {
772 private:
773 using typename CommonIntegerFieldClass<LibObjT>::_ThisCommonIntegerFieldClass;
774
775 protected:
776 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
777 using _ThisCommonBaseEnumerationFieldClass = CommonBaseEnumerationFieldClass<LibObjT>;
778
779 public:
780 using Shared = SharedFieldClass<_ThisCommonBaseEnumerationFieldClass, LibObjT>;
781
782 explicit CommonBaseEnumerationFieldClass(const _LibObjPtr libObjPtr) noexcept :
783 _ThisCommonIntegerFieldClass {libObjPtr}
784 {
785 BT_ASSERT_DBG(this->isEnumeration());
786 }
787
788 template <typename OtherLibObjT>
789 CommonBaseEnumerationFieldClass(const CommonBaseEnumerationFieldClass<OtherLibObjT> fc) noexcept
790 :
791 _ThisCommonIntegerFieldClass {fc}
792 {
793 }
794
795 template <typename OtherLibObjT>
796 CommonBaseEnumerationFieldClass&
797 operator=(const CommonBaseEnumerationFieldClass<OtherLibObjT> fc) noexcept
798 {
799 _ThisCommonIntegerFieldClass::operator=(fc);
800 return *this;
801 }
802
803 CommonBaseEnumerationFieldClass<const bt_field_class> asConst() const noexcept
804 {
805 return CommonBaseEnumerationFieldClass<const bt_field_class> {*this};
806 }
807
808 std::uint64_t length() const noexcept
809 {
810 return bt_field_class_enumeration_get_mapping_count(this->libObjPtr());
811 }
812
813 Shared shared() const noexcept
814 {
815 return Shared::createWithRef(*this);
816 }
817 };
818
819 template <typename LibObjT, typename MappingT>
820 class CommonEnumerationFieldClass final : public CommonBaseEnumerationFieldClass<LibObjT>
821 {
822 private:
823 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
824 using typename CommonBaseEnumerationFieldClass<LibObjT>::_ThisCommonBaseEnumerationFieldClass;
825 using _ThisCommonEnumerationFieldClass = CommonEnumerationFieldClass<LibObjT, MappingT>;
826
827 public:
828 using Shared = SharedFieldClass<_ThisCommonEnumerationFieldClass, LibObjT>;
829 using Iterator = CommonIterator<CommonEnumerationFieldClass, MappingT>;
830 using Mapping = MappingT;
831
832 explicit CommonEnumerationFieldClass(const _LibObjPtr libObjPtr) noexcept :
833 _ThisCommonBaseEnumerationFieldClass {libObjPtr}
834 {
835 BT_ASSERT_DBG(this->isEnumeration());
836 }
837
838 template <typename OtherLibObjT>
839 CommonEnumerationFieldClass(
840 const CommonEnumerationFieldClass<OtherLibObjT, MappingT> fc) noexcept :
841 _ThisCommonEnumerationFieldClass {fc}
842 {
843 }
844
845 template <typename OtherLibObjT>
846 CommonEnumerationFieldClass&
847 operator=(const CommonEnumerationFieldClass<OtherLibObjT, MappingT> fc) noexcept
848 {
849 _ThisCommonEnumerationFieldClass::operator=(fc);
850 return *this;
851 }
852
853 Mapping operator[](const std::uint64_t index) const noexcept
854 {
855 return Mapping {internal::CommonEnumerationFieldClassSpec<MappingT>::mappingByIndex(
856 this->libObjPtr(), index)};
857 }
858
859 nonstd::optional<Mapping> operator[](const char * const label) const noexcept
860 {
861 const auto libObjPtr = internal::CommonEnumerationFieldClassSpec<MappingT>::mappingByLabel(
862 this->libObjPtr(), label);
863
864 if (libObjPtr) {
865 return Mapping {libObjPtr};
866 }
867
868 return nonstd::nullopt;
869 }
870
871 nonstd::optional<Mapping> operator[](const std::string& label) const noexcept
872 {
873 return (*this)[label.data()];
874 }
875
876 void addMapping(const char * const label, const typename Mapping::RangeSet ranges) const
877 {
878 const auto status = internal::CommonEnumerationFieldClassSpec<MappingT>::addMapping(
879 this->libObjPtr(), label, ranges.libObjPtr());
880
881 if (status == BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR) {
882 throw MemoryError {};
883 }
884 }
885
886 void addMapping(const std::string& label, const typename Mapping::RangeSet ranges) const
887 {
888 this->addMapping(label.data(), ranges);
889 }
890
891 Iterator begin() const noexcept
892 {
893 return Iterator {*this, 0};
894 }
895
896 Iterator end() const noexcept
897 {
898 return Iterator {*this, this->length()};
899 }
900
901 Shared shared() const noexcept
902 {
903 return Shared::createWithRef(*this);
904 }
905 };
906
907 using EnumerationFieldClass = CommonBaseEnumerationFieldClass<bt_field_class>;
908 using ConstEnumerationFieldClass = CommonBaseEnumerationFieldClass<const bt_field_class>;
909
910 using UnsignedEnumerationFieldClass =
911 CommonEnumerationFieldClass<bt_field_class, ConstUnsignedEnumerationFieldClassMapping>;
912
913 using ConstUnsignedEnumerationFieldClass =
914 CommonEnumerationFieldClass<const bt_field_class, ConstUnsignedEnumerationFieldClassMapping>;
915
916 using SignedEnumerationFieldClass =
917 CommonEnumerationFieldClass<bt_field_class, ConstSignedEnumerationFieldClassMapping>;
918
919 using ConstSignedEnumerationFieldClass =
920 CommonEnumerationFieldClass<const bt_field_class, ConstSignedEnumerationFieldClassMapping>;
921
922 namespace internal {
923
924 struct UnsignedEnumerationFieldClassTypeDescr
925 {
926 using Const = ConstUnsignedEnumerationFieldClass;
927 using NonConst = UnsignedEnumerationFieldClass;
928 };
929
930 template <>
931 struct TypeDescr<UnsignedEnumerationFieldClass> : public UnsignedEnumerationFieldClassTypeDescr
932 {
933 };
934
935 template <>
936 struct TypeDescr<ConstUnsignedEnumerationFieldClass> : public UnsignedEnumerationFieldClassTypeDescr
937 {
938 };
939
940 struct SignedEnumerationFieldClassTypeDescr
941 {
942 using Const = ConstSignedEnumerationFieldClass;
943 using NonConst = SignedEnumerationFieldClass;
944 };
945
946 template <>
947 struct TypeDescr<SignedEnumerationFieldClass> : public SignedEnumerationFieldClassTypeDescr
948 {
949 };
950
951 template <>
952 struct TypeDescr<ConstSignedEnumerationFieldClass> : public SignedEnumerationFieldClassTypeDescr
953 {
954 };
955
956 template <typename LibObjT>
957 struct CommonStructureFieldClassMemberSpec;
958
959 /* Functions specific to mutable structure field class members */
960 template <>
961 struct CommonStructureFieldClassMemberSpec<bt_field_class_structure_member> final
962 {
963 static bt_field_class *fieldClass(bt_field_class_structure_member * const libObjPtr) noexcept
964 {
965 return bt_field_class_structure_member_borrow_field_class(libObjPtr);
966 }
967
968 static bt_value *userAttributes(bt_field_class_structure_member * const libObjPtr) noexcept
969 {
970 return bt_field_class_structure_member_borrow_user_attributes(libObjPtr);
971 }
972 };
973
974 /* Functions specific to constant structure field class members */
975 template <>
976 struct CommonStructureFieldClassMemberSpec<const bt_field_class_structure_member> final
977 {
978 static const bt_field_class *
979 fieldClass(const bt_field_class_structure_member * const libObjPtr) noexcept
980 {
981 return bt_field_class_structure_member_borrow_field_class_const(libObjPtr);
982 }
983
984 static const bt_value *
985 userAttributes(const bt_field_class_structure_member * const libObjPtr) noexcept
986 {
987 return bt_field_class_structure_member_borrow_user_attributes_const(libObjPtr);
988 }
989 };
990
991 } /* namespace internal */
992
993 template <typename LibObjT>
994 class CommonStructureFieldClassMember final : public BorrowedObject<LibObjT>
995 {
996 private:
997 using typename BorrowedObject<LibObjT>::_LibObjPtr;
998 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
999 using _FieldClass = internal::DepFc<LibObjT>;
1000
1001 public:
1002 using UserAttributes = internal::DepUserAttrs<LibObjT>;
1003
1004 explicit CommonStructureFieldClassMember(const _LibObjPtr libObjPtr) noexcept :
1005 _ThisBorrowedObject {libObjPtr}
1006 {
1007 }
1008
1009 template <typename OtherLibObjT>
1010 CommonStructureFieldClassMember(const CommonStructureFieldClassMember<OtherLibObjT> fc) noexcept
1011 :
1012 _ThisBorrowedObject {fc}
1013 {
1014 }
1015
1016 template <typename OtherLibObjT>
1017 CommonStructureFieldClassMember<LibObjT>&
1018 operator=(const CommonStructureFieldClassMember<OtherLibObjT> fc) noexcept
1019 {
1020 _ThisBorrowedObject::operator=(fc);
1021 return *this;
1022 }
1023
1024 CommonStructureFieldClassMember<const bt_field_class_structure_member> asConst() const noexcept
1025 {
1026 return CommonStructureFieldClassMember<const bt_field_class_structure_member> {*this};
1027 }
1028
1029 bpstd::string_view name() const noexcept
1030 {
1031 return bt_field_class_structure_member_get_name(this->libObjPtr());
1032 }
1033
1034 _FieldClass fieldClass() const noexcept
1035 {
1036 return _FieldClass {
1037 internal::CommonStructureFieldClassMemberSpec<LibObjT>::fieldClass(this->libObjPtr())};
1038 }
1039
1040 template <typename LibValT>
1041 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
1042 {
1043 static_assert(!std::is_const<LibObjT>::value,
1044 "Not available with `bt2::ConstStructureFieldClassMember`.");
1045
1046 bt_field_class_structure_member_set_user_attributes(this->libObjPtr(),
1047 userAttrs.libObjPtr());
1048 }
1049
1050 UserAttributes userAttributes() const noexcept
1051 {
1052 return UserAttributes {
1053 internal::CommonStructureFieldClassMemberSpec<LibObjT>::userAttributes(
1054 this->libObjPtr())};
1055 }
1056 };
1057
1058 using StructureFieldClassMember = CommonStructureFieldClassMember<bt_field_class_structure_member>;
1059
1060 using ConstStructureFieldClassMember =
1061 CommonStructureFieldClassMember<const bt_field_class_structure_member>;
1062
1063 namespace internal {
1064
1065 struct StructureFieldClassMemberTypeDescr
1066 {
1067 using Const = ConstStructureFieldClassMember;
1068 using NonConst = StructureFieldClassMember;
1069 };
1070
1071 template <>
1072 struct TypeDescr<StructureFieldClassMember> : public StructureFieldClassMemberTypeDescr
1073 {
1074 };
1075
1076 template <>
1077 struct TypeDescr<ConstStructureFieldClassMember> : public StructureFieldClassMemberTypeDescr
1078 {
1079 };
1080
1081 template <typename LibObjT>
1082 struct CommonStructureFieldClassSpec;
1083
1084 /* Functions specific to mutable structure field classes */
1085 template <>
1086 struct CommonStructureFieldClassSpec<bt_field_class> final
1087 {
1088 static bt_field_class_structure_member *memberByIndex(bt_field_class * const libObjPtr,
1089 const std::uint64_t index) noexcept
1090 {
1091 return bt_field_class_structure_borrow_member_by_index(libObjPtr, index);
1092 }
1093
1094 static bt_field_class_structure_member *memberByName(bt_field_class * const libObjPtr,
1095 const char * const name) noexcept
1096 {
1097 return bt_field_class_structure_borrow_member_by_name(libObjPtr, name);
1098 }
1099 };
1100
1101 /* Functions specific to constant structure field classes */
1102 template <>
1103 struct CommonStructureFieldClassSpec<const bt_field_class> final
1104 {
1105 static const bt_field_class_structure_member *
1106 memberByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
1107 {
1108 return bt_field_class_structure_borrow_member_by_index_const(libObjPtr, index);
1109 }
1110
1111 static const bt_field_class_structure_member *
1112 memberByName(const bt_field_class * const libObjPtr, const char * const name) noexcept
1113 {
1114 return bt_field_class_structure_borrow_member_by_name_const(libObjPtr, name);
1115 }
1116 };
1117
1118 } /* namespace internal */
1119
1120 template <typename LibObjT>
1121 class CommonStructureFieldClass final : public CommonFieldClass<LibObjT>
1122 {
1123 private:
1124 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1125 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
1126
1127 public:
1128 using Shared = SharedFieldClass<CommonStructureFieldClass<LibObjT>, LibObjT>;
1129
1130 using Member =
1131 internal::DepType<LibObjT, StructureFieldClassMember, ConstStructureFieldClassMember>;
1132
1133 using Iterator = CommonIterator<CommonStructureFieldClass<LibObjT>, Member>;
1134
1135 explicit CommonStructureFieldClass(const _LibObjPtr libObjPtr) noexcept :
1136 _ThisCommonFieldClass {libObjPtr}
1137 {
1138 BT_ASSERT_DBG(this->isStructure());
1139 }
1140
1141 template <typename OtherLibObjT>
1142 CommonStructureFieldClass(const CommonStructureFieldClass<OtherLibObjT> fc) noexcept :
1143 _ThisCommonFieldClass {fc}
1144 {
1145 }
1146
1147 template <typename OtherLibObjT>
1148 CommonStructureFieldClass& operator=(const CommonStructureFieldClass<OtherLibObjT> fc) noexcept
1149 {
1150 _ThisCommonFieldClass::operator=(fc);
1151 return *this;
1152 }
1153
1154 CommonStructureFieldClass<const bt_field_class> asConst() const noexcept
1155 {
1156 return CommonStructureFieldClass<const bt_field_class> {*this};
1157 }
1158
1159 void appendMember(const char * const name, const FieldClass fc) const
1160 {
1161 static_assert(!std::is_const<LibObjT>::value,
1162 "Not available with `bt2::ConstStructureFieldClass`.");
1163
1164 const auto status =
1165 bt_field_class_structure_append_member(this->libObjPtr(), name, fc.libObjPtr());
1166
1167 if (status == BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR) {
1168 throw MemoryError {};
1169 }
1170 }
1171
1172 void appendMember(const std::string& name, const FieldClass fc) const
1173 {
1174 this->appendMember(name.data(), fc);
1175 }
1176
1177 std::uint64_t length() const noexcept
1178 {
1179 return bt_field_class_structure_get_member_count(this->libObjPtr());
1180 }
1181
1182 Iterator begin() const noexcept
1183 {
1184 return Iterator {*this, 0};
1185 }
1186
1187 Iterator end() const noexcept
1188 {
1189 return Iterator {*this, this->length()};
1190 }
1191
1192 Member operator[](const std::uint64_t index) const noexcept
1193 {
1194 return Member {internal::CommonStructureFieldClassSpec<LibObjT>::memberByIndex(
1195 this->libObjPtr(), index)};
1196 }
1197
1198 nonstd::optional<Member> operator[](const char * const name) const noexcept
1199 {
1200 const auto libObjPtr =
1201 internal::CommonStructureFieldClassSpec<LibObjT>::memberByName(this->libObjPtr(), name);
1202
1203 if (libObjPtr) {
1204 return Member {libObjPtr};
1205 }
1206
1207 return nonstd::nullopt;
1208 }
1209
1210 nonstd::optional<Member> operator[](const std::string& name) const noexcept
1211 {
1212 return (*this)[name.data()];
1213 }
1214
1215 Shared shared() const noexcept
1216 {
1217 return Shared::createWithRef(*this);
1218 }
1219 };
1220
1221 using StructureFieldClass = CommonStructureFieldClass<bt_field_class>;
1222 using ConstStructureFieldClass = CommonStructureFieldClass<const bt_field_class>;
1223
1224 namespace internal {
1225
1226 struct StructureFieldClassTypeDescr
1227 {
1228 using Const = ConstStructureFieldClass;
1229 using NonConst = StructureFieldClass;
1230 };
1231
1232 template <>
1233 struct TypeDescr<StructureFieldClass> : public StructureFieldClassTypeDescr
1234 {
1235 };
1236
1237 template <>
1238 struct TypeDescr<ConstStructureFieldClass> : public StructureFieldClassTypeDescr
1239 {
1240 };
1241
1242 template <typename LibObjT>
1243 struct CommonArrayFieldClassSpec;
1244
1245 /* Functions specific to mutable array field classes */
1246 template <>
1247 struct CommonArrayFieldClassSpec<bt_field_class> final
1248 {
1249 static bt_field_class *elementFieldClass(bt_field_class * const libObjPtr) noexcept
1250 {
1251 return bt_field_class_array_borrow_element_field_class(libObjPtr);
1252 }
1253 };
1254
1255 /* Functions specific to constant array field classes */
1256 template <>
1257 struct CommonArrayFieldClassSpec<const bt_field_class> final
1258 {
1259 static const bt_field_class *elementFieldClass(const bt_field_class * const libObjPtr) noexcept
1260 {
1261 return bt_field_class_array_borrow_element_field_class_const(libObjPtr);
1262 }
1263 };
1264
1265 } /* namespace internal */
1266
1267 template <typename LibObjT>
1268 class CommonArrayFieldClass : public CommonFieldClass<LibObjT>
1269 {
1270 private:
1271 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
1272 using _FieldClass = internal::DepFc<LibObjT>;
1273
1274 protected:
1275 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1276 using _ThisCommonArrayFieldClass = CommonArrayFieldClass<LibObjT>;
1277
1278 public:
1279 using Shared = SharedFieldClass<CommonArrayFieldClass<LibObjT>, LibObjT>;
1280
1281 explicit CommonArrayFieldClass(const _LibObjPtr libObjPtr) noexcept :
1282 _ThisCommonFieldClass {libObjPtr}
1283 {
1284 BT_ASSERT_DBG(this->isArray());
1285 }
1286
1287 template <typename OtherLibObjT>
1288 CommonArrayFieldClass(const CommonArrayFieldClass<OtherLibObjT> fc) noexcept :
1289 _ThisCommonFieldClass {fc}
1290 {
1291 }
1292
1293 template <typename OtherLibObjT>
1294 CommonArrayFieldClass& operator=(const CommonArrayFieldClass<OtherLibObjT> fc) noexcept
1295 {
1296 _ThisCommonFieldClass::operator=(fc);
1297 return *this;
1298 }
1299
1300 CommonArrayFieldClass<const bt_field_class> asConst() const noexcept
1301 {
1302 return CommonArrayFieldClass<const bt_field_class> {*this};
1303 }
1304
1305 _FieldClass elementFieldClass() const noexcept
1306 {
1307 return _FieldClass {
1308 internal::CommonArrayFieldClassSpec<LibObjT>::elementFieldClass(this->libObjPtr())};
1309 }
1310
1311 Shared shared() const noexcept
1312 {
1313 return Shared::createWithRef(*this);
1314 }
1315 };
1316
1317 using ArrayFieldClass = CommonArrayFieldClass<bt_field_class>;
1318 using ConstArrayFieldClass = CommonArrayFieldClass<const bt_field_class>;
1319
1320 namespace internal {
1321
1322 struct ArrayFieldClassTypeDescr
1323 {
1324 using Const = ConstArrayFieldClass;
1325 using NonConst = ArrayFieldClass;
1326 };
1327
1328 template <>
1329 struct TypeDescr<ArrayFieldClass> : public ArrayFieldClassTypeDescr
1330 {
1331 };
1332
1333 template <>
1334 struct TypeDescr<ConstArrayFieldClass> : public ArrayFieldClassTypeDescr
1335 {
1336 };
1337
1338 } /* namespace internal */
1339
1340 template <typename LibObjT>
1341 class CommonStaticArrayFieldClass final : public CommonArrayFieldClass<LibObjT>
1342 {
1343 private:
1344 using typename CommonArrayFieldClass<LibObjT>::_ThisCommonArrayFieldClass;
1345 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1346
1347 public:
1348 using Shared = SharedFieldClass<CommonStaticArrayFieldClass<LibObjT>, LibObjT>;
1349
1350 explicit CommonStaticArrayFieldClass(const _LibObjPtr libObjPtr) noexcept :
1351 _ThisCommonArrayFieldClass {libObjPtr}
1352 {
1353 BT_ASSERT_DBG(this->isStaticArray());
1354 }
1355
1356 template <typename OtherLibObjT>
1357 CommonStaticArrayFieldClass(const CommonStaticArrayFieldClass<OtherLibObjT> fc) noexcept :
1358 _ThisCommonArrayFieldClass {fc}
1359 {
1360 }
1361
1362 template <typename OtherLibObjT>
1363 CommonStaticArrayFieldClass&
1364 operator=(const CommonStaticArrayFieldClass<OtherLibObjT> fc) noexcept
1365 {
1366 _ThisCommonArrayFieldClass::operator=(fc);
1367 return *this;
1368 }
1369
1370 CommonStaticArrayFieldClass<const bt_field_class> asConst() const noexcept
1371 {
1372 return CommonStaticArrayFieldClass<const bt_field_class> {*this};
1373 }
1374
1375 std::uint64_t length() const noexcept
1376 {
1377 return bt_field_class_array_static_get_length(this->libObjPtr());
1378 }
1379
1380 Shared shared() const noexcept
1381 {
1382 return Shared::createWithRef(*this);
1383 }
1384 };
1385
1386 using StaticArrayFieldClass = CommonStaticArrayFieldClass<bt_field_class>;
1387 using ConstStaticArrayFieldClass = CommonStaticArrayFieldClass<const bt_field_class>;
1388
1389 namespace internal {
1390
1391 struct StaticArrayFieldClassTypeDescr
1392 {
1393 using Const = ConstStaticArrayFieldClass;
1394 using NonConst = StaticArrayFieldClass;
1395 };
1396
1397 template <>
1398 struct TypeDescr<StaticArrayFieldClass> : public StaticArrayFieldClassTypeDescr
1399 {
1400 };
1401
1402 template <>
1403 struct TypeDescr<ConstStaticArrayFieldClass> : public StaticArrayFieldClassTypeDescr
1404 {
1405 };
1406
1407 } /* namespace internal */
1408
1409 template <typename LibObjT>
1410 class CommonDynamicArrayWithLengthFieldClass final : public CommonArrayFieldClass<LibObjT>
1411 {
1412 private:
1413 using typename CommonArrayFieldClass<LibObjT>::_ThisCommonArrayFieldClass;
1414 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1415
1416 public:
1417 using Shared = SharedFieldClass<CommonDynamicArrayWithLengthFieldClass<LibObjT>, LibObjT>;
1418
1419 explicit CommonDynamicArrayWithLengthFieldClass(const _LibObjPtr libObjPtr) noexcept :
1420 _ThisCommonArrayFieldClass {libObjPtr}
1421 {
1422 BT_ASSERT_DBG(this->isDynamicArrayWithLength());
1423 }
1424
1425 template <typename OtherLibObjT>
1426 CommonDynamicArrayWithLengthFieldClass(
1427 const CommonDynamicArrayWithLengthFieldClass<OtherLibObjT> fc) noexcept :
1428 _ThisCommonArrayFieldClass {fc}
1429 {
1430 }
1431
1432 template <typename OtherLibObjT>
1433 CommonDynamicArrayWithLengthFieldClass&
1434 operator=(const CommonDynamicArrayWithLengthFieldClass<OtherLibObjT> fc) noexcept
1435 {
1436 _ThisCommonArrayFieldClass::operator=(fc);
1437 return *this;
1438 }
1439
1440 CommonDynamicArrayWithLengthFieldClass<const bt_field_class> asConst() const noexcept
1441 {
1442 return CommonDynamicArrayWithLengthFieldClass<const bt_field_class> {*this};
1443 }
1444
1445 ConstFieldPath lengthFieldPath() const noexcept
1446 {
1447 return ConstFieldPath {
1448 bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
1449 this->libObjPtr())};
1450 }
1451
1452 Shared shared() const noexcept
1453 {
1454 return Shared::createWithRef(*this);
1455 }
1456 };
1457
1458 using DynamicArrayWithLengthFieldClass = CommonDynamicArrayWithLengthFieldClass<bt_field_class>;
1459
1460 using ConstDynamicArrayWithLengthFieldClass =
1461 CommonDynamicArrayWithLengthFieldClass<const bt_field_class>;
1462
1463 namespace internal {
1464
1465 struct DynamicArrayWithLengthFieldClassTypeDescr
1466 {
1467 using Const = ConstDynamicArrayWithLengthFieldClass;
1468 using NonConst = DynamicArrayWithLengthFieldClass;
1469 };
1470
1471 template <>
1472 struct TypeDescr<DynamicArrayWithLengthFieldClass> :
1473 public DynamicArrayWithLengthFieldClassTypeDescr
1474 {
1475 };
1476
1477 template <>
1478 struct TypeDescr<ConstDynamicArrayWithLengthFieldClass> :
1479 public DynamicArrayWithLengthFieldClassTypeDescr
1480 {
1481 };
1482
1483 template <typename LibObjT>
1484 struct CommonOptionFieldClassSpec;
1485
1486 /* Functions specific to mutable option field classes */
1487 template <>
1488 struct CommonOptionFieldClassSpec<bt_field_class> final
1489 {
1490 static bt_field_class *fieldClass(bt_field_class * const libObjPtr) noexcept
1491 {
1492 return bt_field_class_option_borrow_field_class(libObjPtr);
1493 }
1494 };
1495
1496 /* Functions specific to constant option field classes */
1497 template <>
1498 struct CommonOptionFieldClassSpec<const bt_field_class> final
1499 {
1500 static const bt_field_class *fieldClass(const bt_field_class * const libObjPtr) noexcept
1501 {
1502 return bt_field_class_option_borrow_field_class_const(libObjPtr);
1503 }
1504 };
1505
1506 } /* namespace internal */
1507
1508 template <typename LibObjT>
1509 class CommonOptionFieldClass : public CommonFieldClass<LibObjT>
1510 {
1511 private:
1512 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
1513 using _FieldClass = internal::DepFc<LibObjT>;
1514
1515 protected:
1516 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1517 using _ThisCommonOptionFieldClass = CommonOptionFieldClass<LibObjT>;
1518
1519 public:
1520 using Shared = SharedFieldClass<CommonOptionFieldClass<LibObjT>, LibObjT>;
1521
1522 explicit CommonOptionFieldClass(const _LibObjPtr libObjPtr) noexcept :
1523 _ThisCommonFieldClass {libObjPtr}
1524 {
1525 BT_ASSERT_DBG(this->isOption());
1526 }
1527
1528 template <typename OtherLibObjT>
1529 CommonOptionFieldClass(const CommonOptionFieldClass<OtherLibObjT> fc) noexcept :
1530 _ThisCommonFieldClass {fc}
1531 {
1532 }
1533
1534 template <typename OtherLibObjT>
1535 CommonOptionFieldClass& operator=(const CommonOptionFieldClass<OtherLibObjT> fc) noexcept
1536 {
1537 _ThisCommonFieldClass::operator=(fc);
1538 return *this;
1539 }
1540
1541 CommonOptionFieldClass<const bt_field_class> asConst() const noexcept
1542 {
1543 return CommonOptionFieldClass<const bt_field_class> {*this};
1544 }
1545
1546 _FieldClass fieldClass() const noexcept
1547 {
1548 return _FieldClass {
1549 internal::CommonOptionFieldClassSpec<LibObjT>::fieldClass(this->libObjPtr())};
1550 }
1551
1552 Shared shared() const noexcept
1553 {
1554 return Shared::createWithRef(*this);
1555 }
1556 };
1557
1558 using OptionFieldClass = CommonOptionFieldClass<bt_field_class>;
1559 using ConstOptionFieldClass = CommonOptionFieldClass<const bt_field_class>;
1560
1561 namespace internal {
1562
1563 struct OptionFieldClassTypeDescr
1564 {
1565 using Const = ConstOptionFieldClass;
1566 using NonConst = OptionFieldClass;
1567 };
1568
1569 template <>
1570 struct TypeDescr<OptionFieldClass> : public OptionFieldClassTypeDescr
1571 {
1572 };
1573
1574 template <>
1575 struct TypeDescr<ConstOptionFieldClass> : public OptionFieldClassTypeDescr
1576 {
1577 };
1578
1579 } /* namespace internal */
1580
1581 template <typename LibObjT>
1582 class CommonOptionWithSelectorFieldClass : public CommonOptionFieldClass<LibObjT>
1583 {
1584 private:
1585 using typename CommonOptionFieldClass<LibObjT>::_ThisCommonOptionFieldClass;
1586
1587 protected:
1588 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1589 using _ThisCommonOptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass<LibObjT>;
1590
1591 public:
1592 using Shared = SharedFieldClass<CommonOptionWithSelectorFieldClass<LibObjT>, LibObjT>;
1593
1594 explicit CommonOptionWithSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept :
1595 _ThisCommonOptionFieldClass {libObjPtr}
1596 {
1597 BT_ASSERT_DBG(this->isOptionWithSelector());
1598 }
1599
1600 template <typename OtherLibObjT>
1601 CommonOptionWithSelectorFieldClass(
1602 const CommonOptionWithSelectorFieldClass<OtherLibObjT> fc) noexcept :
1603 _ThisCommonOptionFieldClass {fc}
1604 {
1605 }
1606
1607 template <typename OtherLibObjT>
1608 CommonOptionWithSelectorFieldClass&
1609 operator=(const CommonOptionWithSelectorFieldClass<OtherLibObjT> fc) noexcept
1610 {
1611 _ThisCommonOptionFieldClass::operator=(fc);
1612 return *this;
1613 }
1614
1615 CommonOptionWithSelectorFieldClass<const bt_field_class> asConst() const noexcept
1616 {
1617 return CommonOptionWithSelectorFieldClass<const bt_field_class> {*this};
1618 }
1619
1620 ConstFieldPath selectorFieldPath() const noexcept
1621 {
1622 return ConstFieldPath {
1623 bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
1624 this->libObjPtr())};
1625 }
1626
1627 Shared shared() const noexcept
1628 {
1629 return Shared::createWithRef(*this);
1630 }
1631 };
1632
1633 using OptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass<bt_field_class>;
1634 using ConstOptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass<const bt_field_class>;
1635
1636 namespace internal {
1637
1638 struct OptionWithSelectorFieldClassTypeDescr
1639 {
1640 using Const = ConstOptionWithSelectorFieldClass;
1641 using NonConst = OptionWithSelectorFieldClass;
1642 };
1643
1644 template <>
1645 struct TypeDescr<OptionWithSelectorFieldClass> : public OptionWithSelectorFieldClassTypeDescr
1646 {
1647 };
1648
1649 template <>
1650 struct TypeDescr<ConstOptionWithSelectorFieldClass> : public OptionWithSelectorFieldClassTypeDescr
1651 {
1652 };
1653
1654 } /* namespace internal */
1655
1656 template <typename LibObjT>
1657 class CommonOptionWithBoolSelectorFieldClass : public CommonOptionWithSelectorFieldClass<LibObjT>
1658 {
1659 private:
1660 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1661
1662 using typename CommonOptionWithSelectorFieldClass<
1663 LibObjT>::_ThisCommonOptionWithSelectorFieldClass;
1664
1665 public:
1666 using Shared = SharedFieldClass<CommonOptionWithBoolSelectorFieldClass<LibObjT>, LibObjT>;
1667
1668 explicit CommonOptionWithBoolSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept :
1669 _ThisCommonOptionWithSelectorFieldClass {libObjPtr}
1670 {
1671 BT_ASSERT_DBG(this->isOptionWithBoolSelector());
1672 }
1673
1674 template <typename OtherLibObjT>
1675 CommonOptionWithBoolSelectorFieldClass(
1676 const CommonOptionWithBoolSelectorFieldClass<OtherLibObjT> fc) noexcept :
1677 _ThisCommonOptionWithSelectorFieldClass {fc}
1678 {
1679 }
1680
1681 template <typename OtherLibObjT>
1682 CommonOptionWithBoolSelectorFieldClass&
1683 operator=(const CommonOptionWithBoolSelectorFieldClass<OtherLibObjT> fc) noexcept
1684 {
1685 _ThisCommonOptionWithSelectorFieldClass::operator=(fc);
1686 return *this;
1687 }
1688
1689 CommonOptionWithBoolSelectorFieldClass<const bt_field_class> asConst() const noexcept
1690 {
1691 return CommonOptionWithBoolSelectorFieldClass<const bt_field_class> {*this};
1692 }
1693
1694 bool selectorIsReversed() const noexcept
1695 {
1696 return bt_field_class_option_with_selector_field_bool_selector_is_reversed(
1697 this->libObjPtr());
1698 }
1699
1700 Shared shared() const noexcept
1701 {
1702 return Shared::createWithRef(*this);
1703 }
1704 };
1705
1706 using OptionWithBoolSelectorFieldClass = CommonOptionWithBoolSelectorFieldClass<bt_field_class>;
1707
1708 using ConstOptionWithBoolSelectorFieldClass =
1709 CommonOptionWithBoolSelectorFieldClass<const bt_field_class>;
1710
1711 namespace internal {
1712
1713 struct OptionWithBoolSelectorFieldClassTypeDescr
1714 {
1715 using Const = ConstOptionWithBoolSelectorFieldClass;
1716 using NonConst = OptionWithBoolSelectorFieldClass;
1717 };
1718
1719 template <>
1720 struct TypeDescr<OptionWithBoolSelectorFieldClass> :
1721 public OptionWithBoolSelectorFieldClassTypeDescr
1722 {
1723 };
1724
1725 template <>
1726 struct TypeDescr<ConstOptionWithBoolSelectorFieldClass> :
1727 public OptionWithBoolSelectorFieldClassTypeDescr
1728 {
1729 };
1730
1731 template <typename RangeSetT>
1732 struct CommonOptionWithIntegerSelectorFieldClassSpec;
1733
1734 /* Functions specific to option field classes with unsigned integer ranges */
1735 template <>
1736 struct CommonOptionWithIntegerSelectorFieldClassSpec<ConstUnsignedIntegerRangeSet> final
1737 {
1738 static const bt_integer_range_set_unsigned *
1739 ranges(const bt_field_class * const libObjPtr) noexcept
1740 {
1741 return bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
1742 libObjPtr);
1743 }
1744 };
1745
1746 /* Functions specific to option field classes with signed ranges */
1747 template <>
1748 struct CommonOptionWithIntegerSelectorFieldClassSpec<ConstSignedIntegerRangeSet> final
1749 {
1750 static const bt_integer_range_set_signed *
1751 ranges(const bt_field_class * const libObjPtr) noexcept
1752 {
1753 return bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
1754 libObjPtr);
1755 }
1756 };
1757
1758 } /* namespace internal */
1759
1760 template <typename LibObjT, typename RangeSetT>
1761 class CommonOptionWithIntegerSelectorFieldClass : public CommonOptionWithSelectorFieldClass<LibObjT>
1762 {
1763 private:
1764 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
1765
1766 using typename CommonOptionWithSelectorFieldClass<
1767 LibObjT>::_ThisCommonOptionWithSelectorFieldClass;
1768
1769 using _ThisCommonOptionWithIntegerSelectorFieldClass =
1770 CommonOptionWithIntegerSelectorFieldClass<LibObjT, RangeSetT>;
1771
1772 public:
1773 using Shared = SharedFieldClass<_ThisCommonOptionWithIntegerSelectorFieldClass, LibObjT>;
1774
1775 using RangeSet = RangeSetT;
1776
1777 explicit CommonOptionWithIntegerSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept :
1778 _ThisCommonOptionWithSelectorFieldClass {libObjPtr}
1779 {
1780 BT_ASSERT_DBG(this->isOptionWithIntegerSelector());
1781 }
1782
1783 template <typename OtherLibObjT>
1784 CommonOptionWithIntegerSelectorFieldClass(
1785 const CommonOptionWithIntegerSelectorFieldClass<OtherLibObjT, RangeSetT> fc) noexcept :
1786 _ThisCommonOptionWithSelectorFieldClass {fc}
1787 {
1788 }
1789
1790 template <typename OtherLibObjT>
1791 CommonOptionWithIntegerSelectorFieldClass&
1792 operator=(const CommonOptionWithIntegerSelectorFieldClass<OtherLibObjT, RangeSetT> fc) noexcept
1793 {
1794 _ThisCommonOptionWithSelectorFieldClass::operator=(fc);
1795 return *this;
1796 }
1797
1798 RangeSet ranges() const noexcept
1799 {
1800 return RangeSet {internal::CommonOptionWithIntegerSelectorFieldClassSpec<RangeSetT>::ranges(
1801 this->libObjPtr())};
1802 }
1803
1804 Shared shared() const noexcept
1805 {
1806 return Shared::createWithRef(*this);
1807 }
1808 };
1809
1810 using OptionWithUnsignedIntegerSelectorFieldClass =
1811 CommonOptionWithIntegerSelectorFieldClass<bt_field_class, ConstUnsignedIntegerRangeSet>;
1812
1813 using ConstOptionWithUnsignedIntegerSelectorFieldClass =
1814 CommonOptionWithIntegerSelectorFieldClass<const bt_field_class, ConstUnsignedIntegerRangeSet>;
1815
1816 using OptionWithSignedIntegerSelectorFieldClass =
1817 CommonOptionWithIntegerSelectorFieldClass<bt_field_class, ConstSignedIntegerRangeSet>;
1818
1819 using ConstOptionWithSignedIntegerSelectorFieldClass =
1820 CommonOptionWithIntegerSelectorFieldClass<const bt_field_class, ConstSignedIntegerRangeSet>;
1821
1822 namespace internal {
1823
1824 struct OptionWithUnsignedIntegerSelectorFieldClassTypeDescr
1825 {
1826 using Const = ConstOptionWithUnsignedIntegerSelectorFieldClass;
1827 using NonConst = OptionWithUnsignedIntegerSelectorFieldClass;
1828 };
1829
1830 template <>
1831 struct TypeDescr<OptionWithUnsignedIntegerSelectorFieldClass> :
1832 public OptionWithUnsignedIntegerSelectorFieldClassTypeDescr
1833 {
1834 };
1835
1836 template <>
1837 struct TypeDescr<ConstOptionWithUnsignedIntegerSelectorFieldClass> :
1838 public OptionWithUnsignedIntegerSelectorFieldClassTypeDescr
1839 {
1840 };
1841
1842 struct OptionWithSignedIntegerSelectorFieldClassTypeDescr
1843 {
1844 using Const = ConstOptionWithSignedIntegerSelectorFieldClass;
1845 using NonConst = OptionWithSignedIntegerSelectorFieldClass;
1846 };
1847
1848 template <>
1849 struct TypeDescr<OptionWithSignedIntegerSelectorFieldClass> :
1850 public OptionWithSignedIntegerSelectorFieldClassTypeDescr
1851 {
1852 };
1853
1854 template <>
1855 struct TypeDescr<ConstOptionWithSignedIntegerSelectorFieldClass> :
1856 public OptionWithSignedIntegerSelectorFieldClassTypeDescr
1857 {
1858 };
1859
1860 template <typename LibObjT>
1861 struct CommonVariantFieldClassOptionSpec;
1862
1863 /* Functions specific to mutable variant field class options */
1864 template <>
1865 struct CommonVariantFieldClassOptionSpec<bt_field_class_variant_option> final
1866 {
1867 static bt_field_class *fieldClass(bt_field_class_variant_option * const libObjPtr) noexcept
1868 {
1869 return bt_field_class_variant_option_borrow_field_class(libObjPtr);
1870 }
1871
1872 static bt_value *userAttributes(bt_field_class_variant_option * const libObjPtr) noexcept
1873 {
1874 return bt_field_class_variant_option_borrow_user_attributes(libObjPtr);
1875 }
1876 };
1877
1878 /* Functions specific to constant variant field class options */
1879 template <>
1880 struct CommonVariantFieldClassOptionSpec<const bt_field_class_variant_option> final
1881 {
1882 static const bt_field_class *
1883 fieldClass(const bt_field_class_variant_option * const libObjPtr) noexcept
1884 {
1885 return bt_field_class_variant_option_borrow_field_class_const(libObjPtr);
1886 }
1887
1888 static const bt_value *
1889 userAttributes(const bt_field_class_variant_option * const libObjPtr) noexcept
1890 {
1891 return bt_field_class_variant_option_borrow_user_attributes_const(libObjPtr);
1892 }
1893 };
1894
1895 } /* namespace internal */
1896
1897 template <typename LibObjT>
1898 class CommonVariantFieldClassOption : public BorrowedObject<LibObjT>
1899 {
1900 private:
1901 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
1902 using typename BorrowedObject<LibObjT>::_LibObjPtr;
1903 using _FieldClass = internal::DepFc<LibObjT>;
1904
1905 public:
1906 using UserAttributes = internal::DepUserAttrs<LibObjT>;
1907
1908 explicit CommonVariantFieldClassOption(const _LibObjPtr libObjPtr) noexcept :
1909 _ThisBorrowedObject {libObjPtr}
1910 {
1911 }
1912
1913 template <typename OtherLibObjT>
1914 CommonVariantFieldClassOption(const CommonVariantFieldClassOption<OtherLibObjT> fc) noexcept :
1915 _ThisBorrowedObject {fc}
1916 {
1917 }
1918
1919 template <typename OtherLibObjT>
1920 CommonVariantFieldClassOption&
1921 operator=(const CommonVariantFieldClassOption<OtherLibObjT> fc) noexcept
1922 {
1923 _ThisBorrowedObject::operator=(fc);
1924 return *this;
1925 }
1926
1927 CommonVariantFieldClassOption<const bt_field_class_variant_option> asConst() const noexcept
1928 {
1929 return CommonVariantFieldClassOption<const bt_field_class_variant_option> {*this};
1930 }
1931
1932 nonstd::optional<bpstd::string_view> name() const noexcept
1933 {
1934 const auto name = bt_field_class_variant_option_get_name(this->libObjPtr());
1935
1936 if (name) {
1937 return name;
1938 }
1939
1940 return nonstd::nullopt;
1941 }
1942
1943 _FieldClass fieldClass() const noexcept
1944 {
1945 return _FieldClass {
1946 internal::CommonVariantFieldClassOptionSpec<LibObjT>::fieldClass(this->libObjPtr())};
1947 }
1948
1949 template <typename LibValT>
1950 void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
1951 {
1952 static_assert(!std::is_const<LibObjT>::value,
1953 "Not available with `bt2::ConstVariantFieldClassOption`.");
1954
1955 bt_field_class_variant_option_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
1956 }
1957
1958 UserAttributes userAttributes() const noexcept
1959 {
1960 return UserAttributes {internal::CommonVariantFieldClassOptionSpec<LibObjT>::userAttributes(
1961 this->libObjPtr())};
1962 }
1963 };
1964
1965 using VariantFieldClassOption = CommonVariantFieldClassOption<bt_field_class_variant_option>;
1966
1967 using ConstVariantFieldClassOption =
1968 CommonVariantFieldClassOption<const bt_field_class_variant_option>;
1969
1970 namespace internal {
1971
1972 struct VariantFieldClassOptionTypeDescr
1973 {
1974 using Const = ConstVariantFieldClassOption;
1975 using NonConst = VariantFieldClassOption;
1976 };
1977
1978 template <>
1979 struct TypeDescr<VariantFieldClassOption> : public VariantFieldClassOptionTypeDescr
1980 {
1981 };
1982
1983 template <>
1984 struct TypeDescr<ConstVariantFieldClassOption> : public VariantFieldClassOptionTypeDescr
1985 {
1986 };
1987
1988 template <typename LibObjT>
1989 struct ConstVariantWithIntegerSelectorFieldClassOptionSpec;
1990
1991 /* Functions specific to variant field class options with unsigned integer selector */
1992 template <>
1993 struct ConstVariantWithIntegerSelectorFieldClassOptionSpec<
1994 const bt_field_class_variant_with_selector_field_integer_unsigned_option>
1995 final
1996 {
1997 static const bt_integer_range_set_unsigned *
1998 ranges(const bt_field_class_variant_with_selector_field_integer_unsigned_option
1999 * const libObjPtr) noexcept
2000 {
2001 return bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const(
2002 libObjPtr);
2003 }
2004
2005 static const bt_field_class_variant_option *
2006 asBaseOption(const bt_field_class_variant_with_selector_field_integer_unsigned_option
2007 * const libObjPtr) noexcept
2008 {
2009 return bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_const(
2010 libObjPtr);
2011 }
2012 };
2013
2014 /* Functions specific to variant field class options with signed integer selector */
2015 template <>
2016 struct ConstVariantWithIntegerSelectorFieldClassOptionSpec<
2017 const bt_field_class_variant_with_selector_field_integer_signed_option>
2018 final
2019 {
2020 static const bt_integer_range_set_signed *
2021 ranges(const bt_field_class_variant_with_selector_field_integer_signed_option
2022 * const libObjPtr) noexcept
2023 {
2024 return bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const(
2025 libObjPtr);
2026 }
2027
2028 static const bt_field_class_variant_option *
2029 asBaseOption(const bt_field_class_variant_with_selector_field_integer_signed_option
2030 * const libObjPtr) noexcept
2031 {
2032 return bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const(
2033 libObjPtr);
2034 }
2035 };
2036
2037 } /* namespace internal */
2038
2039 template <typename LibObjT>
2040 class ConstVariantWithIntegerSelectorFieldClassOption : public BorrowedObject<LibObjT>
2041 {
2042 private:
2043 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
2044 using typename BorrowedObject<LibObjT>::_LibObjPtr;
2045 using _Spec = internal::ConstVariantWithIntegerSelectorFieldClassOptionSpec<LibObjT>;
2046
2047 public:
2048 using RangeSet = typename std::conditional<
2049 std::is_same<
2050 LibObjT,
2051 const bt_field_class_variant_with_selector_field_integer_unsigned_option>::value,
2052 ConstUnsignedIntegerRangeSet, ConstSignedIntegerRangeSet>::type;
2053
2054 explicit ConstVariantWithIntegerSelectorFieldClassOption(const _LibObjPtr libObjPtr) noexcept :
2055 _ThisBorrowedObject {libObjPtr}
2056 {
2057 }
2058
2059 template <typename OtherLibObjT>
2060 ConstVariantWithIntegerSelectorFieldClassOption(
2061 const ConstVariantWithIntegerSelectorFieldClassOption<OtherLibObjT> fc) noexcept :
2062 _ThisBorrowedObject {fc}
2063 {
2064 }
2065
2066 template <typename OtherLibObjT>
2067 ConstVariantWithIntegerSelectorFieldClassOption&
2068 operator=(const ConstVariantWithIntegerSelectorFieldClassOption<OtherLibObjT> fc) noexcept
2069 {
2070 _ThisBorrowedObject::operator=(fc);
2071 return *this;
2072 }
2073
2074 ConstVariantFieldClassOption asBaseOption() const noexcept
2075 {
2076 return ConstVariantFieldClassOption {_Spec::asBaseOption(this->libObjPtr())};
2077 }
2078
2079 nonstd::optional<bpstd::string_view> name() const noexcept
2080 {
2081 return this->asBaseOption().name();
2082 }
2083
2084 ConstFieldClass fieldClass() const noexcept
2085 {
2086 return this->asBaseOption().fieldClass();
2087 }
2088
2089 RangeSet ranges() const noexcept
2090 {
2091 return RangeSet {_Spec::ranges(this->libObjPtr())};
2092 }
2093 };
2094
2095 using ConstVariantWithUnsignedIntegerSelectorFieldClassOption =
2096 ConstVariantWithIntegerSelectorFieldClassOption<
2097 const bt_field_class_variant_with_selector_field_integer_unsigned_option>;
2098
2099 using ConstVariantWithSignedIntegerSelectorFieldClassOption =
2100 ConstVariantWithIntegerSelectorFieldClassOption<
2101 const bt_field_class_variant_with_selector_field_integer_signed_option>;
2102
2103 namespace internal {
2104
2105 template <typename LibObjT>
2106 struct CommonVariantFieldClassSpec;
2107
2108 /* Functions specific to mutable variant field classes */
2109 template <>
2110 struct CommonVariantFieldClassSpec<bt_field_class> final
2111 {
2112 static bt_field_class_variant_option *optionByIndex(bt_field_class * const libObjPtr,
2113 const std::uint64_t index) noexcept
2114 {
2115 return bt_field_class_variant_borrow_option_by_index(libObjPtr, index);
2116 }
2117
2118 static bt_field_class_variant_option *optionByName(bt_field_class * const libObjPtr,
2119 const char * const name) noexcept
2120 {
2121 return bt_field_class_variant_borrow_option_by_name(libObjPtr, name);
2122 }
2123 };
2124
2125 /* Functions specific to constant variant field classes */
2126 template <>
2127 struct CommonVariantFieldClassSpec<const bt_field_class> final
2128 {
2129 static const bt_field_class_variant_option *
2130 optionByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
2131 {
2132 return bt_field_class_variant_borrow_option_by_index_const(libObjPtr, index);
2133 }
2134
2135 static const bt_field_class_variant_option *optionByName(const bt_field_class * const libObjPtr,
2136 const char * const name) noexcept
2137 {
2138 return bt_field_class_variant_borrow_option_by_name_const(libObjPtr, name);
2139 }
2140 };
2141
2142 } /* namespace internal */
2143
2144 template <typename LibObjT>
2145 class CommonVariantFieldClass : public CommonFieldClass<LibObjT>
2146 {
2147 private:
2148 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
2149
2150 protected:
2151 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
2152 using _ThisCommonVariantFieldClass = CommonVariantFieldClass<LibObjT>;
2153
2154 public:
2155 using Shared = SharedFieldClass<CommonVariantFieldClass<LibObjT>, LibObjT>;
2156
2157 using Option =
2158 internal::DepType<LibObjT, VariantFieldClassOption, ConstVariantFieldClassOption>;
2159
2160 using Iterator = CommonIterator<CommonVariantFieldClass, Option>;
2161
2162 explicit CommonVariantFieldClass(const _LibObjPtr libObjPtr) noexcept :
2163 _ThisCommonFieldClass {libObjPtr}
2164 {
2165 BT_ASSERT_DBG(this->isVariant());
2166 }
2167
2168 template <typename OtherLibObjT>
2169 CommonVariantFieldClass(const CommonVariantFieldClass<OtherLibObjT> fc) noexcept :
2170 _ThisCommonFieldClass {fc}
2171 {
2172 }
2173
2174 template <typename OtherLibObjT>
2175 CommonVariantFieldClass& operator=(const CommonVariantFieldClass<OtherLibObjT> fc) noexcept
2176 {
2177 _ThisCommonFieldClass::operator=(fc);
2178 return *this;
2179 }
2180
2181 CommonVariantFieldClass<const bt_field_class> asConst() const noexcept
2182 {
2183 return CommonVariantFieldClass<const bt_field_class> {*this};
2184 }
2185
2186 std::uint64_t length() const noexcept
2187 {
2188 return bt_field_class_variant_get_option_count(this->libObjPtr());
2189 }
2190
2191 Iterator begin() const noexcept
2192 {
2193 return Iterator {*this, 0};
2194 }
2195
2196 Iterator end() const noexcept
2197 {
2198 return Iterator {*this, this->length()};
2199 }
2200
2201 Option operator[](const std::uint64_t index) const noexcept
2202 {
2203 return Option {internal::CommonVariantFieldClassSpec<LibObjT>::optionByIndex(
2204 this->libObjPtr(), index)};
2205 }
2206
2207 nonstd::optional<Option> operator[](const char * const name) const noexcept
2208 {
2209 const auto libObjPtr =
2210 internal::CommonVariantFieldClassSpec<LibObjT>::optionByName(this->libObjPtr(), name);
2211
2212 if (libObjPtr) {
2213 return Option {libObjPtr};
2214 }
2215
2216 return nonstd::nullopt;
2217 }
2218
2219 nonstd::optional<Option> operator[](const std::string& name) const noexcept
2220 {
2221 return (*this)[name.data()];
2222 }
2223
2224 Shared shared() const noexcept
2225 {
2226 return Shared::createWithRef(*this);
2227 }
2228 };
2229
2230 using VariantFieldClass = CommonVariantFieldClass<bt_field_class>;
2231 using ConstVariantFieldClass = CommonVariantFieldClass<const bt_field_class>;
2232
2233 namespace internal {
2234
2235 struct VariantFieldClassTypeDescr
2236 {
2237 using Const = ConstVariantFieldClass;
2238 using NonConst = VariantFieldClass;
2239 };
2240
2241 template <>
2242 struct TypeDescr<VariantFieldClass> : public VariantFieldClassTypeDescr
2243 {
2244 };
2245
2246 template <>
2247 struct TypeDescr<ConstVariantFieldClass> : public VariantFieldClassTypeDescr
2248 {
2249 };
2250
2251 } /* namespace internal */
2252
2253 template <typename LibObjT>
2254 class CommonVariantWithoutSelectorFieldClass : public CommonVariantFieldClass<LibObjT>
2255 {
2256 private:
2257 using typename CommonVariantFieldClass<LibObjT>::_ThisCommonVariantFieldClass;
2258 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
2259
2260 public:
2261 using Shared = SharedFieldClass<CommonVariantWithoutSelectorFieldClass<LibObjT>, LibObjT>;
2262
2263 explicit CommonVariantWithoutSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept :
2264 _ThisCommonVariantFieldClass {libObjPtr}
2265 {
2266 BT_ASSERT_DBG(this->isVariantWithoutSelector());
2267 }
2268
2269 template <typename OtherLibObjT>
2270 CommonVariantWithoutSelectorFieldClass(
2271 const CommonVariantWithoutSelectorFieldClass<OtherLibObjT> fc) noexcept :
2272 _ThisCommonVariantFieldClass {fc}
2273 {
2274 }
2275
2276 template <typename OtherLibObjT>
2277 CommonVariantWithoutSelectorFieldClass&
2278 operator=(const CommonVariantWithoutSelectorFieldClass<OtherLibObjT> fc) noexcept
2279 {
2280 _ThisCommonVariantFieldClass::operator=(fc);
2281 return *this;
2282 }
2283
2284 CommonVariantWithoutSelectorFieldClass<const bt_field_class> asConst() const noexcept
2285 {
2286 return CommonVariantWithoutSelectorFieldClass<const bt_field_class> {*this};
2287 }
2288
2289 void appendOption(const char * const name, const FieldClass fc) const
2290 {
2291 static_assert(!std::is_const<LibObjT>::value,
2292 "Not available with `bt2::ConstVariantWithoutSelectorFieldClass`.");
2293
2294 const auto status = bt_field_class_variant_without_selector_append_option(
2295 this->libObjPtr(), name, fc.libObjPtr());
2296
2297 if (status ==
2298 BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
2299 throw MemoryError {};
2300 }
2301 }
2302
2303 void appendOption(const nonstd::optional<std::string>& name, const FieldClass fc) const
2304 {
2305 this->appendOption(name ? name->data() : nullptr, fc);
2306 }
2307
2308 Shared shared() const noexcept
2309 {
2310 return Shared::createWithRef(*this);
2311 }
2312 };
2313
2314 using VariantWithoutSelectorFieldClass = CommonVariantWithoutSelectorFieldClass<bt_field_class>;
2315 using ConstVariantWithoutSelectorFieldClass =
2316 CommonVariantWithoutSelectorFieldClass<const bt_field_class>;
2317
2318 namespace internal {
2319
2320 struct VariantWithoutSelectorFieldClassTypeDescr
2321 {
2322 using Const = ConstVariantWithoutSelectorFieldClass;
2323 using NonConst = VariantWithoutSelectorFieldClass;
2324 };
2325
2326 template <>
2327 struct TypeDescr<VariantWithoutSelectorFieldClass> :
2328 public VariantWithoutSelectorFieldClassTypeDescr
2329 {
2330 };
2331
2332 template <>
2333 struct TypeDescr<ConstVariantWithoutSelectorFieldClass> :
2334 public VariantWithoutSelectorFieldClassTypeDescr
2335 {
2336 };
2337
2338 template <typename OptionT>
2339 struct CommonVariantWithIntegerSelectorFieldClassSpec;
2340
2341 /* Functions specific to variant field classes with unsigned integer selector */
2342 template <>
2343 struct CommonVariantWithIntegerSelectorFieldClassSpec<
2344 ConstVariantWithUnsignedIntegerSelectorFieldClassOption>
2345 final
2346 {
2347 static const bt_field_class_variant_with_selector_field_integer_unsigned_option *
2348 optionByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
2349 {
2350 return bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
2351 libObjPtr, index);
2352 }
2353
2354 static const bt_field_class_variant_with_selector_field_integer_unsigned_option *
2355 optionByName(const bt_field_class * const libObjPtr, const char * const name) noexcept
2356 {
2357 return bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(
2358 libObjPtr, name);
2359 }
2360
2361 static bt_field_class_variant_with_selector_field_integer_append_option_status
2362 appendOption(bt_field_class * const libObjPtr, const char * const name,
2363 bt_field_class * const libOptFcPtr,
2364 const bt_integer_range_set_unsigned * const libRangesPtr)
2365 {
2366 return bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
2367 libObjPtr, name, libOptFcPtr, libRangesPtr);
2368 }
2369 };
2370
2371 /* Functions specific to variant field classes with signed integer selector */
2372 template <>
2373 struct CommonVariantWithIntegerSelectorFieldClassSpec<
2374 ConstVariantWithSignedIntegerSelectorFieldClassOption>
2375 final
2376 {
2377 static const bt_field_class_variant_with_selector_field_integer_signed_option *
2378 optionByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
2379 {
2380 return bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(
2381 libObjPtr, index);
2382 }
2383
2384 static const bt_field_class_variant_with_selector_field_integer_signed_option *
2385 optionByName(const bt_field_class * const libObjPtr, const char * const name) noexcept
2386 {
2387 return bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(
2388 libObjPtr, name);
2389 }
2390
2391 static bt_field_class_variant_with_selector_field_integer_append_option_status
2392 appendOption(bt_field_class * const libObjPtr, const char * const name,
2393 bt_field_class * const libOptFcPtr,
2394 const bt_integer_range_set_signed * const libRangesPtr)
2395 {
2396 return bt_field_class_variant_with_selector_field_integer_signed_append_option(
2397 libObjPtr, name, libOptFcPtr, libRangesPtr);
2398 }
2399 };
2400
2401 } /* namespace internal */
2402
2403 template <typename LibObjT>
2404 class CommonVariantWithSelectorFieldClass : public CommonVariantFieldClass<LibObjT>
2405 {
2406 private:
2407 using typename CommonVariantFieldClass<LibObjT>::_ThisCommonVariantFieldClass;
2408
2409 protected:
2410 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
2411 using _ThisCommonVariantWithSelectorFieldClass = CommonVariantWithSelectorFieldClass<LibObjT>;
2412
2413 public:
2414 using Shared = SharedFieldClass<_ThisCommonVariantWithSelectorFieldClass, LibObjT>;
2415
2416 explicit CommonVariantWithSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept :
2417 _ThisCommonVariantFieldClass {libObjPtr}
2418 {
2419 BT_ASSERT_DBG(this->isVariantWithSelector());
2420 }
2421
2422 template <typename OtherLibObjT>
2423 CommonVariantWithSelectorFieldClass(
2424 const CommonVariantWithSelectorFieldClass<OtherLibObjT> fc) noexcept :
2425 _ThisCommonVariantFieldClass {fc}
2426 {
2427 }
2428
2429 template <typename OtherLibObjT>
2430 CommonVariantWithSelectorFieldClass&
2431 operator=(const CommonVariantWithSelectorFieldClass<OtherLibObjT> fc) noexcept
2432 {
2433 _ThisCommonVariantFieldClass::operator=(fc);
2434 return *this;
2435 }
2436
2437 CommonVariantWithSelectorFieldClass<const bt_field_class> asConst() const noexcept
2438 {
2439 return CommonVariantWithSelectorFieldClass<const bt_field_class> {*this};
2440 }
2441
2442 ConstFieldPath selectorFieldPath() const noexcept
2443 {
2444 return ConstFieldPath {
2445 bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
2446 this->libObjPtr())};
2447 }
2448
2449 Shared shared() const noexcept
2450 {
2451 return Shared::createWithRef(*this);
2452 }
2453 };
2454
2455 using VariantWithSelectorFieldClass = CommonVariantWithSelectorFieldClass<bt_field_class>;
2456 using ConstVariantWithSelectorFieldClass =
2457 CommonVariantWithSelectorFieldClass<const bt_field_class>;
2458
2459 template <typename LibObjT, typename OptionT>
2460 class CommonVariantWithIntegerSelectorFieldClass :
2461 public CommonVariantWithSelectorFieldClass<LibObjT>
2462 {
2463 private:
2464 using typename CommonVariantWithSelectorFieldClass<
2465 LibObjT>::_ThisCommonVariantWithSelectorFieldClass;
2466 using typename CommonFieldClass<LibObjT>::_LibObjPtr;
2467 using _ThisCommonVariantWithIntegerSelectorFieldClass =
2468 CommonVariantWithIntegerSelectorFieldClass<LibObjT, OptionT>;
2469
2470 using _Spec = internal::CommonVariantWithIntegerSelectorFieldClassSpec<OptionT>;
2471
2472 public:
2473 using Shared = SharedFieldClass<_ThisCommonVariantWithIntegerSelectorFieldClass, LibObjT>;
2474
2475 using Option = OptionT;
2476 using Iterator =
2477 CommonIterator<CommonVariantWithIntegerSelectorFieldClass<LibObjT, Option>, Option>;
2478
2479 explicit CommonVariantWithIntegerSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept :
2480 _ThisCommonVariantWithSelectorFieldClass {libObjPtr}
2481 {
2482 BT_ASSERT_DBG(this->isVariant());
2483 }
2484
2485 template <typename OtherLibObjT>
2486 CommonVariantWithIntegerSelectorFieldClass(
2487 const CommonVariantWithIntegerSelectorFieldClass<OtherLibObjT, OptionT> fc) noexcept :
2488 _ThisCommonVariantWithSelectorFieldClass {fc}
2489 {
2490 }
2491
2492 template <typename OtherLibObjT>
2493 CommonVariantWithIntegerSelectorFieldClass&
2494 operator=(const CommonVariantWithIntegerSelectorFieldClass<OtherLibObjT, OptionT> fc) noexcept
2495 {
2496 _ThisCommonVariantWithSelectorFieldClass::operator=(fc);
2497 return *this;
2498 }
2499
2500 Option operator[](const std::uint64_t index) const noexcept
2501 {
2502 return Option {_Spec::optionByIndex(this->libObjPtr(), index)};
2503 }
2504
2505 nonstd::optional<Option> operator[](const char * const name) const noexcept
2506 {
2507 const auto libObjPtr = _Spec::optionByName(this->libObjPtr(), name);
2508
2509 if (libObjPtr) {
2510 return Option {libObjPtr};
2511 }
2512
2513 return nonstd::nullopt;
2514 }
2515
2516 nonstd::optional<Option> operator[](const std::string& name) const noexcept
2517 {
2518 return (*this)[name.data()];
2519 }
2520
2521 void appendOption(const char * const name, const FieldClass fc,
2522 const typename Option::RangeSet ranges) const
2523 {
2524 static_assert(
2525 !std::is_const<LibObjT>::value,
2526 "Not available with `bt2::ConstVariantWithUnsignedIntegerSelectorFieldClass`.");
2527
2528 const auto status =
2529 _Spec::appendOption(this->libObjPtr(), name, fc.libObjPtr(), ranges.libObjPtr());
2530
2531 if (status ==
2532 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
2533 throw MemoryError {};
2534 }
2535 }
2536
2537 void appendOption(const nonstd::optional<std::string>& name, const FieldClass fc,
2538 const typename Option::RangeSet ranges) const
2539 {
2540 this->appendOption(name ? name->data() : nullptr, fc, ranges);
2541 }
2542
2543 Iterator begin() const noexcept
2544 {
2545 return Iterator {*this, 0};
2546 }
2547
2548 Iterator end() const noexcept
2549 {
2550 return Iterator {*this, this->length()};
2551 }
2552
2553 Shared shared() const noexcept
2554 {
2555 return Shared::createWithRef(*this);
2556 }
2557 };
2558
2559 using VariantWithUnsignedIntegerSelectorFieldClass = CommonVariantWithIntegerSelectorFieldClass<
2560 bt_field_class, ConstVariantWithUnsignedIntegerSelectorFieldClassOption>;
2561
2562 using ConstVariantWithUnsignedIntegerSelectorFieldClass =
2563 CommonVariantWithIntegerSelectorFieldClass<
2564 const bt_field_class, ConstVariantWithUnsignedIntegerSelectorFieldClassOption>;
2565
2566 using VariantWithSignedIntegerSelectorFieldClass = CommonVariantWithIntegerSelectorFieldClass<
2567 bt_field_class, ConstVariantWithSignedIntegerSelectorFieldClassOption>;
2568
2569 using ConstVariantWithSignedIntegerSelectorFieldClass = CommonVariantWithIntegerSelectorFieldClass<
2570 const bt_field_class, ConstVariantWithSignedIntegerSelectorFieldClassOption>;
2571
2572 namespace internal {
2573
2574 struct VariantWithUnsignedIntegerSelectorFieldClassTypeDescr
2575 {
2576 using Const = ConstVariantWithUnsignedIntegerSelectorFieldClass;
2577 using NonConst = VariantWithUnsignedIntegerSelectorFieldClass;
2578 };
2579
2580 template <>
2581 struct TypeDescr<VariantWithUnsignedIntegerSelectorFieldClass> :
2582 public VariantWithUnsignedIntegerSelectorFieldClassTypeDescr
2583 {
2584 };
2585
2586 template <>
2587 struct TypeDescr<ConstVariantWithUnsignedIntegerSelectorFieldClass> :
2588 public VariantWithUnsignedIntegerSelectorFieldClassTypeDescr
2589 {
2590 };
2591
2592 struct VariantWithSignedIntegerSelectorFieldClassTypeDescr
2593 {
2594 using Const = ConstVariantWithSignedIntegerSelectorFieldClass;
2595 using NonConst = VariantWithSignedIntegerSelectorFieldClass;
2596 };
2597
2598 template <>
2599 struct TypeDescr<VariantWithSignedIntegerSelectorFieldClass> :
2600 public VariantWithSignedIntegerSelectorFieldClassTypeDescr
2601 {
2602 };
2603
2604 template <>
2605 struct TypeDescr<ConstVariantWithSignedIntegerSelectorFieldClass> :
2606 public VariantWithSignedIntegerSelectorFieldClassTypeDescr
2607 {
2608 };
2609
2610 } /* namespace internal */
2611
2612 template <typename LibObjT>
2613 CommonBitArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asBitArray() const noexcept
2614 {
2615 BT_ASSERT_DBG(this->isBitArray());
2616 return CommonBitArrayFieldClass<LibObjT> {this->libObjPtr()};
2617 }
2618
2619 template <typename LibObjT>
2620 CommonIntegerFieldClass<LibObjT> CommonFieldClass<LibObjT>::asInteger() const noexcept
2621 {
2622 BT_ASSERT_DBG(this->isInteger());
2623 return CommonIntegerFieldClass<LibObjT> {this->libObjPtr()};
2624 }
2625
2626 template <typename LibObjT>
2627 CommonBaseEnumerationFieldClass<LibObjT> CommonFieldClass<LibObjT>::asEnumeration() const noexcept
2628 {
2629 BT_ASSERT_DBG(this->isEnumeration());
2630 return CommonBaseEnumerationFieldClass<LibObjT> {this->libObjPtr()};
2631 }
2632
2633 template <typename LibObjT>
2634 CommonEnumerationFieldClass<LibObjT, ConstUnsignedEnumerationFieldClassMapping>
2635 CommonFieldClass<LibObjT>::asUnsignedEnumeration() const noexcept
2636 {
2637 BT_ASSERT_DBG(this->isUnsignedEnumeration());
2638 return CommonEnumerationFieldClass<LibObjT, ConstUnsignedEnumerationFieldClassMapping> {
2639 this->libObjPtr()};
2640 }
2641
2642 template <typename LibObjT>
2643 CommonEnumerationFieldClass<LibObjT, ConstSignedEnumerationFieldClassMapping>
2644 CommonFieldClass<LibObjT>::asSignedEnumeration() const noexcept
2645 {
2646 BT_ASSERT_DBG(this->isSignedEnumeration());
2647 return CommonEnumerationFieldClass<LibObjT, ConstSignedEnumerationFieldClassMapping> {
2648 this->libObjPtr()};
2649 }
2650
2651 template <typename LibObjT>
2652 CommonStructureFieldClass<LibObjT> CommonFieldClass<LibObjT>::asStructure() const noexcept
2653 {
2654 BT_ASSERT_DBG(this->isStructure());
2655 return CommonStructureFieldClass<LibObjT> {this->libObjPtr()};
2656 }
2657
2658 template <typename LibObjT>
2659 CommonArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asArray() const noexcept
2660 {
2661 BT_ASSERT_DBG(this->isArray());
2662 return CommonArrayFieldClass<LibObjT> {this->libObjPtr()};
2663 }
2664
2665 template <typename LibObjT>
2666 CommonStaticArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asStaticArray() const noexcept
2667 {
2668 BT_ASSERT_DBG(this->isStaticArray());
2669 return CommonStaticArrayFieldClass<LibObjT> {this->libObjPtr()};
2670 }
2671
2672 template <typename LibObjT>
2673 CommonDynamicArrayWithLengthFieldClass<LibObjT>
2674 CommonFieldClass<LibObjT>::asDynamicArrayWithLength() const noexcept
2675 {
2676 BT_ASSERT_DBG(this->isDynamicArrayWithLength());
2677 return CommonDynamicArrayWithLengthFieldClass<LibObjT> {this->libObjPtr()};
2678 }
2679
2680 template <typename LibObjT>
2681 CommonOptionFieldClass<LibObjT> CommonFieldClass<LibObjT>::asOption() const noexcept
2682 {
2683 BT_ASSERT_DBG(this->isOption());
2684 return CommonOptionFieldClass<LibObjT> {this->libObjPtr()};
2685 }
2686
2687 template <typename LibObjT>
2688 CommonOptionWithSelectorFieldClass<LibObjT>
2689 CommonFieldClass<LibObjT>::asOptionWithSelector() const noexcept
2690 {
2691 BT_ASSERT_DBG(this->isOptionWithSelector());
2692 return CommonOptionWithSelectorFieldClass<LibObjT> {this->libObjPtr()};
2693 }
2694
2695 template <typename LibObjT>
2696 CommonOptionWithBoolSelectorFieldClass<LibObjT>
2697 CommonFieldClass<LibObjT>::asOptionWithBoolSelector() const noexcept
2698 {
2699 BT_ASSERT_DBG(this->isOptionWithBoolSelector());
2700 return CommonOptionWithBoolSelectorFieldClass<LibObjT> {this->libObjPtr()};
2701 }
2702
2703 template <typename LibObjT>
2704 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstUnsignedIntegerRangeSet>
2705 CommonFieldClass<LibObjT>::asOptionWithUnsignedIntegerSelector() const noexcept
2706 {
2707 BT_ASSERT_DBG(this->isOptionWithUnsignedIntegerSelector());
2708 return CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstUnsignedIntegerRangeSet> {
2709 this->libObjPtr()};
2710 }
2711
2712 template <typename LibObjT>
2713 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstSignedIntegerRangeSet>
2714 CommonFieldClass<LibObjT>::asOptionWithSignedIntegerSelector() const noexcept
2715 {
2716 BT_ASSERT_DBG(this->isOptionWithSignedIntegerSelector());
2717 return CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstSignedIntegerRangeSet> {
2718 this->libObjPtr()};
2719 }
2720
2721 template <typename LibObjT>
2722 CommonVariantFieldClass<LibObjT> CommonFieldClass<LibObjT>::asVariant() const noexcept
2723 {
2724 BT_ASSERT_DBG(this->isVariant());
2725 return CommonVariantFieldClass<LibObjT> {this->libObjPtr()};
2726 }
2727
2728 template <typename LibObjT>
2729 CommonVariantWithoutSelectorFieldClass<LibObjT>
2730 CommonFieldClass<LibObjT>::asVariantWithoutSelector() const noexcept
2731 {
2732 BT_ASSERT_DBG(this->isVariantWithoutSelector());
2733 return CommonVariantWithoutSelectorFieldClass<LibObjT> {this->libObjPtr()};
2734 }
2735
2736 template <typename LibObjT>
2737 CommonVariantWithSelectorFieldClass<LibObjT>
2738 CommonFieldClass<LibObjT>::asVariantWithSelector() const noexcept
2739 {
2740 BT_ASSERT_DBG(this->isVariantWithSelector());
2741 return CommonVariantWithSelectorFieldClass<LibObjT> {this->libObjPtr()};
2742 }
2743
2744 template <typename LibObjT>
2745 CommonVariantWithIntegerSelectorFieldClass<LibObjT,
2746 ConstVariantWithUnsignedIntegerSelectorFieldClassOption>
2747 CommonFieldClass<LibObjT>::asVariantWithUnsignedIntegerSelector() const noexcept
2748 {
2749 BT_ASSERT_DBG(this->isVariantWithUnsignedIntegerSelector());
2750 return CommonVariantWithIntegerSelectorFieldClass<
2751 LibObjT, ConstVariantWithUnsignedIntegerSelectorFieldClassOption> {this->libObjPtr()};
2752 }
2753
2754 template <typename LibObjT>
2755 CommonVariantWithIntegerSelectorFieldClass<LibObjT,
2756 ConstVariantWithSignedIntegerSelectorFieldClassOption>
2757 CommonFieldClass<LibObjT>::asVariantWithSignedIntegerSelector() const noexcept
2758 {
2759 BT_ASSERT_DBG(this->isVariantWithSignedIntegerSelector());
2760 return CommonVariantWithIntegerSelectorFieldClass<
2761 LibObjT, ConstVariantWithSignedIntegerSelectorFieldClassOption> {this->libObjPtr()};
2762 }
2763
2764 } /* namespace bt2 */
2765
2766 #endif /* BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP */
This page took 0.080807 seconds and 3 git commands to generate.