Move to kernel style SPDX license identifiers
[babeltrace.git] / src / lib / trace-ir / field-class.h
index f2be12c3453b2090306b9edf0c384ee40425616e..af9254f29de5e3d7af2c2869a7745691dd18665c 100644 (file)
@@ -1,29 +1,13 @@
-#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
-#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
-
 /*
+ * SPDX-License-Identifier: MIT
+ *
  * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
  * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
+#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
+#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
+
 #include "lib/assert-pre.h"
 #include <babeltrace2/trace-ir/clock-class.h>
 #include <babeltrace2/trace-ir/field-class.h>
@@ -31,6 +15,7 @@
 #include "common/common.h"
 #include "lib/object.h"
 #include <babeltrace2/types.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <glib.h>
 
 
 #define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc)                           \
        (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
 
 #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name)                          \
        _name " is not an array field class: %![fc-]+F"
 
+#define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc)                          \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name)                         \
+       _name " is not an option field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc)                 \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name)                \
+       _name " is not an option field class with a selector: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc)             \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name)            \
+       _name " is not an option field class with an integer selector: %![fc-]+F"
+
 #define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc)                         \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR)
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
 
 #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name)                                \
        _name " is not a variant field class: %![fc-]+F"
 
 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc)                        \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR)
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
 
 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name)               \
        _name " is not a variant field class with a selector: %![fc-]+F"
        BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc),             \
                _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
 
+#define BT_ASSERT_PRE_FC_IS_OPTION(_fc, _name)                         \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc),            \
+               _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc, _name)                        \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc),   \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc, _name)            \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
+
 #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc, _name)                                \
        BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc),           \
                _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
        BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc),         \
                _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
 
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc, _name)                     \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc),        \
+               _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc, _name)            \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc, _name)                \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
+
 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc, _name)                    \
        BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc),       \
                _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
@@ -179,6 +213,9 @@ struct bt_field_class {
        enum bt_field_class_type type;
        bool frozen;
 
+       /* Owned by this */
+       struct bt_value *user_attributes;
+
        /*
         * This flag indicates whether or not this field class is part
         * of a trace class.
@@ -190,6 +227,11 @@ struct bt_field_class_bool {
        struct bt_field_class common;
 };
 
+struct bt_field_class_bit_array {
+       struct bt_field_class common;
+       uint64_t length;
+};
+
 struct bt_field_class_integer {
        struct bt_field_class common;
 
@@ -236,7 +278,6 @@ struct bt_field_class_enumeration {
 
 struct bt_field_class_real {
        struct bt_field_class common;
-       bool is_single_precision;
 };
 
 struct bt_field_class_string {
@@ -247,6 +288,9 @@ struct bt_field_class_string {
 struct bt_named_field_class {
        GString *name;
 
+       /* Owned by this */
+       struct bt_value *user_attributes;
+
        /* Owned by this */
        struct bt_field_class *fc;
 
@@ -255,8 +299,8 @@ struct bt_named_field_class {
 
 struct bt_field_class_structure_member;
 struct bt_field_class_variant_option;
-struct bt_field_class_variant_with_selector_unsigned_option;
-struct bt_field_class_variant_with_selector_signed_option;
+struct bt_field_class_variant_with_selector_field_integer_unsigned_option;
+struct bt_field_class_variant_with_selector_field_integer_signed_option;
 
 struct bt_field_class_named_field_class_container {
        struct bt_field_class common;
@@ -302,6 +346,10 @@ struct bt_field_class_option {
 
        /* Owned by this */
        struct bt_field_class *content_fc;
+};
+
+struct bt_field_class_option_with_selector_field {
+       struct bt_field_class_option common;
 
        /* Owned by this */
        struct bt_field_class *selector_fc;
@@ -310,8 +358,22 @@ struct bt_field_class_option {
        struct bt_field_path *selector_field_path;
 };
 
+struct bt_field_class_option_with_selector_field_bool {
+       struct bt_field_class_option_with_selector_field common;
+
+       /* Owned by this */
+       bool sel_is_reversed;
+};
+
+struct bt_field_class_option_with_selector_field_integer {
+       struct bt_field_class_option_with_selector_field common;
+
+       /* Owned by this */
+       const struct bt_integer_range_set *range_set;
+};
+
 /* Variant FC (with selector) option: named field class + range set */
-struct bt_field_class_variant_with_selector_option {
+struct bt_field_class_variant_with_selector_field_option {
        struct bt_named_field_class common;
 
        /* Owned by this */
@@ -324,13 +386,13 @@ struct bt_field_class_variant {
         * named field classes are of type
         * `struct bt_named_field_class *` if the variant field class
         * doesn't have a selector, or
-        * `struct bt_field_class_variant_with_selector_option *`
+        * `struct bt_field_class_variant_with_selector_field_option *`
         * if it has.
         */
        struct bt_field_class_named_field_class_container common;
 };
 
-struct bt_field_class_variant_with_selector {
+struct bt_field_class_variant_with_selector_field {
        struct bt_field_class_variant common;
 
        /*
This page took 0.026295 seconds and 4 git commands to generate.