1 #ifndef BABELTRACE_CTF_IR_PACKET_H
2 #define BABELTRACE_CTF_IR_PACKET_H
5 * BabelTrace - CTF IR: Stream packet
7 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * The Common Trace Format (CTF) Specification is available at
28 * http://www.efficios.com/ctf
38 @defgroup ctfirpacket CTF IR packet
43 #include <babeltrace/ctf-ir/packet.h>
46 A CTF IR <strong><em>packet</em></strong> is a container of packet
47 fields, that is, of the <strong>trace packet header</strong> and
48 <strong>stream packet context</strong> fields.
50 As a reminder, here's the structure of a CTF packet:
54 You can create a CTF IR packet \em from a
55 \link ctfirstream CTF IR stream\endlink with bt_ctf_packet_create(). The
56 stream you use to create a packet object becomes its parent.
58 When you set the trace packet header and stream packet context fields of
59 a packet with resp. bt_ctf_packet_set_header() and
60 bt_ctf_packet_set_context(), their field type \em must be equivalent to
61 the field types returned by resp. bt_ctf_trace_get_packet_header_type()
62 and bt_ctf_stream_class_get_packet_context_type() for its parent trace
63 class and stream class.
65 You can attach a packet object to a \link ctfirevent CTF IR
66 event\endlink object with bt_ctf_event_set_packet().
68 As with any Babeltrace object, CTF IR packet objects have
69 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
70 counts</a>. See \ref refs to learn more about the reference counting
71 management of Babeltrace objects.
73 bt_notification_event_create() \em freezes its event parameter on
74 success, which in turns freezes the event's associated packet object.
75 This is the only way that a CTF IR packet object can be frozen.
76 You cannot modify a frozen packet: it is considered immutable,
77 except for \link refs reference counting\endlink.
84 @brief CTF IR packet type and functions.
87 @addtogroup ctfirpacket
93 @brief A CTF IR packet.
100 @name Creation and parent access functions
105 @brief Creates a default CTF IR packet with \p stream as its parent
108 On success, the packet object's trace packet header and stream packet
109 context fields are not set. You can set them with resp.
110 bt_ctf_packet_set_header() and bt_ctf_packet_set_context().
112 @param[in] stream Parent CTF IR stream of the packet to create.
113 @returns Created packet, or \c NULL on error.
116 @postsuccessrefcountret1
118 extern struct bt_ctf_packet
*bt_ctf_packet_create(
119 struct bt_ctf_stream
*stream
);
122 @brief Returns the parent CTF IR stream of the CTF IR packet \p packet.
124 This function returns a reference to the stream which was used to create
125 the packet object in the first place with bt_ctf_packet_create().
127 @param[in] packet Packet of which to get the parent stream.
128 @returns Parent stream of \p packet, or \c NULL on error.
131 @postrefcountsame{packet}
132 @postsuccessrefcountretinc
134 extern struct bt_ctf_stream
*bt_ctf_packet_get_stream(
135 struct bt_ctf_packet
*packet
);
140 @name Contained fields functions
145 @brief Returns the trace packet header field of the CTF IR packet
148 @param[in] packet Packet of which to get the trace packet header
150 @returns Trace packet header field of \p packet,
151 or \c NULL if the trace packet header
152 field is not set or on error.
155 @postrefcountsame{packet}
156 @postsuccessrefcountretinc
158 @sa bt_ctf_packet_set_header(): Sets the trace packet header
159 field of a given packet.
161 extern struct bt_ctf_field
*bt_ctf_packet_get_header(
162 struct bt_ctf_packet
*packet
);
165 @brief Sets the trace packet header field of the CTF IR packet
166 \p packet to \p header.
168 The field type of \p header, as returned by bt_ctf_field_get_type(),
169 \em must be equivalent to the field type returned by
170 bt_ctf_trace_get_packet_header_type() for the parent trace class
173 @param[in] packet Packet of which to set the trace packet header
175 @param[in] header Trace packet header field.
176 @returns 0 on success, or a negative value on error.
181 @pre \p header has a field type equivalent to the field type returned by
182 bt_ctf_trace_get_packet_header_type() for the parent trace class
184 @postrefcountsame{packet}
185 @postsuccessrefcountinc{header}
187 @sa bt_ctf_packet_get_header(): Returns the trace packet header field
190 extern int bt_ctf_packet_set_header(
191 struct bt_ctf_packet
*packet
, struct bt_ctf_field
*header
);
194 @brief Returns the stream packet context field of the CTF IR packet
197 @param[in] packet Packet of which to get the stream packet context
199 @returns Stream packet context field of \p packet,
200 or \c NULL if the stream packet context
201 field is not set or on error.
204 @postrefcountsame{packet}
205 @postsuccessrefcountretinc
207 @sa bt_ctf_packet_set_context(): Sets the stream packet context
208 field of a given packet.
210 extern struct bt_ctf_field
*bt_ctf_packet_get_context(
211 struct bt_ctf_packet
*packet
);
214 @brief Sets the stream packet context field of the CTF IR packet
215 \p packet to \p context.
217 The field type of \p context, as returned by bt_ctf_field_get_type(),
218 \em must be equivalent to the field type returned by
219 bt_ctf_stream_class_get_packet_context_type() for the parent stream
222 @param[in] packet Packet of which to set the stream packet context
224 @param[in] context Stream packet context field.
225 @returns 0 on success, or a negative value on error.
230 @pre \p context has a field type equivalent to the field type returned
231 by bt_ctf_stream_class_get_packet_context_type() for the parent
232 stream class of \p packet.
233 @postrefcountsame{packet}
234 @postsuccessrefcountinc{context}
236 @sa bt_ctf_packet_get_context(): Returns the stream packet context field
239 extern int bt_ctf_packet_set_context(
240 struct bt_ctf_packet
*packet
, struct bt_ctf_field
*context
);
248 #endif /* BABELTRACE_CTF_IR_PACKET_H */
This page took 0.036091 seconds and 5 git commands to generate.