sessiond: return raw pointer to packet header
[lttng-tools.git] / src / bin / lttng-sessiond / field.cpp
index 25f0e4676bf2f28aed15c311f218ac59a418ce9f..d81cf02c736ccb9f061fdacdf1dcf33cc2ebd66b 100644 (file)
@@ -10,6 +10,8 @@
 #include <common/exception.hpp>
 #include <common/format.hpp>
 
+#include <set>
+
 namespace lst = lttng::sessiond::trace;
 
 namespace {
@@ -68,12 +70,14 @@ lst::integer_type::integer_type(unsigned int in_alignment,
                enum lst::byte_order in_byte_order,
                unsigned int in_size,
                enum lst::integer_type::signedness in_signedness,
-               enum lst::integer_type::base in_base) :
+               enum lst::integer_type::base in_base,
+               roles in_roles) :
        type(in_alignment),
        byte_order{in_byte_order},
        size{in_size},
-       signedness{in_signedness},
-       base{in_base}
+       signedness_{in_signedness},
+       base_{in_base},
+       roles_{std::move(in_roles)}
 {
 }
 
@@ -83,8 +87,9 @@ bool lst::integer_type::_is_equal(const type &base_other) const noexcept
 
        return this->byte_order == other.byte_order &&
                this->size == other.size &&
-               this->signedness == other.signedness &&
-               this->base == other.base;
+               this->signedness_ == other.signedness_ &&
+               this->base_ == other.base_ &&
+               this->roles_ == other.roles_;
 }
 
 void lst::integer_type::accept(type_visitor& visitor) const
@@ -111,19 +116,16 @@ lst::floating_point_type::floating_point_type(unsigned int in_alignment,
        mantissa_digits(in_mantissa_digits)
 {
        /* Allowed (exponent, mantissa) pairs. */
-       static const std::vector<std::pair<unsigned int, unsigned int>> allowed_pairs{
+       static const std::set<std::pair<unsigned int, unsigned int>> allowed_pairs{
                        {5, 11}, /* binary16 */
                        {8, 24}, /* binary32 */
                        {11, 53}, /* binary64 */
                        {15, 113}, /* binary128 */
        };
 
-       const auto input_pair = decltype(allowed_pairs)::value_type(exponent_digits, mantissa_digits);
-       for (const auto& pair : allowed_pairs) {
-               if (input_pair == pair) {
-                       /* mantissa and exponent digits is a valid pair. */
-                       return;
-               }
+       if (allowed_pairs.find({exponent_digits, mantissa_digits}) != allowed_pairs.end()) {
+               /* mantissa and exponent digits is a valid pair. */
+               return;
        }
 
        LTTNG_THROW_INVALID_ARGUMENT_ERROR(
@@ -149,11 +151,20 @@ lst::enumeration_type::enumeration_type(unsigned int in_alignment,
                enum lst::byte_order in_byte_order,
                unsigned int in_size,
                enum signedness in_signedness,
-               enum base in_base) :
-       integer_type(in_alignment, in_byte_order, in_size, in_signedness, in_base)
+               enum base in_base,
+               lst::integer_type::roles in_roles) :
+       integer_type(in_alignment,
+                       in_byte_order,
+                       in_size,
+                       in_signedness,
+                       in_base,
+                       std::move(in_roles))
 {
 }
 
+namespace lttng {
+namespace sessiond {
+namespace trace {
 template <>
 void lst::signed_enumeration_type::accept(type_visitor& visitor) const
 {
@@ -165,6 +176,9 @@ void lst::unsigned_enumeration_type::accept(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)}
@@ -219,8 +233,44 @@ void lst::dynamic_length_array_type::accept(type_visitor& visitor) const
        visitor.visit(*this);
 }
 
+lst::static_length_blob_type::static_length_blob_type(
+               unsigned int in_alignment, uint64_t in_length_bytes, roles in_roles) :
+       type(in_alignment), length_bytes{in_length_bytes}, roles_{std::move(in_roles)}
+{
+}
+
+bool lst::static_length_blob_type::_is_equal(const type& base_other) const noexcept
+{
+       const auto& other = static_cast<decltype(*this)&>(base_other);
+
+       return length_bytes == other.length_bytes && roles_ == other.roles_;
+}
+
+void lst::static_length_blob_type::accept(type_visitor& visitor) const
+{
+       visitor.visit(*this);
+}
+
+lst::dynamic_length_blob_type::dynamic_length_blob_type(
+               unsigned int in_alignment, std::string in_length_field_name) :
+       type(in_alignment), length_field_name{std::move(in_length_field_name)}
+{
+}
+
+bool lst::dynamic_length_blob_type::_is_equal(const type& base_other) const noexcept
+{
+       const auto& other = dynamic_cast<decltype(*this)&>(base_other);
+
+       return length_field_name == other.length_field_name;
+}
+
+void lst::dynamic_length_blob_type::accept(type_visitor& visitor) const
+{
+       visitor.visit(*this);
+}
+
 lst::string_type::string_type(unsigned int in_alignment, enum encoding in_encoding) :
-       type(in_alignment), encoding{in_encoding}
+       type(in_alignment), encoding_{in_encoding}
 {
 }
 
@@ -228,7 +278,7 @@ bool lst::string_type::_is_equal(const type& base_other) const noexcept
 {
        const auto& other = static_cast<decltype(*this)&>(base_other);
 
-       return this->encoding == other.encoding;
+       return this->encoding_ == other.encoding_;
 }
 
 lst::static_length_string_type::static_length_string_type(
@@ -317,4 +367,4 @@ bool lst::variant_type::_is_equal(const type& base_other) const noexcept
 void lst::variant_type::accept(type_visitor& visitor) const
 {
        visitor.visit(*this);
-}
\ No newline at end of file
+}
This page took 0.025745 seconds and 4 git commands to generate.