Fix: Field types native byte order refers to the trace
[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
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 struct bt_ctf_trace;
40 struct bt_ctf_stream;
41 struct bt_ctf_stream_class;
42 struct bt_ctf_clock;
43
44 /*
45 * bt_ctf_trace_create: create a trace instance.
46 *
47 * Allocate a new trace.
48 *
49 * A trace's default packet header is a structure initialized with the following
50 * fields:
51 * - uint32_t magic
52 * - uint8_t uuid[16]
53 * - uint32_t stream_id
54 *
55 * Returns a new trace on success, NULL on error.
56 */
57 extern struct bt_ctf_trace *bt_ctf_trace_create(void);
58
59 /*
60 * bt_ctf_trace_create_stream: create a stream instance.
61 *
62 * Allocate a new stream instance and register it to the trace. The creation of
63 * a stream sets its reference count to 1.
64 *
65 * @param trace Trace instance.
66 * @param stream_class Stream class to instantiate.
67 *
68 * Returns a new stream on success, NULL on error.
69 */
70 extern struct bt_ctf_stream *bt_ctf_trace_create_stream(
71 struct bt_ctf_trace *trace,
72 struct bt_ctf_stream_class *stream_class);
73
74 /*
75 * bt_ctf_trace_add_environment_field: add an environment field to the trace.
76 *
77 * Add an environment field to the trace. The name and value parameters are
78 * copied.
79 *
80 * @param trace Trace instance.
81 * @param name Name of the environment field (will be copied).
82 * @param value Value of the environment field (will be copied).
83 *
84 * Returns 0 on success, a negative value on error.
85 */
86 extern int bt_ctf_trace_add_environment_field(struct bt_ctf_trace *trace,
87 const char *name,
88 const char *value);
89
90 /*
91 * bt_ctf_trace_add_clock: add a clock to the trace.
92 *
93 * Add a clock to the trace. Clocks assigned to stream classes must be
94 * added to the trace beforehand.
95 *
96 * @param trace Trace instance.
97 * @param clock Clock to add to the trace.
98 *
99 * Returns 0 on success, a negative value on error.
100 */
101 extern int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace,
102 struct bt_ctf_clock *clock);
103
104 /*
105 * bt_ctf_trace_get_clock_count: get the number of clocks
106 * associated to the trace.
107 *
108 * @param trace Trace instance.
109 *
110 * Returns the clock count on success, a negative value on error.
111 */
112 extern int bt_ctf_trace_get_clock_count(struct bt_ctf_trace *trace);
113
114 /*
115 * bt_ctf_trace_get_clock: get a trace's clock at index.
116 *
117 * @param trace Trace instance.
118 * @param index Index of the clock in the given trace.
119 *
120 * Return a clock instance on success, NULL on error.
121 */
122 extern struct bt_ctf_clock *bt_ctf_trace_get_clock(
123 struct bt_ctf_trace *trace, int index);
124
125 /*
126 * bt_ctf_trace_get_metadata_string: get metadata string.
127 *
128 * Get the trace's TSDL metadata. The caller assumes the ownership of the
129 * returned string.
130 *
131 * @param trace Trace instance.
132 *
133 * Returns the metadata string on success, NULL on error.
134 */
135 extern char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace);
136
137 /*
138 * bt_ctf_trace_set_byte_order: set a field type's byte order.
139 *
140 * Set the trace's byte order. Defaults to the current host's endianness.
141 *
142 * @param trace Trace instance.
143 * @param byte_order Trace's byte order.
144 *
145 * Returns 0 on success, a negative value on error.
146 *
147 * Note: byte_order must not be BT_CTF_BYTE_ORDER_NATIVE since, according
148 * to the CTF specification, is defined as "the byte order described in the
149 * trace description".
150 */
151 extern int bt_ctf_trace_set_byte_order(struct bt_ctf_trace *trace,
152 enum bt_ctf_byte_order byte_order);
153
154 /*
155 * bt_ctf_trace_get_packet_header_type: get a trace's packet header type.
156 *
157 * Get the trace's packet header type.
158 *
159 * @param trace Trace instance.
160 *
161 * Returns the trace's packet header type (a structure) on success, NULL on
162 * error.
163 */
164 extern struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_type(
165 struct bt_ctf_trace *trace);
166
167 /*
168 * bt_ctf_trace_set_packet_header_type: set a trace's packet header type.
169 *
170 * Set the trace's packet header type.
171 *
172 * @param trace Trace instance.
173 * @param packet_header_type Packet header field type (must be a structure).
174 *
175 * Returns 0 on success, a negative value on error.
176 */
177 extern int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace,
178 struct bt_ctf_field_type *packet_header_type);
179
180 /*
181 * bt_ctf_trace_get and bt_ctf_trace_put: increment and decrement the
182 * trace's reference count.
183 *
184 * These functions ensure that the trace won't be destroyed while it
185 * is in use. The same number of get and put (plus one extra put to
186 * release the initial reference done at creation) have to be done to
187 * destroy a trace.
188 *
189 * When the trace's reference count is decremented to 0 by a
190 * bt_ctf_trace_put, the trace is freed.
191 *
192 * @param trace Trace instance.
193 */
194 extern void bt_ctf_trace_get(struct bt_ctf_trace *trace);
195 extern void bt_ctf_trace_put(struct bt_ctf_trace *trace);
196
197 #ifdef __cplusplus
198 }
199 #endif
200
201 #endif /* BABELTRACE_CTF_IR_TRACE_H */
This page took 0.034287 seconds and 5 git commands to generate.