Commit | Line | Data |
---|---|---|
adc315b8 JG |
1 | #ifndef BABELTRACE_CTF_IR_STREAM_CLASS_H |
2 | #define BABELTRACE_CTF_IR_STREAM_CLASS_H | |
3 | ||
4 | /* | |
5 | * BabelTrace - CTF IR: Stream Class | |
6 | * | |
de9dd397 | 7 | * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
adc315b8 JG |
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 | ||
48d711a2 | 33 | #include <stdint.h> |
8bf65fbd | 34 | #include <babeltrace/ctf-ir/visitor.h> |
48d711a2 | 35 | |
adc315b8 JG |
36 | #ifdef __cplusplus |
37 | extern "C" { | |
38 | #endif | |
39 | ||
594a3fb7 PP |
40 | /** |
41 | @defgroup ctfirstreamclass CTF IR stream class | |
42 | @ingroup ctfir | |
43 | @brief CTF IR stream class. | |
44 | ||
6dd2bd0c PP |
45 | @code |
46 | #include <babeltrace/ctf-ir/stream-class.h> | |
47 | @endcode | |
48 | ||
319f672c | 49 | @note |
dfeca116 PP |
50 | See \ref ctfwriterstreamclass which documents additional CTF IR stream |
51 | class functions exclusive to the CTF writer mode. | |
319f672c | 52 | |
594a3fb7 PP |
53 | A CTF IR <strong><em>stream class</em></strong> is a template that you |
54 | can use to create concrete \link ctfirstream CTF IR streams\endlink. | |
55 | ||
56 | A stream class has the following properties, both of which \em must | |
57 | be unique amongst all the stream classes contained in the same | |
58 | \link ctfirtraceclass CTF IR trace class\endlink: | |
59 | ||
60 | - A \b name. | |
61 | - A numeric \b ID. | |
62 | ||
63 | In the Babeltrace CTF IR system, a \link ctfirtraceclass trace class\endlink | |
64 | contains zero or more stream classes, | |
65 | and a stream class contains zero or more | |
66 | \link ctfireventclass event classes\endlink. | |
67 | You can add an event class | |
68 | to a stream class with bt_ctf_stream_class_add_event_class(). | |
69 | You can add a stream class to a trace class with | |
70 | bt_ctf_trace_add_stream_class(). | |
71 | ||
72 | A stream class owns three \link ctfirfieldtypes field types\endlink: | |
73 | ||
74 | - An optional <strong>stream packet context</strong> field type, which | |
75 | represents the \c stream.packet.context CTF scope. | |
76 | - An optional <strong>stream event header</strong> field type, which | |
77 | represents the \c stream.event.header CTF scope. | |
78 | - An optional <strong>stream event context</strong> field type, which | |
79 | represents the \c stream.event.context CTF scope. | |
80 | ||
81 | Those three field types \em must be structure field types as of | |
82 | Babeltrace \btversion. | |
83 | ||
84 | As per the CTF specification, the event header field type \em must | |
85 | contain a field named \c id if the stream class contains more than one | |
86 | event class. | |
87 | ||
88 | As a reminder, here's the structure of a CTF packet: | |
89 | ||
90 | @imgpacketstructure | |
91 | ||
92 | Before you can create a stream from a stream class with | |
93 | bt_ctf_stream_create(), you \em must add the prepared stream class to a | |
94 | trace class by calling bt_ctf_trace_add_stream_class(). | |
95 | ||
96 | As with any Babeltrace object, CTF IR stream class objects have | |
97 | <a href="https://en.wikipedia.org/wiki/Reference_counting">reference | |
98 | counts</a>. See \ref refs to learn more about the reference counting | |
99 | management of Babeltrace objects. | |
100 | ||
101 | The following functions \em freeze their stream class parameter on | |
102 | success: | |
103 | ||
104 | - bt_ctf_trace_add_stream_class() | |
105 | - bt_ctf_event_create() | |
106 | - bt_ctf_writer_create_stream() | |
dfeca116 | 107 | (\link ctfwriter CTF writer\endlink mode only) |
594a3fb7 PP |
108 | |
109 | You cannot modify a frozen stream class: it is considered immutable, | |
110 | except for: | |
111 | ||
112 | - Adding an event class to it with | |
113 | bt_ctf_stream_class_add_event_class(). | |
114 | - \link refs Reference counting\endlink. | |
115 | ||
116 | @sa ctfirstream | |
117 | @sa ctfireventclass | |
118 | @sa ctfirtraceclass | |
dfeca116 | 119 | @sa ctfwriterstreamclass |
594a3fb7 PP |
120 | |
121 | @file | |
122 | @brief CTF IR stream class type and functions. | |
123 | @sa ctfirstreamclass | |
124 | ||
125 | @addtogroup ctfirstreamclass | |
126 | @{ | |
127 | */ | |
128 | ||
129 | /** | |
130 | @struct bt_ctf_stream_class | |
131 | @brief A CTF IR stream class. | |
132 | @sa ctfirstreamclass | |
133 | */ | |
adc315b8 | 134 | struct bt_ctf_stream_class; |
594a3fb7 | 135 | struct bt_ctf_event_class; |
adc315b8 JG |
136 | struct bt_ctf_clock; |
137 | ||
594a3fb7 PP |
138 | /** |
139 | @name Creation and parent access functions | |
140 | @{ | |
141 | */ | |
142 | ||
143 | /** | |
144 | @brief Creates a default CTF IR stream class named \p name, or a | |
145 | default unnamed stream class if \p name is \c NULL. | |
146 | ||
147 | On success, the packet context field type of the created stream class | |
148 | has the following fields: | |
149 | ||
150 | - <code>timestamp_begin</code>: a 64-bit unsigned integer field type. | |
151 | - <code>timestamp_end</code>: a 64-bit unsigned integer field type. | |
152 | - <code>content_size</code>: a 64-bit unsigned integer field type. | |
153 | - <code>packet_size</code>: a 64-bit unsigned integer field type. | |
154 | - <code>events_discarded</code>: a 64-bit unsigned integer field type. | |
155 | ||
156 | On success, the event header field type of the created stream class | |
157 | has the following fields: | |
158 | ||
159 | - <code>code</code>: a 32-bit unsigned integer field type. | |
160 | - <code>timestamp</code>: a 64-bit unsigned integer field type. | |
161 | ||
162 | You can modify those default field types after the stream class is | |
163 | created with bt_ctf_stream_class_set_packet_context_type() and | |
164 | bt_ctf_stream_class_set_event_header_type(). | |
165 | ||
166 | @param[in] name Name of the stream class to create (can be \c NULL to | |
167 | create an unnamed stream class). | |
168 | @returns Created stream class, or \c NULL on error. | |
169 | ||
170 | @postsuccessrefcountret1 | |
171 | */ | |
adc315b8 JG |
172 | extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name); |
173 | ||
594a3fb7 PP |
174 | /** |
175 | @brief Returns the parent CTF IR trace class of the CTF IR stream | |
176 | class \p stream_class. | |
177 | ||
178 | It is possible that the stream class was not added to a trace class | |
179 | yet, in which case this function returns \c NULL. You can add a | |
180 | stream class to a trace class with | |
181 | bt_ctf_trace_add_stream_class(). | |
182 | ||
183 | @param[in] stream_class Stream class of which to get the parent | |
184 | trace class. | |
185 | @returns Parent trace class of \p stream_class, | |
186 | or \c NULL if \p stream_class was not | |
187 | added to a trace class yet or on error. | |
188 | ||
189 | @prenotnull{stream_class} | |
c2f29fb9 | 190 | @postrefcountsame{stream_class} |
594a3fb7 PP |
191 | @postsuccessrefcountretinc |
192 | ||
193 | @sa bt_ctf_trace_add_stream_class(): Add a stream class to | |
194 | a trace class. | |
195 | */ | |
142c5610 JG |
196 | extern struct bt_ctf_trace *bt_ctf_stream_class_get_trace( |
197 | struct bt_ctf_stream_class *stream_class); | |
198 | ||
594a3fb7 PP |
199 | /** @} */ |
200 | ||
201 | /** | |
202 | @name Properties functions | |
203 | @{ | |
204 | */ | |
205 | ||
206 | /** | |
207 | @brief Returns the name of the CTF IR stream class \p stream_class. | |
208 | ||
209 | On success, \p stream_class remains the sole owner of the returned | |
210 | string. | |
211 | ||
212 | @param[in] stream_class Stream class of which to get the name. | |
213 | @returns Name of stream class \p stream_class, or | |
214 | \c NULL if \p stream_class is unnamed or | |
215 | on error. | |
216 | ||
217 | @prenotnull{stream_class} | |
218 | @postrefcountsame{stream_class} | |
219 | ||
220 | @sa bt_ctf_stream_class_set_name(): Sets the name of a given | |
221 | stream class. | |
222 | */ | |
69dc4535 JG |
223 | extern const char *bt_ctf_stream_class_get_name( |
224 | struct bt_ctf_stream_class *stream_class); | |
225 | ||
594a3fb7 PP |
226 | /** |
227 | @brief Sets the name of the CTF IR stream class | |
228 | \p stream_class to \p name. | |
229 | ||
230 | \p name must be unique amongst the names of all the stream classes | |
231 | of the trace class to which you eventually add \p stream_class. | |
232 | ||
233 | @param[in] stream_class Stream class of which to set the name. | |
234 | @param[in] name Name of the stream class (copied on success). | |
235 | @returns 0 on success, or a negative value on error. | |
236 | ||
237 | @prenotnull{stream_class} | |
238 | @prenotnull{name} | |
239 | @prehot{stream_class} | |
240 | @postrefcountsame{stream_class} | |
241 | ||
242 | @sa bt_ctf_stream_class_get_name(): Returns the name of a given | |
243 | stream class. | |
244 | */ | |
3ea33115 JG |
245 | extern int bt_ctf_stream_class_set_name( |
246 | struct bt_ctf_stream_class *stream_class, const char *name); | |
247 | ||
594a3fb7 PP |
248 | /** |
249 | @brief Returns the numeric ID of the CTF IR stream class \p stream_class. | |
2f100782 | 250 | |
594a3fb7 PP |
251 | @param[in] stream_class Stream class of which to get the numeric ID. |
252 | @returns ID of stream class \p stream_class, or a | |
253 | negative value on error. | |
254 | ||
255 | @prenotnull{stream_class} | |
256 | @postrefcountsame{stream_class} | |
257 | ||
258 | @sa bt_ctf_stream_class_set_id(): Sets the numeric ID of a given | |
259 | stream class. | |
260 | */ | |
2f100782 JG |
261 | extern int64_t bt_ctf_stream_class_get_id( |
262 | struct bt_ctf_stream_class *stream_class); | |
263 | ||
594a3fb7 PP |
264 | /** |
265 | @brief Sets the numeric ID of the CTF IR stream class | |
266 | \p stream_class to \p id. | |
267 | ||
268 | \p id must be unique amongst the IDs of all the stream classes | |
269 | of the trace class to which you eventually add \p stream_class. | |
270 | ||
271 | @param[in] stream_class Stream class of which to set the numeric ID. | |
272 | @param[in] id ID of the stream class. | |
273 | @returns 0 on success, or a negative value on error. | |
274 | ||
275 | @prenotnull{stream_class} | |
276 | @prehot{stream_class} | |
9ac68eb1 | 277 | @pre \p id is lesser than or equal to 9223372036854775807 (\c INT64_MAX). |
594a3fb7 PP |
278 | @postrefcountsame{stream_class} |
279 | ||
280 | @sa bt_ctf_stream_class_get_id(): Returns the numeric ID of a given | |
281 | stream class. | |
282 | */ | |
2f100782 | 283 | extern int bt_ctf_stream_class_set_id( |
9ac68eb1 | 284 | struct bt_ctf_stream_class *stream_class, uint64_t id); |
2f100782 | 285 | |
594a3fb7 | 286 | /** @} */ |
adc315b8 | 287 | |
594a3fb7 PP |
288 | /** |
289 | @name Contained field types functions | |
290 | @{ | |
291 | */ | |
69dc4535 | 292 | |
594a3fb7 PP |
293 | /** |
294 | @brief Returns the packet context field type of the CTF IR stream class | |
295 | \p stream_class. | |
69dc4535 | 296 | |
594a3fb7 PP |
297 | @param[in] stream_class Stream class of which to get the packet |
298 | context field type. | |
299 | @returns Packet context field type of \p stream_class, | |
6b783f49 JG |
300 | or \c NULL if \p stream_class has no packet context |
301 | field type or on error. | |
69dc4535 | 302 | |
594a3fb7 | 303 | @prenotnull{stream_class} |
c2f29fb9 | 304 | @postrefcountsame{stream_class} |
6b783f49 JG |
305 | @post <strong>On success, if the return value is a field type</strong>, its |
306 | reference count is incremented. | |
0863f950 | 307 | |
594a3fb7 PP |
308 | @sa bt_ctf_stream_class_set_packet_context_type(): Sets the packet |
309 | context field type of a given stream class. | |
310 | */ | |
12c8a1a3 JG |
311 | extern struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type( |
312 | struct bt_ctf_stream_class *stream_class); | |
313 | ||
594a3fb7 PP |
314 | /** |
315 | @brief Sets the packet context field type of the CTF IR stream class | |
6b783f49 JG |
316 | \p stream_class to \p packet_context_type, or unsets the current packet |
317 | context field type from \p stream_class. | |
318 | ||
319 | If \p packet_context_type is \c NULL, then this function unsets the current | |
320 | packet context field type from \p stream_class, effectively making | |
321 | \p stream_class a stream class without a packet context field type. | |
594a3fb7 | 322 | |
6b783f49 JG |
323 | As of Babeltrace \btversion, if \p packet_context_type is not \c NULL, |
324 | \p packet_context_type \em must be a CTF IR structure field type object. | |
594a3fb7 PP |
325 | |
326 | @param[in] stream_class Stream class of which to set the packet | |
327 | context field type. | |
6b783f49 JG |
328 | @param[in] packet_context_type Packet context field type, or \c NULL to unset |
329 | the current packet context field type. | |
594a3fb7 PP |
330 | @returns 0 on success, or a negative value on error. |
331 | ||
332 | @prenotnull{stream_class} | |
594a3fb7 | 333 | @prehot{stream_class} |
6b783f49 JG |
334 | @pre <strong>\p packet_context_type, if not \c NULL</strong>, is a CTF IR |
335 | structure field type. | |
594a3fb7 | 336 | @postrefcountsame{stream_class} |
6b783f49 JG |
337 | @post <strong>On success, if \p packet_context_type is not \c NULL</strong>, |
338 | the reference count of \p packet_context_type is incremented. | |
594a3fb7 PP |
339 | |
340 | @sa bt_ctf_stream_class_get_packet_context_type(): Returns the packet | |
341 | context field type of a given stream class. | |
342 | */ | |
12c8a1a3 JG |
343 | extern int bt_ctf_stream_class_set_packet_context_type( |
344 | struct bt_ctf_stream_class *stream_class, | |
345 | struct bt_ctf_field_type *packet_context_type); | |
346 | ||
594a3fb7 PP |
347 | /** |
348 | @brief Returns the event header field type of the CTF IR stream class | |
349 | \p stream_class. | |
350 | ||
351 | @param[in] stream_class Stream class of which to get the event header | |
352 | field type. | |
353 | @returns Event header field type of \p stream_class, | |
6b783f49 JG |
354 | or \c NULL if \p stream_class has no event header field |
355 | type or on error. | |
594a3fb7 PP |
356 | |
357 | @prenotnull{stream_class} | |
c2f29fb9 | 358 | @postrefcountsame{stream_class} |
6b783f49 JG |
359 | @post <strong>On success, if the return value is a field type</strong>, its |
360 | reference count is incremented. | |
594a3fb7 PP |
361 | |
362 | @sa bt_ctf_stream_class_set_event_header_type(): Sets the event | |
363 | header field type of a given stream class. | |
364 | */ | |
662e778c JG |
365 | extern struct bt_ctf_field_type * |
366 | bt_ctf_stream_class_get_event_header_type( | |
367 | struct bt_ctf_stream_class *stream_class); | |
368 | ||
594a3fb7 PP |
369 | /** |
370 | @brief Sets the event header field type of the CTF IR stream class | |
6b783f49 JG |
371 | \p stream_class to \p event_header_type, or unsets the current event |
372 | header field type from \p stream_class. | |
373 | ||
374 | If \p event_header_type is \c NULL, then this function unsets the current | |
375 | event header field type from \p stream_class, effectively making \p stream_class | |
376 | a stream class without a event header field type. | |
594a3fb7 | 377 | |
6b783f49 JG |
378 | As of Babeltrace \btversion, if \p event_header_type is not \c NULL, |
379 | \p event_header_type \em must be a CTF IR structure field type object. | |
594a3fb7 | 380 | |
b2481397 | 381 | @param[in] stream_class Stream class of which to set the event |
594a3fb7 | 382 | header field type. |
6b783f49 JG |
383 | @param[in] event_header_type Event header field type, or \c NULL to unset |
384 | the current event header field type. | |
594a3fb7 PP |
385 | @returns 0 on success, or a negative value on error. |
386 | ||
387 | @prenotnull{stream_class} | |
594a3fb7 | 388 | @prehot{stream_class} |
6b783f49 JG |
389 | @pre <strong>\p event_header_type, if not \c NULL</strong>, is a CTF IR |
390 | structure field type. | |
594a3fb7 | 391 | @postrefcountsame{stream_class} |
6b783f49 JG |
392 | @post <strong>On success, if \p event_header_type is not \c NULL</strong>, |
393 | the reference count of \p event_header_type is incremented. | |
594a3fb7 | 394 | |
b2481397 PP |
395 | @sa bt_ctf_stream_class_get_event_header_type(): Returns the event |
396 | header field type of a given stream class. | |
594a3fb7 | 397 | */ |
662e778c JG |
398 | extern int bt_ctf_stream_class_set_event_header_type( |
399 | struct bt_ctf_stream_class *stream_class, | |
400 | struct bt_ctf_field_type *event_header_type); | |
401 | ||
594a3fb7 | 402 | /** |
6b783f49 JG |
403 | @brief Returns the event context field type of the CTF IR stream class |
404 | \p stream_class. | |
594a3fb7 | 405 | |
6b783f49 JG |
406 | @param[in] stream_class Stream class of which to get the event context |
407 | field type. | |
408 | @returns Event context field type of \p stream_class, | |
409 | or \c NULL if \p stream_class has no event context field | |
410 | type or on error. | |
594a3fb7 PP |
411 | |
412 | @prenotnull{stream_class} | |
c2f29fb9 | 413 | @postrefcountsame{stream_class} |
6b783f49 JG |
414 | @post <strong>On success, if the return value is a field type</strong>, |
415 | its reference count is incremented. | |
416 | ||
594a3fb7 | 417 | |
6b783f49 JG |
418 | @sa bt_ctf_stream_class_set_event_context_type(): Sets the event |
419 | context field type of a given stream class. | |
594a3fb7 | 420 | */ |
af181248 JG |
421 | extern struct bt_ctf_field_type * |
422 | bt_ctf_stream_class_get_event_context_type( | |
423 | struct bt_ctf_stream_class *stream_class); | |
424 | ||
594a3fb7 | 425 | /** |
6b783f49 JG |
426 | @brief Sets the event context field type of the CTF IR stream class |
427 | \p stream_class to \p event_context_type, or unsets the current event | |
428 | context field type from \p stream_class. | |
594a3fb7 | 429 | |
6b783f49 JG |
430 | If \p event_context_type is \c NULL, then this function unsets the current |
431 | event context field type from \p stream_class, effectively making \p | |
432 | stream_class a stream class without a event context field type. | |
594a3fb7 | 433 | |
6b783f49 JG |
434 | As of Babeltrace \btversion, if \p event_context_type is not \c NULL, |
435 | \p event_context_type \em must be a CTF IR structure field type object. | |
436 | ||
437 | @param[in] stream_class Stream class of which to set the packet | |
438 | context field type. | |
439 | @param[in] event_context_type Event context field type, or \c NULL to unset | |
440 | the current event context field type. | |
594a3fb7 PP |
441 | @returns 0 on success, or a negative value on error. |
442 | ||
443 | @prenotnull{stream_class} | |
594a3fb7 | 444 | @prehot{stream_class} |
6b783f49 JG |
445 | @pre <strong>\p event_context_type, if not \c NULL</strong>, is a CTF IR |
446 | structure field type. | |
594a3fb7 | 447 | @postrefcountsame{stream_class} |
6b783f49 JG |
448 | @post <strong>On success, if \p event_context_type is not \c NULL</strong>, |
449 | the reference count of \p event_context_type is incremented. | |
594a3fb7 | 450 | |
6b783f49 JG |
451 | @sa bt_ctf_stream_class_get_event_context_type(): Returns the event context |
452 | field type of a given stream class. | |
594a3fb7 | 453 | */ |
af181248 JG |
454 | extern int bt_ctf_stream_class_set_event_context_type( |
455 | struct bt_ctf_stream_class *stream_class, | |
456 | struct bt_ctf_field_type *event_context_type); | |
457 | ||
594a3fb7 PP |
458 | /** @} */ |
459 | ||
460 | /** | |
461 | @name Event class children functions | |
462 | @{ | |
463 | */ | |
464 | ||
465 | /** | |
466 | @brief Returns the number of event classes contained in the | |
467 | CTF IR stream class \p stream_class. | |
468 | ||
469 | @param[in] stream_class Stream class of which to get the number | |
470 | of children event classes. | |
471 | @returns Number of children event classes | |
472 | contained in \p stream_class, or | |
473 | a negative value on error. | |
474 | ||
475 | @prenotnull{stream_class} | |
476 | @postrefcountsame{stream_class} | |
477 | */ | |
544d0515 | 478 | extern int64_t bt_ctf_stream_class_get_event_class_count( |
594a3fb7 PP |
479 | struct bt_ctf_stream_class *stream_class); |
480 | ||
481 | /** | |
482 | @brief Returns the event class at index \p index in the CTF IR stream | |
483 | class \p stream_class. | |
484 | ||
485 | @param[in] stream_class Stream class of which to get the event class. | |
486 | @param[in] index Index of the event class to find. | |
487 | @returns Event class at index \p index, or \c NULL | |
488 | on error. | |
489 | ||
490 | @prenotnull{stream_class} | |
491 | @pre \p index is lesser than the number of event classes contained in the | |
492 | stream class \p stream_class (see | |
493 | bt_ctf_stream_class_get_event_class_count()). | |
494 | @postrefcountsame{stream_class} | |
495 | @postsuccessrefcountretinc | |
496 | ||
497 | @sa bt_ctf_stream_class_get_event_class_by_id(): Finds an event class | |
498 | by ID. | |
499 | @sa bt_ctf_stream_class_get_event_class_by_name(): Finds an event class | |
500 | by name. | |
501 | */ | |
9ac68eb1 PP |
502 | extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index( |
503 | struct bt_ctf_stream_class *stream_class, uint64_t index); | |
594a3fb7 PP |
504 | |
505 | /** | |
506 | @brief Returns the event class named \c name found in the CTF IR stream | |
507 | class \p stream_class. | |
508 | ||
509 | @param[in] stream_class Stream class of which to get the event class. | |
510 | @param[in] name Name of the event class to find. | |
511 | @returns Event class named \p name, or \c NULL | |
512 | on error. | |
513 | ||
514 | @prenotnull{stream_class} | |
515 | @prenotnull{name} | |
516 | @postrefcountsame{stream_class} | |
517 | @postsuccessrefcountretinc | |
518 | ||
519 | @sa bt_ctf_stream_class_get_event_class_by_id(): Finds an event class | |
520 | by ID. | |
521 | */ | |
522 | extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name( | |
523 | struct bt_ctf_stream_class *stream_class, const char *name); | |
524 | ||
525 | /** | |
526 | @brief Returns the event class with ID \c id found in the CTF IR stream | |
527 | class \p stream_class. | |
528 | ||
529 | @param[in] stream_class Stream class of which to get the event class. | |
530 | @param[in] id ID of the event class to find. | |
531 | @returns Event class with ID \p id, or \c NULL | |
532 | on error. | |
533 | ||
534 | @prenotnull{stream_class} | |
535 | @postrefcountsame{stream_class} | |
536 | @postsuccessrefcountretinc | |
537 | ||
538 | @sa bt_ctf_stream_class_get_event_class_by_name(): Finds an event class | |
539 | by name. | |
540 | */ | |
541 | extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id( | |
9ac68eb1 | 542 | struct bt_ctf_stream_class *stream_class, uint64_t id); |
594a3fb7 PP |
543 | |
544 | /** | |
545 | @brief Adds the CTF IR event class \p event_class to the | |
546 | CTF IR stream class \p stream_class. | |
547 | ||
548 | On success, \p event_class becomes the child of \p stream_class. | |
549 | ||
550 | You can only add a given event class to one stream class. | |
551 | ||
552 | You can call this function even if \p stream_class is frozen. Adding | |
553 | event classes is the only operation that is permitted | |
554 | on a frozen stream class. | |
555 | ||
4cdafd51 PP |
556 | This function tries to resolve the needed |
557 | \link ctfirfieldtypes CTF IR field type\endlink of the dynamic field | |
558 | types that are found anywhere in the context or payload field | |
559 | types of \p event_class. If any automatic resolving fails: | |
560 | ||
561 | - If the needed field type should be found in one of the root field | |
562 | types of \p event_class or \p stream_class, this function fails. | |
563 | - If \p stream_class is the child of a | |
564 | \link ctfirtraceclass CTF IR trace class\endlink (it was added | |
565 | with bt_ctf_trace_add_stream_class()), this function fails. | |
566 | - If \p stream_class is not the child of a trace class yet, the | |
567 | automatic resolving is reported to the next call to | |
568 | bt_ctf_trace_add_stream_class() with \p stream_class. | |
569 | ||
594a3fb7 PP |
570 | @param[in] stream_class Stream class to which to add \p event_class. |
571 | @param[in] event_class Event class to add to \p stream_class. | |
572 | @returns 0 on success, or a negative value on error. | |
573 | ||
574 | @prenotnull{stream_class} | |
575 | @prenotnull{event_class} | |
576 | @prehot{event_class} | |
577 | @postrefcountsame{stream_class} | |
578 | @postsuccessrefcountinc{event_class} | |
2fc61597 | 579 | @postsuccessfrozen{event_class} |
594a3fb7 PP |
580 | */ |
581 | extern int bt_ctf_stream_class_add_event_class( | |
582 | struct bt_ctf_stream_class *stream_class, | |
583 | struct bt_ctf_event_class *event_class); | |
584 | ||
585 | /** @} */ | |
586 | ||
587 | /** | |
588 | @name Misc. function | |
589 | @{ | |
590 | */ | |
591 | ||
592 | /** | |
593 | @brief Accepts the visitor \p visitor to visit the hierarchy of the | |
594 | CTF IR stream class \p stream_class. | |
595 | ||
596 | This function traverses the hierarchy of \p stream_class in pre-order | |
597 | and calls \p visitor on each element. | |
598 | ||
599 | The stream class itself is visited first, and then all its children | |
600 | event classes. | |
601 | ||
602 | @param[in] stream_class Stream class to visit. | |
603 | @param[in] visitor Visiting function. | |
604 | @param[in] data User data. | |
605 | @returns 0 on success, or a negative value on error. | |
606 | ||
607 | @prenotnull{stream_class} | |
608 | @prenotnull{visitor} | |
609 | */ | |
8bf65fbd | 610 | extern int bt_ctf_stream_class_visit(struct bt_ctf_stream_class *stream_class, |
d9a13d86 | 611 | bt_ctf_visitor visitor, void *data); |
8bf65fbd | 612 | |
594a3fb7 PP |
613 | /** @} */ |
614 | ||
615 | /** @} */ | |
616 | ||
adc315b8 JG |
617 | #ifdef __cplusplus |
618 | } | |
619 | #endif | |
620 | ||
621 | #endif /* BABELTRACE_CTF_IR_STREAM_CLASS_H */ |