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