Commit | Line | Data |
---|---|---|
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 | |
40 | extern "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 |
52 | A CTF IR <strong><em>trace class</em></strong> is a descriptor of |
53 | traces. | |
54 | ||
55 | You 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 | |
62 | A 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 | ||
72 | In the Babeltrace CTF IR system, a trace class contains zero or more | |
73 | \link ctfirstreamclass stream classes\endlink, and a stream class | |
74 | contains zero or more \link ctfireventclass event classes\endlink. You | |
75 | can add an event class to a stream class with | |
76 | bt_ctf_stream_class_add_event_class(). You can add a stream class to a | |
77 | trace class with bt_ctf_trace_add_stream_class(). | |
78 | ||
c1e730fe PP |
79 | You can access the streams of a trace, that is, the streams which were |
80 | created from the trace's stream classes with bt_ctf_stream_create(), | |
81 | with bt_ctf_trace_get_stream(). | |
82 | ||
06300316 PP |
83 | A 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 | |
86 | trace packet header fields of the traces that this trace class | |
87 | describes. | |
88 | ||
89 | The trace packet header field type \em must be a structure field type as | |
90 | of Babeltrace \btversion. | |
91 | ||
92 | As per the CTF specification, the trace packet header field type \em | |
93 | must contain a field named \c stream_id if the trace class contains more | |
94 | than one stream class. | |
95 | ||
96 | As a reminder, here's the structure of a CTF packet: | |
97 | ||
98 | @imgpacketstructure | |
99 | ||
100 | A trace class also contains zero or more | |
fe7041b3 | 101 | \link ctfirclockclass CTF IR clock classes\endlink. |
06300316 PP |
102 | |
103 | @todo | |
104 | Elaborate about clock classes irt clock values. | |
105 | ||
2c1c33a4 | 106 | As with any Babeltrace object, CTF IR trace class objects have |
06300316 PP |
107 | <a href="https://en.wikipedia.org/wiki/Reference_counting">reference |
108 | counts</a>. See \ref refs to learn more about the reference counting | |
109 | management of Babeltrace objects. | |
110 | ||
111 | The following functions \em freeze their trace class parameter on | |
112 | success: | |
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 | |
118 | You cannot modify a frozen trace class: it is considered immutable, | |
119 | except 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 | ||
126 | You can add a custom listener with bt_ctf_trace_add_listener() to get | |
127 | notified if anything changes in a trace class, that is, if an event | |
128 | class is added to one of its stream class, if a stream class is added, | |
129 | or 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 |
148 | struct bt_ctf_trace; |
149 | struct bt_ctf_stream; | |
150 | struct bt_ctf_stream_class; | |
ac0c6bdd | 151 | struct 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 | ||
161 | On success, the trace packet header field type of the created trace | |
162 | class 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 | ||
169 | You can modify this default trace packet header field type after the | |
170 | trace class is created with bt_ctf_trace_set_packet_header_type(). | |
171 | ||
172 | The 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 |
191 | extern 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 |
203 | On success, \p trace_class remains the sole owner of the returned |
204 | string. The returned string is valid as long as \p trace_class exists | |
205 | and 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 | */ | |
217 | extern 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 | */ | |
234 | extern 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 | */ | |
252 | extern 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 |
280 | extern 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 | */ | |
e6fa2160 | 296 | extern int 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 | ||
303 | On success, the returned string is valid as long as this trace class | |
304 | exists and is \em not modified. \p trace_class remains the sole owner of | |
305 | the 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 | ||
318 | @sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's | |
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 | 325 | extern const char * |
06300316 | 326 | bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace_class, |
e6fa2160 JG |
327 | int index); |
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 | 350 | extern struct bt_value * |
06300316 | 351 | bt_ctf_trace_get_environment_field_value(struct bt_ctf_trace *trace_class, |
e6fa2160 JG |
352 | int index); |
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 | ||
370 | @sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's | |
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 | 375 | extern struct bt_value * |
06300316 PP |
376 | bt_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 | ||
383 | If an environment entry named \p name exists in \p trace_class, its | |
384 | value 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 | ||
404 | @sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's | |
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 | */ | |
409 | extern 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 | ||
417 | If an environment entry named \p name exists in \p trace_class, its | |
418 | value is first put, and then replaced by a new | |
419 | \link bt_value_integer_create() integer value object\endlink | |
420 | containing \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 | */ | |
437 | extern 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 | ||
445 | If an environment entry named \p name exists in \p trace_class, its | |
446 | value is first put, and then replaced by a new | |
447 | \link bt_value_string_create() string value object\endlink | |
448 | containing \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 | */ | |
467 | extern 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 | */ | |
496 | extern 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 | ||
504 | If \p packet_header_type is \c NULL, then this function unsets the current | |
505 | packet header field type from \p trace_class, effectively making \p trace_class | |
506 | a trace without a packet header field type. | |
06300316 | 507 | |
6b783f49 JG |
508 | As 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 | */ | |
528 | extern 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 | */ | |
ac0c6bdd | 551 | extern int bt_ctf_trace_get_clock_class_count(struct bt_ctf_trace *trace_class); |
06300316 PP |
552 | |
553 | /** | |
fe7041b3 PP |
554 | @brief Returns the CTF IR clock class at index \p index in the CTF |
555 | IR trace class \p trace_class. | |
06300316 | 556 | |
fe7041b3 PP |
557 | @param[in] trace_class Trace class of which to get the clock class |
558 | contained at index \p index. | |
559 | @param[in] index Index of the clock class to find in | |
560 | \p trace_class. | |
561 | @returns Clock class at index \p index in \p trace_class, | |
562 | or \c NULL on error. | |
06300316 PP |
563 | |
564 | @prenotnull{trace_class} | |
565 | @pre \p index is lesser than the number of clock classes contained in | |
566 | the trace class \p trace_class (see | |
ac0c6bdd | 567 | bt_ctf_trace_get_clock_class_count()). |
06300316 PP |
568 | @postrefcountsame{trace_class} |
569 | @postsuccessrefcountretinc | |
570 | ||
fe7041b3 PP |
571 | @sa bt_ctf_trace_get_clock_class_by_name(): Finds a clock class by name |
572 | in a given trace class. | |
ac0c6bdd | 573 | @sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class. |
06300316 | 574 | */ |
ac0c6bdd | 575 | extern struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class( |
06300316 | 576 | struct bt_ctf_trace *trace_class, int index); |
884cd6c3 | 577 | |
06300316 | 578 | /** |
fe7041b3 PP |
579 | @brief Returns the CTF IR clock class named \c name found in the CTF |
580 | IR trace class \p trace_class. | |
06300316 | 581 | |
fe7041b3 PP |
582 | @param[in] trace_class Trace class of which to get the clock class |
583 | named \p name. | |
584 | @param[in] name Name of the clock class to find in \p trace_class. | |
585 | @returns Clock class named \p name in \p trace_class, | |
586 | or \c NULL on error. | |
06300316 PP |
587 | |
588 | @prenotnull{trace_class} | |
589 | @prenotnull{name} | |
590 | @postrefcountsame{trace_class} | |
591 | @postsuccessrefcountretinc | |
592 | ||
ac0c6bdd PP |
593 | @sa bt_ctf_trace_get_clock_class(): Returns the clock class contained |
594 | in a given trace class at a given index. | |
595 | @sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class. | |
06300316 | 596 | */ |
ac0c6bdd | 597 | extern struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name( |
06300316 | 598 | struct bt_ctf_trace *trace_class, const char *name); |
ef0c4a15 | 599 | |
06300316 PP |
600 | /** |
601 | @brief Adds the CTF IR clock class \p clock_class to the CTF IR | |
602 | trace class \p trace_class. | |
ef0c4a15 | 603 | |
fe7041b3 | 604 | On success, \p trace_class contains \p clock_class. |
06300316 | 605 | |
fe7041b3 PP |
606 | You can call this function even if \p trace_class or \p clock_class |
607 | are frozen. | |
06300316 PP |
608 | |
609 | @param[in] trace_class Trace class to which to add \p clock_class. | |
610 | @param[in] clock_class Clock class to add to \p trace_class. | |
611 | @returns 0 on success, or a negative value on error. | |
612 | ||
613 | @prenotnull{trace_class} | |
614 | @prenotnull{clock_class} | |
615 | @postrefcountsame{trace_class} | |
616 | @postsuccessrefcountinc{clock_class} | |
30484384 | 617 | @post <strong>On success, if \p trace_class is frozen</strong>, |
2c1c33a4 | 618 | \p clock_class is frozen. |
06300316 | 619 | |
ac0c6bdd PP |
620 | @sa bt_ctf_trace_get_clock_class(): Returns the clock class contained |
621 | in a given trace class at a given index. | |
fe7041b3 PP |
622 | @sa bt_ctf_trace_get_clock_class_by_name(): Finds a clock class by name |
623 | in a given trace class. | |
06300316 | 624 | */ |
ac0c6bdd PP |
625 | extern int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace_class, |
626 | struct bt_ctf_clock_class *clock_class); | |
06300316 PP |
627 | |
628 | /** @} */ | |
629 | ||
630 | /** | |
631 | @name Stream class children functions | |
632 | @{ | |
633 | */ | |
634 | ||
635 | /** | |
636 | @brief Returns the number of stream classes contained in the | |
637 | CTF IR trace class \p trace_class. | |
638 | ||
639 | @param[in] trace_class Trace class of which to get the number | |
640 | of children stream classes. | |
641 | @returns Number of children stream classes | |
642 | contained in \p trace_class, or a negative | |
643 | value on error. | |
644 | ||
645 | @prenotnull{trace_class} | |
646 | @postrefcountsame{trace_class} | |
647 | */ | |
648 | extern int bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace_class); | |
649 | ||
650 | /** | |
651 | @brief Returns the stream class at index \p index in the CTF IR trace | |
652 | class \p trace_class. | |
653 | ||
654 | @param[in] trace_class Trace class of which to get the stream class. | |
655 | @param[in] index Index of the stream class to find. | |
656 | @returns Stream class at index \p index, or \c NULL | |
657 | on error. | |
658 | ||
659 | @prenotnull{trace_class} | |
660 | @pre \p index is lesser than the number of stream classes contained in | |
661 | the trace class \p trace_class (see | |
662 | bt_ctf_trace_get_stream_class_count()). | |
663 | @postrefcountsame{trace_class} | |
06300316 PP |
664 | |
665 | @sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID. | |
666 | @sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class. | |
667 | */ | |
ef0c4a15 | 668 | extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class( |
06300316 | 669 | struct bt_ctf_trace *trace_class, int index); |
ef0c4a15 | 670 | |
06300316 PP |
671 | /** |
672 | @brief Returns the stream class with ID \c id found in the CTF IR | |
673 | trace class \p trace_class. | |
674 | ||
675 | @param[in] trace_class Trace class of which to get the stream class. | |
676 | @param[in] id ID of the stream class to find. | |
677 | @returns Stream class with ID \p id, or \c NULL | |
678 | on error. | |
679 | ||
680 | @prenotnull{trace_class} | |
681 | @postrefcountsame{trace_class} | |
682 | @postsuccessrefcountretinc | |
683 | ||
ac0c6bdd PP |
684 | @sa bt_ctf_trace_get_stream_class(): Returns the stream class contained |
685 | in a given trace class at a given index. | |
06300316 PP |
686 | @sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class. |
687 | */ | |
4841ccc1 | 688 | extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id( |
06300316 | 689 | struct bt_ctf_trace *trace_class, uint32_t id); |
4841ccc1 | 690 | |
06300316 PP |
691 | /** |
692 | @brief Adds the CTF IR stream class \p stream_class to the | |
693 | CTF IR trace class \p trace_class. | |
7e4347a3 | 694 | |
06300316 | 695 | On success, \p stream_class becomes the child of \p trace_class. |
bc37ae52 | 696 | |
06300316 | 697 | You can only add a given stream class to one trace class. |
4ed90fb3 | 698 | |
06300316 | 699 | You can call this function even if \p trace_class is frozen. |
bc37ae52 | 700 | |
4cdafd51 PP |
701 | This function tries to resolve the needed |
702 | \link ctfirfieldtypes CTF IR field type\endlink of the dynamic field | |
703 | types that are found anywhere in the root field types of | |
704 | \p stream_class and of all its currently contained | |
705 | \link ctfireventclass CTF IR event classes\endlink. If any automatic | |
706 | resolving fails, then this function fails. | |
707 | ||
06300316 PP |
708 | @param[in] trace_class Trace class to which to add \p stream_class. |
709 | @param[in] stream_class Stream class to add to \p trace_class. | |
710 | @returns 0 on success, or a negative value on error. | |
d246b111 | 711 | |
06300316 PP |
712 | @prenotnull{trace_class} |
713 | @prenotnull{stream_class} | |
714 | @postrefcountsame{trace_class} | |
715 | @postsuccessrefcountinc{stream_class} | |
2c1c33a4 | 716 | @postsuccessfrozen{stream_class} |
d246b111 | 717 | |
ac0c6bdd PP |
718 | @sa bt_ctf_trace_get_stream_class(): Returns the stream class contained |
719 | in a given trace class at a given index. | |
06300316 PP |
720 | @sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID. |
721 | */ | |
722 | extern int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace_class, | |
723 | struct bt_ctf_stream_class *stream_class); | |
724 | ||
725 | /** @} */ | |
726 | ||
c1e730fe PP |
727 | /** |
728 | @name Stream children functions | |
729 | @{ | |
730 | */ | |
731 | ||
732 | /** | |
733 | @brief Returns the number of streams contained in the CTF IR trace | |
734 | class \p trace_class. | |
735 | ||
736 | @param[in] trace_class Trace class of which to get the number | |
737 | of children streams. | |
738 | @returns Number of children streams | |
739 | contained in \p trace_class, or a negative | |
740 | value on error. | |
741 | ||
742 | @prenotnull{trace_class} | |
743 | @postrefcountsame{trace_class} | |
744 | */ | |
745 | extern int bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace_class); | |
746 | ||
747 | /** | |
748 | @brief Returns the stream at index \p index in the CTF IR trace | |
749 | class \p trace_class. | |
750 | ||
751 | @param[in] trace_class Trace class of which to get the stream. | |
752 | @param[in] index Index of the stream to find. | |
753 | @returns Stream at index \p index, or \c NULL | |
754 | on error. | |
755 | ||
756 | @prenotnull{trace_class} | |
757 | @pre \p index is lesser than the number of streams contained in | |
758 | the trace class \p trace_class (see | |
759 | bt_ctf_trace_get_stream_count()). | |
760 | @postrefcountsame{trace_class} | |
761 | */ | |
762 | extern struct bt_ctf_stream *bt_ctf_trace_get_stream( | |
763 | struct bt_ctf_trace *trace_class, int index); | |
764 | ||
765 | /** @} */ | |
766 | ||
06300316 PP |
767 | /** |
768 | @name Misc. functions | |
769 | @{ | |
770 | */ | |
771 | ||
06300316 PP |
772 | /** |
773 | @brief Accepts the visitor \p visitor to visit the hierarchy of the | |
774 | CTF IR trace class \p trace_class. | |
775 | ||
776 | This function traverses the hierarchy of \p trace_class in pre-order | |
777 | and calls \p visitor on each element. | |
778 | ||
779 | The trace class itself is visited first, then, for each children stream | |
780 | class, the stream class itself, and all its children event classes. | |
781 | ||
782 | @param[in] trace_class Trace class to visit. | |
783 | @param[in] visitor Visiting function. | |
784 | @param[in] data User data. | |
785 | @returns 0 on success, or a negative value on error. | |
786 | ||
787 | @prenotnull{trace_class} | |
788 | @prenotnull{visitor} | |
789 | */ | |
790 | extern int bt_ctf_trace_visit(struct bt_ctf_trace *trace_class, | |
d9a13d86 | 791 | bt_ctf_visitor visitor, void *data); |
8bf65fbd | 792 | |
06300316 PP |
793 | /** @} */ |
794 | ||
35827558 PP |
795 | /** @} */ |
796 | ||
2204c381 | 797 | /* |
06300316 | 798 | * bt_ctf_trace_get_metadata_string: get metadata string. |
2204c381 | 799 | * |
06300316 PP |
800 | * Get the trace's TSDL metadata. The caller assumes the ownership of the |
801 | * returned string. | |
2204c381 JG |
802 | * |
803 | * @param trace Trace instance. | |
2204c381 | 804 | * |
06300316 | 805 | * Returns the metadata string on success, NULL on error. |
2204c381 | 806 | */ |
06300316 | 807 | extern char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace); |
2204c381 | 808 | |
bc37ae52 JG |
809 | #ifdef __cplusplus |
810 | } | |
811 | #endif | |
812 | ||
813 | #endif /* BABELTRACE_CTF_IR_TRACE_H */ |