Add C++ interface for the libbabeltrace2 `bt_field_class` API
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 17 Dec 2020 18:44:51 +0000 (13:44 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jan 2022 16:22:26 +0000 (11:22 -0500)
commit12435a68fc55fa763809f511465a1e6b2ec25e44
treeafb8350925c3cbf1d7ae0f46007fff3d772c719c
parent40ed8b0148b4b1d02dc1fd4f8fa4f615f40a4f59
Add C++ interface for the libbabeltrace2 `bt_field_class` API

This patch adds C++ wrappers for Babeltrace 2 field class objects.

The class hierarchy is:

    FieldClass
      BitArrayFieldClass
      IntegerFieldClass
        UnsignedEnumerationFieldClass
        SignedEnumerationFieldClass
      StructureFieldClass
      ArrayFieldClass
        StaticArrayFieldClass
        DynamicArrayWithLengthFieldClass
      OptionFieldClass
        OptionWithSelectorFieldClass
          OptionWithBoolSelectorFieldClass
          OptionWithUnsignedIntegerSelectorFieldClass
          OptionWithSignedIntegerSelectorFieldClass
      VariantFieldClass
        VariantWithoutSelectorFieldClass
        VariantWithUnsignedIntegerSelectorFieldClass
        VariantWithSignedIntegerSelectorFieldClass
    ConstFieldClass
      ConstBitArrayFieldClass
      ConstIntegerFieldClass
        ConstUnsignedEnumerationFieldClass
        ConstSignedEnumerationFieldClass
      ConstStructureFieldClass
      ConstArrayFieldClass
        ConstStaticArrayFieldClass
        ConstDynamicArrayWithLengthFieldClass
      ConstOptionFieldClass
        ConstOptionWithSelectorFieldClass
          ConstOptionWithBoolSelectorFieldClass
          ConstOptionWithUnsignedIntegerSelectorFieldClass
          ConstOptionWithSignedIntegerSelectorFieldClass
      ConstVariantFieldClass
        ConstVariantWithoutSelectorFieldClass
        ConstVariantWithUnsignedIntegerSelectorFieldClass
        ConstVariantWithSignedIntegerSelectorFieldClass
    ConstUnsignedEnumerationFieldClassMapping
    ConstSignedEnumerationFieldClassMapping
    StructureFieldClassMember
    ConstStructureFieldClassMember
    VariantFieldClassOption
    ConstVariantFieldClassOption
    ConstVariantWithUnsignedIntegerSelectorFieldClassOption
    ConstVariantWithSignedIntegerSelectorFieldClassOption

`ConstVariantWith*IntegerSelectorFieldClassOption` doesn't inherit
`ConstVariantFieldClassOption` as they don't wrap the same pointer type:
you need to call
bt_field_class_variant_with_selector_field_integer_*_option_as_option_const()
to obtain a `const bt_field_class_variant_option *` value. Therefore,
you can call asBaseOption() to get a `ConstVariantFieldClassOption`. I
also implemented name() and fieldClass() which call
asBaseOption().name() and asBaseOption().fieldClass().

Implicitly convert from a mutable field class to a constant field class
with converting constructors and assignment operators.

Those new template classes follow the approach of other wrappers in
`src/cpp-common/bt2`.

Because `bt2::FieldClass::userAttributes()` needs to access the
libbabeltrace2 pointer of the map value, `bt2::CommonValue` makes
`bt2::FieldClass` a friend.

Because
`bt2::VariantWithUnsignedIntegerSelectorFieldClass::appendOption()` and
`bt2::VariantWithSignedIntegerSelectorFieldClass::appendOption()` need
to access the libbabeltrace2 pointer of the integer range set,
`bt2::CommonIntegerRangeSet` makes those classes friends.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5244b603b1f43e61cfa52c4a5fb6b19e2cbac576
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4612
src/cpp-common/bt2/field-class.hpp [new file with mode: 0644]
src/cpp-common/bt2/integer-range-set.hpp
src/cpp-common/bt2/value.hpp
This page took 0.028304 seconds and 4 git commands to generate.