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