Fix: Missing stdint.h in trace.h
[babeltrace.git] / include / babeltrace / ctf-ir / trace.h
1 #ifndef BABELTRACE_CTF_IR_TRACE_H
2 #define BABELTRACE_CTF_IR_TRACE_H
3
4 /*
5 * BabelTrace - CTF IR: Trace
6 *
7 * Copyright 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 <babeltrace/ctf-ir/event-types.h>
34 #include <stdint.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 struct bt_ctf_trace;
41 struct bt_ctf_stream;
42 struct bt_ctf_stream_class;
43 struct bt_ctf_clock;
44
45 enum bt_environment_field_type {
46 BT_ENVIRONMENT_FIELD_TYPE_UNKNOWN = -1,
47 BT_ENVIRONMENT_FIELD_TYPE_STRING = 0,
48 BT_ENVIRONMENT_FIELD_TYPE_INTEGER = 1,
49 };
50
51 /*
52 * bt_ctf_trace_create: create a trace instance.
53 *
54 * Allocate a new trace.
55 *
56 * A trace's default packet header is a structure initialized with the following
57 * fields:
58 * - uint32_t magic
59 * - uint8_t uuid[16]
60 * - uint32_t stream_id
61 *
62 * Returns a new trace on success, NULL on error.
63 */
64 extern struct bt_ctf_trace *bt_ctf_trace_create(void);
65
66 /*
67 * bt_ctf_trace_create_stream: create a stream instance.
68 *
69 * Allocate a new stream instance and register it to the trace. The creation of
70 * a stream sets its reference count to 1.
71 *
72 * @param trace Trace instance.
73 * @param stream_class Stream class to instantiate.
74 *
75 * Returns a new stream on success, NULL on error.
76 */
77 extern struct bt_ctf_stream *bt_ctf_trace_create_stream(
78 struct bt_ctf_trace *trace,
79 struct bt_ctf_stream_class *stream_class);
80
81 /*
82 * bt_ctf_trace_add_environment_field: add a string environment field to the
83 * trace.
84 *
85 * Add a string environment field to the trace. The name and value parameters
86 * are copied.
87 *
88 * @param trace Trace instance.
89 * @param name Name of the environment field (will be copied).
90 * @param value Value of the environment field (will be copied).
91 *
92 * Returns 0 on success, a negative value on error.
93 */
94 extern int bt_ctf_trace_add_environment_field(struct bt_ctf_trace *trace,
95 const char *name,
96 const char *value);
97
98 /*
99 * bt_ctf_trace_add_environment_field_integer: add an integer environment
100 * field to the trace.
101 *
102 * Add an integer environment field to the trace. The name parameter is
103 * copied.
104 *
105 * @param trace Trace instance.
106 * @param name Name of the environment field (will be copied).
107 * @param value Value of the environment field.
108 *
109 * Returns 0 on success, a negative value on error.
110 */
111 extern int bt_ctf_trace_add_environment_field_integer(
112 struct bt_ctf_trace *trace, const char *name,
113 int64_t value);
114
115 /*
116 * bt_ctf_trace_get_environment_field_count: get environment field count.
117 *
118 * Get the trace's environment field count.
119 *
120 * @param trace Trace instance.
121 *
122 * Returns the environment field count, a negative value on error.
123 */
124 extern int bt_ctf_trace_get_environment_field_count(
125 struct bt_ctf_trace *trace);
126
127 /*
128 * bt_ctf_trace_get_environment_field_type: get environment field type.
129 *
130 * Get an environment field's type.
131 *
132 * @param trace Trace instance.
133 * @param index Index of the environment field.
134 *
135 * Returns the environment field count, a negative value on error.
136 */
137 extern enum bt_environment_field_type
138 bt_ctf_trace_get_environment_field_type(struct bt_ctf_trace *trace,
139 int index);
140
141 /*
142 * bt_ctf_trace_get_environment_field_name: get environment field name.
143 *
144 * Get an environment field's name. The string's ownership is not
145 * transferred to the caller.
146 *
147 * @param trace Trace instance.
148 * @param index Index of the environment field.
149 *
150 * Returns the environment field's name, NULL on error.
151 */
152 extern const char *
153 bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace,
154 int index);
155
156 /*
157 * bt_ctf_trace_get_environment_field_value_string: get environment field
158 * string value.
159 *
160 * Get an environment field's string value. The string's ownership is not
161 * transferred to the caller.
162 *
163 * @param trace Trace instance.
164 * @param index Index of the environment field.
165 *
166 * Returns the environment field's string value, NULL on error.
167 */
168 extern const char *
169 bt_ctf_trace_get_environment_field_value_string(struct bt_ctf_trace *trace,
170 int index);
171
172 /*
173 * bt_ctf_trace_get_environment_field_value_integer: get environment field
174 * integer value.
175 *
176 * Get an environment field's integer value.
177 *
178 * @param trace Trace instance.
179 * @param index Index of the environment field.
180 *
181 * Returns the environment field's integer value, a negative value on error.
182 */
183 extern int
184 bt_ctf_trace_get_environment_field_value_integer(struct bt_ctf_trace *trace,
185 int index, int64_t *value);
186
187 /*
188 * bt_ctf_trace_add_clock: add a clock to the trace.
189 *
190 * Add a clock to the trace. Clocks assigned to stream classes must be
191 * added to the trace beforehand.
192 *
193 * @param trace Trace instance.
194 * @param clock Clock to add to the trace.
195 *
196 * Returns 0 on success, a negative value on error.
197 */
198 extern int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace,
199 struct bt_ctf_clock *clock);
200
201 /*
202 * bt_ctf_trace_get_clock_count: get the number of clocks
203 * associated to the trace.
204 *
205 * @param trace Trace instance.
206 *
207 * Returns the clock count on success, a negative value on error.
208 */
209 extern int bt_ctf_trace_get_clock_count(struct bt_ctf_trace *trace);
210
211 /*
212 * bt_ctf_trace_get_clock: get a trace's clock at index.
213 *
214 * @param trace Trace instance.
215 * @param index Index of the clock in the given trace.
216 *
217 * Return a clock instance on success, NULL on error.
218 */
219 extern struct bt_ctf_clock *bt_ctf_trace_get_clock(
220 struct bt_ctf_trace *trace, int index);
221
222 /*
223 * bt_ctf_trace_get_metadata_string: get metadata string.
224 *
225 * Get the trace's TSDL metadata. The caller assumes the ownership of the
226 * returned string.
227 *
228 * @param trace Trace instance.
229 *
230 * Returns the metadata string on success, NULL on error.
231 */
232 extern char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace);
233
234 /*
235 * bt_ctf_trace_set_byte_order: set a field type's byte order.
236 *
237 * Set the trace's byte order. Defaults to the current host's endianness.
238 *
239 * @param trace Trace instance.
240 * @param byte_order Trace's byte order.
241 *
242 * Returns 0 on success, a negative value on error.
243 *
244 * Note: byte_order must not be BT_CTF_BYTE_ORDER_NATIVE since, according
245 * to the CTF specification, is defined as "the byte order described in the
246 * trace description".
247 */
248 extern int bt_ctf_trace_set_byte_order(struct bt_ctf_trace *trace,
249 enum bt_ctf_byte_order byte_order);
250
251 /*
252 * bt_ctf_trace_get_packet_header_type: get a trace's packet header type.
253 *
254 * Get the trace's packet header type.
255 *
256 * @param trace Trace instance.
257 *
258 * Returns the trace's packet header type (a structure) on success, NULL on
259 * error.
260 */
261 extern struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_type(
262 struct bt_ctf_trace *trace);
263
264 /*
265 * bt_ctf_trace_set_packet_header_type: set a trace's packet header type.
266 *
267 * Set the trace's packet header type.
268 *
269 * @param trace Trace instance.
270 * @param packet_header_type Packet header field type (must be a structure).
271 *
272 * Returns 0 on success, a negative value on error.
273 */
274 extern int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace,
275 struct bt_ctf_field_type *packet_header_type);
276
277 /*
278 * bt_ctf_trace_get and bt_ctf_trace_put: increment and decrement the
279 * trace's reference count.
280 *
281 * These functions ensure that the trace won't be destroyed while it
282 * is in use. The same number of get and put (plus one extra put to
283 * release the initial reference done at creation) have to be done to
284 * destroy a trace.
285 *
286 * When the trace's reference count is decremented to 0 by a
287 * bt_ctf_trace_put, the trace is freed.
288 *
289 * @param trace Trace instance.
290 */
291 extern void bt_ctf_trace_get(struct bt_ctf_trace *trace);
292 extern void bt_ctf_trace_put(struct bt_ctf_trace *trace);
293
294 #ifdef __cplusplus
295 }
296 #endif
297
298 #endif /* BABELTRACE_CTF_IR_TRACE_H */
This page took 0.036563 seconds and 5 git commands to generate.