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_OPTION
,
37 FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
,
40 struct fs_sink_ctf_field_class
{
41 enum fs_sink_ctf_field_class_type type
;
44 const bt_field_class
*ir_fc
;
46 unsigned int alignment
;
48 /* Index of the field class within its own parent */
49 uint64_t index_in_parent
;
52 struct fs_sink_ctf_field_class_bit_array
{
53 struct fs_sink_ctf_field_class base
;
57 struct fs_sink_ctf_field_class_bool
{
58 struct fs_sink_ctf_field_class_bit_array base
;
61 struct fs_sink_ctf_field_class_int
{
62 struct fs_sink_ctf_field_class_bit_array base
;
66 struct fs_sink_ctf_field_class_float
{
67 struct fs_sink_ctf_field_class_bit_array base
;
70 struct fs_sink_ctf_field_class_string
{
71 struct fs_sink_ctf_field_class base
;
74 struct fs_sink_ctf_named_field_class
{
78 struct fs_sink_ctf_field_class
*fc
;
81 struct fs_sink_ctf_field_class_struct
{
82 struct fs_sink_ctf_field_class base
;
84 /* Array of `struct fs_sink_ctf_named_field_class` */
88 struct fs_sink_ctf_field_class_option
{
89 struct fs_sink_ctf_field_class base
;
90 struct fs_sink_ctf_field_class
*content_fc
;
94 struct fs_sink_ctf_field_class_variant
{
95 struct fs_sink_ctf_field_class base
;
99 /* Array of `struct fs_sink_ctf_named_field_class` */
103 struct fs_sink_ctf_field_class_array_base
{
104 struct fs_sink_ctf_field_class base
;
105 struct fs_sink_ctf_field_class
*elem_fc
;
108 struct fs_sink_ctf_field_class_array
{
109 struct fs_sink_ctf_field_class_array_base base
;
113 struct fs_sink_ctf_field_class_sequence
{
114 struct fs_sink_ctf_field_class_array_base base
;
116 bool length_is_before
;
119 struct fs_sink_ctf_stream_class
;
121 struct fs_sink_ctf_event_class
{
123 const bt_event_class
*ir_ec
;
126 struct fs_sink_ctf_stream_class
*sc
;
129 struct fs_sink_ctf_field_class
*spec_context_fc
;
132 struct fs_sink_ctf_field_class
*payload_fc
;
135 struct fs_sink_ctf_trace
;
137 struct fs_sink_ctf_stream_class
{
139 struct fs_sink_ctf_trace
*trace
;
142 const bt_stream_class
*ir_sc
;
145 const bt_clock_class
*default_clock_class
;
147 GString
*default_clock_class_name
;
149 bool packets_have_ts_begin
;
150 bool packets_have_ts_end
;
151 bool has_discarded_events
;
152 bool discarded_events_has_ts
;
153 bool discarded_packets_has_ts
;
156 struct fs_sink_ctf_field_class
*packet_context_fc
;
159 struct fs_sink_ctf_field_class
*event_common_context_fc
;
161 /* Array of `struct fs_sink_ctf_event_class *` (owned by this) */
162 GPtrArray
*event_classes
;
165 * `const bt_event_class *` (weak) ->
166 * `struct fs_sink_ctf_event_class *` (weak)
168 GHashTable
*event_classes_from_ir
;
171 struct fs_sink_ctf_trace
{
173 const bt_trace
*ir_trace
;
176 const bt_trace_class
*ir_tc
;
180 /* Array of `struct fs_sink_ctf_stream_class *` (owned by this) */
181 GPtrArray
*stream_classes
;
185 void fs_sink_ctf_field_class_destroy(struct fs_sink_ctf_field_class
*fc
);
188 void _fs_sink_ctf_field_class_init(struct fs_sink_ctf_field_class
*fc
,
189 enum fs_sink_ctf_field_class_type type
,
190 const bt_field_class
*ir_fc
, unsigned int alignment
,
191 uint64_t index_in_parent
)
196 fc
->alignment
= alignment
;
197 fc
->index_in_parent
= index_in_parent
;
201 void _fs_sink_ctf_field_class_bit_array_init(
202 struct fs_sink_ctf_field_class_bit_array
*fc
,
203 enum fs_sink_ctf_field_class_type type
,
204 const bt_field_class
*ir_fc
, unsigned int size
,
205 uint64_t index_in_parent
)
207 _fs_sink_ctf_field_class_init((void *) fc
, type
, ir_fc
,
208 size
% 8 == 0 ? 8 : 1, index_in_parent
);
213 void _fs_sink_ctf_field_class_int_init(struct fs_sink_ctf_field_class_int
*fc
,
214 enum fs_sink_ctf_field_class_type type
,
215 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
217 bt_field_class_type ir_fc_type
= bt_field_class_get_type(ir_fc
);
219 _fs_sink_ctf_field_class_bit_array_init((void *) fc
, type
, ir_fc
,
220 (unsigned int) bt_field_class_integer_get_field_value_range(
223 fc
->is_signed
= (ir_fc_type
== BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
||
224 ir_fc_type
== BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
);
228 void _fs_sink_ctf_named_field_class_init(
229 struct fs_sink_ctf_named_field_class
*named_fc
)
232 named_fc
->name
= g_string_new(NULL
);
233 BT_ASSERT(named_fc
->name
);
237 void _fs_sink_ctf_named_field_class_fini(
238 struct fs_sink_ctf_named_field_class
*named_fc
)
242 if (named_fc
->name
) {
243 g_string_free(named_fc
->name
, TRUE
);
244 named_fc
->name
= NULL
;
247 fs_sink_ctf_field_class_destroy(named_fc
->fc
);
252 struct fs_sink_ctf_field_class_bool
*fs_sink_ctf_field_class_bool_create(
253 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
255 struct fs_sink_ctf_field_class_bool
*fc
=
256 g_new0(struct fs_sink_ctf_field_class_bool
, 1);
261 * CTF 1.8 has no boolean field class type, so this component
262 * translates it to an 8-bit unsigned integer field class.
264 _fs_sink_ctf_field_class_bit_array_init((void *) fc
,
265 FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL
, ir_fc
,
271 struct fs_sink_ctf_field_class_int
*fs_sink_ctf_field_class_int_create(
272 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
274 struct fs_sink_ctf_field_class_int
*fc
=
275 g_new0(struct fs_sink_ctf_field_class_int
, 1);
278 _fs_sink_ctf_field_class_int_init(fc
, FS_SINK_CTF_FIELD_CLASS_TYPE_INT
,
279 ir_fc
, index_in_parent
);
284 struct fs_sink_ctf_field_class_float
*fs_sink_ctf_field_class_float_create(
285 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
287 struct fs_sink_ctf_field_class_float
*fc
=
288 g_new0(struct fs_sink_ctf_field_class_float
, 1);
291 _fs_sink_ctf_field_class_bit_array_init((void *) fc
,
292 FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT
,
293 ir_fc
, bt_field_class_real_is_single_precision(ir_fc
) ? 32 : 64,
299 struct fs_sink_ctf_field_class_string
*fs_sink_ctf_field_class_string_create(
300 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
302 struct fs_sink_ctf_field_class_string
*fc
=
303 g_new0(struct fs_sink_ctf_field_class_string
, 1);
306 _fs_sink_ctf_field_class_init((void *) fc
,
307 FS_SINK_CTF_FIELD_CLASS_TYPE_STRING
, ir_fc
,
313 struct fs_sink_ctf_field_class_struct
*fs_sink_ctf_field_class_struct_create_empty(
314 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
316 struct fs_sink_ctf_field_class_struct
*fc
=
317 g_new0(struct fs_sink_ctf_field_class_struct
, 1);
320 _fs_sink_ctf_field_class_init((void *) fc
,
321 FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
, ir_fc
, 1, index_in_parent
);
322 fc
->members
= g_array_new(FALSE
, TRUE
,
323 sizeof(struct fs_sink_ctf_named_field_class
));
324 BT_ASSERT(fc
->members
);
329 struct fs_sink_ctf_field_class_option
*fs_sink_ctf_field_class_option_create_empty(
330 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
332 struct fs_sink_ctf_field_class_option
*fc
=
333 g_new0(struct fs_sink_ctf_field_class_option
, 1);
336 _fs_sink_ctf_field_class_init((void *) fc
,
337 FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION
, ir_fc
,
339 fc
->tag_ref
= g_string_new(NULL
);
340 BT_ASSERT(fc
->tag_ref
);
345 struct fs_sink_ctf_field_class_variant
*fs_sink_ctf_field_class_variant_create_empty(
346 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
348 struct fs_sink_ctf_field_class_variant
*fc
=
349 g_new0(struct fs_sink_ctf_field_class_variant
, 1);
352 _fs_sink_ctf_field_class_init((void *) fc
,
353 FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
, ir_fc
,
355 fc
->options
= g_array_new(FALSE
, TRUE
,
356 sizeof(struct fs_sink_ctf_named_field_class
));
357 BT_ASSERT(fc
->options
);
358 fc
->tag_ref
= g_string_new(NULL
);
359 BT_ASSERT(fc
->tag_ref
);
361 bt_field_class_get_type(fc
->base
.ir_fc
) ==
362 BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
;
367 struct fs_sink_ctf_field_class_array
*fs_sink_ctf_field_class_array_create_empty(
368 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
370 struct fs_sink_ctf_field_class_array
*fc
=
371 g_new0(struct fs_sink_ctf_field_class_array
, 1);
374 _fs_sink_ctf_field_class_init((void *) fc
,
375 FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
, ir_fc
,
377 fc
->length
= bt_field_class_array_static_get_length(ir_fc
);
382 struct fs_sink_ctf_field_class_sequence
*fs_sink_ctf_field_class_sequence_create_empty(
383 const bt_field_class
*ir_fc
, uint64_t index_in_parent
)
385 struct fs_sink_ctf_field_class_sequence
*fc
=
386 g_new0(struct fs_sink_ctf_field_class_sequence
, 1);
389 _fs_sink_ctf_field_class_init((void *) fc
,
390 FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
,
391 ir_fc
, 1, index_in_parent
);
392 fc
->length_ref
= g_string_new(NULL
);
393 BT_ASSERT(fc
->length_ref
);
394 fc
->length_is_before
=
395 bt_field_class_array_dynamic_borrow_length_field_path_const(ir_fc
) ==
401 struct fs_sink_ctf_named_field_class
*
402 fs_sink_ctf_field_class_struct_borrow_member_by_index(
403 struct fs_sink_ctf_field_class_struct
*fc
, uint64_t index
);
406 struct fs_sink_ctf_named_field_class
*
407 fs_sink_ctf_field_class_variant_borrow_option_by_index(
408 struct fs_sink_ctf_field_class_variant
*fc
, uint64_t index
);
411 void _fs_sink_ctf_field_class_fini(struct fs_sink_ctf_field_class
*fc
)
417 void _fs_sink_ctf_field_class_bool_destroy(
418 struct fs_sink_ctf_field_class_int
*fc
)
421 _fs_sink_ctf_field_class_fini((void *) fc
);
426 void _fs_sink_ctf_field_class_int_destroy(
427 struct fs_sink_ctf_field_class_int
*fc
)
430 _fs_sink_ctf_field_class_fini((void *) fc
);
435 void _fs_sink_ctf_field_class_float_destroy(
436 struct fs_sink_ctf_field_class_float
*fc
)
439 _fs_sink_ctf_field_class_fini((void *) fc
);
444 void _fs_sink_ctf_field_class_string_destroy(
445 struct fs_sink_ctf_field_class_string
*fc
)
448 _fs_sink_ctf_field_class_fini((void *) fc
);
453 void _fs_sink_ctf_field_class_struct_destroy(
454 struct fs_sink_ctf_field_class_struct
*fc
)
457 _fs_sink_ctf_field_class_fini((void *) fc
);
462 for (i
= 0; i
< fc
->members
->len
; i
++) {
463 struct fs_sink_ctf_named_field_class
*named_fc
=
464 fs_sink_ctf_field_class_struct_borrow_member_by_index(
467 _fs_sink_ctf_named_field_class_fini(named_fc
);
470 g_array_free(fc
->members
, TRUE
);
478 void _fs_sink_ctf_field_class_array_base_fini(
479 struct fs_sink_ctf_field_class_array_base
*fc
)
482 _fs_sink_ctf_field_class_fini((void *) fc
);
483 fs_sink_ctf_field_class_destroy(fc
->elem_fc
);
488 void _fs_sink_ctf_field_class_array_destroy(
489 struct fs_sink_ctf_field_class_array
*fc
)
492 _fs_sink_ctf_field_class_array_base_fini((void *) fc
);
497 void _fs_sink_ctf_field_class_sequence_destroy(
498 struct fs_sink_ctf_field_class_sequence
*fc
)
501 _fs_sink_ctf_field_class_array_base_fini((void *) fc
);
503 if (fc
->length_ref
) {
504 g_string_free(fc
->length_ref
, TRUE
);
505 fc
->length_ref
= NULL
;
512 void _fs_sink_ctf_field_class_option_destroy(
513 struct fs_sink_ctf_field_class_option
*fc
)
516 _fs_sink_ctf_field_class_fini((void *) fc
);
517 fs_sink_ctf_field_class_destroy(fc
->content_fc
);
520 g_string_free(fc
->tag_ref
, TRUE
);
528 void _fs_sink_ctf_field_class_variant_destroy(
529 struct fs_sink_ctf_field_class_variant
*fc
)
532 _fs_sink_ctf_field_class_fini((void *) fc
);
537 for (i
= 0; i
< fc
->options
->len
; i
++) {
538 struct fs_sink_ctf_named_field_class
*named_fc
=
539 fs_sink_ctf_field_class_variant_borrow_option_by_index(
542 _fs_sink_ctf_named_field_class_fini(named_fc
);
545 g_array_free(fc
->options
, TRUE
);
550 g_string_free(fc
->tag_ref
, TRUE
);
558 void fs_sink_ctf_field_class_destroy(struct fs_sink_ctf_field_class
*fc
)
565 case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL
:
566 _fs_sink_ctf_field_class_bool_destroy((void *) fc
);
568 case FS_SINK_CTF_FIELD_CLASS_TYPE_INT
:
569 _fs_sink_ctf_field_class_int_destroy((void *) fc
);
571 case FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT
:
572 _fs_sink_ctf_field_class_float_destroy((void *) fc
);
574 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRING
:
575 _fs_sink_ctf_field_class_string_destroy((void *) fc
);
577 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
578 _fs_sink_ctf_field_class_struct_destroy((void *) fc
);
580 case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
:
581 _fs_sink_ctf_field_class_array_destroy((void *) fc
);
583 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
584 _fs_sink_ctf_field_class_sequence_destroy((void *) fc
);
586 case FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION
:
587 _fs_sink_ctf_field_class_option_destroy((void *) fc
);
589 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
590 _fs_sink_ctf_field_class_variant_destroy((void *) fc
);
598 struct fs_sink_ctf_named_field_class
*
599 fs_sink_ctf_field_class_struct_borrow_member_by_index(
600 struct fs_sink_ctf_field_class_struct
*fc
, uint64_t index
)
603 BT_ASSERT(index
< fc
->members
->len
);
604 return &g_array_index(fc
->members
, struct fs_sink_ctf_named_field_class
,
609 struct fs_sink_ctf_named_field_class
*
610 fs_sink_ctf_field_class_struct_borrow_member_by_name(
611 struct fs_sink_ctf_field_class_struct
*fc
, const char *name
)
614 struct fs_sink_ctf_named_field_class
*ret_named_fc
= NULL
;
619 for (i
= 0; i
< fc
->members
->len
; i
++) {
620 struct fs_sink_ctf_named_field_class
*named_fc
=
621 fs_sink_ctf_field_class_struct_borrow_member_by_index(
624 if (strcmp(name
, named_fc
->name
->str
) == 0) {
625 ret_named_fc
= named_fc
;
635 struct fs_sink_ctf_field_class
*
636 fs_sink_ctf_field_class_struct_borrow_member_field_class_by_name(
637 struct fs_sink_ctf_field_class_struct
*struct_fc
, const char *name
)
639 struct fs_sink_ctf_named_field_class
*named_fc
= NULL
;
640 struct fs_sink_ctf_field_class
*fc
= NULL
;
646 named_fc
= fs_sink_ctf_field_class_struct_borrow_member_by_name(
659 struct fs_sink_ctf_field_class_int
*
660 fs_sink_ctf_field_class_struct_borrow_member_int_field_class_by_name(
661 struct fs_sink_ctf_field_class_struct
*struct_fc
,
664 struct fs_sink_ctf_field_class_int
*int_fc
= NULL
;
667 fs_sink_ctf_field_class_struct_borrow_member_field_class_by_name(
673 if (int_fc
->base
.base
.type
!= FS_SINK_CTF_FIELD_CLASS_TYPE_INT
) {
683 void fs_sink_ctf_field_class_struct_align_at_least(
684 struct fs_sink_ctf_field_class_struct
*fc
,
685 unsigned int alignment
)
687 if (alignment
> fc
->base
.alignment
) {
688 fc
->base
.alignment
= alignment
;
693 void fs_sink_ctf_field_class_struct_append_member(
694 struct fs_sink_ctf_field_class_struct
*fc
,
695 const char *name
, struct fs_sink_ctf_field_class
*member_fc
)
697 struct fs_sink_ctf_named_field_class
*named_fc
;
701 g_array_set_size(fc
->members
, fc
->members
->len
+ 1);
703 named_fc
= &g_array_index(fc
->members
,
704 struct fs_sink_ctf_named_field_class
, fc
->members
->len
- 1);
705 _fs_sink_ctf_named_field_class_init(named_fc
);
706 g_string_assign(named_fc
->name
, name
);
707 named_fc
->fc
= member_fc
;
708 fs_sink_ctf_field_class_struct_align_at_least(fc
, member_fc
->alignment
);
712 struct fs_sink_ctf_named_field_class
*
713 fs_sink_ctf_field_class_variant_borrow_option_by_index(
714 struct fs_sink_ctf_field_class_variant
*fc
, uint64_t index
)
717 BT_ASSERT(index
< fc
->options
->len
);
718 return &g_array_index(fc
->options
, struct fs_sink_ctf_named_field_class
,
723 struct fs_sink_ctf_named_field_class
*
724 fs_sink_ctf_field_class_variant_borrow_option_by_name(
725 struct fs_sink_ctf_field_class_variant
*fc
, const char *name
)
728 struct fs_sink_ctf_named_field_class
*ret_named_fc
= NULL
;
733 for (i
= 0; i
< fc
->options
->len
; i
++) {
734 struct fs_sink_ctf_named_field_class
*named_fc
=
735 fs_sink_ctf_field_class_variant_borrow_option_by_index(
738 if (strcmp(name
, named_fc
->name
->str
) == 0) {
739 ret_named_fc
= named_fc
;
749 void fs_sink_ctf_field_class_variant_append_option(
750 struct fs_sink_ctf_field_class_variant
*fc
,
751 const char *name
, struct fs_sink_ctf_field_class
*option_fc
)
753 struct fs_sink_ctf_named_field_class
*named_fc
;
757 g_array_set_size(fc
->options
, fc
->options
->len
+ 1);
759 named_fc
= &g_array_index(fc
->options
,
760 struct fs_sink_ctf_named_field_class
, fc
->options
->len
- 1);
761 _fs_sink_ctf_named_field_class_init(named_fc
);
762 g_string_assign(named_fc
->name
, name
);
763 named_fc
->fc
= option_fc
;
767 struct fs_sink_ctf_event_class
*fs_sink_ctf_event_class_create(
768 struct fs_sink_ctf_stream_class
*sc
,
769 const bt_event_class
*ir_ec
)
771 struct fs_sink_ctf_event_class
*ec
=
772 g_new0(struct fs_sink_ctf_event_class
, 1);
779 g_ptr_array_add(sc
->event_classes
, ec
);
780 g_hash_table_insert(sc
->event_classes_from_ir
, (gpointer
) ir_ec
, ec
);
785 void fs_sink_ctf_event_class_destroy(struct fs_sink_ctf_event_class
*ec
)
791 fs_sink_ctf_field_class_destroy(ec
->spec_context_fc
);
792 ec
->spec_context_fc
= NULL
;
793 fs_sink_ctf_field_class_destroy(ec
->payload_fc
);
794 ec
->payload_fc
= NULL
;
799 struct fs_sink_ctf_stream_class
*fs_sink_ctf_stream_class_create(
800 struct fs_sink_ctf_trace
*trace
,
801 const bt_stream_class
*ir_sc
)
803 struct fs_sink_ctf_stream_class
*sc
=
804 g_new0(struct fs_sink_ctf_stream_class
, 1);
811 sc
->default_clock_class
=
812 bt_stream_class_borrow_default_clock_class_const(ir_sc
);
813 sc
->default_clock_class_name
= g_string_new(NULL
);
814 BT_ASSERT(sc
->default_clock_class_name
);
815 sc
->event_classes
= g_ptr_array_new_with_free_func(
816 (GDestroyNotify
) fs_sink_ctf_event_class_destroy
);
817 BT_ASSERT(sc
->event_classes
);
818 sc
->event_classes_from_ir
= g_hash_table_new(g_direct_hash
,
820 BT_ASSERT(sc
->event_classes_from_ir
);
821 sc
->has_packets
= bt_stream_class_supports_packets(ir_sc
);
822 sc
->packets_have_ts_begin
=
823 bt_stream_class_packets_have_beginning_default_clock_snapshot(
825 sc
->packets_have_ts_end
=
826 bt_stream_class_packets_have_end_default_clock_snapshot(ir_sc
);
827 sc
->has_discarded_events
=
828 bt_stream_class_supports_discarded_events(ir_sc
);
830 if (sc
->has_discarded_events
) {
831 sc
->discarded_events_has_ts
=
832 bt_stream_class_discarded_events_have_default_clock_snapshots(
836 if (bt_stream_class_supports_discarded_packets(ir_sc
)) {
837 sc
->discarded_packets_has_ts
=
838 bt_stream_class_discarded_packets_have_default_clock_snapshots(
842 g_ptr_array_add(trace
->stream_classes
, sc
);
847 void fs_sink_ctf_stream_class_destroy(struct fs_sink_ctf_stream_class
*sc
)
853 if (sc
->default_clock_class_name
) {
854 g_string_free(sc
->default_clock_class_name
, TRUE
);
855 sc
->default_clock_class_name
= NULL
;
858 if (sc
->event_classes
) {
859 g_ptr_array_free(sc
->event_classes
, TRUE
);
860 sc
->event_classes
= NULL
;
863 if (sc
->event_classes_from_ir
) {
864 g_hash_table_destroy(sc
->event_classes_from_ir
);
865 sc
->event_classes_from_ir
= NULL
;
868 fs_sink_ctf_field_class_destroy(sc
->packet_context_fc
);
869 sc
->packet_context_fc
= NULL
;
870 fs_sink_ctf_field_class_destroy(sc
->event_common_context_fc
);
871 sc
->event_common_context_fc
= NULL
;
876 void fs_sink_ctf_stream_class_append_event_class(
877 struct fs_sink_ctf_stream_class
*sc
,
878 struct fs_sink_ctf_event_class
*ec
)
880 g_ptr_array_add(sc
->event_classes
, ec
);
884 void fs_sink_ctf_trace_destroy(struct fs_sink_ctf_trace
*trace
)
890 if (trace
->stream_classes
) {
891 g_ptr_array_free(trace
->stream_classes
, TRUE
);
892 trace
->stream_classes
= NULL
;
899 struct fs_sink_ctf_trace
*fs_sink_ctf_trace_create(const bt_trace
*ir_trace
)
901 struct fs_sink_ctf_trace
*trace
=
902 g_new0(struct fs_sink_ctf_trace
, 1);
906 bt_uuid_generate(trace
->uuid
);
908 trace
->ir_trace
= ir_trace
;
909 trace
->ir_tc
= bt_trace_borrow_class_const(ir_trace
);
910 trace
->stream_classes
= g_ptr_array_new_with_free_func(
911 (GDestroyNotify
) fs_sink_ctf_stream_class_destroy
);
912 BT_ASSERT(trace
->stream_classes
);
917 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_CTF_META_H */