X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ffield.cpp;h=e46e06631eae121b4736547b31995839783bd381;hb=4bcf2294f0701b731d620c38216e1922e919e1b9;hp=35f4aa0eb4a9b3db1eb636312b433358c213c3e0;hpb=45110cdd99bd9ecc13a12d29afde3fffa48b4641;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/field.cpp b/src/bin/lttng-sessiond/field.cpp index 35f4aa0eb..e46e06631 100644 --- a/src/bin/lttng-sessiond/field.cpp +++ b/src/bin/lttng-sessiond/field.cpp @@ -110,6 +110,12 @@ lst::integer_type::integer_type(unsigned int in_alignment, { } +lst::type::cuptr lst::integer_type::copy() const +{ + return lttng::make_unique( + alignment, byte_order, size, signedness_, base_, roles_); +} + bool lst::integer_type::_is_equal(const type &base_other) const noexcept { const auto& other = static_cast(base_other); @@ -162,6 +168,12 @@ lst::floating_point_type::floating_point_type(unsigned int in_alignment, typeid(*this))); } +lst::type::cuptr lst::floating_point_type::copy() const +{ + return lttng::make_unique( + alignment, byte_order, exponent_digits, mantissa_digits); +} + void lst::floating_point_type::accept(type_visitor& visitor) const { visitor.visit(*this); @@ -191,37 +203,42 @@ lst::enumeration_type::enumeration_type(unsigned int in_alignment, { } +/* + * Due to a bug in g++ < 7.1, these specializations must be enclosed in the namespaces + * rather than using the usual `namespace::namespace::function` notation: + * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480. + */ namespace lttng { namespace sessiond { namespace trace { template <> -void lst::signed_enumeration_type::accept(type_visitor& visitor) const +void signed_enumeration_type::accept(type_visitor& visitor) const { visitor.visit(*this); } template <> -void lst::unsigned_enumeration_type::accept(type_visitor& visitor) const +void unsigned_enumeration_type::accept(type_visitor& visitor) const { visitor.visit(*this); } -} /* namespace trace */ -} /* namespace sessiond */ -} /* namespace lttng */ template <> -void lst::variant_type::accept( +void variant_type::accept( lst::type_visitor& visitor) const { visitor.visit(*this); } template <> -void lst::variant_type::accept( +void variant_type::accept( lst::type_visitor& visitor) const { visitor.visit(*this); } +} /* namespace trace */ +} /* namespace sessiond */ +} /* namespace lttng */ lst::array_type::array_type(unsigned int in_alignment, type::cuptr in_element_type) : type(in_alignment), element_type{std::move(in_element_type)} @@ -250,6 +267,12 @@ bool lst::static_length_array_type::_is_equal(const type& base_other) const noex return array_type::_is_equal(base_other) && this->length == other.length; } +lst::type::cuptr lst::static_length_array_type::copy() const +{ + return lttng::make_unique( + alignment, element_type->copy(), length); +} + void lst::static_length_array_type::accept(type_visitor& visitor) const { visitor.visit(*this); @@ -271,6 +294,12 @@ bool lst::dynamic_length_array_type::_is_equal(const type& base_other) const noe this->length_field_location == other.length_field_location; } +lst::type::cuptr lst::dynamic_length_array_type::copy() const +{ + return lttng::make_unique( + alignment, element_type->copy(), length_field_location); +} + void lst::dynamic_length_array_type::accept(type_visitor& visitor) const { visitor.visit(*this); @@ -289,6 +318,11 @@ bool lst::static_length_blob_type::_is_equal(const type& base_other) const noexc return length_bytes == other.length_bytes && roles_ == other.roles_; } +lst::type::cuptr lst::static_length_blob_type::copy() const +{ + return lttng::make_unique(alignment, length_bytes, roles_); +} + void lst::static_length_blob_type::accept(type_visitor& visitor) const { visitor.visit(*this); @@ -307,6 +341,11 @@ bool lst::dynamic_length_blob_type::_is_equal(const type& base_other) const noex return length_field_location == other.length_field_location; } +lst::type::cuptr lst::dynamic_length_blob_type::copy() const +{ + return lttng::make_unique(alignment, length_field_location); +} + void lst::dynamic_length_blob_type::accept(type_visitor& visitor) const { visitor.visit(*this); @@ -337,6 +376,11 @@ bool lst::static_length_string_type::_is_equal(const type& base_other) const noe return string_type::_is_equal(base_other) && this->length == other.length; } +lst::type::cuptr lst::static_length_string_type::copy() const +{ + return lttng::make_unique(alignment, encoding_, length); +} + void lst::static_length_string_type::accept(type_visitor& visitor) const { visitor.visit(*this); @@ -358,6 +402,12 @@ bool lst::dynamic_length_string_type::_is_equal(const type& base_other) const no this->length_field_location == other.length_field_location; } +lst::type::cuptr lst::dynamic_length_string_type::copy() const +{ + return lttng::make_unique( + alignment, encoding_, length_field_location); +} + void lst::dynamic_length_string_type::accept(type_visitor& visitor) const { visitor.visit(*this); @@ -369,13 +419,18 @@ lst::null_terminated_string_type::null_terminated_string_type(unsigned int in_al { } +lst::type::cuptr lst::null_terminated_string_type::copy() const +{ + return lttng::make_unique(alignment, encoding_); +} + void lst::null_terminated_string_type::accept(type_visitor& visitor) const { visitor.visit(*this); } lst::structure_type::structure_type(unsigned int in_alignment, fields in_fields) : - type(in_alignment), _fields{std::move(in_fields)} + type(in_alignment), fields_{std::move(in_fields)} { } @@ -383,7 +438,20 @@ bool lst::structure_type::_is_equal(const type& base_other) const noexcept { const auto &other = static_cast(base_other); - return fields_are_equal(this->_fields, other._fields); + return fields_are_equal(this->fields_, other.fields_); +} + +lst::type::cuptr lst::structure_type::copy() const +{ + structure_type::fields copy_of_fields; + + copy_of_fields.reserve(fields_.size()); + for (const auto& field : fields_) { + copy_of_fields.emplace_back(lttng::make_unique( + field->name, field->get_type().copy())); + } + + return lttng::make_unique(alignment, std::move(copy_of_fields)); } void lst::structure_type::accept(type_visitor& visitor) const