Restructure objects around generic_rw() accessor
[babeltrace.git] / include / babeltrace / types.h
index 080ea6f17a7182ef7eabc0e3ed34e124e5cc5dba..c44ea2ddbaab3e5bff4aa7072b3ad52062c6ad8b 100644 (file)
@@ -35,10 +35,6 @@ struct stream_pos;
 struct format;
 struct definition;
 
-/* Parent of per-plugin positions */
-struct stream_pos {
-};
-
 /* type scope */
 struct declaration_scope {
        /* Hash table mapping type name GQuark to "struct declaration" */
@@ -99,13 +95,6 @@ struct declaration {
         * definition_free called with definition ref is decremented to 0.
         */
        void (*definition_free)(struct definition *definition);
-       /*
-        * Definition copy function. Knows how to find the child
-        * definition from the parent definition.
-        */
-       void (*copy)(struct stream_pos *dest, const struct format *fdest, 
-                    struct stream_pos *src, const struct format *fsrc,
-                    struct definition *definition);
 };
 
 struct definition {
@@ -114,6 +103,26 @@ struct definition {
        int ref;                /* number of references to the definition */
 };
 
+typedef void (*rw_dispatch)(struct stream_pos *pos,
+                           struct definition *definition);
+
+/* Parent of per-plugin positions */
+struct stream_pos {
+       /* read/write dispatch table. Specific to plugin used for stream. */
+       rw_dispatch *rw_table;  /* rw dispatch table */
+};
+
+static inline
+void generic_rw(struct stream_pos *pos, struct definition *definition)
+{
+       enum ctf_type_id dispatch_id = definition->declaration->id;
+       rw_dispatch call;
+
+       assert(pos->rw_table[dispatch_id] != NULL);
+       call = pos->rw_table[dispatch_id];
+       call(pos, definition);
+}
+
 /*
  * Because we address in bits, bitfields end up being exactly the same as
  * integers, except that their read/write functions must be able to deal with
@@ -148,6 +157,9 @@ struct declaration_float {
 struct definition_float {
        struct definition p;
        struct declaration_float *declaration;
+       struct definition_integer *sign;
+       struct definition_integer *mantissa;
+       struct definition_integer *exp;
        /* Last values read */
        long double value;
 };
@@ -219,6 +231,7 @@ struct definition_string {
        struct definition p;
        struct declaration_string *declaration;
        char *value;    /* freed at definition_string teardown */
+       size_t len, alloc_len;
 };
 
 struct declaration_field {
@@ -424,6 +437,7 @@ struct_declaration_get_field_from_index(struct declaration_struct *struct_declar
 struct field *
 struct_definition_get_field_from_index(struct definition_struct *struct_definition,
                                       int index);
+void struct_rw(struct stream_pos *pos, struct definition *definition);
 
 /*
  * The tag enumeration is validated to ensure that it contains only mappings
@@ -452,6 +466,7 @@ int variant_definition_set_tag(struct definition_variant *variant,
  * to.
  */
 struct field *variant_get_current_field(struct definition_variant *variant);
+void variant_rw(struct stream_pos *pos, struct definition *definition);
 
 /*
  * elem_declaration passed as parameter now belongs to the array. No
@@ -463,6 +478,7 @@ struct declaration_array *
                struct declaration_scope *parent_scope);
 uint64_t array_len(struct definition_array *array);
 struct definition *array_index(struct definition_array *array, uint64_t i);
+void array_rw(struct stream_pos *pos, struct definition *definition);
 
 /*
  * int_declaration and elem_declaration passed as parameter now belong
@@ -474,6 +490,7 @@ struct declaration_sequence *
                struct declaration_scope *parent_scope);
 uint64_t sequence_len(struct definition_sequence *sequence);
 struct definition *sequence_index(struct definition_sequence *sequence, uint64_t i);
+void sequence_rw(struct stream_pos *pos, struct definition *definition);
 
 /*
  * in: path (dot separated), out: q (GArray of GQuark)
This page took 0.023724 seconds and 4 git commands to generate.