1 #ifndef BABELTRACE_CTF_IR_EVENT_FIELDS_H
2 #define BABELTRACE_CTF_IR_EVENT_FIELDS_H
5 * BabelTrace - CTF IR: Event Fields
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
40 struct bt_ctf_event_class
;
43 struct bt_ctf_field_type
;
46 * bt_ctf_field_create: create an instance of a field.
48 * Allocate a new field of the type described by the bt_ctf_field_type
49 * structure.The creation of a field sets its reference count to 1.
51 * @param type Field type to be instanciated.
53 * Returns an allocated field on success, NULL on error.
55 extern struct bt_ctf_field
*bt_ctf_field_create(
56 struct bt_ctf_field_type
*type
);
59 * bt_ctf_field_structure_get_field: get a structure's field.
61 * Get the structure's field corresponding to the provided field name.
62 * bt_ctf_field_put() must be called on the returned value.
64 * @param structure Structure field instance.
65 * @param name Name of the field in the provided structure.
67 * Returns a field instance on success, NULL on error.
69 extern struct bt_ctf_field
*bt_ctf_field_structure_get_field(
70 struct bt_ctf_field
*structure
, const char *name
);
73 * bt_ctf_field_structure_get_field_by_index: get a structure's field by index.
75 * Get the structure's field corresponding to the provided field name.
76 * bt_ctf_field_put() must be called on the returned value.
77 * The indexes are the same as those provided for bt_ctf_field_type_structure.
79 * @param structure Structure field instance.
80 * @param index Index of the field in the provided structure.
82 * Returns a field instance on success, NULL on error.
84 extern struct bt_ctf_field
*bt_ctf_field_structure_get_field_by_index(
85 struct bt_ctf_field
*structure
, int index
);
88 * bt_ctf_field_array_get_field: get an array's field at position "index".
90 * Return the array's field at position "index". bt_ctf_field_put() must be
91 * called on the returned value.
93 * @param array Array field instance.
94 * @param index Position of the array's desired element.
96 * Returns a field instance on success, NULL on error.
98 extern struct bt_ctf_field
*bt_ctf_field_array_get_field(
99 struct bt_ctf_field
*array
, uint64_t index
);
102 * bt_ctf_field_sequence_get_length: get a sequence's length.
104 * Get the sequence's length field.
106 * @param sequence Sequence field instance.
108 * Returns a field instance on success, NULL if a length was never set.
110 extern struct bt_ctf_field
*bt_ctf_field_sequence_get_length(
111 struct bt_ctf_field
*sequence
);
114 * bt_ctf_field_sequence_set_length: set a sequence's length.
116 * Set the sequence's length field.
118 * @param sequence Sequence field instance.
119 * @param length_field Unsigned integer field instance indicating the
122 * Returns 0 on success, a negative value on error.
124 extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field
*sequence
,
125 struct bt_ctf_field
*length_field
);
128 * bt_ctf_field_sequence_get_field: get a sequence's field at position "index".
130 * Return the sequence's field at position "index". The sequence's length must
131 * have been set prior to calling this function using
132 * bt_ctf_field_sequence_set_length().
133 * bt_ctf_field_put() must be called on the returned value.
135 * @param array Sequence field instance.
136 * @param index Position of the sequence's desired element.
138 * Returns a field instance on success, NULL on error.
140 extern struct bt_ctf_field
*bt_ctf_field_sequence_get_field(
141 struct bt_ctf_field
*sequence
, uint64_t index
);
144 * bt_ctf_field_variant_get_field: get a variant's selected field.
146 * Return the variant's selected field. The "tag" field is the selector enum
147 * field. bt_ctf_field_put() must be called on the returned value.
149 * @param variant Variant field instance.
150 * @param tag Selector enumeration field.
152 * Returns a field instance on success, NULL on error.
154 extern struct bt_ctf_field
*bt_ctf_field_variant_get_field(
155 struct bt_ctf_field
*variant
, struct bt_ctf_field
*tag
);
158 * bt_ctf_field_variant_get_current_field: get the current selected field of a
161 * Return the variant's current selected field. This function, unlike
162 * bt_ctf_field_variant_get_field(), does not create any field; it
163 * returns NULL if there's no current selected field yet.
165 * @param variant Variant field instance.
167 * Returns a field instance on success, NULL on error or when there's no
168 * current selected field.
170 extern struct bt_ctf_field
*bt_ctf_field_variant_get_current_field(
171 struct bt_ctf_field
*variant
);
174 * bt_ctf_field_enumeration_get_container: get an enumeration field's container.
176 * Return the enumeration's underlying container field (an integer).
177 * bt_ctf_field_put() must be called on the returned value.
179 * @param enumeration Enumeration field instance.
181 * Returns a field instance on success, NULL on error.
183 extern struct bt_ctf_field
*bt_ctf_field_enumeration_get_container(
184 struct bt_ctf_field
*enumeration
);
187 * bt_ctf_field_enumeration_get_mapping_name: get an enumeration field's mapping
190 * Return the enumeration's underlying container field (an integer).
191 * bt_ctf_field_put() must be called on the returned value.
193 * @param enumeration Enumeration field instance.
195 * Returns a field instance on success, NULL on error.
197 extern const char *bt_ctf_field_enumeration_get_mapping_name(
198 struct bt_ctf_field
*enumeration
);
201 * bt_ctf_field_signed_integer_get_value: get a signed integer field's value
203 * Get a signed integer field's value.
205 * @param integer Signed integer field instance.
206 * @param value Pointer to a signed integer where the value will be stored.
208 * Returns 0 on success, a negative value on error.
210 extern int bt_ctf_field_signed_integer_get_value(struct bt_ctf_field
*integer
,
214 * bt_ctf_field_signed_integer_set_value: set a signed integer field's value
216 * Set a signed integer field's value. The value is checked to make sure it
217 * can be stored in the underlying field.
219 * @param integer Signed integer field instance.
220 * @param value Signed integer field value.
222 * Returns 0 on success, a negative value on error.
224 extern int bt_ctf_field_signed_integer_set_value(struct bt_ctf_field
*integer
,
228 * bt_ctf_field_unsigned_integer_get_value: get unsigned integer field's value
230 * Get an unsigned integer field's value.
232 * @param integer Unsigned integer field instance.
233 * @param value Pointer to an unsigned integer where the value will be stored.
235 * Returns 0 on success, a negative value on error.
237 extern int bt_ctf_field_unsigned_integer_get_value(struct bt_ctf_field
*integer
,
241 * bt_ctf_field_unsigned_integer_set_value: set unsigned integer field's value
243 * Set an unsigned integer field's value. The value is checked to make sure it
244 * can be stored in the underlying field.
246 * @param integer Unsigned integer field instance.
247 * @param value Unsigned integer field value.
249 * Returns 0 on success, a negative value on error.
251 extern int bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field
*integer
,
255 * bt_ctf_field_floating_point_get_value: get a floating point field's value
257 * Get a floating point field's value.
259 * @param floating_point Floating point field instance.
260 * @param value Pointer to a double where the value will be stored.
262 * Returns 0 on success, a negative value on error.
264 extern int bt_ctf_field_floating_point_get_value(
265 struct bt_ctf_field
*floating_point
, double *value
);
268 * bt_ctf_field_floating_point_set_value: set a floating point field's value
270 * Set a floating point field's value. The underlying type may not support the
271 * double's full precision.
273 * @param floating_point Floating point field instance.
274 * @param value Floating point field value.
276 * Returns 0 on success, a negative value on error.
278 extern int bt_ctf_field_floating_point_set_value(
279 struct bt_ctf_field
*floating_point
,
283 * bt_ctf_field_string_get_value: get a string field's value
285 * Get a string field's value.
287 * @param string_field String field instance.
289 * Returns the string's value, NULL if unset.
291 extern const char *bt_ctf_field_string_get_value(
292 struct bt_ctf_field
*string_field
);
295 * bt_ctf_field_string_set_value: set a string field's value
297 * Set a string field's value.
299 * @param string_field String field instance.
300 * @param value String field value (will be copied).
302 * Returns 0 on success, a negative value on error.
304 extern int bt_ctf_field_string_set_value(struct bt_ctf_field
*string_field
,
308 * bt_ctf_field_string_append: append a string to a string field's
311 * Append a string to the current value of a string field. If the string
312 * field was never set using bt_ctf_field_string_set_value(), it is
313 * first set to an empty string, and then the concatenation happens.
315 * @param string_field String field instance.
316 * @param value String to append to the current string field's value.
318 * Returns 0 on success, a negative value on error.
320 extern int bt_ctf_field_string_append(struct bt_ctf_field
*string_field
,
324 * bt_ctf_field_string_append_len: append a string of a given length to
325 * a string field's current value.
327 * Append a string of a given length to the current value of a string
328 * field. If the string field was never set using
329 * bt_ctf_field_string_set_value(), it is first set to an empty string,
330 * and then the concatenation happens.
332 * If a null byte is encountered before the given length, only the
333 * substring before the first null byte is appended.
335 * @param string_field String field instance.
336 * @param value String to append to the current string field's value.
337 * @param length Length of string value to append.
339 * Returns 0 on success, a negative value on error.
341 extern int bt_ctf_field_string_append_len(
342 struct bt_ctf_field
*string_field
, const char *value
,
343 unsigned int length
);
346 * bt_ctf_field_get_type: get a field's type
348 * @param field Field intance.
350 * Returns a field type instance on success, NULL on error.
352 extern struct bt_ctf_field_type
*bt_ctf_field_get_type(
353 struct bt_ctf_field
*field
);
356 * bt_ctf_field_copy: get a field's deep copy.
358 * Get a field's deep copy. The created field copy shares the source's
359 * associated field types.
361 * On success, the returned copy has its reference count set to 1.
363 * @param field Field instance.
365 * Returns the field copy on success, NULL on error.
367 extern struct bt_ctf_field
*bt_ctf_field_copy(struct bt_ctf_field
*field
);
370 * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
371 * field's reference count.
373 * These functions ensure that the field won't be destroyed when it
374 * is in use. The same number of get and put (plus one extra put to
375 * release the initial reference done at creation) have to be done to
378 * When the field's reference count is decremented to 0 by a bt_ctf_field_put,
379 * the field is freed.
381 * @param field Field instance.
383 extern void bt_ctf_field_get(struct bt_ctf_field
*field
);
384 extern void bt_ctf_field_put(struct bt_ctf_field
*field
);
390 #endif /* BABELTRACE_CTF_IR_EVENT_FIELDS_H */
This page took 0.03846 seconds and 6 git commands to generate.