1 #ifndef BABELTRACE_CTF_WRITER_STREAM_H
2 #define BABELTRACE_CTF_WRITER_STREAM_H
5 * BabelTrace - CTF Writer: Stream
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
33 #include <babeltrace/ctf-ir/event.h>
34 #include <babeltrace/ctf-ir/stream.h>
35 #include <babeltrace/ctf-writer/stream-class.h>
42 * bt_stream_get_discarded_events_count: get the number of discarded
43 * events associated with this stream.
45 * Note that discarded events are not stored if the stream's packet
46 * context has no "events_discarded" field. An error will be returned
49 * @param stream Stream instance.
51 * Returns the number of discarded events, a negative value on error.
53 extern int bt_stream_get_discarded_events_count(
54 struct bt_stream
*stream
, uint64_t *count
);
57 * bt_stream_append_discarded_events: increment discarded events count.
59 * Increase the current packet's discarded event count. Has no effect if the
60 * stream class' packet context has no "events_discarded" field.
62 * @param stream Stream instance.
63 * @param event_count Number of discarded events to add to the stream's current
66 extern void bt_stream_append_discarded_events(struct bt_stream
*stream
,
67 uint64_t event_count
);
70 * bt_stream_append_event: append an event to the stream.
72 * Append "event" to the stream's current packet. The stream's associated clock
73 * will be sampled during this call. The event shall not be modified after
74 * being appended to a stream. The stream will share the event's ownership by
75 * incrementing its reference count. The current packet is not flushed to disk
76 * until the next call to bt_stream_flush.
78 * The stream event context will be sampled for every appended event if
79 * a stream event context was defined.
81 * @param stream Stream instance.
82 * @param event Event instance to append to the stream's current packet.
84 * Returns 0 on success, a negative value on error.
86 extern int bt_stream_append_event(struct bt_stream
*stream
,
87 struct bt_event
*event
);
90 * bt_stream_get_packet_header: get a stream's packet header.
92 * @param stream Stream instance.
94 * Returns a field instance on success, NULL on error.
96 extern struct bt_field
*bt_stream_get_packet_header(
97 struct bt_stream
*stream
);
100 * bt_stream_set_packet_header: set a stream's packet header.
102 * The packet header's type must match the trace's packet header
105 * @param stream Stream instance.
106 * @param packet_header Packet header instance.
108 * Returns a field instance on success, NULL on error.
110 extern int bt_stream_set_packet_header(
111 struct bt_stream
*stream
,
112 struct bt_field
*packet_header
);
115 * bt_stream_get_packet_context: get a stream's packet context.
117 * @param stream Stream instance.
119 * Returns a field instance on success, NULL on error.
121 extern struct bt_field
*bt_stream_get_packet_context(
122 struct bt_stream
*stream
);
125 * bt_stream_set_packet_context: set a stream's packet context.
127 * The packet context's type must match the stream class' packet
130 * @param stream Stream instance.
131 * @param packet_context Packet context field instance.
133 * Returns a field instance on success, NULL on error.
135 extern int bt_stream_set_packet_context(
136 struct bt_stream
*stream
,
137 struct bt_field
*packet_context
);
140 * bt_stream_flush: flush a stream.
142 * The stream's current packet's events will be flushed, thus closing the
143 * current packet. Events subsequently appended to the stream will be
144 * added to a new packet.
146 * Flushing will also set the packet context's default attributes if
147 * they remained unset while populating the current packet. These default
148 * attributes, along with their expected types, are detailed in stream-class.h.
150 * @param stream Stream instance.
152 * Returns 0 on success, a negative value on error.
154 extern int bt_stream_flush(struct bt_stream
*stream
);
156 extern int bt_stream_is_writer(struct bt_stream
*stream
);
158 /* Pre-2.0 CTF writer compatibility */
159 #define bt_ctf_stream_get_discarded_events_count bt_stream_get_discarded_events_count
160 #define bt_ctf_stream_append_discarded_events bt_stream_append_discarded_events
161 #define bt_ctf_stream_append_event bt_stream_append_event
162 #define bt_ctf_stream_get_packet_context bt_stream_get_packet_context
163 #define bt_ctf_stream_flush bt_stream_flush
165 extern void bt_ctf_stream_get(struct bt_stream
*stream
);
166 extern void bt_ctf_stream_put(struct bt_stream
*stream
);
172 #endif /* BABELTRACE_CTF_WRITER_STREAM_H */
This page took 0.034106 seconds and 4 git commands to generate.