lib: allow a single mapped clock class within a stream class
[babeltrace.git] / include / babeltrace / ctf-ir / stream-class-internal.h
index 2a481b0852c4d2a409a4eeba7e843e55700879dd..24c75848370e8c95dce52f3a77f6c66c69bb5694 100644 (file)
 #include <babeltrace/ctf-ir/trace.h>
 #include <babeltrace/object-internal.h>
 #include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf/types.h>
+#include <babeltrace/ctf-ir/trace-internal.h>
+#include <assert.h>
 #include <glib.h>
 
-struct bt_ctf_stream_class {
+struct bt_stream_class {
        struct bt_object base;
        GString *name;
        struct bt_ctf_clock *clock;
-       GPtrArray *event_classes; /* Array of pointers to bt_ctf_event_class */
+       GPtrArray *event_classes; /* Array of pointers to bt_event_class */
+       /* event class id (int64_t) to event class */
+       GHashTable *event_classes_ht;
        int id_set;
-       uint32_t id;
-       uint32_t next_event_id;
-       uint32_t next_stream_id;
-       /* Weak reference; a stream class does not have ownership of a trace */
-       struct bt_ctf_trace *trace;
-       struct bt_ctf_field_type *packet_context_type;
-       struct bt_ctf_field_type *event_header_type;
-       struct bt_ctf_field_type *event_context_type;
+       int64_t id;
+       int64_t next_event_id;
+       int64_t next_stream_id;
+       struct bt_field_type *packet_context_type;
+       struct bt_field_type *event_header_type;
+       struct bt_field_type *event_context_type;
        int frozen;
        int byte_order;
+
+       /*
+        * This flag indicates if the stream class is valid. A valid
+        * stream class is _always_ frozen.
+        */
+       int valid;
+
+       /*
+        * Unique clock class mapped to any field type within this
+        * stream class, including all the stream class's event class
+        * field types. This is only set if the stream class is frozen.
+        *
+        * If the stream class is frozen and this is still NULL, it is
+        * still possible that it becomes non-NULL because
+        * bt_stream_class_add_event_class() can add an event class
+        * containing a field type mapped to some clock class. In this
+        * case, this is the mapped clock class, and at this point, both
+        * the new event class and the stream class are frozen, so the
+        * next added event classes are expected to contain field types
+        * which only map to this specific clock class.
+        *
+        * If this is a CTF writer stream class, then this is the
+        * backing clock class of the `clock` member above.
+        */
+       struct bt_clock_class *clock_class;
 };
 
 BT_HIDDEN
-void bt_ctf_stream_class_freeze(struct bt_ctf_stream_class *stream_class);
+void bt_stream_class_freeze(struct bt_stream_class *stream_class);
 
 BT_HIDDEN
-int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class,
+int bt_stream_class_serialize(struct bt_stream_class *stream_class,
                struct metadata_context *context);
 
 BT_HIDDEN
-int bt_ctf_stream_class_set_byte_order(struct bt_ctf_stream_class *stream_class,
-               enum bt_ctf_byte_order byte_order);
+void bt_stream_class_set_byte_order(
+               struct bt_stream_class *stream_class, int byte_order);
 
 /* Set stream_class id without checking if the stream class is frozen */
 BT_HIDDEN
-int _bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class,
-               uint32_t id);
+void _bt_stream_class_set_id(struct bt_stream_class *stream_class,
+               int64_t id);
 
 BT_HIDDEN
-int bt_ctf_stream_class_set_id_no_check(
-               struct bt_ctf_stream_class *stream_class, uint32_t id);
+int bt_stream_class_set_id_no_check(
+               struct bt_stream_class *stream_class, int64_t id);
 
 BT_HIDDEN
-int bt_ctf_stream_class_set_trace(struct bt_ctf_stream_class *stream_class,
-               struct bt_ctf_trace *trace);
+int bt_stream_class_map_clock_class(
+               struct bt_stream_class *stream_class,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type);
+
+BT_HIDDEN
+int bt_stream_class_validate_single_clock_class(
+               struct bt_stream_class *stream_class,
+               struct bt_clock_class **expected_clock_class);
+
+static inline
+struct bt_trace *bt_stream_class_borrow_trace(
+               struct bt_stream_class *stream_class)
+{
+       assert(stream_class);
+       return (void *) bt_object_borrow_parent(stream_class);
+}
 
 #endif /* BABELTRACE_CTF_IR_STREAM_CLASS_INTERNAL_H */
This page took 0.023853 seconds and 4 git commands to generate.