From 341a67c453bb283829a0af408a3a8dda89a4da4a Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 26 Apr 2022 11:39:11 -0400 Subject: [PATCH] cpp-common: Expose BorrowedObj::libObjPtr() as public method This will be useful for component class queries that may use bt2::Value C++ wrappers but must return a `bt_value` at the moment. Signed-off-by: Francis Deslauriers Change-Id: Iea93caa6b47ce1afeb7977fee26dffdd3f97013e Reviewed-on: https://review.lttng.org/c/babeltrace/+/7948 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/10787 CI-Build: Philippe Proulx Tested-by: jenkins --- src/cpp-common/bt2/clock-class.hpp | 36 +-- src/cpp-common/bt2/clock-snapshot.hpp | 4 +- src/cpp-common/bt2/field-class.hpp | 144 +++++----- src/cpp-common/bt2/field-path.hpp | 12 +- src/cpp-common/bt2/field.hpp | 136 ++++----- src/cpp-common/bt2/integer-range-set.hpp | 14 +- src/cpp-common/bt2/integer-range.hpp | 8 +- src/cpp-common/bt2/internal/borrowed-obj.hpp | 14 +- src/cpp-common/bt2/internal/shared-obj.hpp | 4 +- src/cpp-common/bt2/message.hpp | 82 +++--- src/cpp-common/bt2/trace-ir.hpp | 280 +++++++++---------- src/cpp-common/bt2/value.hpp | 102 ++++--- 12 files changed, 412 insertions(+), 424 deletions(-) diff --git a/src/cpp-common/bt2/clock-class.hpp b/src/cpp-common/bt2/clock-class.hpp index c312bdbf..92caa9e4 100644 --- a/src/cpp-common/bt2/clock-class.hpp +++ b/src/cpp-common/bt2/clock-class.hpp @@ -124,19 +124,19 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_clock_class_set_frequency(this->_libObjPtr(), frequency); + bt_clock_class_set_frequency(this->libObjPtr(), frequency); } std::uint64_t frequency() const noexcept { - return bt_clock_class_get_frequency(this->_libObjPtr()); + return bt_clock_class_get_frequency(this->libObjPtr()); } void offset(const ClockClassOffset& offset) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_clock_class_set_offset(this->_libObjPtr(), offset.seconds(), offset.cycles()); + bt_clock_class_set_offset(this->libObjPtr(), offset.seconds(), offset.cycles()); } ClockClassOffset offset() const noexcept @@ -144,7 +144,7 @@ public: std::int64_t seconds; std::uint64_t cycles; - bt_clock_class_get_offset(this->_libObjPtr(), &seconds, &cycles); + bt_clock_class_get_offset(this->libObjPtr(), &seconds, &cycles); return ClockClassOffset {seconds, cycles}; } @@ -152,32 +152,32 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_clock_class_set_precision(this->_libObjPtr(), precision); + bt_clock_class_set_precision(this->libObjPtr(), precision); } std::uint64_t precision() const noexcept { - return bt_clock_class_get_precision(this->_libObjPtr()); + return bt_clock_class_get_precision(this->libObjPtr()); } void originIsUnixEpoch(const bool originIsUnixEpoch) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_clock_class_set_origin_is_unix_epoch(this->_libObjPtr(), + bt_clock_class_set_origin_is_unix_epoch(this->libObjPtr(), static_cast(originIsUnixEpoch)); } bool originIsUnixEpoch() const noexcept { - return static_cast(bt_clock_class_origin_is_unix_epoch(this->_libObjPtr())); + return static_cast(bt_clock_class_origin_is_unix_epoch(this->libObjPtr())); } void name(const char * const name) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_clock_class_set_name(this->_libObjPtr(), name); + const auto status = bt_clock_class_set_name(this->libObjPtr(), name); if (status == BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR) { throw LibMemoryError {}; @@ -191,7 +191,7 @@ public: nonstd::optional name() const noexcept { - const auto name = bt_clock_class_get_name(this->_libObjPtr()); + const auto name = bt_clock_class_get_name(this->libObjPtr()); if (name) { return name; @@ -204,7 +204,7 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_clock_class_set_description(this->_libObjPtr(), description); + const auto status = bt_clock_class_set_description(this->libObjPtr(), description); if (status == BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR) { throw LibMemoryError {}; @@ -218,7 +218,7 @@ public: nonstd::optional description() const noexcept { - const auto description = bt_clock_class_get_description(this->_libObjPtr()); + const auto description = bt_clock_class_get_description(this->libObjPtr()); if (description) { return description; @@ -229,12 +229,12 @@ public: void uuid(const std::uint8_t * const uuid) noexcept { - bt_clock_class_set_uuid(this->_libObjPtr(), uuid); + bt_clock_class_set_uuid(this->libObjPtr(), uuid); } nonstd::optional uuid() const noexcept { - const auto uuid = bt_clock_class_get_uuid(this->_libObjPtr()); + const auto uuid = bt_clock_class_get_uuid(this->libObjPtr()); if (uuid) { return bt2_common::UuidView {uuid}; @@ -248,26 +248,26 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_clock_class_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); + bt_clock_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); } ConstMapValue userAttributes() const noexcept { return ConstMapValue {internal::CommonClockClassSpec::userAttributes( - this->_libObjPtr())}; + this->libObjPtr())}; } UserAttributes userAttributes() noexcept { return UserAttributes { - internal::CommonClockClassSpec::userAttributes(this->_libObjPtr())}; + internal::CommonClockClassSpec::userAttributes(this->libObjPtr())}; } std::int64_t cyclesToNsFromOrigin(const std::uint64_t value) const { std::int64_t nsFromOrigin; const auto status = - bt_clock_class_cycles_to_ns_from_origin(this->_libObjPtr(), value, &nsFromOrigin); + bt_clock_class_cycles_to_ns_from_origin(this->libObjPtr(), value, &nsFromOrigin); if (status == BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) { throw LibOverflowError {}; diff --git a/src/cpp-common/bt2/clock-snapshot.hpp b/src/cpp-common/bt2/clock-snapshot.hpp index 301931f6..9bd7a6d6 100644 --- a/src/cpp-common/bt2/clock-snapshot.hpp +++ b/src/cpp-common/bt2/clock-snapshot.hpp @@ -35,7 +35,7 @@ public: std::uint64_t value() const noexcept { - return bt_clock_snapshot_get_value(this->_libObjPtr()); + return bt_clock_snapshot_get_value(this->libObjPtr()); } operator std::uint64_t() const noexcept @@ -46,7 +46,7 @@ public: std::int64_t nsFromOrigin() const { std::int64_t nsFromOrigin; - const auto status = bt_clock_snapshot_get_ns_from_origin(this->_libObjPtr(), &nsFromOrigin); + const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin); if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) { throw LibOverflowError {}; diff --git a/src/cpp-common/bt2/field-class.hpp b/src/cpp-common/bt2/field-class.hpp index dc25d4cf..a7ec0125 100644 --- a/src/cpp-common/bt2/field-class.hpp +++ b/src/cpp-common/bt2/field-class.hpp @@ -161,10 +161,10 @@ enum class FieldClassType template class CommonFieldClass : public internal::BorrowedObj { - /* Allow appendMember() to call `fc._libObjPtr()` */ + /* Allow appendMember() to call `fc.libObjPtr()` */ friend class CommonStructureFieldClass; - /* Allow appendOption() to call `fc._libObjPtr()` */ + /* Allow appendOption() to call `fc.libObjPtr()` */ friend class CommonVariantWithoutSelectorFieldClass; friend class CommonVariantWithIntegerSelectorFieldClass< @@ -177,11 +177,11 @@ class CommonFieldClass : public internal::BorrowedObj ConstVariantWithIntegerSelectorFieldClassOption< const bt_field_class_variant_with_selector_field_integer_signed_option>>; - /* Allow *FieldClass() to call `fc._libObjPtr()` */ + /* Allow *FieldClass() to call `fc.libObjPtr()` */ friend class CommonEventClass; friend class CommonStreamClass; - /* Allow create*FieldClass() to call `fc._libObjPtr()` */ + /* Allow create*FieldClass() to call `fc.libObjPtr()` */ friend class CommonTraceClass; private: @@ -215,7 +215,7 @@ public: FieldClassType type() const noexcept { - return static_cast(bt_field_class_get_type(this->_libObjPtr())); + return static_cast(bt_field_class_get_type(this->libObjPtr())); } bool isBool() const noexcept @@ -417,19 +417,19 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_field_class_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); + bt_field_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); } ConstMapValue userAttributes() const noexcept { return ConstMapValue {internal::CommonFieldClassSpec::userAttributes( - this->_libObjPtr())}; + this->libObjPtr())}; } UserAttributes userAttributes() noexcept { return UserAttributes { - internal::CommonFieldClassSpec::userAttributes(this->_libObjPtr())}; + internal::CommonFieldClassSpec::userAttributes(this->libObjPtr())}; } Shared shared() const noexcept @@ -440,7 +440,7 @@ public: protected: bool _libTypeIs(const bt_field_class_type type) const noexcept { - return bt_field_class_type_is(bt_field_class_get_type(this->_libObjPtr()), type); + return bt_field_class_type_is(bt_field_class_get_type(this->libObjPtr()), type); } }; @@ -479,7 +479,7 @@ public: std::uint64_t length() const noexcept { - return bt_field_class_bit_array_get_length(this->_libObjPtr()); + return bt_field_class_bit_array_get_length(this->libObjPtr()); } Shared shared() const noexcept @@ -535,12 +535,12 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_field_class_integer_get_field_value_range(this->_libObjPtr(), n); + bt_field_class_integer_get_field_value_range(this->libObjPtr(), n); } std::uint64_t fieldValueRange() const noexcept { - return bt_field_class_integer_get_field_value_range(this->_libObjPtr()); + return bt_field_class_integer_get_field_value_range(this->libObjPtr()); } void preferredDisplayBase(const DisplayBase base) noexcept @@ -548,13 +548,13 @@ public: static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); bt_field_class_integer_set_preferred_display_base( - this->_libObjPtr(), static_cast(base)); + this->libObjPtr(), static_cast(base)); } DisplayBase preferredDisplayBase() const noexcept { return static_cast( - bt_field_class_integer_get_preferred_display_base(this->_libObjPtr())); + bt_field_class_integer_get_preferred_display_base(this->libObjPtr())); } Shared shared() const noexcept @@ -642,12 +642,12 @@ public: RangeSet ranges() const noexcept { return RangeSet { - internal::ConstEnumerationFieldClassMappingSpec::ranges(this->_libObjPtr())}; + internal::ConstEnumerationFieldClassMappingSpec::ranges(this->libObjPtr())}; } bpstd::string_view label() const noexcept { - return internal::ConstEnumerationFieldClassMappingSpec::label(this->_libObjPtr()); + return internal::ConstEnumerationFieldClassMappingSpec::label(this->libObjPtr()); } }; @@ -734,7 +734,7 @@ public: std::uint64_t size() const noexcept { - return bt_field_class_enumeration_get_mapping_count(this->_libObjPtr()); + return bt_field_class_enumeration_get_mapping_count(this->libObjPtr()); } Shared shared() const noexcept @@ -779,13 +779,13 @@ public: Mapping operator[](const std::uint64_t index) const noexcept { return Mapping {internal::CommonEnumerationFieldClassSpec::mappingByIndex( - this->_libObjPtr(), index)}; + this->libObjPtr(), index)}; } nonstd::optional operator[](const char * const label) const noexcept { const auto libObjPtr = internal::CommonEnumerationFieldClassSpec::mappingByLabel( - this->_libObjPtr(), label); + this->libObjPtr(), label); if (libObjPtr) { return Mapping {libObjPtr}; @@ -881,19 +881,19 @@ public: bpstd::string_view name() const noexcept { - return bt_field_class_structure_member_get_name(this->_libObjPtr()); + return bt_field_class_structure_member_get_name(this->libObjPtr()); } ConstFieldClass fieldClass() const noexcept { return ConstFieldClass {internal::CommonStructureFieldClassMemberSpec< - const bt_field_class_structure_member>::fieldClass(this->_libObjPtr())}; + const bt_field_class_structure_member>::fieldClass(this->libObjPtr())}; } _FieldClass fieldClass() noexcept { return _FieldClass { - internal::CommonStructureFieldClassMemberSpec::fieldClass(this->_libObjPtr())}; + internal::CommonStructureFieldClassMemberSpec::fieldClass(this->libObjPtr())}; } }; @@ -982,7 +982,7 @@ public: static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto status = - bt_field_class_structure_append_member(this->_libObjPtr(), name, fc._libObjPtr()); + bt_field_class_structure_append_member(this->libObjPtr(), name, fc.libObjPtr()); if (status == BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR) { throw LibMemoryError {}; @@ -996,7 +996,7 @@ public: std::uint64_t size() const noexcept { - return bt_field_class_structure_get_member_count(this->_libObjPtr()); + return bt_field_class_structure_get_member_count(this->libObjPtr()); } Iterator begin() const noexcept @@ -1013,13 +1013,13 @@ public: { return ConstStructureFieldClassMember { internal::CommonStructureFieldClassSpec::memberByIndex( - this->_libObjPtr(), index)}; + this->libObjPtr(), index)}; } Member operator[](const std::uint64_t index) noexcept { return Member {internal::CommonStructureFieldClassSpec::memberByIndex( - this->_libObjPtr(), index)}; + this->libObjPtr(), index)}; } nonstd::optional @@ -1027,7 +1027,7 @@ public: { const auto libObjPtr = internal::CommonStructureFieldClassSpec::memberByName( - this->_libObjPtr(), name); + this->libObjPtr(), name); if (libObjPtr) { return ConstStructureFieldClassMember {libObjPtr}; @@ -1044,8 +1044,8 @@ public: nonstd::optional operator[](const char * const name) noexcept { - const auto libObjPtr = internal::CommonStructureFieldClassSpec::memberByName( - this->_libObjPtr(), name); + const auto libObjPtr = + internal::CommonStructureFieldClassSpec::memberByName(this->libObjPtr(), name); if (libObjPtr) { return Member {libObjPtr}; @@ -1134,13 +1134,13 @@ public: { return ConstFieldClass { internal::CommonArrayFieldClassSpec::elementFieldClass( - this->_libObjPtr())}; + this->libObjPtr())}; } _FieldClass elementFieldClass() noexcept { return _FieldClass { - internal::CommonArrayFieldClassSpec::elementFieldClass(this->_libObjPtr())}; + internal::CommonArrayFieldClassSpec::elementFieldClass(this->libObjPtr())}; } Shared shared() const noexcept @@ -1184,7 +1184,7 @@ public: std::uint64_t length() const noexcept { - return bt_field_class_array_static_get_length(this->_libObjPtr()); + return bt_field_class_array_static_get_length(this->libObjPtr()); } Shared shared() const noexcept @@ -1232,7 +1232,7 @@ public: { return ConstFieldPath { bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const( - this->_libObjPtr())}; + this->libObjPtr())}; } Shared shared() const noexcept @@ -1312,13 +1312,13 @@ public: { return ConstFieldClass { internal::CommonOptionFieldClassSpec::fieldClass( - this->_libObjPtr())}; + this->libObjPtr())}; } _FieldClass fieldClass() noexcept { return _FieldClass { - internal::CommonOptionFieldClassSpec::fieldClass(this->_libObjPtr())}; + internal::CommonOptionFieldClassSpec::fieldClass(this->libObjPtr())}; } Shared shared() const noexcept @@ -1368,7 +1368,7 @@ public: { return ConstFieldPath { bt_field_class_option_with_selector_field_borrow_selector_field_path_const( - this->_libObjPtr())}; + this->libObjPtr())}; } Shared shared() const noexcept @@ -1417,7 +1417,7 @@ public: bool selectorIsReversed() const noexcept { return bt_field_class_option_with_selector_field_bool_selector_is_reversed( - this->_libObjPtr()); + this->libObjPtr()); } Shared shared() const noexcept @@ -1504,7 +1504,7 @@ public: RangeSet ranges() const noexcept { return RangeSet {internal::CommonOptionWithIntegerSelectorFieldClassSpec::ranges( - this->_libObjPtr())}; + this->libObjPtr())}; } Shared shared() const noexcept @@ -1585,19 +1585,19 @@ public: bpstd::string_view name() const noexcept { - return bt_field_class_variant_option_get_name(this->_libObjPtr()); + return bt_field_class_variant_option_get_name(this->libObjPtr()); } ConstFieldClass fieldClass() const noexcept { return ConstFieldClass {internal::CommonVariantFieldClassOptionSpec< - const bt_field_class_variant_option>::fieldClass(this->_libObjPtr())}; + const bt_field_class_variant_option>::fieldClass(this->libObjPtr())}; } _FieldClass fieldClass() noexcept { return _FieldClass { - internal::CommonVariantFieldClassOptionSpec::fieldClass(this->_libObjPtr())}; + internal::CommonVariantFieldClassOptionSpec::fieldClass(this->libObjPtr())}; } }; @@ -1696,7 +1696,7 @@ public: ConstVariantFieldClassOption asBaseOption() const noexcept { - return ConstVariantFieldClassOption {_Spec::asBaseOption(this->_libObjPtr())}; + return ConstVariantFieldClassOption {_Spec::asBaseOption(this->libObjPtr())}; } bpstd::string_view name() const noexcept @@ -1711,7 +1711,7 @@ public: RangeSet ranges() const noexcept { - return RangeSet {_Spec::ranges(this->_libObjPtr())}; + return RangeSet {_Spec::ranges(this->libObjPtr())}; } }; @@ -1804,7 +1804,7 @@ public: std::uint64_t size() const noexcept { - return bt_field_class_variant_get_option_count(this->_libObjPtr()); + return bt_field_class_variant_get_option_count(this->libObjPtr()); } Iterator begin() const noexcept @@ -1821,13 +1821,13 @@ public: { return ConstVariantFieldClassOption { internal::CommonVariantFieldClassSpec::optionByIndex( - this->_libObjPtr(), index)}; + this->libObjPtr(), index)}; } Option operator[](const std::uint64_t index) noexcept { return Option {internal::CommonVariantFieldClassSpec::optionByIndex( - this->_libObjPtr(), index)}; + this->libObjPtr(), index)}; } nonstd::optional @@ -1835,7 +1835,7 @@ public: { const auto libObjPtr = internal::CommonVariantFieldClassSpec::optionByName( - this->_libObjPtr(), name); + this->libObjPtr(), name); if (libObjPtr) { return ConstVariantFieldClassOption {libObjPtr}; @@ -1853,7 +1853,7 @@ public: nonstd::optional