Add bt_plugin_set object
[babeltrace.git] / include / babeltrace / ctf-ir / trace.h
CommitLineData
bc37ae52
JG
1#ifndef BABELTRACE_CTF_IR_TRACE_H
2#define BABELTRACE_CTF_IR_TRACE_H
3
4/*
5 * BabelTrace - CTF IR: Trace
6 *
7 * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 *
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
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
27 * SOFTWARE.
28 *
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
31 */
32
2e33ac5a 33#include <babeltrace/ctf-ir/field-types.h>
8bf65fbd 34#include <babeltrace/ctf-ir/visitor.h>
dac5c838 35#include <babeltrace/values.h>
b2e0c907 36#include <babeltrace/graph/notification.h>
410d0373 37#include <stdint.h>
bc37ae52
JG
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
06300316
PP
43/**
44@defgroup ctfirtraceclass CTF IR trace class
45@ingroup ctfir
46@brief CTF IR trace class.
47
6dd2bd0c
PP
48@code
49#include <babeltrace/ctf-ir/trace.h>
50@endcode
51
06300316
PP
52A CTF IR <strong><em>trace class</em></strong> is a descriptor of
53traces.
54
55You can obtain a trace class in two different modes:
56
57- <strong>Normal mode</strong>: use bt_ctf_trace_create() to create a
58 default, empty trace class.
dfeca116
PP
59- <strong>CTF writer mode</strong>: use bt_ctf_writer_get_trace() to
60 get the trace class created by a given CTF writer object.
06300316
PP
61
62A trace class has the following properties:
63
64- A \b name.
65- A <strong>default byte order</strong>: all the
654515f1 66 \link ctfirfieldtypes field types\endlink eventually part of the trace
06300316
PP
67 class with a byte order set to #BT_CTF_BYTE_ORDER_NATIVE have this
68 "real" byte order.
69- An \b environment, which is a custom key-value mapping. Keys are
70 strings and values can be strings or integers.
71
72In the Babeltrace CTF IR system, a trace class contains zero or more
73\link ctfirstreamclass stream classes\endlink, and a stream class
74contains zero or more \link ctfireventclass event classes\endlink. You
75can add an event class to a stream class with
76bt_ctf_stream_class_add_event_class(). You can add a stream class to a
77trace class with bt_ctf_trace_add_stream_class().
78
79A trace class owns the <strong>trace packet header</strong>
80\link ctfirfieldtypes field type\endlink, which represents the
81\c trace.packet.header CTF scope. This field type describes the
82trace packet header fields of the traces that this trace class
83describes.
84
85The trace packet header field type \em must be a structure field type as
86of Babeltrace \btversion.
87
88As per the CTF specification, the trace packet header field type \em
89must contain a field named \c stream_id if the trace class contains more
90than one stream class.
91
92As a reminder, here's the structure of a CTF packet:
93
94@imgpacketstructure
95
96A trace class also contains zero or more
fe7041b3 97\link ctfirclockclass CTF IR clock classes\endlink.
06300316
PP
98
99@todo
100Elaborate about clock classes irt clock values.
101
2c1c33a4 102As with any Babeltrace object, CTF IR trace class objects have
06300316
PP
103<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
104counts</a>. See \ref refs to learn more about the reference counting
105management of Babeltrace objects.
106
107The following functions \em freeze their trace class parameter on
108success:
109
110- bt_ctf_trace_add_stream_class()
111- bt_ctf_writer_create_stream()
dfeca116 112 (\link ctfwriter CTF writer\endlink mode only)
06300316
PP
113
114You cannot modify a frozen trace class: it is considered immutable,
115except for:
116
117- Adding a stream class to it with
118 bt_ctf_trace_add_stream_class().
fe7041b3 119- Adding a CTF IR clock class to it with bt_ctf_trace_add_clock_class().
06300316
PP
120- \link refs Reference counting\endlink.
121
122You can add a custom listener with bt_ctf_trace_add_listener() to get
123notified if anything changes in a trace class, that is, if an event
124class is added to one of its stream class, if a stream class is added,
125or if a clock class is added.
126
127@sa ctfirstreamclass
128@sa ctfireventclass
129@sa ctfirclockclass
130
131@file
132@brief CTF IR trace class type and functions.
133@sa ctfirtraceclass
134
135@addtogroup ctfirtraceclass
136@{
137*/
138
139/**
140@struct bt_ctf_trace
141@brief A CTF IR trace class.
142@sa ctfirtraceclass
143*/
bc37ae52
JG
144struct bt_ctf_trace;
145struct bt_ctf_stream;
146struct bt_ctf_stream_class;
ac0c6bdd 147struct bt_ctf_clock_class;
bc37ae52 148
2204c381 149/**
06300316
PP
150@name Creation function
151@{
152*/
2204c381 153
06300316
PP
154/**
155@brief Creates a default CTF IR trace class.
156
157On success, the trace packet header field type of the created trace
158class has the following fields:
159
160- <code>magic</code>: a 32-bit unsigned integer field type.
161- <code>uuid</code>: an array field type of 16 8-bit unsigned integer
162 field types.
163- <code>stream_id</code>: a 32-bit unsigned integer field type.
164
165You can modify this default trace packet header field type after the
166trace class is created with bt_ctf_trace_set_packet_header_type().
167
168The created trace class has the following initial properties:
169
170- <strong>Name</strong>: none. You can set a name
171 with bt_ctf_trace_set_name().
172- <strong>Default byte order</strong>: #BT_CTF_BYTE_ORDER_NATIVE. You
391c8f0d 173 can set a default byte order with bt_ctf_trace_set_native_byte_order().
06300316
PP
174
175 Note that you \em must set the default byte order if any field type
176 contained in the created trace class, in its stream classes, or in
177 its event classes, has a byte order set to #BT_CTF_BYTE_ORDER_NATIVE.
178- <strong>Environment</strong>: empty. You can add environment entries
179 with bt_ctf_trace_set_environment_field(),
180 bt_ctf_trace_set_environment_field_integer(), and
181 bt_ctf_trace_set_environment_field_string().
182
183@returns Created trace class, or \c NULL on error.
184
185@postsuccessrefcountret1
186*/
bc37ae52
JG
187extern struct bt_ctf_trace *bt_ctf_trace_create(void);
188
06300316 189/** @} */
e96045d4 190
06300316
PP
191/**
192@name Properties functions
193@{
194*/
e96045d4 195
06300316
PP
196/**
197@brief Returns the name of the CTF IR trace class \p trace_class.
7f800dc7 198
06300316
PP
199On success, \p trace_class remains the sole owner of the returned
200string. The returned string is valid as long as \p trace_class exists
201and is not modified.
bc37ae52 202
06300316
PP
203@param[in] trace_class Trace class of which to get the name.
204@returns Name of trace class \p trace_class, or
205 \c NULL if \p trace_class is unnamed or
206 on error.
3487c9f3 207
06300316
PP
208@prenotnull{trace_class}
209@postrefcountsame{trace_class}
210
211@sa bt_ctf_trace_set_name(): Sets the name of a given trace class.
212*/
213extern const char *bt_ctf_trace_get_name(struct bt_ctf_trace *trace_class);
214
215/**
216@brief Sets the name of the CTF IR trace class \p trace_class
217 to \p name.
218
219@param[in] trace_class Trace class of which to set the name.
220@param[in] name Name of the trace class (copied on success).
221@returns 0 on success, or a negative value on error.
222
223@prenotnull{trace_class}
224@prenotnull{name}
225@prehot{trace_class}
226@postrefcountsame{trace_class}
227
228@sa bt_ctf_trace_get_name(): Returns the name of a given trace class.
229*/
230extern int bt_ctf_trace_set_name(struct bt_ctf_trace *trace_class,
231 const char *name);
232
233/**
234@brief Returns the default byte order of the CTF IR trace class
235 \p trace_class.
236
237@param[in] trace_class Trace class of which to get the default byte
238 order.
239@returns Default byte order of trace class
240 \p trace_class, or #BT_CTF_BYTE_ORDER_UNKNOWN
241 on error.
242
243@prenotnull{trace_class}
244@postrefcountsame{trace_class}
245
246@sa bt_ctf_trace_set_name(): Sets the name of a given trace class.
247*/
248extern enum bt_ctf_byte_order bt_ctf_trace_get_byte_order(
249 struct bt_ctf_trace *trace_class);
250
251/**
252@brief Sets the default byte order of the CTF IR trace class
391c8f0d 253 \p trace_class to \p native_byte_order.
06300316 254
391c8f0d 255\p native_byte_order \em must be one of:
06300316
PP
256
257- #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
258- #BT_CTF_BYTE_ORDER_BIG_ENDIAN
259- #BT_CTF_BYTE_ORDER_NETWORK
260
391c8f0d
PP
261@param[in] trace_class Trace class of which to set the default byte
262 order.
263@param[in] native_byte_order Default byte order of the trace class.
264@returns 0 on success, or a negative value on error.
06300316
PP
265
266@prenotnull{trace_class}
267@prenotnull{name}
268@prehot{trace_class}
391c8f0d 269@pre \p native_byte_order is either #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
06300316
PP
270 #BT_CTF_BYTE_ORDER_BIG_ENDIAN, or
271 #BT_CTF_BYTE_ORDER_NETWORK.
272@postrefcountsame{trace_class}
273
274@sa bt_ctf_trace_get_name(): Returns the name of a given trace class.
275*/
391c8f0d
PP
276extern int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace_class,
277 enum bt_ctf_byte_order native_byte_order);
06300316
PP
278
279/**
280@brief Returns the number of entries contained in the environment of
281 the CTF IR trace class \p trace_class.
282
283@param[in] trace_class Trace class of which to get the number
284 of environment entries.
285@returns Number of environment entries
286 contained in \p trace_class, or
287 a negative value on error.
288
289@prenotnull{trace_class}
290@postrefcountsame{trace_class}
291*/
e6fa2160 292extern int bt_ctf_trace_get_environment_field_count(
06300316 293 struct bt_ctf_trace *trace_class);
e6fa2160 294
06300316
PP
295/**
296@brief Returns the field name of the environment entry at index
297 \p index in the CTF IR trace class \p trace_class.
298
299On success, the returned string is valid as long as this trace class
300exists and is \em not modified. \p trace_class remains the sole owner of
301the returned string.
302
303@param[in] trace_class Trace class of which to get the name of the
304 environment entry at index \p index.
305@param[in] index Index of environment entry to find.
306@returns Name of the environment entry at index \p index
307 in \p trace_class, or \c NULL on error.
308
309@prenotnull{trace_class}
310@pre \p index is lesser than the number of environment entries in
311 \p trace_class (see bt_ctf_trace_get_environment_field_count()).
312@postrefcountsame{trace_class}
313
314@sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's
315 environment entry by index.
316@sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace
317 class's environment entry by name.
318@sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
319 class's environment entry.
320*/
e6fa2160 321extern const char *
06300316 322bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace_class,
e6fa2160
JG
323 int index);
324
06300316
PP
325/**
326@brief Returns the value of the environment entry at index
327 \p index in the CTF IR trace class \p trace_class.
328
329@param[in] trace_class Trace class of which to get the value of the
330 environment entry at index \p index.
331@param[in] index Index of the environment entry to find.
332@returns Value of the environment entry at index \p index
333 in \p trace_class, or \c NULL on error.
334
335@prenotnull{trace_class}
336@pre \p index is lesser than the number of environment entries in
337 \p trace_class (see bt_ctf_trace_get_environment_field_count()).
338@postrefcountsame{trace_class}
339@postsuccessrefcountretinc
340
341@sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace
342 class's environment entry by name.
343@sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
344 class's environment entry.
345*/
dac5c838 346extern struct bt_value *
06300316 347bt_ctf_trace_get_environment_field_value(struct bt_ctf_trace *trace_class,
e6fa2160
JG
348 int index);
349
06300316
PP
350/**
351@brief Returns the value of the environment entry named \p name
352 in the CTF IR trace class \p trace_class.
353
354@param[in] trace_class Trace class of which to get the value of the
355 environment entry named \p name.
356@param[in] name Name of the environment entry to find.
357@returns Value of the environment entry named \p name
358 in \p trace_class, or \c NULL if there's no such
359 entry or on error.
360
361@prenotnull{trace_class}
362@prenotnull{name}
363@postrefcountsame{trace_class}
364@postsuccessrefcountretinc
365
366@sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's
367 environment entry by index.
368@sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
369 class's environment entry.
370*/
dac5c838 371extern struct bt_value *
06300316
PP
372bt_ctf_trace_get_environment_field_value_by_name(
373 struct bt_ctf_trace *trace_class, const char *name);
e6fa2160 374
06300316
PP
375/**
376@brief Sets the environment entry named \p name in the
377 CTF IR trace class \p trace_class to \p value.
378
379If an environment entry named \p name exists in \p trace_class, its
380value is first put, and then replaced by \p value.
381
382@param[in] trace_class Trace class of which to set the environment
383 entry.
384@param[in] name Name of the environment entry to set (copied
385 on success).
386@param[in] value Value of the environment entry named \p name.
387@returns 0 on success, or a negative value on error.
388
389@prenotnull{trace_class}
390@prenotnull{name}
391@prenotnull{value}
392@prehot{trace_class}
393@pre \p value is an
394 \link bt_value_integer_create() integer value object\endlink
395 or a
396 \link bt_value_string_create() string value object\endlink.
397@postrefcountsame{trace_class}
398@postsuccessrefcountinc{value}
399
400@sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's
401 environment entry by index.
402@sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace
403 class's environment entry by name.
404*/
405extern int bt_ctf_trace_set_environment_field(
406 struct bt_ctf_trace *trace_class, const char *name,
407 struct bt_value *value);
bc37ae52 408
06300316
PP
409/**
410@brief Sets the environment entry named \p name in the
411 CTF IR trace class \p trace_class to \p value.
412
413If an environment entry named \p name exists in \p trace_class, its
414value is first put, and then replaced by a new
415\link bt_value_integer_create() integer value object\endlink
416containing \p value.
417
418@param[in] trace_class Trace class of which to set the environment
419 entry.
420@param[in] name Name of the environment entry to set (copied
421 on success).
422@param[in] value Value of the environment entry named \p name.
423@returns 0 on success, or a negative value on error.
424
425@prenotnull{trace_class}
426@prenotnull{name}
427@prehot{trace_class}
428@postrefcountsame{trace_class}
429
430@sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
431 class's environment entry.
432*/
433extern int bt_ctf_trace_set_environment_field_integer(
434 struct bt_ctf_trace *trace_class, const char *name,
435 int64_t value);
884cd6c3 436
06300316
PP
437/**
438@brief Sets the environment entry named \p name in the
439 CTF IR trace class \p trace_class to \p value.
440
441If an environment entry named \p name exists in \p trace_class, its
442value is first put, and then replaced by a new
443\link bt_value_string_create() string value object\endlink
444containing \p value.
445
446@param[in] trace_class Trace class of which to set the environment
447 entry.
448@param[in] name Name of the environment entry to set (copied
449 on success).
450@param[in] value Value of the environment entry named \p name
451 (copied on success).
452@returns 0 on success, or a negative value on error.
453
454@prenotnull{trace_class}
455@prenotnull{name}
456@prenotnull{value}
457@prehot{trace_class}
458@postrefcountsame{trace_class}
459
460@sa bt_ctf_trace_set_environment_field(): Sets the value of a trace
461 class's environment entry.
462*/
463extern int bt_ctf_trace_set_environment_field_string(
464 struct bt_ctf_trace *trace_class, const char *name,
465 const char *value);
466
467/** @} */
468
469/**
470@name Contained field types functions
471@{
472*/
473
474/**
475@brief Returns the packet header field type of the CTF IR trace class
476 \p trace_class.
477
478@param[in] trace_class Trace class of which to get the packet
479 header field type.
480@returns Packet header field type of \p trace_class,
6b783f49
JG
481 or \c NULL if \p trace_class has no packet header field
482 type or on error.
06300316
PP
483
484@prenotnull{trace_class}
c2f29fb9 485@postrefcountsame{trace_class}
6b783f49
JG
486@post <strong>On success, if the return value is a field type</strong>, its
487 reference count is incremented.
06300316
PP
488
489@sa bt_ctf_trace_set_packet_header_type(): Sets the packet
490 header field type of a given trace class.
491*/
492extern struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_type(
493 struct bt_ctf_trace *trace_class);
494
495/**
496@brief Sets the packet header field type of the CTF IR trace class
6b783f49
JG
497 \p trace_class to \p packet_header_type, or unsets the current packet
498 header field type from \p trace_class.
499
500If \p packet_header_type is \c NULL, then this function unsets the current
501packet header field type from \p trace_class, effectively making \p trace_class
502a trace without a packet header field type.
06300316 503
6b783f49
JG
504As of Babeltrace \btversion, if \p packet_header_type is not \c NULL,
505\p packet_header_type \em must be a CTF IR structure field type object.
06300316
PP
506
507@param[in] trace_class Trace class of which to set the packet
508 header field type.
6b783f49
JG
509@param[in] packet_header_type Packet header field type, or \c NULL to unset
510 the current packet header field type.
06300316
PP
511@returns 0 on success, or a negative value on error.
512
513@prenotnull{trace_class}
06300316 514@prehot{trace_class}
6b783f49
JG
515@pre <strong>\p packet_header_type, if not \c NULL</strong>, is a CTF IR
516 structure field type.
06300316 517@postrefcountsame{trace_class}
6b783f49
JG
518@post <strong>On success, if \p packet_header_type is not \c NULL</strong>,
519 the reference count of \p packet_header_type is incremented.
06300316
PP
520
521@sa bt_ctf_trace_get_packet_header_type(): Returns the packet
522 header field type of a given trace class.
523*/
524extern int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace_class,
525 struct bt_ctf_field_type *packet_header_type);
526
527/** @} */
528
529/**
fe7041b3 530@name Contained clock classes functions
06300316
PP
531@{
532*/
533
534/**
fe7041b3 535@brief Returns the number of CTF IR clock classes contained in the
06300316
PP
536 CTF IR trace class \p trace_class.
537
538@param[in] trace_class Trace class of which to get the number
fe7041b3
PP
539 of contained clock classes.
540@returns Number of contained clock classes
06300316
PP
541 contained in \p trace_class, or a negative
542 value on error.
543
544@prenotnull{trace_class}
545@postrefcountsame{trace_class}
546*/
ac0c6bdd 547extern int bt_ctf_trace_get_clock_class_count(struct bt_ctf_trace *trace_class);
06300316
PP
548
549/**
fe7041b3
PP
550@brief Returns the CTF IR clock class at index \p index in the CTF
551 IR trace class \p trace_class.
06300316 552
fe7041b3
PP
553@param[in] trace_class Trace class of which to get the clock class
554 contained at index \p index.
555@param[in] index Index of the clock class to find in
556 \p trace_class.
557@returns Clock class at index \p index in \p trace_class,
558 or \c NULL on error.
06300316
PP
559
560@prenotnull{trace_class}
561@pre \p index is lesser than the number of clock classes contained in
562 the trace class \p trace_class (see
ac0c6bdd 563 bt_ctf_trace_get_clock_class_count()).
06300316
PP
564@postrefcountsame{trace_class}
565@postsuccessrefcountretinc
566
fe7041b3
PP
567@sa bt_ctf_trace_get_clock_class_by_name(): Finds a clock class by name
568 in a given trace class.
ac0c6bdd 569@sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class.
06300316 570*/
ac0c6bdd 571extern struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class(
06300316 572 struct bt_ctf_trace *trace_class, int index);
884cd6c3 573
06300316 574/**
fe7041b3
PP
575@brief Returns the CTF IR clock class named \c name found in the CTF
576 IR trace class \p trace_class.
06300316 577
fe7041b3
PP
578@param[in] trace_class Trace class of which to get the clock class
579 named \p name.
580@param[in] name Name of the clock class to find in \p trace_class.
581@returns Clock class named \p name in \p trace_class,
582 or \c NULL on error.
06300316
PP
583
584@prenotnull{trace_class}
585@prenotnull{name}
586@postrefcountsame{trace_class}
587@postsuccessrefcountretinc
588
ac0c6bdd
PP
589@sa bt_ctf_trace_get_clock_class(): Returns the clock class contained
590 in a given trace class at a given index.
591@sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class.
06300316 592*/
ac0c6bdd 593extern struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name(
06300316 594 struct bt_ctf_trace *trace_class, const char *name);
ef0c4a15 595
06300316
PP
596/**
597@brief Adds the CTF IR clock class \p clock_class to the CTF IR
598 trace class \p trace_class.
ef0c4a15 599
fe7041b3 600On success, \p trace_class contains \p clock_class.
06300316 601
fe7041b3
PP
602You can call this function even if \p trace_class or \p clock_class
603are frozen.
06300316
PP
604
605@param[in] trace_class Trace class to which to add \p clock_class.
606@param[in] clock_class Clock class to add to \p trace_class.
607@returns 0 on success, or a negative value on error.
608
609@prenotnull{trace_class}
610@prenotnull{clock_class}
611@postrefcountsame{trace_class}
612@postsuccessrefcountinc{clock_class}
30484384 613@post <strong>On success, if \p trace_class is frozen</strong>,
2c1c33a4 614 \p clock_class is frozen.
06300316 615
ac0c6bdd
PP
616@sa bt_ctf_trace_get_clock_class(): Returns the clock class contained
617 in a given trace class at a given index.
fe7041b3
PP
618@sa bt_ctf_trace_get_clock_class_by_name(): Finds a clock class by name
619 in a given trace class.
06300316 620*/
ac0c6bdd
PP
621extern int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace_class,
622 struct bt_ctf_clock_class *clock_class);
06300316
PP
623
624/** @} */
625
626/**
627@name Stream class children functions
628@{
629*/
630
631/**
632@brief Returns the number of stream classes contained in the
633 CTF IR trace class \p trace_class.
634
635@param[in] trace_class Trace class of which to get the number
636 of children stream classes.
637@returns Number of children stream classes
638 contained in \p trace_class, or a negative
639 value on error.
640
641@prenotnull{trace_class}
642@postrefcountsame{trace_class}
643*/
644extern int bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace_class);
645
646/**
647@brief Returns the stream class at index \p index in the CTF IR trace
648 class \p trace_class.
649
650@param[in] trace_class Trace class of which to get the stream class.
651@param[in] index Index of the stream class to find.
652@returns Stream class at index \p index, or \c NULL
653 on error.
654
655@prenotnull{trace_class}
656@pre \p index is lesser than the number of stream classes contained in
657 the trace class \p trace_class (see
658 bt_ctf_trace_get_stream_class_count()).
659@postrefcountsame{trace_class}
06300316
PP
660
661@sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID.
662@sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class.
663*/
ef0c4a15 664extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class(
06300316 665 struct bt_ctf_trace *trace_class, int index);
ef0c4a15 666
06300316
PP
667/**
668@brief Returns the stream class with ID \c id found in the CTF IR
669 trace class \p trace_class.
670
671@param[in] trace_class Trace class of which to get the stream class.
672@param[in] id ID of the stream class to find.
673@returns Stream class with ID \p id, or \c NULL
674 on error.
675
676@prenotnull{trace_class}
677@postrefcountsame{trace_class}
678@postsuccessrefcountretinc
679
ac0c6bdd
PP
680@sa bt_ctf_trace_get_stream_class(): Returns the stream class contained
681 in a given trace class at a given index.
06300316
PP
682@sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class.
683*/
4841ccc1 684extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
06300316 685 struct bt_ctf_trace *trace_class, uint32_t id);
4841ccc1 686
06300316
PP
687/**
688@brief Adds the CTF IR stream class \p stream_class to the
689 CTF IR trace class \p trace_class.
7e4347a3 690
06300316 691On success, \p stream_class becomes the child of \p trace_class.
bc37ae52 692
06300316 693You can only add a given stream class to one trace class.
4ed90fb3 694
06300316 695You can call this function even if \p trace_class is frozen.
bc37ae52 696
4cdafd51
PP
697This function tries to resolve the needed
698\link ctfirfieldtypes CTF IR field type\endlink of the dynamic field
699types that are found anywhere in the root field types of
700\p stream_class and of all its currently contained
701\link ctfireventclass CTF IR event classes\endlink. If any automatic
702resolving fails, then this function fails.
703
06300316
PP
704@param[in] trace_class Trace class to which to add \p stream_class.
705@param[in] stream_class Stream class to add to \p trace_class.
706@returns 0 on success, or a negative value on error.
d246b111 707
06300316
PP
708@prenotnull{trace_class}
709@prenotnull{stream_class}
710@postrefcountsame{trace_class}
711@postsuccessrefcountinc{stream_class}
2c1c33a4 712@postsuccessfrozen{stream_class}
d246b111 713
ac0c6bdd
PP
714@sa bt_ctf_trace_get_stream_class(): Returns the stream class contained
715 in a given trace class at a given index.
06300316
PP
716@sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID.
717*/
718extern int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace_class,
719 struct bt_ctf_stream_class *stream_class);
720
721/** @} */
722
723/**
724@name Misc. functions
725@{
726*/
727
06300316
PP
728/**
729@brief Accepts the visitor \p visitor to visit the hierarchy of the
730 CTF IR trace class \p trace_class.
731
732This function traverses the hierarchy of \p trace_class in pre-order
733and calls \p visitor on each element.
734
735The trace class itself is visited first, then, for each children stream
736class, the stream class itself, and all its children event classes.
737
738@param[in] trace_class Trace class to visit.
739@param[in] visitor Visiting function.
740@param[in] data User data.
741@returns 0 on success, or a negative value on error.
742
743@prenotnull{trace_class}
744@prenotnull{visitor}
745*/
746extern int bt_ctf_trace_visit(struct bt_ctf_trace *trace_class,
d9a13d86 747 bt_ctf_visitor visitor, void *data);
8bf65fbd 748
06300316
PP
749/** @} */
750
35827558
PP
751/** @} */
752
2204c381 753/*
06300316 754 * bt_ctf_trace_get_metadata_string: get metadata string.
2204c381 755 *
06300316
PP
756 * Get the trace's TSDL metadata. The caller assumes the ownership of the
757 * returned string.
2204c381
JG
758 *
759 * @param trace Trace instance.
2204c381 760 *
06300316 761 * Returns the metadata string on success, NULL on error.
2204c381 762 */
06300316 763extern char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace);
2204c381 764
bc37ae52
JG
765#ifdef __cplusplus
766}
767#endif
768
769#endif /* BABELTRACE_CTF_IR_TRACE_H */
This page took 0.069582 seconds and 4 git commands to generate.