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