lib: add option field classes with integer selectors
[babeltrace.git] / src / lib / trace-ir / field-class.h
index 568edaf9ac738a870580b05f28dc0a3ea0b76433..fa970d435d856a909fc57f2ae22a9d7c484cbda7 100644 (file)
 #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 || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR)
+
+#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 || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR)
+
+#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 || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR)
+
+#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 || \
        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))
@@ -312,6 +360,10 @@ struct bt_field_class_option {
 
        /* Owned by this */
        struct bt_field_class *content_fc;
+};
+
+struct bt_field_class_option_with_selector {
+       struct bt_field_class_option common;
 
        /* Owned by this */
        struct bt_field_class *selector_fc;
@@ -320,6 +372,20 @@ struct bt_field_class_option {
        struct bt_field_path *selector_field_path;
 };
 
+struct bt_field_class_option_with_selector_bool {
+       struct bt_field_class_option_with_selector common;
+
+       /* Owned by this */
+       bool sel_is_reversed;
+};
+
+struct bt_field_class_option_with_selector_integer {
+       struct bt_field_class_option_with_selector 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_named_field_class common;
This page took 0.02458 seconds and 4 git commands to generate.