1 #ifndef BABELTRACE_CTF_IR_TRACE_H
2 #define BABELTRACE_CTF_IR_TRACE_H
5 * BabelTrace - CTF IR: Trace
7 * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
33 #include <babeltrace/ctf-ir/field-types.h>
34 #include <babeltrace/ctf-ir/visitor.h>
35 #include <babeltrace/values.h>
36 #include <babeltrace/graph/notification.h>
37 #include <babeltrace/types.h>
45 @defgroup ctfirtraceclass CTF IR trace class
47 @brief CTF IR trace class.
50 #include <babeltrace/ctf-ir/trace.h>
53 A CTF IR <strong><em>trace class</em></strong> is a descriptor of
56 You can obtain a trace class in two different modes:
58 - <strong>Normal mode</strong>: use bt_ctf_trace_create() to create a
59 default, empty trace class.
60 - <strong>CTF writer mode</strong>: use bt_ctf_writer_get_trace() to
61 get the trace class created by a given CTF writer object.
63 A trace class has the following properties:
66 - A <strong>native byte order</strong>: all the
67 \link ctfirfieldtypes field types\endlink eventually part of the trace
68 class with a byte order set to #BT_CTF_BYTE_ORDER_NATIVE have this
71 - An \b environment, which is a custom key-value mapping. Keys are
72 strings and values can be strings or integers.
74 In the Babeltrace CTF IR system, a trace class contains zero or more
75 \link ctfirstreamclass stream classes\endlink, and a stream class
76 contains zero or more \link ctfireventclass event classes\endlink. You
77 can add an event class to a stream class with
78 bt_ctf_stream_class_add_event_class(). You can add a stream class to a
79 trace class with bt_ctf_trace_add_stream_class().
81 You can access the streams of a trace, that is, the streams which were
82 created from the trace's stream classes with bt_ctf_stream_create(),
83 with bt_ctf_trace_get_stream_by_index().
85 A trace class owns the <strong>trace packet header</strong>
86 \link ctfirfieldtypes field type\endlink, which represents the
87 \c trace.packet.header CTF scope. This field type describes the
88 trace packet header fields of the traces that this trace class
91 The trace packet header field type \em must be a structure field type as
92 of Babeltrace \btversion.
94 As per the CTF specification, the trace packet header field type \em
95 must contain a field named \c stream_id if the trace class contains more
96 than one stream class.
98 As a reminder, here's the structure of a CTF packet:
102 A trace class also contains zero or more
103 \link ctfirclockclass CTF IR clock classes\endlink.
106 Elaborate about clock classes irt clock values.
108 As with any Babeltrace object, CTF IR trace class objects have
109 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
110 counts</a>. See \ref refs to learn more about the reference counting
111 management of Babeltrace objects.
113 The following functions \em freeze their trace class parameter on
116 - bt_ctf_trace_add_stream_class()
117 - bt_ctf_writer_create_stream()
118 (\link ctfwriter CTF writer\endlink mode only)
120 You cannot modify a frozen trace class: it is considered immutable,
123 - Adding a stream class to it with
124 bt_ctf_trace_add_stream_class().
125 - Adding a CTF IR clock class to it with bt_ctf_trace_add_clock_class().
126 - \link refs Reference counting\endlink.
133 @brief CTF IR trace class type and functions.
136 @addtogroup ctfirtraceclass
142 @brief A CTF IR trace class.
146 struct bt_ctf_stream
;
147 struct bt_ctf_stream_class
;
148 struct bt_ctf_clock_class
;
151 @brief User function type to use with
152 bt_ctf_trace_add_is_static_listener().
154 @param[in] trace_class Trace class which is now static.
155 @param[in] data User data as passed to
156 bt_ctf_trace_add_is_static_listener() when
157 you added the listener.
159 @prenotnull{trace_class}
161 typedef void (* bt_ctf_trace_is_static_listener
)(
162 struct bt_ctf_trace
*trace_class
, void *data
);
165 @name Creation function
170 @brief Creates a default CTF IR trace class.
172 On success, the trace packet header field type of the created trace
173 class is an empty structure field type. You can modify this default
174 trace packet header field type after the trace class is created with
175 bt_ctf_trace_get_packet_header_type() and
176 bt_ctf_trace_set_packet_header_type().
178 The created trace class has the following initial properties:
180 - <strong>Name</strong>: none. You can set a name
181 with bt_ctf_trace_set_name().
182 - <strong>UUID</strong>: none. You can set a UUID with
183 bt_ctf_trace_set_uuid().
184 - <strong>Native byte order</strong>: #BT_CTF_BYTE_ORDER_UNSPECIFIED.
185 You can set a native byte order with
186 bt_ctf_trace_set_native_byte_order().
187 - <strong>Environment</strong>: empty. You can add environment entries
188 with bt_ctf_trace_set_environment_field(),
189 bt_ctf_trace_set_environment_field_integer(), and
190 bt_ctf_trace_set_environment_field_string().
192 @returns Created trace class, or \c NULL on error.
194 @postsuccessrefcountret1
196 extern struct bt_ctf_trace
*bt_ctf_trace_create(void);
201 @name Properties functions
206 @brief Returns the name of the CTF IR trace class \p trace_class.
208 On success, \p trace_class remains the sole owner of the returned
209 string. The returned string is valid as long as \p trace_class exists
212 @param[in] trace_class Trace class of which to get the name.
213 @returns Name of trace class \p trace_class, or
214 \c NULL if \p trace_class is unnamed or
217 @prenotnull{trace_class}
218 @postrefcountsame{trace_class}
220 @sa bt_ctf_trace_set_name(): Sets the name of a given trace class.
222 extern const char *bt_ctf_trace_get_name(struct bt_ctf_trace
*trace_class
);
225 @brief Sets the name of the CTF IR trace class \p trace_class
228 @param[in] trace_class Trace class of which to set the name.
229 @param[in] name Name of the trace class (copied on success).
230 @returns 0 on success, or a negative value on error.
232 @prenotnull{trace_class}
235 @postrefcountsame{trace_class}
237 @sa bt_ctf_trace_get_name(): Returns the name of a given trace class.
239 extern int bt_ctf_trace_set_name(struct bt_ctf_trace
*trace_class
,
243 @brief Returns the native byte order of the CTF IR trace class
246 @param[in] trace_class Trace class of which to get the default byte
248 @returns Native byte order of \p trace_class,
249 or #BT_CTF_BYTE_ORDER_UNKNOWN on error.
251 @prenotnull{trace_class}
252 @postrefcountsame{trace_class}
254 @sa bt_ctf_trace_set_native_byte_order(): Sets the native byte order of
257 extern enum bt_ctf_byte_order
bt_ctf_trace_get_native_byte_order(
258 struct bt_ctf_trace
*trace_class
);
261 @brief Sets the native byte order of the CTF IR trace class
262 \p trace_class to \p native_byte_order.
264 \p native_byte_order \em must be one of:
266 - #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
267 - #BT_CTF_BYTE_ORDER_BIG_ENDIAN
268 - #BT_CTF_BYTE_ORDER_NETWORK
269 - <strong>If the trace is not in CTF writer mode<strong>,
270 #BT_CTF_BYTE_ORDER_UNSPECIFIED.
272 @param[in] trace_class Trace class of which to set the native byte
274 @param[in] native_byte_order Native byte order of the trace class.
275 @returns 0 on success, or a negative value on error.
277 @prenotnull{trace_class}
279 @pre \p native_byte_order is either #BT_CTF_BYTE_ORDER_UNSPECIFIED (if the
280 trace is not in CTF writer mode),
281 #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, #BT_CTF_BYTE_ORDER_BIG_ENDIAN, or
282 #BT_CTF_BYTE_ORDER_NETWORK.
283 @postrefcountsame{trace_class}
285 @sa bt_ctf_trace_get_native_byte_order(): Returns the native byte order of a
288 extern int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace
*trace_class
,
289 enum bt_ctf_byte_order native_byte_order
);
292 @brief Returns the UUID of the CTF IR trace class \p trace_class.
294 On success, the return value is an array of 16 bytes.
296 @param[in] trace_class Trace class of which to get the UUID.
297 @returns UUID of trace class \p trace_class, or
298 \c NULL if \p trace_class has no UUID or on error.
300 @prenotnull{trace_class}
301 @postrefcountsame{trace_class}
303 @sa bt_ctf_trace_set_uuid(): Sets the UUID of a given trace class.
305 extern const unsigned char *bt_ctf_trace_get_uuid(
306 struct bt_ctf_trace
*trace_class
);
309 @brief Sets the UUID of the CTF IR trace class \p trace_class to
312 \p uuid \em must be an array of 16 bytes.
314 @param[in] trace_class Trace class of which to set the UUID.
315 @param[in] uuid UUID of the \p trace_class (copied on
317 @returns 0 on success, or a negative value on error.
319 @prenotnull{trace_class}
322 @pre \p uuid is an array of 16 bytes.
323 @postrefcountsame{trace_class}
325 @sa bt_ctf_trace_get_uuid(): Returns the UUID of a given trace class.
327 extern int bt_ctf_trace_set_uuid(struct bt_ctf_trace
*trace_class
,
328 const unsigned char *uuid
);
331 @brief Returns the number of entries contained in the environment of
332 the CTF IR trace class \p trace_class.
334 @param[in] trace_class Trace class of which to get the number
335 of environment entries.
336 @returns Number of environment entries
337 contained in \p trace_class, or
338 a negative value on error.
340 @prenotnull{trace_class}
341 @postrefcountsame{trace_class}
343 extern int64_t bt_ctf_trace_get_environment_field_count(
344 struct bt_ctf_trace
*trace_class
);
347 @brief Returns the field name of the environment entry at index
348 \p index in the CTF IR trace class \p trace_class.
350 On success, the returned string is valid as long as this trace class
351 exists and is \em not modified. \p trace_class remains the sole owner of
354 @param[in] trace_class Trace class of which to get the name of the
355 environment entry at index \p index.
356 @param[in] index Index of environment entry to find.
357 @returns Name of the environment entry at index \p index
358 in \p trace_class, or \c NULL on error.
360 @prenotnull{trace_class}
361 @pre \p index is lesser than the number of environment entries in
362 \p trace_class (see bt_ctf_trace_get_environment_field_count()).
363 @postrefcountsame{trace_class}
365 @sa bt_ctf_trace_get_environment_field_value_by_index(): Finds a trace class's
366 environment entry by index.
367 @sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace
368 class's environment entry by name.
369 @sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
370 class's environment entry.
373 bt_ctf_trace_get_environment_field_name_by_index(
374 struct bt_ctf_trace
*trace_class
, uint64_t index
);
377 @brief Returns the value of the environment entry at index
378 \p index in the CTF IR trace class \p trace_class.
380 @param[in] trace_class Trace class of which to get the value of the
381 environment entry at index \p index.
382 @param[in] index Index of the environment entry to find.
383 @returns Value of the environment entry at index \p index
384 in \p trace_class, or \c NULL on error.
386 @prenotnull{trace_class}
387 @pre \p index is lesser than the number of environment entries in
388 \p trace_class (see bt_ctf_trace_get_environment_field_count()).
389 @postrefcountsame{trace_class}
390 @postsuccessrefcountretinc
392 @sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace
393 class's environment entry by name.
394 @sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
395 class's environment entry.
397 extern struct bt_value
*
398 bt_ctf_trace_get_environment_field_value_by_index(struct bt_ctf_trace
*trace_class
,
402 @brief Returns the value of the environment entry named \p name
403 in the CTF IR trace class \p trace_class.
405 @param[in] trace_class Trace class of which to get the value of the
406 environment entry named \p name.
407 @param[in] name Name of the environment entry to find.
408 @returns Value of the environment entry named \p name
409 in \p trace_class, or \c NULL if there's no such
412 @prenotnull{trace_class}
414 @postrefcountsame{trace_class}
415 @postsuccessrefcountretinc
417 @sa bt_ctf_trace_get_environment_field_value_by_index(): Finds a trace class's
418 environment entry by index.
419 @sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
420 class's environment entry.
422 extern struct bt_value
*
423 bt_ctf_trace_get_environment_field_value_by_name(
424 struct bt_ctf_trace
*trace_class
, const char *name
);
427 @brief Sets the environment entry named \p name in the
428 CTF IR trace class \p trace_class to \p value.
430 If an environment entry named \p name exists in \p trace_class, its
431 value is first put, and then replaced by \p value.
433 @param[in] trace_class Trace class of which to set the environment
435 @param[in] name Name of the environment entry to set (copied
437 @param[in] value Value of the environment entry named \p name.
438 @returns 0 on success, or a negative value on error.
440 @prenotnull{trace_class}
445 \link bt_value_integer_create() integer value object\endlink
447 \link bt_value_string_create() string value object\endlink.
448 @postrefcountsame{trace_class}
449 @postsuccessrefcountinc{value}
451 @sa bt_ctf_trace_get_environment_field_value_by_index(): Finds a trace class's
452 environment entry by index.
453 @sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace
454 class's environment entry by name.
456 extern int bt_ctf_trace_set_environment_field(
457 struct bt_ctf_trace
*trace_class
, const char *name
,
458 struct bt_value
*value
);
461 @brief Sets the environment entry named \p name in the
462 CTF IR trace class \p trace_class to \p value.
464 If an environment entry named \p name exists in \p trace_class, its
465 value is first put, and then replaced by a new
466 \link bt_value_integer_create() integer value object\endlink
469 @param[in] trace_class Trace class of which to set the environment
471 @param[in] name Name of the environment entry to set (copied
473 @param[in] value Value of the environment entry named \p name.
474 @returns 0 on success, or a negative value on error.
476 @prenotnull{trace_class}
479 @postrefcountsame{trace_class}
481 @sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
482 class's environment entry.
484 extern int bt_ctf_trace_set_environment_field_integer(
485 struct bt_ctf_trace
*trace_class
, const char *name
,
489 @brief Sets the environment entry named \p name in the
490 CTF IR trace class \p trace_class to \p value.
492 If an environment entry named \p name exists in \p trace_class, its
493 value is first put, and then replaced by a new
494 \link bt_value_string_create() string value object\endlink
497 @param[in] trace_class Trace class of which to set the environment
499 @param[in] name Name of the environment entry to set (copied
501 @param[in] value Value of the environment entry named \p name
503 @returns 0 on success, or a negative value on error.
505 @prenotnull{trace_class}
509 @postrefcountsame{trace_class}
511 @sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
512 class's environment entry.
514 extern int bt_ctf_trace_set_environment_field_string(
515 struct bt_ctf_trace
*trace_class
, const char *name
,
521 @name Contained field types functions
526 @brief Returns the packet header field type of the CTF IR trace class
529 @param[in] trace_class Trace class of which to get the packet
531 @returns Packet header field type of \p trace_class,
532 or \c NULL if \p trace_class has no packet header field
535 @prenotnull{trace_class}
536 @postrefcountsame{trace_class}
537 @post <strong>On success, if the return value is a field type</strong>, its
538 reference count is incremented.
540 @sa bt_ctf_trace_set_packet_header_type(): Sets the packet
541 header field type of a given trace class.
543 extern struct bt_ctf_field_type
*bt_ctf_trace_get_packet_header_type(
544 struct bt_ctf_trace
*trace_class
);
547 @brief Sets the packet header field type of the CTF IR trace class
548 \p trace_class to \p packet_header_type, or unsets the current packet
549 header field type from \p trace_class.
551 If \p packet_header_type is \c NULL, then this function unsets the current
552 packet header field type from \p trace_class, effectively making \p trace_class
553 a trace without a packet header field type.
555 As of Babeltrace \btversion, if \p packet_header_type is not \c NULL,
556 \p packet_header_type \em must be a CTF IR structure field type object.
558 @param[in] trace_class Trace class of which to set the packet
560 @param[in] packet_header_type Packet header field type, or \c NULL to unset
561 the current packet header field type.
562 @returns 0 on success, or a negative value on error.
564 @prenotnull{trace_class}
566 @pre <strong>\p packet_header_type, if not \c NULL</strong>, is a CTF IR
567 structure field type.
568 @postrefcountsame{trace_class}
569 @post <strong>On success, if \p packet_header_type is not \c NULL</strong>,
570 the reference count of \p packet_header_type is incremented.
572 @sa bt_ctf_trace_get_packet_header_type(): Returns the packet
573 header field type of a given trace class.
575 extern int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace
*trace_class
,
576 struct bt_ctf_field_type
*packet_header_type
);
581 @name Contained clock classes functions
586 @brief Returns the number of CTF IR clock classes contained in the
587 CTF IR trace class \p trace_class.
589 @param[in] trace_class Trace class of which to get the number
590 of contained clock classes.
591 @returns Number of contained clock classes
592 contained in \p trace_class, or a negative
595 @prenotnull{trace_class}
596 @postrefcountsame{trace_class}
598 extern int64_t bt_ctf_trace_get_clock_class_count(
599 struct bt_ctf_trace
*trace_class
);
602 @brief Returns the CTF IR clock class at index \p index in the CTF
603 IR trace class \p trace_class.
605 @param[in] trace_class Trace class of which to get the clock class
606 contained at index \p index.
607 @param[in] index Index of the clock class to find in
609 @returns Clock class at index \p index in \p trace_class,
612 @prenotnull{trace_class}
613 @pre \p index is lesser than the number of clock classes contained in
614 the trace class \p trace_class (see
615 bt_ctf_trace_get_clock_class_count()).
616 @postrefcountsame{trace_class}
617 @postsuccessrefcountretinc
619 @sa bt_ctf_trace_get_clock_class_by_name(): Finds a clock class by name
620 in a given trace class.
621 @sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class.
623 extern struct bt_ctf_clock_class
*bt_ctf_trace_get_clock_class_by_index(
624 struct bt_ctf_trace
*trace_class
, uint64_t index
);
627 @brief Returns the CTF IR clock class named \c name found in the CTF
628 IR trace class \p trace_class.
630 @param[in] trace_class Trace class of which to get the clock class
632 @param[in] name Name of the clock class to find in \p trace_class.
633 @returns Clock class named \p name in \p trace_class,
636 @prenotnull{trace_class}
638 @postrefcountsame{trace_class}
639 @postsuccessrefcountretinc
641 @sa bt_ctf_trace_get_clock_class_by_index(): Returns the clock class contained
642 in a given trace class at a given index.
643 @sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class.
645 extern struct bt_ctf_clock_class
*bt_ctf_trace_get_clock_class_by_name(
646 struct bt_ctf_trace
*trace_class
, const char *name
);
649 @brief Adds the CTF IR clock class \p clock_class to the CTF IR
650 trace class \p trace_class.
652 On success, \p trace_class contains \p clock_class.
654 You can call this function even if \p trace_class or \p clock_class
657 @param[in] trace_class Trace class to which to add \p clock_class.
658 @param[in] clock_class Clock class to add to \p trace_class.
659 @returns 0 on success, or a negative value on error.
661 @prenotnull{trace_class}
662 @prenotnull{clock_class}
663 @postrefcountsame{trace_class}
664 @postsuccessrefcountinc{clock_class}
665 @post <strong>On success, if \p trace_class is frozen</strong>,
666 \p clock_class is frozen.
668 @sa bt_ctf_trace_get_clock_class_by_index(): Returns the clock class contained
669 in a given trace class at a given index.
670 @sa bt_ctf_trace_get_clock_class_by_name(): Finds a clock class by name
671 in a given trace class.
673 extern int bt_ctf_trace_add_clock_class(struct bt_ctf_trace
*trace_class
,
674 struct bt_ctf_clock_class
*clock_class
);
679 @name Stream class children functions
684 @brief Returns the number of stream classes contained in the
685 CTF IR trace class \p trace_class.
687 @param[in] trace_class Trace class of which to get the number
688 of children stream classes.
689 @returns Number of children stream classes
690 contained in \p trace_class, or a negative
693 @prenotnull{trace_class}
694 @postrefcountsame{trace_class}
696 extern int64_t bt_ctf_trace_get_stream_class_count(
697 struct bt_ctf_trace
*trace_class
);
700 @brief Returns the stream class at index \p index in the CTF IR trace
701 class \p trace_class.
703 @param[in] trace_class Trace class of which to get the stream class.
704 @param[in] index Index of the stream class to find.
705 @returns Stream class at index \p index, or \c NULL
708 @prenotnull{trace_class}
709 @pre \p index is lesser than the number of stream classes contained in
710 the trace class \p trace_class (see
711 bt_ctf_trace_get_stream_class_count()).
712 @postrefcountsame{trace_class}
714 @sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID.
715 @sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class.
717 extern struct bt_ctf_stream_class
*bt_ctf_trace_get_stream_class_by_index(
718 struct bt_ctf_trace
*trace_class
, uint64_t index
);
721 @brief Returns the stream class with ID \c id found in the CTF IR
722 trace class \p trace_class.
724 @param[in] trace_class Trace class of which to get the stream class.
725 @param[in] id ID of the stream class to find.
726 @returns Stream class with ID \p id, or \c NULL
729 @prenotnull{trace_class}
730 @postrefcountsame{trace_class}
731 @postsuccessrefcountretinc
733 @sa bt_ctf_trace_get_stream_class_by_index(): Returns the stream class contained
734 in a given trace class at a given index.
735 @sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class.
737 extern struct bt_ctf_stream_class
*bt_ctf_trace_get_stream_class_by_id(
738 struct bt_ctf_trace
*trace_class
, uint64_t id
);
741 @brief Adds the CTF IR stream class \p stream_class to the
742 CTF IR trace class \p trace_class.
744 On success, \p stream_class becomes the child of \p trace_class.
746 You can only add a given stream class to one trace class.
748 You can call this function even if \p trace_class is frozen.
750 This function tries to resolve the needed
751 \link ctfirfieldtypes CTF IR field type\endlink of the dynamic field
752 types that are found anywhere in the root field types of
753 \p stream_class and of all its currently contained
754 \link ctfireventclass CTF IR event classes\endlink. If any automatic
755 resolving fails, then this function fails.
757 @param[in] trace_class Trace class to which to add \p stream_class.
758 @param[in] stream_class Stream class to add to \p trace_class.
759 @returns 0 on success, or a negative value on error.
761 @prenotnull{trace_class}
762 @prenotnull{stream_class}
763 @postrefcountsame{trace_class}
764 @postsuccessrefcountinc{stream_class}
765 @postsuccessfrozen{stream_class}
767 @sa bt_ctf_trace_get_stream_class_by_index(): Returns the stream class contained
768 in a given trace class at a given index.
769 @sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID.
771 extern int bt_ctf_trace_add_stream_class(struct bt_ctf_trace
*trace_class
,
772 struct bt_ctf_stream_class
*stream_class
);
777 @name Stream children functions
782 @brief Returns the number of streams contained in the CTF IR trace
783 class \p trace_class.
785 @param[in] trace_class Trace class of which to get the number
787 @returns Number of children streams
788 contained in \p trace_class, or a negative
791 @prenotnull{trace_class}
792 @postrefcountsame{trace_class}
794 extern int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace
*trace_class
);
797 @brief Returns the stream at index \p index in the CTF IR trace
798 class \p trace_class.
800 @param[in] trace_class Trace class of which to get the stream.
801 @param[in] index Index of the stream to find.
802 @returns Stream at index \p index, or \c NULL
805 @prenotnull{trace_class}
806 @pre \p index is lesser than the number of streams contained in
807 the trace class \p trace_class (see
808 bt_ctf_trace_get_stream_count()).
809 @postrefcountsame{trace_class}
811 extern struct bt_ctf_stream
*bt_ctf_trace_get_stream_by_index(
812 struct bt_ctf_trace
*trace_class
, uint64_t index
);
817 @name Misc. functions
822 @brief Returns whether or not the CTF IR trace class \p trace_class
825 It is guaranteed that a static trace class will never contain new
826 streams, stream classes, or clock classes. A static class is always
829 This function returns #BT_TRUE if bt_ctf_trace_set_is_static() was
830 previously called on it.
832 @param[in] trace_class Trace class to check.
833 @returns #BT_TRUE if \p trace_class is static,
835 @sa bt_ctf_trace_set_is_static(): Makes a trace class static.
837 extern bt_bool
bt_ctf_trace_is_static(struct bt_ctf_trace
*trace_class
);
840 @brief Makes the CTF IR trace class \p trace_class static.
842 A static trace class is frozen and you cannot call any modifying
845 - bt_ctf_trace_add_stream_class()
846 - bt_ctf_trace_add_clock_class()
847 - bt_ctf_trace_set_environment_field()
848 - bt_ctf_trace_set_environment_field_integer()
849 - bt_ctf_trace_set_environment_field_string()
850 - bt_ctf_trace_add_is_static_listener()
852 You cannot create a stream with bt_ctf_stream_create() with any of the
853 stream classes of a static trace class.
855 @param[in] trace_class Trace class to make static.
856 @returns 0 on success, or a negative value on error.
858 @prenotnull{trace_class}
859 @postrefcountsame{trace_class}
860 @postsuccessfrozen{trace_class}
862 @sa bt_ctf_trace_is_static(): Checks whether or not a given trace class
864 @sa bt_ctf_trace_add_is_static_listener(): Adds a listener to a trace
865 class which is called when the trace class is made static.
867 extern int bt_ctf_trace_set_is_static(struct bt_ctf_trace
*trace_class
);
870 @brief Adds the listener \p listener to the CTF IR trace class
871 \p trace_class which is called when the trace is made static.
873 \p listener is called with \p data, the user data, the first time
874 bt_ctf_trace_set_is_static() is called on \p trace_class.
876 This function fails if \p trace_class is already static: you need to
877 check the condition first with bt_ctf_trace_is_static().
879 On success, this function returns a unique numeric identifier for this
880 listener within \p trace. You can use this identifier to remove the
881 specific listener you added with
882 bt_ctf_trace_remove_is_static_listener().
884 @param[in] trace_class Trace class to which to add the listener.
885 @param[in] listener Listener to add to \p trace_class.
886 @param[in] data User data passed when \p listener is called.
887 @returns A unique numeric identifier for this listener
888 on success (0 or greater), or a negative value
891 @prenotnull{trace_class}
892 @prenotnull{listener}
893 @pre \p trace_class is not static.
894 @postrefcountsame{trace_class}
896 @sa bt_ctf_trace_remove_is_static_listener(): Removes a "trace is
897 static" listener from a trace class previously added with this
899 @sa bt_ctf_trace_is_static(): Checks whether or not a given trace class
901 @sa bt_ctf_trace_set_is_static(): Makes a trace class static.
903 extern int bt_ctf_trace_add_is_static_listener(
904 struct bt_ctf_trace
*trace_class
,
905 bt_ctf_trace_is_static_listener listener
, void *data
);
908 @brief Removes the "trace is static" listener identified by
909 \p listener_id from the trace class \p trace_class.
911 @param[in] trace_class Trace class from which to remove the listener
912 identified by \p listener_id.
913 @param[in] listener_id Identifier of the listener to remove from
915 @returns 0 if this function removed the listener, or
916 a negative value on error.
918 @prenotnull{trace_class}
919 @pre \p listener_id is the identifier of a listener that you previously
920 added with bt_ctf_trace_add_is_static_listener() and did not
921 already remove with this function.
922 @postrefcountsame{trace_class}
924 @sa bt_ctf_trace_add_is_static_listener(): Adds a listener to a trace
925 class which is called when the trace class is made static.
927 extern int bt_ctf_trace_remove_is_static_listener(
928 struct bt_ctf_trace
*trace_class
, int listener_id
);
931 @brief Accepts the visitor \p visitor to visit the hierarchy of the
932 CTF IR trace class \p trace_class.
934 This function traverses the hierarchy of \p trace_class in pre-order
935 and calls \p visitor on each element.
937 The trace class itself is visited first, then, for each children stream
938 class, the stream class itself, and all its children event classes.
940 @param[in] trace_class Trace class to visit.
941 @param[in] visitor Visiting function.
942 @param[in] data User data.
943 @returns 0 on success, or a negative value on error.
945 @prenotnull{trace_class}
948 extern int bt_ctf_trace_visit(struct bt_ctf_trace
*trace_class
,
949 bt_ctf_visitor visitor
, void *data
);
959 #endif /* BABELTRACE_CTF_IR_TRACE_H */