ir: rename ctf_type_id -> bt_ctf_type_id
[babeltrace.git] / include / babeltrace / ctf-ir / event-types-internal.h
index a5057e207b5cab8583781814389e0156f0a0407d..8eaaeb88e8cda89d083fe6cf91fe42bcf72ec03d 100644 (file)
  */
 
 #include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/ctf-writer/ref-internal.h>
 #include <babeltrace/ctf-writer/event-fields.h>
 #include <babeltrace/ctf-writer/writer.h>
 #include <babeltrace/ctf-ir/trace-internal.h>
 #include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/object-internal.h>
 #include <babeltrace/types.h>
 #include <babeltrace/ctf/events.h>
 #include <glib.h>
@@ -42,7 +42,7 @@ typedef int (*type_serialize_func)(struct bt_ctf_field_type *,
                struct metadata_context *);
 
 struct bt_ctf_field_type {
-       struct bt_ctf_ref ref_count;
+       struct bt_object base;
        struct bt_declaration *declaration;
        type_freeze_func freeze;
        type_serialize_func serialize;
@@ -51,12 +51,27 @@ struct bt_ctf_field_type {
         * a field has been instanciated from it.
         */
        int frozen;
+
+       /*
+        * This flag indicates if the field type is valid. A valid
+        * field type is _always_ frozen. All the nested field types of
+        * a valid field type are also valid (and thus frozen).
+        */
+       int valid;
 };
 
 struct bt_ctf_field_type_integer {
        struct bt_ctf_field_type parent;
        struct declaration_integer declaration;
        struct bt_ctf_clock *mapped_clock;
+
+       /*
+        * This is what the user sets and is never modified by internal
+        * code.
+        *
+        * This field must contain a `BT_CTF_BYTE_ORDER_*` value.
+        */
+       enum bt_ctf_byte_order user_byte_order;
 };
 
 struct enumeration_mapping {
@@ -75,16 +90,30 @@ struct enumeration_mapping {
 struct bt_ctf_field_type_enumeration {
        struct bt_ctf_field_type parent;
        struct bt_ctf_field_type *container;
-       GPtrArray *entries; /* Array of pointers to struct enum_mapping */
+       GPtrArray *entries; /* Array of ptrs to struct enumeration_mapping */
        struct declaration_enum declaration;
 };
 
 struct bt_ctf_field_type_floating_point {
        struct bt_ctf_field_type parent;
        struct declaration_float declaration;
+
+       /*
+        * The `declaration` field above contains 3 pointers pointing
+        * to the fields below. This avoids unnecessary dynamic
+        * allocations.
+        */
        struct declaration_integer sign;
        struct declaration_integer mantissa;
        struct declaration_integer exp;
+
+       /*
+        * This is what the user sets and is never modified by internal
+        * code.
+        *
+        * This field must contain a `BT_CTF_BYTE_ORDER_*` value.
+        */
+       enum bt_ctf_byte_order user_byte_order;
 };
 
 struct structure_field {
@@ -103,6 +132,7 @@ struct bt_ctf_field_type_variant {
        struct bt_ctf_field_type parent;
        GString *tag_name;
        struct bt_ctf_field_type_enumeration *tag;
+       struct bt_ctf_field_path *tag_field_path;
        GHashTable *field_name_to_index;
        GPtrArray *fields; /* Array of pointers to struct structure_field */
        struct declaration_variant declaration;
@@ -119,6 +149,7 @@ struct bt_ctf_field_type_sequence {
        struct bt_ctf_field_type parent;
        struct bt_ctf_field_type *element_type;
        GString *length_field_name;
+       struct bt_ctf_field_path *length_field_path;
        struct declaration_sequence declaration;
 };
 
@@ -165,8 +196,56 @@ BT_HIDDEN
 struct bt_ctf_field_type *bt_ctf_field_type_copy(
                struct bt_ctf_field_type *type);
 
-
 BT_HIDDEN
 int bt_ctf_field_type_structure_get_field_name_index(
                struct bt_ctf_field_type *structure, const char *name);
+
+/* Replace an existing field's type in a structure */
+BT_HIDDEN
+int bt_ctf_field_type_structure_set_field_index(
+               struct bt_ctf_field_type *structure,
+               struct bt_ctf_field_type *field, int index);
+
+BT_HIDDEN
+int bt_ctf_field_type_variant_get_field_name_index(
+               struct bt_ctf_field_type *variant, const char *name);
+
+BT_HIDDEN
+int bt_ctf_field_type_sequence_set_length_field_path(
+               struct bt_ctf_field_type *type,
+               struct bt_ctf_field_path *path);
+
+BT_HIDDEN
+int bt_ctf_field_type_variant_set_tag_field_path(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_path *path);
+
+BT_HIDDEN
+int bt_ctf_field_type_variant_set_tag_field_type(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_type *tag_type);
+
+/* Replace an existing field's type in a variant */
+BT_HIDDEN
+int bt_ctf_field_type_variant_set_field_index(
+               struct bt_ctf_field_type *variant,
+               struct bt_ctf_field_type *field, int index);
+
+BT_HIDDEN
+int bt_ctf_field_type_array_set_element_type(struct bt_ctf_field_type *array,
+               struct bt_ctf_field_type *element_type);
+
+BT_HIDDEN
+int bt_ctf_field_type_sequence_set_element_type(struct bt_ctf_field_type *array,
+               struct bt_ctf_field_type *element_type);
+
+BT_HIDDEN
+int bt_ctf_field_type_get_field_count(struct bt_ctf_field_type *type);
+
+BT_HIDDEN
+struct bt_ctf_field_type *bt_ctf_field_type_get_field_at_index(
+               struct bt_ctf_field_type *type, int index);
+
+BT_HIDDEN
+int bt_ctf_field_type_get_field_index(struct bt_ctf_field_type *type,
+               const char *name);
+
 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.02682 seconds and 4 git commands to generate.