X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=include%2Fbabeltrace%2Ftypes.h;h=7da11af24bab4c8e02b9c56f1322afaa45768f0c;hp=305d553d700d9a8a9588f22bac9c02580b603791;hb=2e7d72cf823b70b03d84e287ae4fda5b9ead7cb5;hpb=7fe001942cc8ece60d945cbfbd1d135ff548dc7d diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h index 305d553d..7da11af2 100644 --- a/include/babeltrace/types.h +++ b/include/babeltrace/types.h @@ -27,6 +27,9 @@ #include #include +/* Preallocate this many fields for structures */ +#define DEFAULT_NR_STRUCT_FIELDS 8 + /* * Always update stream_pos with move_pos and init_pos. */ @@ -128,9 +131,27 @@ struct type_class_string { struct type_class p; }; +struct field { + GQuark name; + struct type_class *type_class; +}; + struct type_class_struct { struct type_class p; - /* TODO */ + GHashTable *fields_by_name; /* Tuples (field name, field index) */ + GArray *fields; /* Array of fields */ +}; + +struct type_class_array { + struct type_class p; + size_t len; + struct type_class *elem; +}; + +struct type_class_sequence { + struct type_class p; + struct type_class_integer *len_class; + struct type_class *elem; }; struct type_class *ctf_lookup_type(GQuark qname); @@ -175,4 +196,40 @@ struct type_class_enum *enum_type_new(const char *name, size_t alignment); void enum_type_free(struct type_class_enum *enum_class); +struct type_class_struct *struct_type_new(const char *name); +void struct_type_free(struct type_class_struct *struct_class); +void struct_type_add_field(struct type_class_struct *struct_class, + GQuark field_name, + struct type_class *type_class); +/* + * Returns the index of a field within a structure. + */ +unsigned long +struct_type_lookup_field_index(struct type_class_struct *struct_class, + GQuark field_name); +/* + * field returned only valid as long as the field structure is not appended to. + */ +struct field * +struct_type_get_field_from_index(struct type_class_struct *struct_class, + unsigned long index); + +/* + * elem_class passed as parameter now belongs to the array. No need to free it + * explicitely. + */ +struct type_class_array *array_type_new(const char *name, + size_t len, + struct type_class *elem_class); +void array_type_free(struct type_class_array *array_class); + +/* + * int_class and elem_class passed as parameter now belongs to the sequence. No + * need to free them explicitely. + */ +struct type_class_sequence *sequence_type_new(const char *name, + struct type_class_integer *len_class, + struct type_class *elem_class); +void sequence_type_free(struct type_class_sequence *sequence_class); + #endif /* _BABELTRACE_TYPES_H */