52d110ee1372d893eb1ee1c91fccc4362771ef09
1 #ifndef BABELTRACE2_TRACE_IR_PACKET_H
2 #define BABELTRACE2_TRACE_IR_PACKET_H
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
32 #include <babeltrace2/types.h>
39 @defgroup api-tir-pkt Packet
45 A <strong><em>packet</em></strong> is a conceptual container of
46 \bt_p_ev within a \bt_stream.
48 Some trace formats group events together within packets. This is the
49 case, for example, of the
50 <a href="https://diamon.org/ctf/">Common Trace Format</a>.
52 Because a packet could contain millions of events, there are no actual
53 links from a packet to its events. However, there are links from a
54 packet's events to it (see bt_event_borrow_packet() and
55 bt_event_borrow_packet_const()).
57 A packet can contain a context \bt_field which is data associated to
58 all the events of the packet.
60 A packet is a \ref api-tir "trace IR" data object.
62 A packet conceptually belongs to a \bt_stream. Borrow the stream of a
63 packet with bt_packet_borrow_stream() and
64 bt_packet_borrow_stream_const().
66 Before you create a packet for a given stream, the stream's class must
67 \ref api-tir-stream-cls-prop-supports-pkt "support packets".
69 Create a packet with bt_packet_create(). You can then use this packet to
70 create a \bt_pb_msg and a \bt_pe_msg.
72 A packet is a \ref api-fund-shared-object "shared object": get a
73 new reference with bt_packet_get_ref() and put an existing
74 reference with bt_packet_put_ref().
76 Some library functions \ref api-fund-freezing "freeze" packets on
77 success. The documentation of those functions indicate this
80 The type of a packet is #bt_packet.
84 A packet has the following property:
87 <dt>\anchor api-tir-pkt-prop-ctx Context field</dt>
89 Packet's context \bt_field.
91 The context of a packet contains data associated to all its
94 The \ref api-tir-fc "class" of a packet's context field is set
95 at the packet's \bt_stream_cls level. See
96 bt_stream_class_set_packet_context_field_class()
97 bt_stream_class_borrow_packet_context_field_class(),
98 and bt_stream_class_borrow_packet_context_field_class_const()
100 Use bt_packet_borrow_context_field() and
101 bt_packet_borrow_context_field_const().
112 @typedef struct bt_packet bt_packet;
127 Creates a packet for the \bt_stream \bt_p{stream}.
131 Only use this function if
134 bt_stream_class_supports_packets(bt_stream_borrow_class_const(stream))
140 On success, the returned packet has the following property value:
147 <td>\ref api-tir-pkt-prop-ctx "Context field"
149 Unset instance of the
150 \ref api-tir-stream-cls-prop-pc-fc "packet context field class" of
151 the \ref api-tir-stream-cls "class" of \bt_p{stream}.
155 Stream for which to create the packet.
158 New packet reference, or \c NULL on memory error.
161 <code>bt_stream_class_supports_packets(bt_stream_borrow_class_const(stream))</code>
164 extern bt_packet
*bt_packet_create(const bt_stream
*stream
);
175 Borrows the \bt_stream conceptually containing the packet
179 Packet of which to borrow the stream conceptually containing it.
182 \em Borrowed reference of the stream conceptually containing
185 @bt_pre_not_null{packet}
187 @sa bt_packet_borrow_stream_const() —
188 \c const version of this function.
190 extern bt_stream
*bt_packet_borrow_stream(bt_packet
*packet
);
194 Borrows the \bt_stream conceptually containing the packet
195 \bt_p{packet} (\c const version).
197 See bt_packet_borrow_stream().
199 extern const bt_stream
*bt_packet_borrow_stream_const(
200 const bt_packet
*packet
);
211 Borrows the context \bt_field of the packet \bt_p{packet}.
213 See the \ref api-tir-pkt-prop-ctx "context field" property.
216 Packet of which to borrow the context field.
219 \em Borrowed reference of the context field of
220 \bt_p{packet}, or \c NULL if none.
222 @bt_pre_not_null{packet}
224 @sa bt_packet_borrow_context_field_const() —
225 \c const version of this function.
228 bt_field
*bt_packet_borrow_context_field(bt_packet
*packet
);
232 Borrows the context \bt_field of the packet \bt_p{packet}
235 See bt_packet_borrow_context_field().
238 const bt_field
*bt_packet_borrow_context_field_const(
239 const bt_packet
*packet
);
244 @name Reference count
250 Increments the \ref api-fund-shared-object "reference count" of
251 the packet \bt_p{packet}.
255 Packet of which to increment the reference count.
260 @sa bt_packet_put_ref() —
261 Decrements the reference count of a packet.
263 extern void bt_packet_get_ref(const bt_packet
*packet
);
267 Decrements the \ref api-fund-shared-object "reference count" of
268 the packet \bt_p{packet}.
272 Packet of which to decrement the reference count.
277 @sa bt_packet_get_ref() —
278 Increments the reference count of a packet.
280 extern void bt_packet_put_ref(const bt_packet
*packet
);
284 Decrements the reference count of the packet
285 \bt_p{_packet}, and then sets \bt_p{_packet} to \c NULL.
289 Packet of which to decrement the reference count.
294 @bt_pre_assign_expr{_packet}
296 #define BT_PACKET_PUT_REF_AND_RESET(_packet) \
298 bt_packet_put_ref(_packet); \
304 Decrements the reference count of the packet \bt_p{_dst}, sets
305 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
307 This macro effectively moves a packet reference from the expression
308 \bt_p{_src} to the expression \bt_p{_dst}, putting the existing
309 \bt_p{_dst} reference.
313 Destination expression.
324 @bt_pre_assign_expr{_dst}
325 @bt_pre_assign_expr{_src}
327 #define BT_PACKET_MOVE_REF(_dst, _src) \
329 bt_packet_put_ref(_dst); \
342 #endif /* BABELTRACE2_TRACE_IR_PACKET_H */
This page took 0.038052 seconds and 3 git commands to generate.