+ bt_ctf_event_class_freeze(event_class);
+
+ if (stream_class->byte_order) {
+ /*
+ * Only set native byte order if it has been initialized
+ * when the stream class was added to a trace.
+ *
+ * If not set here, this will be set when the stream
+ * classe will be added to a trace.
+ */
+ bt_ctf_event_class_set_native_byte_order(event_class,
+ stream_class->byte_order);
+ }
+end:
+ return ret;
+}
+
+int bt_ctf_stream_class_get_event_class_count(
+ struct bt_ctf_stream_class *stream_class)
+{
+ int ret;
+
+ if (!stream_class) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = (int) stream_class->event_classes->len;
+end:
+ return ret;
+}
+
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
+ struct bt_ctf_stream_class *stream_class, int index)
+{
+ struct bt_ctf_event_class *event_class = NULL;
+
+ if (!stream_class || index < 0 ||
+ index >= stream_class->event_classes->len) {
+ goto end;
+ }
+
+ event_class = g_ptr_array_index(stream_class->event_classes, index);
+ bt_ctf_event_class_get(event_class);
+end:
+ return event_class;
+}
+
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
+ struct bt_ctf_stream_class *stream_class, const char *name)
+{
+ size_t i;
+ GQuark name_quark;
+ struct bt_ctf_event_class *event_class = NULL;
+
+ if (!stream_class || !name) {
+ goto end;
+ }
+
+ name_quark = g_quark_try_string(name);
+ if (!name_quark) {
+ goto end;
+ }
+
+ for (i = 0; i < stream_class->event_classes->len; i++) {
+ struct bt_ctf_event_class *current_event_class =
+ g_ptr_array_index(stream_class->event_classes, i);
+
+ if (name_quark == current_event_class->name) {
+ event_class = current_event_class;
+ bt_ctf_event_class_get(event_class);
+ goto end;
+ }
+ }
+end:
+ return event_class;
+}
+
+struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
+ struct bt_ctf_stream_class *stream_class)
+{
+ struct bt_ctf_field_type *ret = NULL;
+
+ if (!stream_class) {
+ goto end;
+ }
+
+ assert(stream_class->packet_context_type);
+ bt_ctf_field_type_get(stream_class->packet_context_type);
+ ret = stream_class->packet_context_type;
+end:
+ return ret;
+}
+
+int bt_ctf_stream_class_set_packet_context_type(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_field_type *packet_context_type)
+{
+ int ret = 0;
+
+ if (!stream_class || !packet_context_type || stream_class->frozen) {
+ ret = -1;
+ goto end;
+ }
+
+ 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 */
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_field_type_put(stream_class->packet_context_type);
+ bt_ctf_field_type_get(packet_context_type);
+ stream_class->packet_context_type = packet_context_type;
+end:
+ 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)
+{
+ struct bt_ctf_field_type *ret = NULL;
+
+ if (!stream_class || !stream_class->event_context_type) {
+ goto end;
+ }
+
+ assert(stream_class->event_context_type);
+ bt_ctf_field_type_get(stream_class->event_context_type);
+ ret = stream_class->event_context_type;
+end:
+ return ret;
+}
+
+int bt_ctf_stream_class_set_event_context_type(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_field_type *event_context_type)
+{
+ int ret = 0;
+
+ if (!stream_class || !event_context_type || stream_class->frozen) {
+ ret = -1;
+ goto end;
+ }
+
+ if (bt_ctf_field_type_get_type_id(event_context_type) !=
+ CTF_TYPE_STRUCT) {
+ /* A packet context must be a structure */
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_field_type_put(stream_class->event_context_type);
+ bt_ctf_field_type_get(event_context_type);
+ stream_class->event_context_type = event_context_type;