+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;
+ }
+
+ bt_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 || stream_class->frozen) {
+ ret = -1;
+ goto end;
+ }
+
+ if (event_context_type &&
+ bt_ctf_field_type_get_type_id(event_context_type) !=
+ BT_CTF_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(stream_class->event_context_type);
+ stream_class->event_context_type = bt_get(event_context_type);
+end:
+ return ret;
+}
+
+void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class)
+{
+ bt_get(stream_class);
+}
+
+void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class)
+{
+ bt_put(stream_class);
+}
+
+static
+int get_event_class_count(void *element)
+{
+ return bt_ctf_stream_class_get_event_class_count(
+ (struct bt_ctf_stream_class *) element);
+}
+
+static
+void *get_event_class(void *element, int i)
+{
+ return bt_ctf_stream_class_get_event_class(
+ (struct bt_ctf_stream_class *) element, i);
+}
+
+static
+int visit_event_class(void *object, bt_ctf_visitor visitor,void *data)
+{
+ struct bt_ctf_object obj =
+ { .object = object,
+ .type = BT_CTF_OBJECT_TYPE_EVENT_CLASS };
+
+ return visitor(&obj, data);
+}
+
+int bt_ctf_stream_class_visit(struct bt_ctf_stream_class *stream_class,
+ bt_ctf_visitor visitor, void *data)
+{
+ int ret;
+ struct bt_ctf_object obj =
+ { .object = stream_class,
+ .type = BT_CTF_OBJECT_TYPE_STREAM_CLASS };
+
+ if (!stream_class || !visitor) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = visitor_helper(&obj, get_event_class_count,
+ get_event_class,
+ visit_event_class, visitor, data);
+end:
+ return ret;
+}
+
+BT_HIDDEN
+void bt_ctf_stream_class_freeze(struct bt_ctf_stream_class *stream_class)
+{
+ if (!stream_class) {
+ return;
+ }
+
+ 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);
+
+ if (stream_class->clock) {
+ bt_ctf_clock_class_freeze(stream_class->clock->clock_class);
+ }
+}
+
+BT_HIDDEN
+void bt_ctf_stream_class_set_byte_order(
+ struct bt_ctf_stream_class *stream_class, int byte_order)
+{
+ int i;
+
+ assert(stream_class);
+ assert(byte_order == LITTLE_ENDIAN || byte_order == BIG_ENDIAN);
+ stream_class->byte_order = byte_order;
+
+ /* Set native byte order to little or big endian */
+ bt_ctf_field_type_set_native_byte_order(
+ stream_class->event_header_type, byte_order);
+ bt_ctf_field_type_set_native_byte_order(
+ stream_class->packet_context_type, byte_order);
+ bt_ctf_field_type_set_native_byte_order(
+ stream_class->event_context_type, byte_order);
+
+ /* Set all events' native byte order */
+ for (i = 0; i < stream_class->event_classes->len; i++) {
+ struct bt_ctf_event_class *event_class =
+ g_ptr_array_index(stream_class->event_classes, i);
+
+ bt_ctf_event_class_set_native_byte_order(event_class,
+ byte_order);
+ }
+}
+