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 @postrefcountsame{event_class}
159 @postsuccessrefcountretinc
161 @sa bt_ctf_stream_class_add_event_class(): Add an event class to
164 extern struct bt_ctf_stream_class
*bt_ctf_event_class_get_stream_class(
165 struct bt_ctf_event_class
*event_class
);
170 @name Attribute functions
175 @brief Returns the name of the CTF IR event class \p event_class.
177 On success, \p event_class remains the sole owner of the returned
180 @param[in] event_class Event class of which to get the name.
181 @returns Name of event class \p event_class, or
184 @prenotnull{event_class}
185 @postrefcountsame{event_class}
187 extern const char *bt_ctf_event_class_get_name(
188 struct bt_ctf_event_class
*event_class
);
191 @brief Returns the numeric ID of the CTF IR event class \p event_class.
193 @param[in] event_class Event class of which to get the numeric ID.
194 @returns ID of event class \p event_class, or a
195 negative value on error.
197 @prenotnull{event_class}
198 @postrefcountsame{event_class}
200 @sa bt_ctf_event_class_set_id(): Sets the numeric ID of a given
203 extern int64_t bt_ctf_event_class_get_id(
204 struct bt_ctf_event_class
*event_class
);
207 @brief Sets the numeric ID of the CTF IR event class
208 \p event_class to \p id.
210 \p id must be unique amongst the IDs of all the event classes
211 of the stream class to which you eventually add \p event_class.
213 @param[in] event_class Event class of which to set the numeric ID.
214 @param[in] id ID of the event class.
215 @returns 0 on success, or a negative value on error.
217 @prenotnull{event_class}
219 @postrefcountsame{event_class}
221 @sa bt_ctf_event_class_get_id(): Returns the numeric ID of a given
224 extern int bt_ctf_event_class_set_id(
225 struct bt_ctf_event_class
*event_class
, uint32_t id
);
228 @brief Returns the number of attributes contained in the CTF IR event
229 class \p event_class.
231 @param[in] event_class Event class of which to get the number
232 of contained attributes.
233 @returns Number of contained attributes in
234 \p event_class, or a negative value on error.
236 @prenotnull{event_class}
237 @postrefcountsame{event_class}
239 @sa bt_ctf_event_class_get_attribute_name(): Returns the name of
240 the attribute of a given event class at a given index.
241 @sa bt_ctf_event_class_get_attribute_value(): Returns the value of
242 the attribute of a given event class at a given index.
244 extern int bt_ctf_event_class_get_attribute_count(
245 struct bt_ctf_event_class
*event_class
);
248 @brief Returns the name of the attribute at the index \p index of the
249 CTF IR event class \p event_class.
251 On success, \p event_class remains the sole owner of the returned
254 @param[in] event_class Event class of which to get the name
256 @param[in] index Index of the attribute of which to get the name.
257 @returns Attribute name, or \c NULL on error.
259 @prenotnull{event_class}
260 @pre \p index is lesser than the number of attributes contained by
262 @postrefcountsame{event_class}
264 @sa bt_ctf_event_class_get_attribute_value(): Returns the value of
265 the attribute of a given event class at a given index.
268 bt_ctf_event_class_get_attribute_name(
269 struct bt_ctf_event_class
*event_class
, int index
);
272 @brief Returns the value of the attribute at the index \p index of the
273 CTF IR event class \p event_class.
275 @param[in] event_class Event class of which to get the value
277 @param[in] index Index of the attribute of which to get the value.
278 @returns Attribute value, or \c NULL on error.
280 @prenotnull{event_class}
281 @pre \p index is lesser than the number of attributes contained by
283 @postsuccessrefcountretinc
284 @postrefcountsame{event_class}
286 @sa bt_ctf_event_class_get_attribute_name(): Returns the name of
287 the attribute of a given event class at a given index.
289 extern struct bt_value
*
290 bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class
*event_class
,
294 @brief Returns the value of the attribute named \p name of the CTF IR
295 event class \p event_class.
297 On success, the reference count of the returned value object is
300 @param[in] event_class Event class of which to get the value
302 @param[in] name Name of the attribute to get.
303 @returns Attribute value, or \c NULL on error.
305 @prenotnull{event_class}
307 @postsuccessrefcountretinc
308 @postrefcountsame{event_class}
310 extern struct bt_value
*
311 bt_ctf_event_class_get_attribute_value_by_name(
312 struct bt_ctf_event_class
*event_class
, const char *name
);
315 @brief Sets the attribute named \p name of the CTF IR event class
316 \p event_class to the value \p value.
318 Valid attributes, as of Babeltrace \btversion, are:
320 - <code>id</code>: \em must be an integer value object with a raw value
321 that is greater than or equal to 0. This represents the event class's
322 numeric ID and you can also set it with bt_ctf_event_class_set_id().
324 - <code>name</code>: must be a string value object. This represents
325 the name of the event class.
327 - <code>loglevel</code>: must be an integer value object with a raw
328 value greater than or equal to 0. This represents the numeric log level
329 associated with this event class. Log level values
330 are application-specific.
332 - <code>model.emf.uri</code>: must be a string value object. This
333 represents the application-specific Eclipse Modeling Framework URI
336 @param[in] event_class Event class of which to set an
338 @param[in] name Attribute name (copied on success).
339 @param[in] value Attribute value.
340 @returns 0 on success, or a negative value on error.
342 @prenotnull{event_class}
346 @postrefcountsame{event_class}
347 @postsuccessrefcountinc{value}
349 @sa bt_ctf_event_class_get_attribute_value_by_name(): Returns the
350 attribute of a given event class having a given name.
352 extern int bt_ctf_event_class_set_attribute(
353 struct bt_ctf_event_class
*event_class
, const char *name
,
354 struct bt_value
*value
);
359 @name Contained field types functions
364 @brief Returns the context field type of the CTF IR event class
367 @param[in] event_class Event class of which to get the
369 @returns Context field type of \p event_class,
372 @prenotnull{event_class}
373 @postrefcountsame{event_class}
374 @postsuccessrefcountretinc
376 @sa bt_ctf_event_class_set_context_type(): Sets the context field
377 type of a given event class.
379 extern struct bt_ctf_field_type
*bt_ctf_event_class_get_context_type(
380 struct bt_ctf_event_class
*event_class
);
383 @brief Sets the context field type of the CTF IR event class
384 \p event_class to \p context_type.
386 As of Babeltrace \btversion, \p context_type \em must be a
387 CTF IR structure field type object.
389 @param[in] event_class Event class of which to set the context
391 @param[in] context_type Context field type.
392 @returns 0 on success, or a negative value on error.
394 @prenotnull{event_class}
395 @prenotnull{context_type}
397 @preisstructft{context_type}
398 @postrefcountsame{event_class}
399 @postsuccessrefcountinc{context_type}
401 @sa bt_ctf_event_class_get_context_type(): Returns the context field
402 type of a given event class.
404 extern int bt_ctf_event_class_set_context_type(
405 struct bt_ctf_event_class
*event_class
,
406 struct bt_ctf_field_type
*context_type
);
409 @brief Returns the payload field type of the CTF IR event class
412 @param[in] event_class Event class of which to get the
414 @returns Payload field type of \p event_class,
417 @prenotnull{event_class}
418 @postrefcountsame{event_class}
419 @postsuccessrefcountretinc
421 @sa bt_ctf_event_class_set_payload_type(): Sets the payload field
422 type of a given event class.
424 extern struct bt_ctf_field_type
*bt_ctf_event_class_get_payload_type(
425 struct bt_ctf_event_class
*event_class
);
428 @brief Sets the payload field type of the CTF IR event class
429 \p event_class to \p payload_type.
431 As of Babeltrace \btversion, \p payload_type \em must be a
432 CTF IR structure field type object.
434 @param[in] event_class Event class of which to set the payload
436 @param[in] payload_type Payload field type.
437 @returns 0 on success, or a negative value on error.
439 @prenotnull{event_class}
440 @prenotnull{payload_type}
442 @preisstructft{payload_type}
443 @postrefcountsame{event_class}
444 @postsuccessrefcountinc{payload_type}
446 @sa bt_ctf_event_class_get_payload_type(): Returns the payload field
447 type of a given event class.
449 extern int bt_ctf_event_class_set_payload_type(
450 struct bt_ctf_event_class
*event_class
,
451 struct bt_ctf_field_type
*payload_type
);
454 @brief Returns the number of fields contained in the
455 payload field type of the CTF IR event class \p event_class.
458 Calling this function is the equivalent of getting the payload field
459 type of \p event_class with bt_ctf_event_class_get_payload_type() and
460 getting its field count with
461 bt_ctf_field_type_structure_get_field_count().
463 @param[in] event_class Event class of which to get the number
464 of fields contained in its payload field type.
465 @returns Number of fields in the payload field type
466 of \p event_class, or a negative value on error.
468 @prenotnull{event_class}
469 @postrefcountsame{event_class}
471 extern int bt_ctf_event_class_get_field_count(
472 struct bt_ctf_event_class
*event_class
);
475 @brief Returns the type and the name of the field at index \p index
476 in the payload field type of the CTF IR event class
479 On success, the field's type is placed in \p *field_type if
480 \p field_type is not \c NULL. The field's name is placed in
481 \p *name if \p name is not \c NULL. \p event_class remains the sole
484 Both \p name and \p field_type can be \c NULL if the caller is not
485 interested in one of them.
488 Calling this function is the equivalent of getting the payload field
489 type of \p event_class with bt_ctf_event_class_get_payload_type() and
490 getting the type and name of one of its field with
491 bt_ctf_field_type_structure_get_field().
493 @param[in] event_class Event class of which to get the type and name
494 of a field in its payload field type.
495 @param[out] field_name Name of the field at the index
496 \p index in the payload field type of
497 \p event_class (can be \c NULL).
498 @param[out] field_type Type of the field at the index \p index in the
499 payload field type of \p event_class
501 @param[in] index Index of the payload field type's field to find.
502 @returns 0 on success, or a negative value on error.
504 @prenotnull{event_class}
505 @pre \p index is lesser than the number of fields contained in the
506 payload field type of \p event_class (see
507 bt_ctf_event_class_get_field_count()).
508 @postrefcountsame{event_class}
509 @post <strong>On success, if \p field_type is not \c NULL</strong>, the
510 reference count of \p *field_type is incremented.
512 extern int bt_ctf_event_class_get_field(struct bt_ctf_event_class
*event_class
,
513 const char **field_name
, struct bt_ctf_field_type
**field_type
,
517 @brief Returns the type of the field named \p name in the payload
518 field type of the CTF IR event class \p event_class.
521 Calling this function is the equivalent of getting the payload field
522 type of \p event_class with bt_ctf_event_class_get_payload_type() and
523 getting the type of one of its field with
524 bt_ctf_field_type_structure_get_field_type_by_name().
526 @param[in] event_class Event class of which to get the type of a
527 payload field type's field.
528 @param[in] name Name of the payload field type's field to get.
529 @returns Type of the field named \p name in the payload
530 field type of \p event_class, or \c NULL if
531 the function cannot find the field or
534 @prenotnull{event_class}
536 @postrefcountsame{event_class}
537 @postsuccessrefcountretinc
539 extern struct bt_ctf_field_type
*bt_ctf_event_class_get_field_by_name(
540 struct bt_ctf_event_class
*event_class
, const char *name
);
543 @brief Adds a field named \p name with the type \p field_type to the
544 payload field type of the CTF IR event class \p event_class.
547 Calling this function is the equivalent of getting the payload field
548 type of \p event_class with bt_ctf_event_class_get_payload_type() and
549 adding a field to it with bt_ctf_field_type_structure_add_field().
551 @param[in] event_class Event class containing the payload field
552 type in which to add a field.
553 @param[in] field_type Type of the field to add.
554 @param[in] name Name of the field to add (copied on
556 @returns 0 on success, or a negative value on error.
558 @prenotnull{event_class}
562 @postrefcountsame{event_class}
563 @postsuccessrefcountinc{field_type}
565 extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class
*event_class
,
566 struct bt_ctf_field_type
*field_type
,
577 #endif /* BABELTRACE_CTF_IR_EVENT_CLASS_H */
This page took 0.044477 seconds and 4 git commands to generate.