bt_ctf_ref_put(&event_class->ref_count, bt_ctf_event_class_destroy);
}
+BT_HIDDEN
+int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class,
+ uint32_t stream_id)
+{
+ int ret = 0;
+ struct bt_object *obj;
+
+ obj = bt_object_integer_create_init(stream_id);
+
+ if (!obj) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_attributes_set_field_value(event_class->attributes,
+ "stream_id", obj);
+
+end:
+ BT_OBJECT_PUT(obj);
+
+ return ret;
+}
+
struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class)
{
- int ret;
- struct bt_object *obj = NULL;
struct bt_ctf_event *event = NULL;
if (!event_class) {
goto end;
}
assert(event_class->stream_class->event_header_type);
-
- /* set "stream_id" attribute now that we know its value */
- obj = bt_object_integer_create_init(event_class->stream_class->id);
- if (!obj) {
- goto end;
- }
-
- ret = bt_ctf_attributes_set_field_value(event_class->attributes,
- "stream_id", obj);
- BT_OBJECT_PUT(obj);
-
- if (ret) {
- goto end;
- }
-
event = g_new0(struct bt_ctf_event, 1);
if (!event) {
goto end;
return 0;
}
-int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class,
- uint32_t id)
+struct event_class_set_stream_id_data {
+ uint32_t stream_id;
+ int ret;
+};
+
+static
+void event_class_set_stream_id(gpointer event_class, gpointer data)
+{
+ struct event_class_set_stream_id_data *typed_data = data;
+
+ typed_data->ret |= bt_ctf_event_class_set_stream_id(event_class,
+ typed_data->stream_id);
+}
+
+BT_HIDDEN
+int bt_ctf_stream_class_set_id_no_check(
+ struct bt_ctf_stream_class *stream_class, uint32_t id)
{
int ret = 0;
+ struct event_class_set_stream_id_data data =
+ { .stream_id = id, .ret = 0 };
- if (!stream_class || stream_class->frozen) {
- ret = -1;
+ /*
+ * Make sure all event classes have their "stream_id" attribute
+ * set to this value.
+ */
+ g_ptr_array_foreach(stream_class->event_classes,
+ event_class_set_stream_id, &data);
+ ret = data.ret;
+ if (ret) {
goto end;
}
return ret;
}
+int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class,
+ uint32_t id)
+{
+ int ret = 0;
+
+ if (!stream_class || stream_class->frozen) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_stream_class_set_id_no_check(stream_class, id);
+end:
+ return ret;
+}
+
static
void event_class_exists(gpointer element, gpointer query)
{
goto end;
}
+ ret = bt_ctf_event_class_set_stream_id(event_class, stream_class->id);
+ if (ret) {
+ goto end;
+ }
+
bt_ctf_event_class_get(event_class);
g_ptr_array_add(stream_class->event_classes, event_class);
bt_ctf_event_class_freeze(event_class);
int _bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class,
uint32_t id);
+BT_HIDDEN
+int bt_ctf_stream_class_set_id_no_check(
+ struct bt_ctf_stream_class *stream_class, uint32_t id);
+
BT_HIDDEN
int bt_ctf_stream_class_set_trace(struct bt_ctf_stream_class *stream_class,
struct bt_ctf_trace *trace);