e87a5f806dc86cf23553dcd05c993c66a1706758
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
32 #include <babeltrace/ref.h>
41 @defgroup ctfirpacket CTF IR packet
46 #include <babeltrace/ctf-ir/packet.h>
49 A CTF IR <strong><em>packet</em></strong> is a container of packet
50 fields, that is, of the <strong>trace packet header</strong> and
51 <strong>stream packet context</strong> fields.
53 As a reminder, here's the structure of a CTF packet:
57 You can create a CTF IR packet \em from a
58 \link ctfirstream CTF IR stream\endlink with bt_packet_create(). The
59 stream you use to create a packet object becomes its parent.
61 When you set the trace packet header and stream packet context fields of
62 a packet with resp. bt_packet_set_header() and
63 bt_packet_set_context(), their field type \em must be equivalent to
64 the field types returned by resp. bt_trace_get_packet_header_type()
65 and bt_stream_class_get_packet_context_type() for its parent trace
66 class and stream class.
68 You can attach a packet object to a \link ctfirevent CTF IR
69 event\endlink object with bt_event_set_packet().
71 As with any Babeltrace object, CTF IR packet objects have
72 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
73 counts</a>. See \ref refs to learn more about the reference counting
74 management of Babeltrace objects.
76 bt_notification_event_create() \em freezes its event parameter on
77 success, which in turns freezes the event's associated packet object.
78 This is the only way that a CTF IR packet object can be frozen.
79 You cannot modify a frozen packet: it is considered immutable,
80 except for \link refs reference counting\endlink.
87 @brief CTF IR packet type and functions.
90 @addtogroup ctfirpacket
96 @brief A CTF IR packet.
100 struct bt_packet_header_field
;
101 struct bt_packet_context_field
;
105 @name Creation and parent access functions
110 @brief Creates a default CTF IR packet with \p stream as its parent
113 On success, the packet object's trace packet header and stream packet
114 context fields are not set. You can set them with resp.
115 bt_packet_set_header() and bt_packet_set_context().
117 @param[in] stream Parent CTF IR stream of the packet to create.
118 @returns Created packet, or \c NULL on error.
121 @postsuccessrefcountret1
123 extern struct bt_packet
*bt_packet_create(struct bt_stream
*stream
);
125 extern struct bt_stream
*bt_packet_borrow_stream(struct bt_packet
*packet
);
128 @brief Returns the parent CTF IR stream of the CTF IR packet \p packet.
130 This function returns a reference to the stream which was used to create
131 the packet object in the first place with bt_packet_create().
133 @param[in] packet Packet of which to get the parent stream.
134 @returns Parent stream of \p packet, or \c NULL on error.
137 @postrefcountsame{packet}
138 @postsuccessrefcountretinc
141 struct bt_stream
*bt_packet_get_stream(
142 struct bt_packet
*packet
)
144 return bt_get(bt_packet_borrow_stream(packet
));
150 @name Contained fields functions
155 struct bt_field
*bt_packet_borrow_header(struct bt_packet
*packet
);
158 int bt_packet_move_header(struct bt_packet
*packet
,
159 struct bt_packet_header_field
*header
);
162 struct bt_field
*bt_packet_borrow_context(struct bt_packet
*packet
);
165 int bt_packet_move_context(struct bt_packet
*packet
,
166 struct bt_packet_context_field
*context
);
176 #endif /* BABELTRACE_CTF_IR_PACKET_H */
This page took 0.032647 seconds and 4 git commands to generate.