| Babeltrace 2 C API 2.0.6
    Open-source trace manipulation framework | 
Trace packet.
A packet is a conceptual container of events within a stream.
Some trace formats group events together within packets. This is the case, for example, of the Common Trace Format.
Because a packet could contain millions of events, there are no actual links from a packet to its events. However, there are links from a packet's events to it (see bt_event_borrow_packet() and bt_event_borrow_packet_const()).
A packet can contain a context field which is data associated to all the events of the packet.
A packet is a trace IR data object.
A packet conceptually belongs to a stream. Borrow the stream of a packet with bt_packet_borrow_stream() and bt_packet_borrow_stream_const().
Before you create a packet for a given stream, the stream's class must support packets.
Create a packet with bt_packet_create(). You can then use this packet to create a packet beginning message and a packet end message.
A packet is a shared object: get a new reference with bt_packet_get_ref() and put an existing reference with bt_packet_put_ref().
Some library functions freeze packets on success. The documentation of those functions indicate this postcondition.
The type of a packet is bt_packet.
A packet has the following property:
Packet's context field.
The context of a packet contains data associated to all its events.
The class of a packet's context field is set at the packet's stream class level. See bt_stream_class_set_packet_context_field_class() bt_stream_class_borrow_packet_context_field_class(), and bt_stream_class_borrow_packet_context_field_class_const()
Use bt_packet_borrow_context_field() and bt_packet_borrow_context_field_const().
| Creation | |
| bt_packet * | bt_packet_create (const bt_stream *stream) | 
| Creates a packet for the stream stream. | |
| Stream access | |
| bt_stream * | bt_packet_borrow_stream (bt_packet *packet) | 
| Borrows the stream conceptually containing the packet packet. | |
| const bt_stream * | bt_packet_borrow_stream_const (const bt_packet *packet) | 
| Borrows the stream conceptually containing the packet packet ( constversion). | |
| Property | |
| bt_field * | bt_packet_borrow_context_field (bt_packet *packet) | 
| Borrows the context field of the packet packet. | |
| const bt_field * | bt_packet_borrow_context_field_const (const bt_packet *packet) | 
| Borrows the context field of the packet packet ( constversion). | |
| Reference count | |
| void | bt_packet_get_ref (const bt_packet *packet) | 
| Increments the reference count of the packet packet. | |
| void | bt_packet_put_ref (const bt_packet *packet) | 
| Decrements the reference count of the packet packet. | |
| #define | BT_PACKET_PUT_REF_AND_RESET(_packet) | 
| Decrements the reference count of the packet _packet, and then sets _packet to NULL. | |
| #define | BT_PACKET_MOVE_REF(_dst, _src) | 
| Decrements the reference count of the packet _dst, sets _dst to _src, and then sets _src to NULL. | |
| Type | |
| typedef struct bt_packet | bt_packet | 
| Packet. | |
| #define BT_PACKET_PUT_REF_AND_RESET | ( | _packet | ) | 
Decrements the reference count of the packet _packet, and then sets _packet to NULL. 
| _packet | Packet of which to decrement the reference count. Can contain  | 
| #define BT_PACKET_MOVE_REF | ( | _dst, | |
| _src ) | 
Decrements the reference count of the packet _dst, sets _dst to _src, and then sets _src to NULL. 
This macro effectively moves a packet reference from the expression _src to the expression _dst, putting the existing _dst reference.
| _dst | Destination expression. Can contain  | 
| _src | Source expression. Can contain  | 
Creates a packet for the stream stream.
Only use this function if
returns BT_TRUE.
On success, the returned packet has the following property value:
| Property | Value | 
|---|---|
| Context field | Unset instance of the packet context field class of the class of stream. | 
| [in] | stream | Stream for which to create the packet. | 
NULL on memory error.bt_stream_class_supports_packets(bt_stream_borrow_class_const(stream)) returns BT_TRUE. Borrows the stream conceptually containing the packet packet.
| [in] | packet | Packet of which to borrow the stream conceptually containing it. | 
NULL.const version of this function. Borrows the stream conceptually containing the packet packet (const version). 
Borrows the context field of the packet packet.
See the context field property.
| [in] | packet | Packet of which to borrow the context field. | 
NULL if none.NULL.const version of this function. Borrows the context field of the packet packet (const version). 
| 
 | extern | 
Increments the reference count of the packet packet.
| [in] | packet | Packet of which to increment the reference count. Can be  | 
| 
 | extern | 
Decrements the reference count of the packet packet.
| [in] | packet | Packet of which to decrement the reference count. Can be  |