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