f446cc2cfd862291e1ea20c9da71f3344f80f22c
1 #ifndef BABELTRACE_CTF_IR_EVENT_CLASS_H
2 #define BABELTRACE_CTF_IR_EVENT_CLASS_H
5 * BabelTrace - CTF IR: Event class
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
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
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
35 #include <babeltrace/values.h>
42 @defgroup ctfireventclass CTF IR event class
44 @brief CTF IR event class.
47 #include <babeltrace/ctf-ir/event-class.h>
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.
53 An event class has the following properties, both of which \em must
54 be unique amongst all the event classes contained in the same
55 \link ctfirstreamclass CTF IR stream class\endlink:
60 A CTF IR event class owns two
61 \link ctfirfieldtypes field types\endlink:
63 - An optional <strong>event context</strong> field type, which
64 represents the \c event.context CTF scope.
65 - A mandatory <strong>event payload</strong> field type, which
66 represents the \c event.fields CTF scope.
68 Both field types \em must be structure field types as of
69 Babeltrace \btversion.
70 The event payload field type <em>must not</em> be empty.
72 As a reminder, here's the structure of a CTF packet:
76 In the Babeltrace CTF IR system, a \link ctfirtraceclass trace
77 class\endlink contains zero or more \link ctfirstreamclass stream
78 classes\endlink, and a stream class contains zero or more event classes.
80 Before you can create an event from an event class with
81 bt_ctf_event_create(), you \em must add the prepared event class to a
82 stream class by calling bt_ctf_stream_class_add_event_class(). This
83 function, when successful, \em freezes the event class, disallowing any
84 future modification of its properties and field types by the user.
86 As with any Babeltrace object, CTF IR event class objects have
87 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
88 counts</a>. See \ref refs to learn more about the reference counting
89 management of Babeltrace objects.
91 bt_ctf_stream_class_add_event_class() \em freezes its event class
92 parameter on success. You cannot modify a frozen event class: it is
93 considered immutable, except for \link refs reference counting\endlink.
99 @brief CTF IR event class type and functions.
102 @addtogroup ctfireventclass
107 @struct bt_ctf_event_class
108 @brief A CTF IR event class.
111 struct bt_ctf_event_class
;
113 struct bt_ctf_field_type
;
114 struct bt_ctf_stream_class
;
117 @name Creation and parent access functions
122 @brief Creates a default CTF IR event class named \p name.
124 The event class is created \em without an event context
125 \link ctfirfieldtypes field type\endlink and with an empty event
128 Upon creation, the event class's ID is <em>not set</em>. You
129 can set it to a specific value with bt_ctf_event_class_set_id(). If it
130 is still unset when you call bt_ctf_stream_class_add_event_class(), then
131 the stream class assigns a unique ID to this event class before
134 @param[in] name Name of the event class to create (copied on success).
135 @returns Created event class, or \c NULL on error.
138 @postsuccessrefcountret1
140 extern struct bt_ctf_event_class
*bt_ctf_event_class_create(const char *name
);
143 @brief Returns the parent CTF IR stream class of the CTF IR event
144 class \p event_class.
146 It is possible that the event class was not added to a stream class
147 yet, in which case this function returns \c NULL. You can add an
148 event class to a stream class with
149 bt_ctf_stream_class_add_event_class().
151 @param[in] event_class Event class of which to get the parent
153 @returns Parent stream class of \p event_class,
154 or \c NULL if \p event_class was not
155 added to a stream class yet or on error.
157 @prenotnull{event_class}
158 @postsuccessrefcountretinc
160 @sa bt_ctf_stream_class_add_event_class(): Add an event class to
163 extern struct bt_ctf_stream_class
*bt_ctf_event_class_get_stream_class(
164 struct bt_ctf_event_class
*event_class
);
169 @name Attribute functions
174 @brief Returns the name of the CTF IR event class \p event_class.
176 On success, \p event_class remains the sole owner of the returned
179 @param[in] event_class Event class of which to get the name.
180 @returns Name of event class \p event_class, or
183 @prenotnull{event_class}
184 @postrefcountsame{event_class}
186 extern const char *bt_ctf_event_class_get_name(
187 struct bt_ctf_event_class
*event_class
);
190 @brief Returns the numeric ID of the CTF IR event class \p event_class.
192 @param[in] event_class Event class of which to get the numeric ID.
193 @returns ID of event class \p event_class, or a
194 negative value on error.
196 @prenotnull{event_class}
197 @postrefcountsame{event_class}
199 @sa bt_ctf_event_class_set_id(): Sets the numeric ID of a given
202 extern int64_t bt_ctf_event_class_get_id(
203 struct bt_ctf_event_class
*event_class
);
206 @brief Sets the numeric ID of the CTF IR event class
207 \p event_class to \p id.
209 \p id must be unique amongst the IDs of all the event classes
210 of the stream class to which you eventually add \p event_class.
212 @param[in] event_class Event class of which to set the numeric ID.
213 @param[in] id ID of the event class.
214 @returns 0 on success, or a negative value on error.
216 @prenotnull{event_class}
218 @postrefcountsame{event_class}
220 @sa bt_ctf_event_class_get_id(): Returns the numeric ID of a given
223 extern int bt_ctf_event_class_set_id(
224 struct bt_ctf_event_class
*event_class
, uint32_t id
);
227 @brief Returns the number of attributes contained in the CTF IR event
228 class \p event_class.
230 @param[in] event_class Event class of which to get the number
231 of contained attributes.
232 @returns Number of contained attributes in
233 \p event_class, or a negative value on error.
235 @prenotnull{event_class}
236 @postrefcountsame{event_class}
238 @sa bt_ctf_event_class_get_attribute_name(): Returns the name of
239 the attribute of a given event class at a given index.
240 @sa bt_ctf_event_class_get_attribute_value(): Returns the value of
241 the attribute of a given event class at a given index.
243 extern int bt_ctf_event_class_get_attribute_count(
244 struct bt_ctf_event_class
*event_class
);
247 @brief Returns the name of the attribute at the index \p index of the
248 CTF IR event class \p event_class.
250 On success, \p event_class remains the sole owner of the returned
253 @param[in] event_class Event class of which to get the name
255 @param[in] index Index of the attribute of which to get the name.
256 @returns Attribute name, or \c NULL on error.
258 @prenotnull{event_class}
259 @pre \p index is lesser than the number of attributes contained by
261 @postrefcountsame{event_class}
263 @sa bt_ctf_event_class_get_attribute_value(): Returns the value of
264 the attribute of a given event class at a given index.
267 bt_ctf_event_class_get_attribute_name(
268 struct bt_ctf_event_class
*event_class
, int index
);
271 @brief Returns the value of the attribute at the index \p index of the
272 CTF IR event class \p event_class.
274 @param[in] event_class Event class of which to get the value
276 @param[in] index Index of the attribute of which to get the value.
277 @returns Attribute value, or \c NULL on error.
279 @prenotnull{event_class}
280 @pre \p index is lesser than the number of attributes contained by
282 @postsuccessrefcountretinc
283 @postrefcountsame{event_class}
285 @sa bt_ctf_event_class_get_attribute_name(): Returns the name of
286 the attribute of a given event class at a given index.
288 extern struct bt_value
*
289 bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class
*event_class
,
293 @brief Returns the value of the attribute named \p name of the CTF IR
294 event class \p event_class.
296 On success, the reference count of the returned value object is
299 @param[in] event_class Event class of which to get the value
301 @param[in] name Name of the attribute to get.
302 @returns Attribute value, or \c NULL on error.
304 @prenotnull{event_class}
306 @postsuccessrefcountretinc
307 @postrefcountsame{event_class}
309 extern struct bt_value
*
310 bt_ctf_event_class_get_attribute_value_by_name(
311 struct bt_ctf_event_class
*event_class
, const char *name
);
314 @brief Sets the attribute named \p name of the CTF IR event class
315 \p event_class to the value \p value.
317 Valid attributes, as of Babeltrace \btversion, are:
319 - <code>id</code>: \em must be an integer value object with a raw value
320 that is greater than or equal to 0. This represents the event class's
321 numeric ID and you can also set it with bt_ctf_event_class_set_id().
323 - <code>name</code>: must be a string value object. This represents
324 the name of the event class.
326 - <code>loglevel</code>: must be an integer value object with a raw
327 value greater than or equal to 0. This represents the numeric log level
328 associated with this event class. Log level values
329 are application-specific.
331 - <code>model.emf.uri</code>: must be a string value object. This
332 represents the application-specific Eclipse Modeling Framework URI
335 @param[in] event_class Event class of which to set an
337 @param[in] name Attribute name (copied on success).
338 @param[in] value Attribute value.
339 @returns 0 on success, or a negative value on error.
341 @prenotnull{event_class}
345 @postrefcountsame{event_class}
346 @postsuccessrefcountinc{value}
348 @sa bt_ctf_event_class_get_attribute_value_by_name(): Returns the
349 attribute of a given event class having a given name.
351 extern int bt_ctf_event_class_set_attribute(
352 struct bt_ctf_event_class
*event_class
, const char *name
,
353 struct bt_value
*value
);
358 @name Contained field types functions
363 @brief Returns the context field type of the CTF IR event class
366 @param[in] event_class Event class of which to get the
368 @returns Context field type of \p event_class,
371 @prenotnull{event_class}
372 @postsuccessrefcountretinc
374 @sa bt_ctf_event_class_set_context_type(): Sets the context field
375 type of a given event class.
377 extern struct bt_ctf_field_type
*bt_ctf_event_class_get_context_type(
378 struct bt_ctf_event_class
*event_class
);
381 @brief Sets the context field type of the CTF IR event class
382 \p event_class to \p context_type.
384 As of Babeltrace \btversion, \p context_type \em must be a
385 CTF IR structure field type object.
387 @param[in] event_class Event class of which to set the context
389 @param[in] context_type Context field type.
390 @returns 0 on success, or a negative value on error.
392 @prenotnull{event_class}
393 @prenotnull{context_type}
395 @preisstructft{context_type}
396 @postrefcountsame{event_class}
397 @postsuccessrefcountinc{context_type}
399 @sa bt_ctf_event_class_get_context_type(): Returns the context field
400 type of a given event class.
402 extern int bt_ctf_event_class_set_context_type(
403 struct bt_ctf_event_class
*event_class
,
404 struct bt_ctf_field_type
*context_type
);
407 @brief Returns the payload field type of the CTF IR event class
410 @param[in] event_class Event class of which to get the
412 @returns Payload field type of \p event_class,
415 @prenotnull{event_class}
416 @postsuccessrefcountretinc
418 @sa bt_ctf_event_class_set_payload_type(): Sets the payload field
419 type of a given event class.
421 extern struct bt_ctf_field_type
*bt_ctf_event_class_get_payload_type(
422 struct bt_ctf_event_class
*event_class
);
425 @brief Sets the payload field type of the CTF IR event class
426 \p event_class to \p payload_type.
428 As of Babeltrace \btversion, \p payload_type \em must be a
429 CTF IR structure field type object.
431 @param[in] event_class Event class of which to set the payload
433 @param[in] payload_type Payload field type.
434 @returns 0 on success, or a negative value on error.
436 @prenotnull{event_class}
437 @prenotnull{payload_type}
439 @preisstructft{payload_type}
440 @postrefcountsame{event_class}
441 @postsuccessrefcountinc{payload_type}
443 @sa bt_ctf_event_class_get_payload_type(): Returns the payload field
444 type of a given event class.
446 extern int bt_ctf_event_class_set_payload_type(
447 struct bt_ctf_event_class
*event_class
,
448 struct bt_ctf_field_type
*payload_type
);
451 @brief Returns the number of fields contained in the
452 payload field type of the CTF IR event class \p event_class.
455 Calling this function is the equivalent of getting the payload field
456 type of \p event_class with bt_ctf_event_class_get_payload_type() and
457 getting its field count with
458 bt_ctf_field_type_structure_get_field_count().
460 @param[in] event_class Event class of which to get the number
461 of fields contained in its payload field type.
462 @returns Number of fields in the payload field type
463 of \p event_class, or a negative value on error.
465 @prenotnull{event_class}
466 @postrefcountsame{event_class}
468 extern int bt_ctf_event_class_get_field_count(
469 struct bt_ctf_event_class
*event_class
);
472 @brief Returns the type and the name of the field at index \p index
473 in the payload field type of the CTF IR event class
476 On success, the field's type is placed in \p *field_type if
477 \p field_type is not \c NULL. The field's name is placed in
478 \p *name if \p name is not \c NULL. \p event_class remains the sole
481 Both \p name and \p field_type can be \c NULL if the caller is not
482 interested in one of them.
485 Calling this function is the equivalent of getting the payload field
486 type of \p event_class with bt_ctf_event_class_get_payload_type() and
487 getting the type and name of one of its field with
488 bt_ctf_field_type_structure_get_field().
490 @param[in] event_class Event class of which to get the type and name
491 of a field in its payload field type.
492 @param[out] field_name Name of the field at the index
493 \p index in the payload field type of
494 \p event_class (can be \c NULL).
495 @param[out] field_type Type of the field at the index \p index in the
496 payload field type of \p event_class
498 @param[in] index Index of the payload field type's field to find.
499 @returns 0 on success, or a negative value on error.
501 @prenotnull{event_class}
502 @pre \p index is lesser than the number of fields contained in the
503 payload field type of \p event_class (see
504 bt_ctf_event_class_get_field_count()).
505 @postrefcountsame{event_class}
506 @post <strong>On success, if \p field_type is not \c NULL</strong>, the
507 reference count of \p *field_type is incremented.
509 extern int bt_ctf_event_class_get_field(struct bt_ctf_event_class
*event_class
,
510 const char **field_name
, struct bt_ctf_field_type
**field_type
,
514 @brief Returns the type of the field named \p name in the payload
515 field type of the CTF IR event class \p event_class.
518 Calling this function is the equivalent of getting the payload field
519 type of \p event_class with bt_ctf_event_class_get_payload_type() and
520 getting the type of one of its field with
521 bt_ctf_field_type_structure_get_field_type_by_name().
523 @param[in] event_class Event class of which to get the type of a
524 payload field type's field.
525 @param[in] name Name of the payload field type's field to get.
526 @returns Type of the field named \p name in the payload
527 field type of \p event_class, or \c NULL if
528 the function cannot find the field or
531 @prenotnull{event_class}
533 @postrefcountsame{event_class}
534 @postsuccessrefcountretinc
537 extern struct bt_ctf_field_type
*bt_ctf_event_class_get_field_by_name(
538 struct bt_ctf_event_class
*event_class
, const char *name
);
541 @brief Adds a field named \p name with the type \p field_type to the
542 payload field type of the CTF IR event class \p event_class.
545 Calling this function is the equivalent of getting the payload field
546 type of \p event_class with bt_ctf_event_class_get_payload_type() and
547 adding a field to it with bt_ctf_field_type_structure_add_field().
549 @param[in] event_class Event class containing the payload field
550 type in which to add a field.
551 @param[in] field_type Type of the field to add.
552 @param[in] name Name of the field to add (copied on
554 @returns 0 on success, or a negative value on error.
556 @prenotnull{event_class}
560 @postrefcountsame{event_class}
561 @postsuccessrefcountinc{field_type}
563 extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class
*event_class
,
564 struct bt_ctf_field_type
*field_type
,
575 #endif /* BABELTRACE_CTF_IR_EVENT_CLASS_H */
This page took 0.040369 seconds and 4 git commands to generate.