Big cleanup of network live
[lttngtop.git] / lib / babeltrace / ctf-writer / event-fields.h
1 #ifndef BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
2 #define BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
3
4 /*
5 * BabelTrace - CTF Writer: Event Fields
6 *
7 * Copyright 2013 EfficiOS Inc.
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
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 struct bt_ctf_event_class;
40 struct bt_ctf_event;
41 struct bt_ctf_field;
42 struct bt_ctf_field_type;
43
44 /*
45 * bt_ctf_field_create: create an instance of a field.
46 *
47 * Allocate a new field of the type described by the bt_ctf_field_type
48 * structure.The creation of a field sets its reference count to 1.
49 *
50 * @param type Field type to be instanciated.
51 *
52 * Returns an allocated field on success, NULL on error.
53 */
54 extern struct bt_ctf_field *bt_ctf_field_create(
55 struct bt_ctf_field_type *type);
56
57 /*
58 * bt_ctf_field_structure_get_field: get a structure's field.
59 *
60 * Get the structure's field corresponding to the provided field name.
61 * bt_ctf_field_put() must be called on the returned value.
62 *
63 * @param structure Structure field instance.
64 * @param name Name of the field in the provided structure.
65 *
66 * Returns a field instance on success, NULL on error.
67 */
68 extern struct bt_ctf_field *bt_ctf_field_structure_get_field(
69 struct bt_ctf_field *structure, const char *name);
70
71 /*
72 * bt_ctf_field_array_get_field: get an array's field at position "index".
73 *
74 * Return the array's field at position "index". bt_ctf_field_put() must be
75 * called on the returned value.
76 *
77 * @param array Array field instance.
78 * @param index Position of the array's desired element.
79 *
80 * Returns a field instance on success, NULL on error.
81 */
82 extern struct bt_ctf_field *bt_ctf_field_array_get_field(
83 struct bt_ctf_field *array, uint64_t index);
84
85 /*
86 * bt_ctf_field_sequence_set_length: set a sequence's length.
87 *
88 * Set the sequence's length field.
89 *
90 * @param sequence Sequence field instance.
91 * @param length_field Integer field instance indicating the sequence's length.
92 *
93 * Returns a field instance on success, NULL on error.
94 */
95 extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence,
96 struct bt_ctf_field *length_field);
97
98 /*
99 * bt_ctf_field_sequence_get_field: get a sequence's field at position "index".
100 *
101 * Return the sequence's field at position "index". The sequence's length must
102 * have been set prior to calling this function using
103 * bt_ctf_field_sequence_set_length().
104 * bt_ctf_field_put() must be called on the returned value.
105 *
106 * @param array Sequence field instance.
107 * @param index Position of the sequence's desired element.
108 *
109 * Returns a field instance on success, NULL on error.
110 */
111 extern struct bt_ctf_field *bt_ctf_field_sequence_get_field(
112 struct bt_ctf_field *sequence, uint64_t index);
113
114 /*
115 * bt_ctf_field_variant_get_field: get a variant's selected field.
116 *
117 * Return the variant's selected field. The "tag" field is the selector enum
118 * field. bt_ctf_field_put() must be called on the returned value.
119 *
120 * @param variant Variant field instance.
121 * @param tag Selector enumeration field.
122 *
123 * Returns a field instance on success, NULL on error.
124 */
125 extern struct bt_ctf_field *bt_ctf_field_variant_get_field(
126 struct bt_ctf_field *variant, struct bt_ctf_field *tag);
127
128 /*
129 * bt_ctf_field_enumeration_get_container: get an enumeration field's container.
130 *
131 * Return the enumeration's underlying container field (an integer).
132 * bt_ctf_field_put() must be called on the returned value.
133 *
134 * @param enumeration Enumeration field instance.
135 *
136 * Returns a field instance on success, NULL on error.
137 */
138 extern struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
139 struct bt_ctf_field *enumeration);
140
141 /*
142 * bt_ctf_field_signed_integer_set_value: set a signed integer field's value
143 *
144 * Set a signed integer field's value. The value is checked to make sure it
145 * can be stored in the underlying field.
146 *
147 * @param integer Signed integer field instance.
148 * @param value Signed integer field value.
149 *
150 * Returns 0 on success, a negative value on error.
151 */
152 extern int bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *integer,
153 int64_t value);
154
155 /*
156 * bt_ctf_field_unsigned_integer_set_value: set unsigned integer field's value
157 *
158 * Set an unsigned integer field's value. The value is checked to make sure it
159 * can be stored in the underlying field.
160 *
161 * @param integer Unsigned integer field instance.
162 * @param value Unsigned integer field value.
163 *
164 * Returns 0 on success, a negative value on error.
165 */
166 extern int bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field *integer,
167 uint64_t value);
168
169 /*
170 * bt_ctf_field_floating_point_set_value: set a floating point field's value
171 *
172 * Set a floating point field's value. The underlying type may not support the
173 * double's full precision.
174 *
175 * @param floating_point Floating point field instance.
176 * @param value Floating point field value.
177 *
178 * Returns 0 on success, a negative value on error.
179 */
180 extern int bt_ctf_field_floating_point_set_value(
181 struct bt_ctf_field *floating_point,
182 double value);
183
184 /*
185 * bt_ctf_field_string_set_value: set a string field's value
186 *
187 * Set a string field's value.
188 *
189 * @param string String field instance.
190 * @param value String field value (will be copied).
191 *
192 * Returns 0 on success, a negative value on error.
193 */
194 extern int bt_ctf_field_string_set_value(struct bt_ctf_field *string,
195 const char *value);
196
197 /*
198 * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
199 * field's reference count.
200 *
201 * These functions ensure that the field won't be destroyed when it
202 * is in use. The same number of get and put (plus one extra put to
203 * release the initial reference done at creation) have to be done to
204 * destroy a field.
205 *
206 * When the field's reference count is decremented to 0 by a bt_ctf_field_put,
207 * the field is freed.
208 *
209 * @param field Field instance.
210 */
211 extern void bt_ctf_field_get(struct bt_ctf_field *field);
212 extern void bt_ctf_field_put(struct bt_ctf_field *field);
213
214 #ifdef __cplusplus
215 }
216 #endif
217
218 #endif /* BABELTRACE_CTF_WRITER_EVENT_FIELDS_H */
This page took 0.032888 seconds and 4 git commands to generate.