static
void bt_ctf_stream_class_destroy(struct bt_ctf_ref *ref);
static
-int init_event_header(struct bt_ctf_stream_class *stream_class,
- enum bt_ctf_byte_order byte_order);
+int init_event_header(struct bt_ctf_stream_class *stream_class);
static
-int init_packet_context(struct bt_ctf_stream_class *stream_class,
- enum bt_ctf_byte_order byte_order);
+int init_packet_context(struct bt_ctf_stream_class *stream_class);
struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name)
{
goto error_destroy;
}
- ret = init_packet_context(stream_class, BT_CTF_BYTE_ORDER_NATIVE);
+ ret = init_event_header(stream_class);
+ if (ret) {
+ goto error_destroy;
+ }
+
+ ret = init_packet_context(stream_class);
if (ret) {
goto error_destroy;
}
}
assert(stream_class->packet_context_type);
+ if (stream_class->packet_context_type == packet_context_type) {
+ goto end;
+ }
if (bt_ctf_field_type_get_type_id(packet_context_type) !=
CTF_TYPE_STRUCT) {
/* A packet context must be a structure */
return ret;
}
+struct bt_ctf_field_type *bt_ctf_stream_class_get_event_header_type(
+ struct bt_ctf_stream_class *stream_class)
+{
+ struct bt_ctf_field_type *ret = NULL;
+
+ if (!stream_class || !stream_class->event_header_type) {
+ goto end;
+ }
+
+ assert(stream_class->event_header_type);
+ bt_ctf_field_type_get(stream_class->event_header_type);
+ ret = stream_class->event_header_type;
+end:
+ return ret;
+}
+
+int bt_ctf_stream_class_set_event_header_type(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_field_type *event_header_type)
+{
+ int ret = 0;
+
+ if (!stream_class || !event_header_type || stream_class->frozen) {
+ ret = -1;
+ goto end;
+ }
+
+ assert(stream_class->event_header_type);
+ if (stream_class->event_header_type == event_header_type) {
+ goto end;
+ }
+ if (bt_ctf_field_type_get_type_id(event_header_type) !=
+ CTF_TYPE_STRUCT) {
+ /* An event header must be a structure */
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_field_type_put(stream_class->event_header_type);
+ bt_ctf_field_type_get(event_header_type);
+ stream_class->event_header_type = event_header_type;
+end:
+ return ret;
+}
+
struct bt_ctf_field_type *bt_ctf_stream_class_get_event_context_type(
struct bt_ctf_stream_class *stream_class)
{
}
stream_class->frozen = 1;
+ bt_ctf_field_type_freeze(stream_class->event_header_type);
bt_ctf_field_type_freeze(stream_class->packet_context_type);
bt_ctf_field_type_freeze(stream_class->event_context_type);
bt_ctf_clock_freeze(stream_class->clock);
}
bt_ctf_field_type_put(stream_class->event_header_type);
- bt_ctf_field_put(stream_class->event_header);
bt_ctf_field_type_put(stream_class->packet_context_type);
if (stream_class->event_context_type) {
bt_ctf_field_type_put(stream_class->event_context_type);
}
static
-int init_event_header(struct bt_ctf_stream_class *stream_class,
- enum bt_ctf_byte_order byte_order)
+int init_event_header(struct bt_ctf_stream_class *stream_class)
{
int ret = 0;
struct bt_ctf_field_type *event_header_type =
goto end;
}
- stream_class->event_header_type = event_header_type;
- stream_class->event_header = bt_ctf_field_create(
- stream_class->event_header_type);
- if (!stream_class->event_header) {
- ret = -1;
+ if (stream_class->event_header_type) {
+ bt_ctf_field_type_put(stream_class->event_header_type);
}
+ stream_class->event_header_type = event_header_type;
end:
if (ret) {
bt_ctf_field_type_put(event_header_type);
}
static
-int init_packet_context(struct bt_ctf_stream_class *stream_class,
- enum bt_ctf_byte_order byte_order)
+int init_packet_context(struct bt_ctf_stream_class *stream_class)
{
int ret = 0;
struct bt_ctf_field_type *packet_context_type =
goto end;
}
+ if (stream_class->packet_context_type) {
+ bt_ctf_field_type_put(stream_class->packet_context_type);
+ }
stream_class->packet_context_type = packet_context_type;
end:
if (ret) {