X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ffield.cpp;h=35f4aa0eb4a9b3db1eb636312b433358c213c3e0;hp=df51df488498589f9f4524f6025cce8a4f2366a4;hb=45110cdd99bd9ecc13a12d29afde3fffa48b4641;hpb=6e01cdc6c6e9cd18d99e8898fa3df41911388e8e diff --git a/src/bin/lttng-sessiond/field.cpp b/src/bin/lttng-sessiond/field.cpp index df51df488..35f4aa0eb 100644 --- a/src/bin/lttng-sessiond/field.cpp +++ b/src/bin/lttng-sessiond/field.cpp @@ -66,6 +66,9 @@ bool lst::type::operator!=(const lst::type& other) const noexcept lst::field::field(std::string in_name, lst::type::cuptr in_type) : name{std::move(in_name)}, _type{std::move(in_type)} { + if (!_type) { + LTTNG_THROW_ERROR(fmt::format("Invalid type used to create field: field name = `{}`", name)); + } } void lst::field::accept(lst::field_visitor& visitor) const @@ -78,6 +81,20 @@ bool lst::field::operator==(const lst::field& other) const noexcept return name == other.name && *_type == *other._type; } +lst::type::cuptr lst::field::move_type() noexcept +{ + return std::move(_type); +} + +const lst::type &lst::field::get_type() const +{ + if (_type) { + return *_type; + } else { + LTTNG_THROW_ERROR(fmt::format("Invalid attempt to access field type after transfer: field name = `{}`", name)); + } +} + lst::integer_type::integer_type(unsigned int in_alignment, enum lst::byte_order in_byte_order, unsigned int in_size, @@ -192,6 +209,20 @@ void lst::unsigned_enumeration_type::accept(type_visitor& visitor) const } /* namespace sessiond */ } /* namespace lttng */ +template <> +void lst::variant_type::accept( + lst::type_visitor& visitor) const +{ + visitor.visit(*this); +} + +template <> +void lst::variant_type::accept( + lst::type_visitor& visitor) const +{ + visitor.visit(*this); +} + lst::array_type::array_type(unsigned int in_alignment, type::cuptr in_element_type) : type(in_alignment), element_type{std::move(in_element_type)} { @@ -359,28 +390,3 @@ void lst::structure_type::accept(type_visitor& visitor) const { visitor.visit(*this); } - -lst::variant_type::variant_type(unsigned int in_alignment, - field_location in_selector_field_location, - choices in_choices) : - type(in_alignment), - selector_field_location{std::move(in_selector_field_location)}, - _choices -{std::move(in_choices)} -{ -} - -bool lst::variant_type::_is_equal(const type& base_other) const noexcept -{ - const auto &other = static_cast(base_other); - - return this->selector_field_location == other.selector_field_location && - fields_are_equal(this->_choices -, other._choices -); -} - -void lst::variant_type::accept(type_visitor& visitor) const -{ - visitor.visit(*this); -}