sessiond: ust: conditionally enable the underscore prefix variant quirk
[lttng-tools.git] / src / bin / lttng-sessiond / field.cpp
index 4a7915e203b0fcf74a743b40b3503066dd61eaf8..e46e06631eae121b4736547b31995839783bd381 100644 (file)
@@ -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<integer_type>(
+                       alignment, byte_order, size, signedness_, base_, roles_);
+}
+
 bool lst::integer_type::_is_equal(const type &base_other) const noexcept
 {
        const auto& other = static_cast<decltype(*this)&>(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<floating_point_type>(
+                       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<lst::signed_enumeration_type::mapping::range_t::range_integer_t>::accept(
+void variant_type<lst::signed_enumeration_type::mapping::range_t::range_integer_t>::accept(
                lst::type_visitor& visitor) const
 {
        visitor.visit(*this);
 }
 
 template <>
-void lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::accept(
+void variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::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<static_length_array_type>(
+                       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<dynamic_length_array_type>(
+                       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<static_length_blob_type>(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<dynamic_length_blob_type>(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<static_length_string_type>(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<dynamic_length_string_type>(
+                       alignment, encoding_, length_field_location);
+}
+
 void lst::dynamic_length_string_type::accept(type_visitor& visitor) const
 {
        visitor.visit(*this);
@@ -369,6 +419,11 @@ 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<null_terminated_string_type>(alignment, encoding_);
+}
+
 void lst::null_terminated_string_type::accept(type_visitor& visitor) const
 {
        visitor.visit(*this);
@@ -386,7 +441,20 @@ bool lst::structure_type::_is_equal(const type& base_other) const noexcept
        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<lst::field>(
+                               field->name, field->get_type().copy()));
+       }
+
+       return lttng::make_unique<structure_type>(alignment, std::move(copy_of_fields));
+}
+
 void lst::structure_type::accept(type_visitor& visitor) const
 {
        visitor.visit(*this);
-}
\ No newline at end of file
+}
This page took 0.025439 seconds and 4 git commands to generate.