1 #ifndef BABELTRACE_CTF_IR_STREAM_CLASS_H
2 #define BABELTRACE_CTF_IR_STREAM_CLASS_H
5 * BabelTrace - CTF IR: Stream Class
7 * Copyright 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
34 #include <babeltrace/ctf-ir/visitor.h>
40 struct bt_ctf_event_class
;
41 struct bt_ctf_stream_class
;
45 * bt_ctf_stream_class_create: create a stream class.
47 * Allocate a new stream class of the given name. The creation of an event class
48 * sets its reference count to 1.
50 * A stream class' packet context is a structure initialized with the following
52 * - uint64_t timestamp_begin
53 * - uint64_t timestamp_end
54 * - uint64_t content_size
55 * - uint64_t packet_size
56 * - uint64_t events_discarded
58 * A stream class's event header is a structure initialized the following
61 * - uint64_t timestamp
63 * @param name Stream name, NULL to create an unnamed stream class.
65 * Returns an allocated stream class on success, NULL on error.
67 extern struct bt_ctf_stream_class
*bt_ctf_stream_class_create(const char *name
);
70 * bt_ctf_stream_class_get_trace: Get a stream class' associated trace.
72 * @param stream_class Stream class.
74 * Returns the stream class' associated trace, NULL on error.
76 extern struct bt_ctf_trace
*bt_ctf_stream_class_get_trace(
77 struct bt_ctf_stream_class
*stream_class
);
80 * bt_ctf_stream_class_get_name: Get a stream class' name.
82 * @param stream_class Stream class.
84 * Returns the stream class' name, NULL on error.
86 extern const char *bt_ctf_stream_class_get_name(
87 struct bt_ctf_stream_class
*stream_class
);
90 * bt_ctf_stream_class_set_name: Set a stream class' name.
92 * @param stream_class Stream class.
94 * Returns 0 on success, a negative value on error.
96 extern int bt_ctf_stream_class_set_name(
97 struct bt_ctf_stream_class
*stream_class
, const char *name
);
100 * bt_ctf_stream_class_get_clock: get the clock associated with a stream class.
102 * @param stream_class Stream class.
104 * Returns a clock instance, NULL on error.
106 extern struct bt_ctf_clock
*bt_ctf_stream_class_get_clock(
107 struct bt_ctf_stream_class
*stream_class
);
110 * bt_ctf_stream_class_get_id: Get a stream class' id.
112 * @param stream_class Stream class.
114 * Returns the stream class' id, a negative value on error.
116 extern int64_t bt_ctf_stream_class_get_id(
117 struct bt_ctf_stream_class
*stream_class
);
120 * bt_ctf_stream_class_set_id: Set a stream class' id.
122 * Set a stream class' id. Must be unique trace-wise.
123 * Note that stream classes are assigned a unique id when a stream instance
124 * is created for the first time from a trace or writer.
126 * @param stream_class Stream class.
127 * @param id Stream class id.
129 * Returns 0 on success, a negative value on error.
131 extern int bt_ctf_stream_class_set_id(
132 struct bt_ctf_stream_class
*stream_class
, uint32_t id
);
135 * bt_ctf_stream_class_set_clock: assign a clock to a stream class.
137 * Add an event class to a stream class. New events can be added even after a
138 * stream has beem instanciated and events have been appended. However, a stream
139 * will not accept events of a class that has not been registered beforehand.
140 * The stream class will share the ownership of "event_class" by incrementing
141 * its reference count.
143 * Note that an event class may only be added to one stream class. It
144 * also becomes immutable.
146 * @param stream_class Stream class.
147 * @param event_class Event class to add to the provided stream class.
149 * Returns 0 on success, a negative value on error.
151 extern int bt_ctf_stream_class_add_event_class(
152 struct bt_ctf_stream_class
*stream_class
,
153 struct bt_ctf_event_class
*event_class
);
156 * bt_ctf_stream_class_get_event_class_count: Get a stream class' event class
159 * @param stream_class Stream class.
161 * Returns the stream class' event count, a negative value on error.
163 extern int bt_ctf_stream_class_get_event_class_count(
164 struct bt_ctf_stream_class
*stream_class
);
167 * bt_ctf_stream_class_get_event_class: Get stream class event class by index.
169 * @param stream_class Stream class.
170 * @param index Index of field.
172 * Returns event class, NULL on error.
174 extern struct bt_ctf_event_class
*bt_ctf_stream_class_get_event_class(
175 struct bt_ctf_stream_class
*stream_class
, int index
);
178 * bt_ctf_stream_class_get_event_class_by_name: Get stream class event class by
181 * @param stream_class Stream class.
182 * @param name Event name.
184 * Returns event class, NULL on error.
186 extern struct bt_ctf_event_class
*bt_ctf_stream_class_get_event_class_by_name(
187 struct bt_ctf_stream_class
*stream_class
, const char *name
);
190 * bt_ctf_stream_class_get_event_class_by_name: Get stream class event class by
193 * @param stream_class Stream class.
194 * @param id Event class ID.
196 * Returns event class, NULL on error.
198 extern struct bt_ctf_event_class
*bt_ctf_stream_class_get_event_class_by_id(
199 struct bt_ctf_stream_class
*stream_class
, uint32_t id
);
202 * bt_ctf_stream_class_get_packet_context_type: get the stream class' packet
205 * @param stream_class Stream class.
207 * Returns the packet context's type (a structure), NULL on error.
209 extern struct bt_ctf_field_type
*bt_ctf_stream_class_get_packet_context_type(
210 struct bt_ctf_stream_class
*stream_class
);
213 * bt_ctf_stream_class_set_packet_context_type: set the stream class' packet
216 * @param stream_class Stream class.
217 * @param packet_context_type Packet context type (must be a structure).
219 * Returns 0 on success, a negative value on error.
221 extern int bt_ctf_stream_class_set_packet_context_type(
222 struct bt_ctf_stream_class
*stream_class
,
223 struct bt_ctf_field_type
*packet_context_type
);
226 * bt_ctf_stream_class_get_event_header_type: get the stream class'
229 * @param stream_class Stream class.
231 * Returns the stream event header's type (a structure), NULL on error.
233 extern struct bt_ctf_field_type
*
234 bt_ctf_stream_class_get_event_header_type(
235 struct bt_ctf_stream_class
*stream_class
);
238 * bt_ctf_stream_class_set_event_header_type: set the stream class'
241 * @param stream_class Stream class.
242 * @param event_header_type Event header type (must be a structure).
244 * Returns 0 on success, a negative value on error.
246 extern int bt_ctf_stream_class_set_event_header_type(
247 struct bt_ctf_stream_class
*stream_class
,
248 struct bt_ctf_field_type
*event_header_type
);
251 * bt_ctf_stream_class_get_event_context_type: get the stream class'
252 * event context type.
254 * @param stream_class Stream class.
256 * Returns the stream event context's type (a structure), NULL on error.
258 extern struct bt_ctf_field_type
*
259 bt_ctf_stream_class_get_event_context_type(
260 struct bt_ctf_stream_class
*stream_class
);
263 * bt_ctf_stream_class_set_event_context_type: set the stream class'
264 * event context type.
266 * @param stream_class Stream class.
267 * @param event_context_type Event context type (must be a structure).
269 * Returns 0 on success, a negative value on error.
271 extern int bt_ctf_stream_class_set_event_context_type(
272 struct bt_ctf_stream_class
*stream_class
,
273 struct bt_ctf_field_type
*event_context_type
);
276 * bt_ctf_stream_class_visit: visit a stream class' event classes.
278 * Call visitor on each of a stream class' event classes.
280 * @param stream_class Stream class instance.
281 * @param visitor visitor function to invoke for each stream class.
282 * @param data user data passed to the visitor.
284 * Returns 0 on success, a negative value on error.
286 extern int bt_ctf_stream_class_visit(struct bt_ctf_stream_class
*stream_class
,
287 bt_ctf_ir_visitor visitor
, void *data
);
293 #endif /* BABELTRACE_CTF_IR_STREAM_CLASS_H */