Commit | Line | Data |
---|---|---|
272df73e PP |
1 | #ifndef BABELTRACE_CTF_IR_EVENT_CLASS_H |
2 | #define BABELTRACE_CTF_IR_EVENT_CLASS_H | |
3 | ||
4 | /* | |
5 | * BabelTrace - CTF IR: Event class | |
6 | * | |
7 | * Copyright 2013, 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 | ||
33 | #include <stdint.h> | |
34 | #include <stddef.h> | |
272df73e PP |
35 | |
36 | #ifdef __cplusplus | |
37 | extern "C" { | |
38 | #endif | |
39 | ||
9d408fca PP |
40 | struct bt_value; |
41 | ||
d5a28207 PP |
42 | /** |
43 | @defgroup ctfireventclass CTF IR event class | |
44 | @ingroup ctfir | |
45 | @brief CTF IR event class. | |
46 | ||
6dd2bd0c PP |
47 | @code |
48 | #include <babeltrace/ctf-ir/event-class.h> | |
49 | @endcode | |
50 | ||
d5a28207 PP |
51 | A CTF IR <strong><em>event class</em></strong> is a template that you |
52 | can use to create concrete \link ctfirevent CTF IR events\endlink. | |
53 | ||
cf76ce92 | 54 | An event class has the following properties: |
d5a28207 PP |
55 | |
56 | - A \b name. | |
cf76ce92 PP |
57 | - A numeric \b ID (\em must be unique amongst all the event classes |
58 | contained in the same | |
59 | \link ctfirstreamclass CTF IR stream class\endlink). | |
60 | - A optional <strong>log level</strong>. | |
61 | - An optional <strong>Eclipse Modeling Framework URI</strong>. | |
d5a28207 PP |
62 | |
63 | A CTF IR event class owns two | |
64 | \link ctfirfieldtypes field types\endlink: | |
65 | ||
66 | - An optional <strong>event context</strong> field type, which | |
67 | represents the \c event.context CTF scope. | |
68 | - A mandatory <strong>event payload</strong> field type, which | |
69 | represents the \c event.fields CTF scope. | |
70 | ||
71 | Both field types \em must be structure field types as of | |
72 | Babeltrace \btversion. | |
73 | The event payload field type <em>must not</em> be empty. | |
74 | ||
75 | As a reminder, here's the structure of a CTF packet: | |
76 | ||
77 | @imgpacketstructure | |
78 | ||
79 | In the Babeltrace CTF IR system, a \link ctfirtraceclass trace | |
80 | class\endlink contains zero or more \link ctfirstreamclass stream | |
81 | classes\endlink, and a stream class contains zero or more event classes. | |
82 | ||
83 | Before you can create an event from an event class with | |
50842bdc PP |
84 | bt_event_create(), you \em must add the prepared event class to a |
85 | stream class by calling bt_stream_class_add_event_class(). This | |
d5a28207 PP |
86 | function, when successful, \em freezes the event class, disallowing any |
87 | future modification of its properties and field types by the user. | |
88 | ||
89 | As with any Babeltrace object, CTF IR event class objects have | |
90 | <a href="https://en.wikipedia.org/wiki/Reference_counting">reference | |
91 | counts</a>. See \ref refs to learn more about the reference counting | |
92 | management of Babeltrace objects. | |
93 | ||
50842bdc | 94 | bt_stream_class_add_event_class() \em freezes its event class |
d5a28207 PP |
95 | parameter on success. You cannot modify a frozen event class: it is |
96 | considered immutable, except for \link refs reference counting\endlink. | |
97 | ||
98 | @sa ctfirevent | |
99 | @sa ctfirstreamclass | |
100 | ||
101 | @file | |
102 | @brief CTF IR event class type and functions. | |
103 | @sa ctfireventclass | |
104 | ||
105 | @addtogroup ctfireventclass | |
106 | @{ | |
107 | */ | |
108 | ||
109 | /** | |
50842bdc | 110 | @struct bt_event_class |
d5a28207 PP |
111 | @brief A CTF IR event class. |
112 | @sa ctfireventclass | |
113 | */ | |
50842bdc PP |
114 | struct bt_event_class; |
115 | struct bt_field; | |
116 | struct bt_field_type; | |
117 | struct bt_stream_class; | |
272df73e | 118 | |
cf76ce92 PP |
119 | /** |
120 | @brief Log level of an event class. | |
121 | */ | |
50842bdc | 122 | enum bt_event_class_log_level { |
cf76ce92 | 123 | /// Unknown, used for errors. |
50842bdc | 124 | BT_EVENT_CLASS_LOG_LEVEL_UNKNOWN = -1, |
cf76ce92 PP |
125 | |
126 | /// Unspecified log level. | |
50842bdc | 127 | BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED = 255, |
cf76ce92 PP |
128 | |
129 | /// System is unusable. | |
50842bdc | 130 | BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY = 0, |
cf76ce92 PP |
131 | |
132 | /// Action must be taken immediately. | |
50842bdc | 133 | BT_EVENT_CLASS_LOG_LEVEL_ALERT = 1, |
cf76ce92 PP |
134 | |
135 | /// Critical conditions. | |
50842bdc | 136 | BT_EVENT_CLASS_LOG_LEVEL_CRITICAL = 2, |
cf76ce92 PP |
137 | |
138 | /// Error conditions. | |
50842bdc | 139 | BT_EVENT_CLASS_LOG_LEVEL_ERROR = 3, |
cf76ce92 PP |
140 | |
141 | /// Warning conditions. | |
50842bdc | 142 | BT_EVENT_CLASS_LOG_LEVEL_WARNING = 4, |
cf76ce92 PP |
143 | |
144 | /// Normal, but significant, condition. | |
50842bdc | 145 | BT_EVENT_CLASS_LOG_LEVEL_NOTICE = 5, |
cf76ce92 PP |
146 | |
147 | /// Informational message. | |
50842bdc | 148 | BT_EVENT_CLASS_LOG_LEVEL_INFO = 6, |
cf76ce92 PP |
149 | |
150 | /// Debug information with system-level scope (set of programs). | |
50842bdc | 151 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM = 7, |
cf76ce92 PP |
152 | |
153 | /// Debug information with program-level scope (set of processes). | |
50842bdc | 154 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM = 8, |
cf76ce92 PP |
155 | |
156 | /// Debug information with process-level scope (set of modules). | |
50842bdc | 157 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS = 9, |
cf76ce92 PP |
158 | |
159 | /// Debug information with module (executable/library) scope (set of units). | |
50842bdc | 160 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE = 10, |
cf76ce92 PP |
161 | |
162 | /// Debug information with compilation unit scope (set of functions). | |
50842bdc | 163 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT = 11, |
cf76ce92 PP |
164 | |
165 | /// Debug information with function-level scope. | |
50842bdc | 166 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION = 12, |
cf76ce92 PP |
167 | |
168 | /// Debug information with line-level scope (default log level). | |
50842bdc | 169 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE = 13, |
cf76ce92 PP |
170 | |
171 | /// Debug-level message. | |
50842bdc | 172 | BT_EVENT_CLASS_LOG_LEVEL_DEBUG = 14, |
cf76ce92 PP |
173 | }; |
174 | ||
d5a28207 PP |
175 | /** |
176 | @name Creation and parent access functions | |
177 | @{ | |
178 | */ | |
179 | ||
180 | /** | |
181 | @brief Creates a default CTF IR event class named \p name. | |
182 | ||
53a1cae7 PP |
183 | On success, the context and payload field types are empty structure |
184 | field types. You can modify those default field types after the | |
185 | event class is created with | |
50842bdc PP |
186 | bt_event_class_set_context_type() and |
187 | bt_event_class_set_payload_type(). | |
d5a28207 PP |
188 | |
189 | Upon creation, the event class's ID is <em>not set</em>. You | |
50842bdc PP |
190 | can set it to a specific value with bt_event_class_set_id(). If it |
191 | is still unset when you call bt_stream_class_add_event_class(), then | |
d5a28207 PP |
192 | the stream class assigns a unique ID to this event class before |
193 | freezing it. | |
194 | ||
cf76ce92 | 195 | The created event class's log level is initially set to |
50842bdc | 196 | #BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED and it has no Eclipse Modeling |
cf76ce92 PP |
197 | Framework URI. |
198 | ||
d5a28207 PP |
199 | @param[in] name Name of the event class to create (copied on success). |
200 | @returns Created event class, or \c NULL on error. | |
201 | ||
202 | @prenotnull{name} | |
203 | @postsuccessrefcountret1 | |
204 | */ | |
50842bdc | 205 | extern struct bt_event_class *bt_event_class_create(const char *name); |
272df73e | 206 | |
d5a28207 PP |
207 | /** |
208 | @brief Returns the parent CTF IR stream class of the CTF IR event | |
209 | class \p event_class. | |
210 | ||
211 | It is possible that the event class was not added to a stream class | |
212 | yet, in which case this function returns \c NULL. You can add an | |
213 | event class to a stream class with | |
50842bdc | 214 | bt_stream_class_add_event_class(). |
d5a28207 PP |
215 | |
216 | @param[in] event_class Event class of which to get the parent | |
217 | stream class. | |
218 | @returns Parent stream class of \p event_class, | |
219 | or \c NULL if \p event_class was not | |
220 | added to a stream class yet or on error. | |
221 | ||
222 | @prenotnull{event_class} | |
c2f29fb9 | 223 | @postrefcountsame{event_class} |
d5a28207 PP |
224 | @postsuccessrefcountretinc |
225 | ||
50842bdc | 226 | @sa bt_stream_class_add_event_class(): Add an event class to |
d5a28207 PP |
227 | a stream class. |
228 | */ | |
50842bdc PP |
229 | extern struct bt_stream_class *bt_event_class_get_stream_class( |
230 | struct bt_event_class *event_class); | |
d5a28207 PP |
231 | |
232 | /** @} */ | |
233 | ||
234 | /** | |
235 | @name Attribute functions | |
236 | @{ | |
237 | */ | |
238 | ||
239 | /** | |
240 | @brief Returns the name of the CTF IR event class \p event_class. | |
241 | ||
242 | On success, \p event_class remains the sole owner of the returned | |
243 | string. | |
244 | ||
245 | @param[in] event_class Event class of which to get the name. | |
246 | @returns Name of event class \p event_class, or | |
247 | \c NULL on error. | |
248 | ||
249 | @prenotnull{event_class} | |
250 | @postrefcountsame{event_class} | |
251 | */ | |
50842bdc PP |
252 | extern const char *bt_event_class_get_name( |
253 | struct bt_event_class *event_class); | |
272df73e | 254 | |
d5a28207 PP |
255 | /** |
256 | @brief Returns the numeric ID of the CTF IR event class \p event_class. | |
257 | ||
258 | @param[in] event_class Event class of which to get the numeric ID. | |
259 | @returns ID of event class \p event_class, or a | |
260 | negative value on error. | |
261 | ||
262 | @prenotnull{event_class} | |
263 | @postrefcountsame{event_class} | |
264 | ||
50842bdc | 265 | @sa bt_event_class_set_id(): Sets the numeric ID of a given |
d5a28207 PP |
266 | event class. |
267 | */ | |
50842bdc PP |
268 | extern int64_t bt_event_class_get_id( |
269 | struct bt_event_class *event_class); | |
272df73e | 270 | |
d5a28207 PP |
271 | /** |
272 | @brief Sets the numeric ID of the CTF IR event class | |
273 | \p event_class to \p id. | |
274 | ||
275 | \p id must be unique amongst the IDs of all the event classes | |
276 | of the stream class to which you eventually add \p event_class. | |
277 | ||
278 | @param[in] event_class Event class of which to set the numeric ID. | |
279 | @param[in] id ID of the event class. | |
280 | @returns 0 on success, or a negative value on error. | |
281 | ||
282 | @prenotnull{event_class} | |
283 | @prehot{event_class} | |
9ac68eb1 | 284 | @pre \p id is lesser than or equal to 9223372036854775807 (\c INT64_MAX). |
d5a28207 PP |
285 | @postrefcountsame{event_class} |
286 | ||
50842bdc | 287 | @sa bt_event_class_get_id(): Returns the numeric ID of a given |
d5a28207 PP |
288 | event class. |
289 | */ | |
50842bdc PP |
290 | extern int bt_event_class_set_id( |
291 | struct bt_event_class *event_class, uint64_t id); | |
272df73e | 292 | |
d5a28207 | 293 | /** |
cf76ce92 | 294 | @brief Returns the log level of the CTF IR event class \p event_class. |
272df73e | 295 | |
cf76ce92 PP |
296 | @param[in] event_class Event class of which to get the log level. |
297 | @returns Log level of event class \p event_class, | |
50842bdc | 298 | #BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED if |
cf76ce92 | 299 | not specified, or |
50842bdc | 300 | #BT_EVENT_CLASS_LOG_LEVEL_UNKNOWN on error. |
d5a28207 PP |
301 | |
302 | @prenotnull{event_class} | |
303 | @postrefcountsame{event_class} | |
304 | ||
50842bdc | 305 | @sa bt_event_class_set_log_level(): Sets the log level of a given |
cf76ce92 | 306 | event class. |
d5a28207 | 307 | */ |
50842bdc PP |
308 | extern enum bt_event_class_log_level bt_event_class_get_log_level( |
309 | struct bt_event_class *event_class); | |
272df73e | 310 | |
d5a28207 | 311 | /** |
cf76ce92 PP |
312 | @brief Sets the log level of the CTF IR event class |
313 | \p event_class to \p log_level. | |
d5a28207 | 314 | |
cf76ce92 PP |
315 | @param[in] event_class Event class of which to set the log level. |
316 | @param[in] log_level Log level of the event class. | |
317 | @returns 0 on success, or a negative value on error. | |
d5a28207 PP |
318 | |
319 | @prenotnull{event_class} | |
cf76ce92 | 320 | @prehot{event_class} |
50842bdc PP |
321 | @pre \p log_level is #BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED, |
322 | #BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY, | |
323 | #BT_EVENT_CLASS_LOG_LEVEL_ALERT, | |
324 | #BT_EVENT_CLASS_LOG_LEVEL_CRITICAL, | |
325 | #BT_EVENT_CLASS_LOG_LEVEL_ERROR, | |
326 | #BT_EVENT_CLASS_LOG_LEVEL_WARNING, | |
327 | #BT_EVENT_CLASS_LOG_LEVEL_NOTICE, | |
328 | #BT_EVENT_CLASS_LOG_LEVEL_INFO, | |
329 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM, | |
330 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM, | |
331 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS, | |
332 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE, | |
333 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT, | |
334 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION, | |
335 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE, or | |
336 | #BT_EVENT_CLASS_LOG_LEVEL_DEBUG. | |
d5a28207 PP |
337 | @postrefcountsame{event_class} |
338 | ||
50842bdc | 339 | @sa bt_event_class_get_log_level(): Returns the log level of a given |
cf76ce92 | 340 | event class. |
d5a28207 | 341 | */ |
50842bdc PP |
342 | extern int bt_event_class_set_log_level( |
343 | struct bt_event_class *event_class, | |
344 | enum bt_event_class_log_level log_level); | |
272df73e | 345 | |
d5a28207 | 346 | /** |
cf76ce92 PP |
347 | @brief Returns the Eclipse Modeling Framework URI of the CTF IR event |
348 | class \p event_class. | |
d5a28207 | 349 | |
cf76ce92 PP |
350 | @param[in] event_class Event class of which to get the |
351 | Eclipse Modeling Framework URI. | |
352 | @returns Eclipse Modeling Framework URI of event | |
353 | class \p event_class, or \c NULL on error. | |
d5a28207 PP |
354 | |
355 | @prenotnull{event_class} | |
d5a28207 PP |
356 | @postrefcountsame{event_class} |
357 | ||
50842bdc | 358 | @sa bt_event_class_set_emf_uri(): Sets the Eclipse Modeling |
cf76ce92 | 359 | Framework URI of a given event class. |
d5a28207 | 360 | */ |
50842bdc PP |
361 | extern const char *bt_event_class_get_emf_uri( |
362 | struct bt_event_class *event_class); | |
272df73e | 363 | |
d5a28207 | 364 | /** |
cf76ce92 PP |
365 | @brief Sets the Eclipse Modeling Framework URI of the CTF IR event class |
366 | \p event_class to \p emf_uri, or unsets the event class's EMF URI. | |
d5a28207 | 367 | |
cf76ce92 PP |
368 | @param[in] event_class Event class of which to set the |
369 | Eclipse Modeling Framework URI. | |
370 | @param[in] emf_uri Eclipse Modeling Framework URI of the | |
371 | event class (copied on success), or \c NULL | |
372 | to unset the current EMF URI. | |
373 | @returns 0 on success, or a negative value if there's | |
374 | no EMF URI or on error. | |
d5a28207 PP |
375 | |
376 | @prenotnull{event_class} | |
cf76ce92 | 377 | @prenotnull{emf_uri} |
d5a28207 PP |
378 | @prehot{event_class} |
379 | @postrefcountsame{event_class} | |
d5a28207 | 380 | |
50842bdc | 381 | @sa bt_event_class_get_emf_uri(): Returns the Eclipse Modeling |
cf76ce92 | 382 | Framework URI of a given event class. |
d5a28207 | 383 | */ |
50842bdc PP |
384 | extern int bt_event_class_set_emf_uri( |
385 | struct bt_event_class *event_class, | |
cf76ce92 | 386 | const char *emf_uri); |
d5a28207 PP |
387 | |
388 | /** @} */ | |
389 | ||
390 | /** | |
391 | @name Contained field types functions | |
392 | @{ | |
393 | */ | |
394 | ||
29620c97 PP |
395 | /** |
396 | @brief Returns the context field type of the CTF IR event class | |
397 | \p event_class. | |
398 | ||
6b783f49 JG |
399 | @param[in] event_class Event class of which to get the context field type. |
400 | @returns Context field type of \p event_class, or \c NULL if | |
401 | \p event_class has no context field type or on error. | |
29620c97 PP |
402 | |
403 | @prenotnull{event_class} | |
c2f29fb9 | 404 | @postrefcountsame{event_class} |
6b783f49 JG |
405 | @post <strong>On success, if the return value is a field type</strong>, its |
406 | reference count is incremented. | |
29620c97 | 407 | |
50842bdc | 408 | @sa bt_event_class_set_context_type(): Sets the context field type of a |
6b783f49 | 409 | given event class. |
29620c97 | 410 | */ |
50842bdc PP |
411 | extern struct bt_field_type *bt_event_class_get_context_type( |
412 | struct bt_event_class *event_class); | |
29620c97 PP |
413 | |
414 | /** | |
6b783f49 JG |
415 | @brief Sets the context field type of the CTF IR event class \p event_class to |
416 | \p context_type, or unsets the current context field type from | |
417 | \p event_class. | |
29620c97 | 418 | |
6b783f49 JG |
419 | If \p context_type is \c NULL, then this function unsets the current context |
420 | field type from \p event_class, effectively making \p event_class an event class | |
421 | without a context field type. | |
29620c97 | 422 | |
6b783f49 JG |
423 | As of Babeltrace \btversion, if \p context_type is not \c NULL, |
424 | \p context_type \em must be a CTF IR structure field type object. | |
425 | ||
426 | @param[in] event_class Event class of which to set the context field | |
427 | type. | |
428 | @param[in] context_type Context field type, or \c NULL to unset the | |
429 | current context field type. | |
430 | @returns 0 on success, or a negative value on error. | |
29620c97 PP |
431 | |
432 | @prenotnull{event_class} | |
29620c97 | 433 | @prehot{event_class} |
6b783f49 JG |
434 | @pre <strong>If \p context_type is not \c NULL</strong>, \p context_type is a |
435 | CTF IR structure field type. | |
29620c97 | 436 | @postrefcountsame{event_class} |
6b783f49 JG |
437 | @post <strong>On success, if \p context_type is not \c NULL</strong>, |
438 | the reference count of \p context_type is incremented. | |
29620c97 | 439 | |
50842bdc | 440 | @sa bt_event_class_get_context_type(): Returns the context field type of a |
6b783f49 | 441 | given event class. |
29620c97 | 442 | */ |
50842bdc PP |
443 | extern int bt_event_class_set_context_type( |
444 | struct bt_event_class *event_class, | |
445 | struct bt_field_type *context_type); | |
29620c97 | 446 | |
d5a28207 PP |
447 | /** |
448 | @brief Returns the payload field type of the CTF IR event class | |
449 | \p event_class. | |
450 | ||
6b783f49 JG |
451 | @param[in] event_class Event class of which to get the payload field type. |
452 | @returns Payload field type of \p event_class, or \c NULL if | |
453 | \p event_class has no payload field type or on error. | |
d5a28207 PP |
454 | |
455 | @prenotnull{event_class} | |
c2f29fb9 | 456 | @postrefcountsame{event_class} |
6b783f49 JG |
457 | @post <strong>On success, if the return value is a field type</strong>, its |
458 | reference count is incremented. | |
d5a28207 | 459 | |
50842bdc | 460 | @sa bt_event_class_set_payload_type(): Sets the payload field type of a |
6b783f49 | 461 | given event class. |
d5a28207 | 462 | */ |
50842bdc PP |
463 | extern struct bt_field_type *bt_event_class_get_payload_type( |
464 | struct bt_event_class *event_class); | |
272df73e | 465 | |
d5a28207 | 466 | /** |
6b783f49 JG |
467 | @brief Sets the payload field type of the CTF IR event class \p event_class to |
468 | \p payload_type, or unsets the current payload field type from | |
469 | \p event_class. | |
d5a28207 | 470 | |
6b783f49 JG |
471 | If \p payload_type is \c NULL, then this function unsets the current payload |
472 | field type from \p event_class, effectively making \p event_class an event class | |
473 | without a payload field type. | |
d5a28207 | 474 | |
6b783f49 JG |
475 | As of Babeltrace \btversion, if \p payload_type is not \c NULL, |
476 | \p payload_type \em must be a CTF IR structure field type object. | |
477 | ||
478 | @param[in] event_class Event class of which to set the payload field | |
479 | type. | |
480 | @param[in] payload_type Payload field type, or \c NULL to unset the | |
481 | current payload field type. | |
482 | @returns 0 on success, or a negative value on error. | |
d5a28207 PP |
483 | |
484 | @prenotnull{event_class} | |
d5a28207 | 485 | @prehot{event_class} |
6b783f49 JG |
486 | @pre <strong>If \p payload_type is not \c NULL</strong>, \p payload_type is a |
487 | CTF IR structure field type. | |
d5a28207 | 488 | @postrefcountsame{event_class} |
6b783f49 JG |
489 | @post <strong>On success, if \p payload_type is not \c NULL</strong>, |
490 | the reference count of \p payload_type is incremented. | |
d5a28207 | 491 | |
50842bdc | 492 | @sa bt_event_class_get_payload_type(): Returns the payload field type of a |
6b783f49 | 493 | given event class. |
d5a28207 | 494 | */ |
50842bdc PP |
495 | extern int bt_event_class_set_payload_type( |
496 | struct bt_event_class *event_class, | |
497 | struct bt_field_type *payload_type); | |
272df73e | 498 | |
d5a28207 PP |
499 | /** |
500 | @brief Returns the number of fields contained in the | |
501 | payload field type of the CTF IR event class \p event_class. | |
272df73e | 502 | |
d5a28207 PP |
503 | @remarks |
504 | Calling this function is the equivalent of getting the payload field | |
50842bdc | 505 | type of \p event_class with bt_event_class_get_payload_type() and |
d5a28207 | 506 | getting its field count with |
50842bdc | 507 | bt_field_type_structure_get_field_count(). |
d5a28207 PP |
508 | |
509 | @param[in] event_class Event class of which to get the number | |
510 | of fields contained in its payload field type. | |
511 | @returns Number of fields in the payload field type | |
512 | of \p event_class, or a negative value on error. | |
513 | ||
514 | @prenotnull{event_class} | |
515 | @postrefcountsame{event_class} | |
516 | */ | |
50842bdc PP |
517 | extern int64_t bt_event_class_get_payload_type_field_count( |
518 | struct bt_event_class *event_class); | |
272df73e | 519 | |
d5a28207 PP |
520 | /** |
521 | @brief Returns the type and the name of the field at index \p index | |
522 | in the payload field type of the CTF IR event class | |
523 | \p event_class. | |
524 | ||
525 | On success, the field's type is placed in \p *field_type if | |
526 | \p field_type is not \c NULL. The field's name is placed in | |
527 | \p *name if \p name is not \c NULL. \p event_class remains the sole | |
528 | owner of \p *name. | |
529 | ||
530 | Both \p name and \p field_type can be \c NULL if the caller is not | |
531 | interested in one of them. | |
532 | ||
533 | @remarks | |
534 | Calling this function is the equivalent of getting the payload field | |
50842bdc | 535 | type of \p event_class with bt_event_class_get_payload_type() and |
d5a28207 | 536 | getting the type and name of one of its field with |
50842bdc | 537 | bt_field_type_structure_get_field(). |
d5a28207 PP |
538 | |
539 | @param[in] event_class Event class of which to get the type and name | |
540 | of a field in its payload field type. | |
541 | @param[out] field_name Name of the field at the index | |
542 | \p index in the payload field type of | |
543 | \p event_class (can be \c NULL). | |
544 | @param[out] field_type Type of the field at the index \p index in the | |
545 | payload field type of \p event_class | |
546 | (can be \c NULL). | |
547 | @param[in] index Index of the payload field type's field to find. | |
548 | @returns 0 on success, or a negative value on error. | |
549 | ||
550 | @prenotnull{event_class} | |
551 | @pre \p index is lesser than the number of fields contained in the | |
552 | payload field type of \p event_class (see | |
50842bdc | 553 | bt_event_class_get_payload_type_field_count()). |
d5a28207 PP |
554 | @postrefcountsame{event_class} |
555 | @post <strong>On success, if \p field_type is not \c NULL</strong>, the | |
556 | reference count of \p *field_type is incremented. | |
557 | */ | |
50842bdc PP |
558 | extern int bt_event_class_get_payload_type_field_by_index( |
559 | struct bt_event_class *event_class, | |
560 | const char **field_name, struct bt_field_type **field_type, | |
9ac68eb1 | 561 | uint64_t index); |
272df73e | 562 | |
d5a28207 PP |
563 | /** |
564 | @brief Returns the type of the field named \p name in the payload | |
565 | field type of the CTF IR event class \p event_class. | |
566 | ||
567 | @remarks | |
568 | Calling this function is the equivalent of getting the payload field | |
50842bdc | 569 | type of \p event_class with bt_event_class_get_payload_type() and |
d5a28207 | 570 | getting the type of one of its field with |
50842bdc | 571 | bt_field_type_structure_get_field_type_by_name(). |
d5a28207 PP |
572 | |
573 | @param[in] event_class Event class of which to get the type of a | |
574 | payload field type's field. | |
575 | @param[in] name Name of the payload field type's field to get. | |
576 | @returns Type of the field named \p name in the payload | |
577 | field type of \p event_class, or \c NULL if | |
578 | the function cannot find the field or | |
579 | on error. | |
580 | ||
581 | @prenotnull{event_class} | |
582 | @prenotnull{name} | |
583 | @postrefcountsame{event_class} | |
584 | @postsuccessrefcountretinc | |
d5a28207 | 585 | */ |
50842bdc PP |
586 | extern struct bt_field_type * |
587 | bt_event_class_get_payload_type_field_type_by_name( | |
588 | struct bt_event_class *event_class, const char *name); | |
9ac68eb1 | 589 | |
d5a28207 PP |
590 | /** |
591 | @brief Adds a field named \p name with the type \p field_type to the | |
592 | payload field type of the CTF IR event class \p event_class. | |
593 | ||
594 | @remarks | |
595 | Calling this function is the equivalent of getting the payload field | |
50842bdc PP |
596 | type of \p event_class with bt_event_class_get_payload_type() and |
597 | adding a field to it with bt_field_type_structure_add_field(). | |
d5a28207 PP |
598 | |
599 | @param[in] event_class Event class containing the payload field | |
600 | type in which to add a field. | |
601 | @param[in] field_type Type of the field to add. | |
602 | @param[in] name Name of the field to add (copied on | |
603 | success). | |
604 | @returns 0 on success, or a negative value on error. | |
605 | ||
606 | @prenotnull{event_class} | |
607 | @prenotnull{type} | |
608 | @prenotnull{name} | |
609 | @prehot{event_class} | |
610 | @postrefcountsame{event_class} | |
611 | @postsuccessrefcountinc{field_type} | |
612 | */ | |
50842bdc PP |
613 | extern int bt_event_class_add_field(struct bt_event_class *event_class, |
614 | struct bt_field_type *field_type, | |
d5a28207 PP |
615 | const char *name); |
616 | ||
d5a28207 PP |
617 | /** @} */ |
618 | ||
619 | /** @} */ | |
272df73e | 620 | |
50842bdc PP |
621 | /* Pre-2.0 CTF writer compatibility */ |
622 | #define bt_ctf_event_class bt_event_class | |
623 | #define bt_ctf_event_class_create bt_event_class_create | |
624 | #define bt_ctf_event_class_get_field_by_name bt_event_class_get_payload_type_field_type_by_name | |
625 | #define bt_ctf_event_class_add_field bt_event_class_add_field | |
626 | ||
272df73e PP |
627 | #ifdef __cplusplus |
628 | } | |
629 | #endif | |
630 | ||
631 | #endif /* BABELTRACE_CTF_IR_EVENT_CLASS_H */ |