1 #ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_CTF_META_H
2 #define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_CTF_META_H
5 * Copyright 2018-2019 - Philippe Proulx <pproulx@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
18 #include <babeltrace2/babeltrace.h>
19 #include "common/common.h"
20 #include "common/assert.h"
21 #include "common/uuid.h"
28 enum fs_sink_ctf_field_class_type
{
29 FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL
,
30 FS_SINK_CTF_FIELD_CLASS_TYPE_INT
,
31 FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT
,
32 FS_SINK_CTF_FIELD_CLASS_TYPE_STRING
,
33 FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
,
34 FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
,
35 FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
,
36 FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
,
39 struct fs_sink_ctf_field_class
{
40 enum fs_sink_ctf_field_class_type type
;
43 const bt_field_class
*ir_fc
;
45 unsigned int alignment
;
47 /* Index of the field class within its own parent */
48 uint64_t index_in_parent
;
51 struct fs_sink_ctf_field_class_bit_array
{
52 struct fs_sink_ctf_field_class base
;
56 struct fs_sink_ctf_field_class_bool
{
57 struct fs_sink_ctf_field_class_bit_array base
;
60 struct fs_sink_ctf_field_class_int
{
61 struct fs_sink_ctf_field_class_bit_array base
;
65 struct fs_sink_ctf_field_class_float
{
66 struct fs_sink_ctf_field_class_bit_array base
;
69 struct fs_sink_ctf_field_class_string
{
70 struct fs_sink_ctf_field_class base
;
73 struct fs_sink_ctf_named_field_class
{
77 struct fs_sink_ctf_field_class
*fc
;
80 struct fs_sink_ctf_field_class_struct
{
81 struct fs_sink_ctf_field_class base
;
83 /* Array of `struct fs_sink_ctf_named_field_class` */
87 struct fs_sink_ctf_field_class_variant
{
88 struct fs_sink_ctf_field_class base
;
92 /* Array of `struct fs_sink_ctf_named_field_class` */
96 struct fs_sink_ctf_field_class_array_base
{
97 struct fs_sink_ctf_field_class base
;
98 struct fs_sink_ctf_field_class
*elem_fc
;
101 struct fs_sink_ctf_field_class_array
{
102 struct fs_sink_ctf_field_class_array_base base
;
106 struct fs_sink_ctf_field_class_sequence
{
107 struct fs_sink_ctf_field_class_array_base base
;
109 bool length_is_before
;
112 struct fs_sink_ctf_stream_class
;
114 struct fs_sink_ctf_event_class
{
116 const bt_event_class
*ir_ec
;
119 struct fs_sink_ctf_stream_class
*sc
;
122 struct fs_sink_ctf_field_class
*spec_context_fc
;
125 struct fs_sink_ctf_field_class
*payload_fc
;
128 struct fs_sink_ctf_trace
;
130 struct fs_sink_ctf_stream_class
{
132 struct fs_sink_ctf_trace
*trace
;
135 const bt_stream_class
*ir_sc
;
138 const bt_clock_class
*default_clock_class
;
140 GString
*default_clock_class_name
;
142 bool packets_have_ts_begin
;
143 bool packets_have_ts_end
;
144 bool has_discarded_events
;
145 bool discarded_events_has_ts
;
146 bool discarded_packets_has_ts
;
149 struct fs_sink_ctf_field_class
*packet_context_fc
;
152 struct fs_sink_ctf_field_class
*event_common_context_fc
;
154 /* Array of `struct fs_sink_ctf_event_class *` (owned by this) */
155 GPtrArray
*event_classes
;
158 * `const bt_event_class *` (weak) ->
159 * `struct fs_sink_ctf_event_class *` (weak)
161 GHashTable
*event_classes_from_ir
;
164 struct fs_sink_ctf_trace
{
166 const bt_trace
*ir_trace
;
169 const bt_trace_class
*ir_tc
;
173 /* Array of `struct fs_sink_ctf_stream_class *` (owned by this) */
174 GPtrArray
*stream_classes
;
178 void fs_sink_ctf_field_class_destroy(struct fs_sink_ctf_field_class
*fc
);
181 void _fs_sink_ctf_field_class_init(struct fs_sink_ctf_field_class
*fc
,
182 enum fs_sink_ctf_field_class_type type
,
183 const bt_field_class
*ir_fc
, unsigned int alignment
,
184 uint64_t index_in_parent
)
189 fc
->alignment
= alignment
;
190 fc
->index_in_parent
= index_in_parent
;
194 void _fs_sink_ctf_field_class_bit_array_init(
195 struct fs_sink_ctf_field_class_bit_array
*fc
,
196 enum fs_sink_ctf_field_class_type type
,
197 const bt_field_class
*ir_fc
, unsigned int size
,
198 uint64_t index_in_parent
)
200 _fs_sink_ctf_field_class_init((void *) fc
, type
, ir_fc
,
201 size
% 8 == 0 ? 8 : 1, index_in_parent
);
206 void _fs_sink_ctf_field_class_int_init(struct fs_sink_ctf_field_class_int
*fc
,
207 enum fs_sink_ctf_field_class_type type
,
208 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
210 bt_field_class_type ir_fc_type
= bt_field_class_get_type(ir_fc
);
212 _fs_sink_ctf_field_class_bit_array_init((void *) fc
, type
, ir_fc
,
213 (unsigned int) bt_field_class_integer_get_field_value_range(
216 fc
->is_signed
= (ir_fc_type
== BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
||
217 ir_fc_type
== BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
);
221 void _fs_sink_ctf_named_field_class_init(
222 struct fs_sink_ctf_named_field_class
*named_fc
)
225 named_fc
->name
= g_string_new(NULL
);
226 BT_ASSERT(named_fc
->name
);
230 void _fs_sink_ctf_named_field_class_fini(
231 struct fs_sink_ctf_named_field_class
*named_fc
)
235 if (named_fc
->name
) {
236 g_string_free(named_fc
->name
, TRUE
);
237 named_fc
->name
= NULL
;
240 fs_sink_ctf_field_class_destroy(named_fc
->fc
);
245 struct fs_sink_ctf_field_class_bool
*fs_sink_ctf_field_class_bool_create(
246 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
248 struct fs_sink_ctf_field_class_bool
*fc
=
249 g_new0(struct fs_sink_ctf_field_class_bool
, 1);
254 * CTF 1.8 has no boolean field class type, so this component
255 * translates it to an 8-bit unsigned integer field class.
257 _fs_sink_ctf_field_class_bit_array_init((void *) fc
,
258 FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL
, ir_fc
,
264 struct fs_sink_ctf_field_class_int
*fs_sink_ctf_field_class_int_create(
265 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
267 struct fs_sink_ctf_field_class_int
*fc
=
268 g_new0(struct fs_sink_ctf_field_class_int
, 1);
271 _fs_sink_ctf_field_class_int_init(fc
, FS_SINK_CTF_FIELD_CLASS_TYPE_INT
,
272 ir_fc
, index_in_parent
);
277 struct fs_sink_ctf_field_class_float
*fs_sink_ctf_field_class_float_create(
278 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
280 struct fs_sink_ctf_field_class_float
*fc
=
281 g_new0(struct fs_sink_ctf_field_class_float
, 1);
284 _fs_sink_ctf_field_class_bit_array_init((void *) fc
,
285 FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT
,
286 ir_fc
, bt_field_class_real_is_single_precision(ir_fc
) ? 32 : 64,
292 struct fs_sink_ctf_field_class_string
*fs_sink_ctf_field_class_string_create(
293 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
295 struct fs_sink_ctf_field_class_string
*fc
=
296 g_new0(struct fs_sink_ctf_field_class_string
, 1);
299 _fs_sink_ctf_field_class_init((void *) fc
,
300 FS_SINK_CTF_FIELD_CLASS_TYPE_STRING
, ir_fc
,
306 struct fs_sink_ctf_field_class_struct
*fs_sink_ctf_field_class_struct_create_empty(
307 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
309 struct fs_sink_ctf_field_class_struct
*fc
=
310 g_new0(struct fs_sink_ctf_field_class_struct
, 1);
313 _fs_sink_ctf_field_class_init((void *) fc
,
314 FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
, ir_fc
, 1, index_in_parent
);
315 fc
->members
= g_array_new(FALSE
, TRUE
,
316 sizeof(struct fs_sink_ctf_named_field_class
));
317 BT_ASSERT(fc
->members
);
322 struct fs_sink_ctf_field_class_variant
*fs_sink_ctf_field_class_variant_create_empty(
323 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
325 struct fs_sink_ctf_field_class_variant
*fc
=
326 g_new0(struct fs_sink_ctf_field_class_variant
, 1);
329 _fs_sink_ctf_field_class_init((void *) fc
,
330 FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
, ir_fc
,
332 fc
->options
= g_array_new(FALSE
, TRUE
,
333 sizeof(struct fs_sink_ctf_named_field_class
));
334 BT_ASSERT(fc
->options
);
335 fc
->tag_ref
= g_string_new(NULL
);
336 BT_ASSERT(fc
->tag_ref
);
338 bt_field_class_get_type(fc
->base
.ir_fc
) ==
339 BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
;
344 struct fs_sink_ctf_field_class_array
*fs_sink_ctf_field_class_array_create_empty(
345 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
347 struct fs_sink_ctf_field_class_array
*fc
=
348 g_new0(struct fs_sink_ctf_field_class_array
, 1);
351 _fs_sink_ctf_field_class_init((void *) fc
,
352 FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
, ir_fc
,
354 fc
->length
= bt_field_class_array_static_get_length(ir_fc
);
359 struct fs_sink_ctf_field_class_sequence
*fs_sink_ctf_field_class_sequence_create_empty(
360 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
362 struct fs_sink_ctf_field_class_sequence
*fc
=
363 g_new0(struct fs_sink_ctf_field_class_sequence
, 1);
366 _fs_sink_ctf_field_class_init((void *) fc
,
367 FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
,
368 ir_fc
, 1, index_in_parent
);
369 fc
->length_ref
= g_string_new(NULL
);
370 BT_ASSERT(fc
->length_ref
);
371 fc
->length_is_before
=
372 bt_field_class_array_dynamic_borrow_length_field_path_const(ir_fc
) ==
378 struct fs_sink_ctf_named_field_class
*
379 fs_sink_ctf_field_class_struct_borrow_member_by_index(
380 struct fs_sink_ctf_field_class_struct
*fc
, uint64_t index
);
383 struct fs_sink_ctf_named_field_class
*
384 fs_sink_ctf_field_class_variant_borrow_option_by_index(
385 struct fs_sink_ctf_field_class_variant
*fc
, uint64_t index
);
388 void _fs_sink_ctf_field_class_fini(struct fs_sink_ctf_field_class
*fc
)
394 void _fs_sink_ctf_field_class_bool_destroy(
395 struct fs_sink_ctf_field_class_int
*fc
)
398 _fs_sink_ctf_field_class_fini((void *) fc
);
403 void _fs_sink_ctf_field_class_int_destroy(
404 struct fs_sink_ctf_field_class_int
*fc
)
407 _fs_sink_ctf_field_class_fini((void *) fc
);
412 void _fs_sink_ctf_field_class_float_destroy(
413 struct fs_sink_ctf_field_class_float
*fc
)
416 _fs_sink_ctf_field_class_fini((void *) fc
);
421 void _fs_sink_ctf_field_class_string_destroy(
422 struct fs_sink_ctf_field_class_string
*fc
)
425 _fs_sink_ctf_field_class_fini((void *) fc
);
430 void _fs_sink_ctf_field_class_struct_destroy(
431 struct fs_sink_ctf_field_class_struct
*fc
)
434 _fs_sink_ctf_field_class_fini((void *) fc
);
439 for (i
= 0; i
< fc
->members
->len
; i
++) {
440 struct fs_sink_ctf_named_field_class
*named_fc
=
441 fs_sink_ctf_field_class_struct_borrow_member_by_index(
444 _fs_sink_ctf_named_field_class_fini(named_fc
);
447 g_array_free(fc
->members
, TRUE
);
455 void _fs_sink_ctf_field_class_array_base_fini(
456 struct fs_sink_ctf_field_class_array_base
*fc
)
459 _fs_sink_ctf_field_class_fini((void *) fc
);
460 fs_sink_ctf_field_class_destroy(fc
->elem_fc
);
465 void _fs_sink_ctf_field_class_array_destroy(
466 struct fs_sink_ctf_field_class_array
*fc
)
469 _fs_sink_ctf_field_class_array_base_fini((void *) fc
);
474 void _fs_sink_ctf_field_class_sequence_destroy(
475 struct fs_sink_ctf_field_class_sequence
*fc
)
478 _fs_sink_ctf_field_class_array_base_fini((void *) fc
);
480 if (fc
->length_ref
) {
481 g_string_free(fc
->length_ref
, TRUE
);
482 fc
->length_ref
= NULL
;
489 void _fs_sink_ctf_field_class_variant_destroy(
490 struct fs_sink_ctf_field_class_variant
*fc
)
493 _fs_sink_ctf_field_class_fini((void *) fc
);
498 for (i
= 0; i
< fc
->options
->len
; i
++) {
499 struct fs_sink_ctf_named_field_class
*named_fc
=
500 fs_sink_ctf_field_class_variant_borrow_option_by_index(
503 _fs_sink_ctf_named_field_class_fini(named_fc
);
506 g_array_free(fc
->options
, TRUE
);
511 g_string_free(fc
->tag_ref
, TRUE
);
519 void fs_sink_ctf_field_class_destroy(struct fs_sink_ctf_field_class
*fc
)
526 case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL
:
527 _fs_sink_ctf_field_class_bool_destroy((void *) fc
);
529 case FS_SINK_CTF_FIELD_CLASS_TYPE_INT
:
530 _fs_sink_ctf_field_class_int_destroy((void *) fc
);
532 case FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT
:
533 _fs_sink_ctf_field_class_float_destroy((void *) fc
);
535 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRING
:
536 _fs_sink_ctf_field_class_string_destroy((void *) fc
);
538 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
539 _fs_sink_ctf_field_class_struct_destroy((void *) fc
);
541 case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
:
542 _fs_sink_ctf_field_class_array_destroy((void *) fc
);
544 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
545 _fs_sink_ctf_field_class_sequence_destroy((void *) fc
);
547 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
548 _fs_sink_ctf_field_class_variant_destroy((void *) fc
);
556 struct fs_sink_ctf_named_field_class
*
557 fs_sink_ctf_field_class_struct_borrow_member_by_index(
558 struct fs_sink_ctf_field_class_struct
*fc
, uint64_t index
)
561 BT_ASSERT(index
< fc
->members
->len
);
562 return &g_array_index(fc
->members
, struct fs_sink_ctf_named_field_class
,
567 struct fs_sink_ctf_named_field_class
*
568 fs_sink_ctf_field_class_struct_borrow_member_by_name(
569 struct fs_sink_ctf_field_class_struct
*fc
, const char *name
)
572 struct fs_sink_ctf_named_field_class
*ret_named_fc
= NULL
;
577 for (i
= 0; i
< fc
->members
->len
; i
++) {
578 struct fs_sink_ctf_named_field_class
*named_fc
=
579 fs_sink_ctf_field_class_struct_borrow_member_by_index(
582 if (strcmp(name
, named_fc
->name
->str
) == 0) {
583 ret_named_fc
= named_fc
;
593 struct fs_sink_ctf_field_class
*
594 fs_sink_ctf_field_class_struct_borrow_member_field_class_by_name(
595 struct fs_sink_ctf_field_class_struct
*struct_fc
, const char *name
)
597 struct fs_sink_ctf_named_field_class
*named_fc
= NULL
;
598 struct fs_sink_ctf_field_class
*fc
= NULL
;
604 named_fc
= fs_sink_ctf_field_class_struct_borrow_member_by_name(
617 struct fs_sink_ctf_field_class_int
*
618 fs_sink_ctf_field_class_struct_borrow_member_int_field_class_by_name(
619 struct fs_sink_ctf_field_class_struct
*struct_fc
,
622 struct fs_sink_ctf_field_class_int
*int_fc
= NULL
;
625 fs_sink_ctf_field_class_struct_borrow_member_field_class_by_name(
631 if (int_fc
->base
.base
.type
!= FS_SINK_CTF_FIELD_CLASS_TYPE_INT
) {
641 void fs_sink_ctf_field_class_struct_align_at_least(
642 struct fs_sink_ctf_field_class_struct
*fc
,
643 unsigned int alignment
)
645 if (alignment
> fc
->base
.alignment
) {
646 fc
->base
.alignment
= alignment
;
651 void fs_sink_ctf_field_class_struct_append_member(
652 struct fs_sink_ctf_field_class_struct
*fc
,
653 const char *name
, struct fs_sink_ctf_field_class
*member_fc
)
655 struct fs_sink_ctf_named_field_class
*named_fc
;
659 g_array_set_size(fc
->members
, fc
->members
->len
+ 1);
661 named_fc
= &g_array_index(fc
->members
,
662 struct fs_sink_ctf_named_field_class
, fc
->members
->len
- 1);
663 _fs_sink_ctf_named_field_class_init(named_fc
);
664 g_string_assign(named_fc
->name
, name
);
665 named_fc
->fc
= member_fc
;
666 fs_sink_ctf_field_class_struct_align_at_least(fc
, member_fc
->alignment
);
670 struct fs_sink_ctf_named_field_class
*
671 fs_sink_ctf_field_class_variant_borrow_option_by_index(
672 struct fs_sink_ctf_field_class_variant
*fc
, uint64_t index
)
675 BT_ASSERT(index
< fc
->options
->len
);
676 return &g_array_index(fc
->options
, struct fs_sink_ctf_named_field_class
,
681 struct fs_sink_ctf_named_field_class
*
682 fs_sink_ctf_field_class_variant_borrow_option_by_name(
683 struct fs_sink_ctf_field_class_variant
*fc
, const char *name
)
686 struct fs_sink_ctf_named_field_class
*ret_named_fc
= NULL
;
691 for (i
= 0; i
< fc
->options
->len
; i
++) {
692 struct fs_sink_ctf_named_field_class
*named_fc
=
693 fs_sink_ctf_field_class_variant_borrow_option_by_index(
696 if (strcmp(name
, named_fc
->name
->str
) == 0) {
697 ret_named_fc
= named_fc
;
707 void fs_sink_ctf_field_class_variant_append_option(
708 struct fs_sink_ctf_field_class_variant
*fc
,
709 const char *name
, struct fs_sink_ctf_field_class
*option_fc
)
711 struct fs_sink_ctf_named_field_class
*named_fc
;
715 g_array_set_size(fc
->options
, fc
->options
->len
+ 1);
717 named_fc
= &g_array_index(fc
->options
,
718 struct fs_sink_ctf_named_field_class
, fc
->options
->len
- 1);
719 _fs_sink_ctf_named_field_class_init(named_fc
);
720 g_string_assign(named_fc
->name
, name
);
721 named_fc
->fc
= option_fc
;
725 struct fs_sink_ctf_event_class
*fs_sink_ctf_event_class_create(
726 struct fs_sink_ctf_stream_class
*sc
,
727 const bt_event_class
*ir_ec
)
729 struct fs_sink_ctf_event_class
*ec
=
730 g_new0(struct fs_sink_ctf_event_class
, 1);
737 g_ptr_array_add(sc
->event_classes
, ec
);
738 g_hash_table_insert(sc
->event_classes_from_ir
, (gpointer
) ir_ec
, ec
);
743 void fs_sink_ctf_event_class_destroy(struct fs_sink_ctf_event_class
*ec
)
749 fs_sink_ctf_field_class_destroy(ec
->spec_context_fc
);
750 ec
->spec_context_fc
= NULL
;
751 fs_sink_ctf_field_class_destroy(ec
->payload_fc
);
752 ec
->payload_fc
= NULL
;
757 struct fs_sink_ctf_stream_class
*fs_sink_ctf_stream_class_create(
758 struct fs_sink_ctf_trace
*trace
,
759 const bt_stream_class
*ir_sc
)
761 struct fs_sink_ctf_stream_class
*sc
=
762 g_new0(struct fs_sink_ctf_stream_class
, 1);
769 sc
->default_clock_class
=
770 bt_stream_class_borrow_default_clock_class_const(ir_sc
);
771 sc
->default_clock_class_name
= g_string_new(NULL
);
772 BT_ASSERT(sc
->default_clock_class_name
);
773 sc
->event_classes
= g_ptr_array_new_with_free_func(
774 (GDestroyNotify
) fs_sink_ctf_event_class_destroy
);
775 BT_ASSERT(sc
->event_classes
);
776 sc
->event_classes_from_ir
= g_hash_table_new(g_direct_hash
,
778 BT_ASSERT(sc
->event_classes_from_ir
);
779 sc
->has_packets
= bt_stream_class_supports_packets(ir_sc
);
780 sc
->packets_have_ts_begin
=
781 bt_stream_class_packets_have_beginning_default_clock_snapshot(
783 sc
->packets_have_ts_end
=
784 bt_stream_class_packets_have_end_default_clock_snapshot(ir_sc
);
785 sc
->has_discarded_events
=
786 bt_stream_class_supports_discarded_events(ir_sc
);
788 if (sc
->has_discarded_events
) {
789 sc
->discarded_events_has_ts
=
790 bt_stream_class_discarded_events_have_default_clock_snapshots(
794 if (bt_stream_class_supports_discarded_packets(ir_sc
)) {
795 sc
->discarded_packets_has_ts
=
796 bt_stream_class_discarded_packets_have_default_clock_snapshots(
800 g_ptr_array_add(trace
->stream_classes
, sc
);
805 void fs_sink_ctf_stream_class_destroy(struct fs_sink_ctf_stream_class
*sc
)
811 if (sc
->default_clock_class_name
) {
812 g_string_free(sc
->default_clock_class_name
, TRUE
);
813 sc
->default_clock_class_name
= NULL
;
816 if (sc
->event_classes
) {
817 g_ptr_array_free(sc
->event_classes
, TRUE
);
818 sc
->event_classes
= NULL
;
821 if (sc
->event_classes_from_ir
) {
822 g_hash_table_destroy(sc
->event_classes_from_ir
);
823 sc
->event_classes_from_ir
= NULL
;
826 fs_sink_ctf_field_class_destroy(sc
->packet_context_fc
);
827 sc
->packet_context_fc
= NULL
;
828 fs_sink_ctf_field_class_destroy(sc
->event_common_context_fc
);
829 sc
->event_common_context_fc
= NULL
;
834 void fs_sink_ctf_stream_class_append_event_class(
835 struct fs_sink_ctf_stream_class
*sc
,
836 struct fs_sink_ctf_event_class
*ec
)
838 g_ptr_array_add(sc
->event_classes
, ec
);
842 void fs_sink_ctf_trace_destroy(struct fs_sink_ctf_trace
*trace
)
848 if (trace
->stream_classes
) {
849 g_ptr_array_free(trace
->stream_classes
, TRUE
);
850 trace
->stream_classes
= NULL
;
857 struct fs_sink_ctf_trace
*fs_sink_ctf_trace_create(const bt_trace
*ir_trace
)
859 struct fs_sink_ctf_trace
*trace
=
860 g_new0(struct fs_sink_ctf_trace
, 1);
864 bt_uuid_generate(trace
->uuid
);
866 trace
->ir_trace
= ir_trace
;
867 trace
->ir_tc
= bt_trace_borrow_class_const(ir_trace
);
868 trace
->stream_classes
= g_ptr_array_new_with_free_func(
869 (GDestroyNotify
) fs_sink_ctf_stream_class_destroy
);
870 BT_ASSERT(trace
->stream_classes
);
875 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_CTF_META_H */