lib: add internal object pool API and use it; adapt plugins/tests
[babeltrace.git] / include / babeltrace / ctf-ir / packet.h
index 126fa20331885a6a12ad5ad7c88796b7219c3bdd..e87a5f806dc86cf23553dcd05c993c66a1706758 100644 (file)
@@ -28,6 +28,9 @@
  * http://www.efficios.com/ctf
  */
 
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
 #include <stdint.h>
 
 #ifdef __cplusplus
@@ -39,6 +42,10 @@ extern "C" {
 @ingroup ctfir
 @brief CTF IR packet.
 
+@code
+#include <babeltrace/ctf-ir/packet.h>
+@endcode
+
 A CTF IR <strong><em>packet</em></strong> is a container of packet
 fields, that is, of the <strong>trace packet header</strong> and
 <strong>stream packet context</strong> fields.
@@ -48,18 +55,18 @@ As a reminder, here's the structure of a CTF packet:
 @imgpacketstructure
 
 You can create a CTF IR packet \em from a
-\link ctfirstream CTF IR stream\endlink with bt_ctf_packet_create(). The
+\link ctfirstream CTF IR stream\endlink with bt_packet_create(). The
 stream you use to create a packet object becomes its parent.
 
 When you set the trace packet header and stream packet context fields of
-a packet with resp. bt_ctf_packet_set_header() and
-bt_ctf_packet_set_context(), their field type \em must be equivalent to
-the field types returned by resp. bt_ctf_trace_get_packet_header_type()
-and bt_ctf_stream_class_get_packet_context_type() for its parent trace
+a packet with resp. bt_packet_set_header() and
+bt_packet_set_context(), their field type \em must be equivalent to
+the field types returned by resp. bt_trace_get_packet_header_type()
+and bt_stream_class_get_packet_context_type() for its parent trace
 class and stream class.
 
 You can attach a packet object to a \link ctfirevent CTF IR
-event\endlink object with bt_ctf_event_set_packet().
+event\endlink object with bt_event_set_packet().
 
 As with any Babeltrace object, CTF IR packet objects have
 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
@@ -85,12 +92,14 @@ except for \link refs reference counting\endlink.
 */
 
 /**
-@struct bt_ctf_packet
+@struct bt_packet
 @brief A CTF IR packet.
 @sa ctfirpacket
 */
-struct bt_ctf_packet;
-struct bt_ctf_stream;
+struct bt_packet;
+struct bt_packet_header_field;
+struct bt_packet_context_field;
+struct bt_stream;
 
 /**
 @name Creation and parent access functions
@@ -103,7 +112,7 @@ struct bt_ctf_stream;
 
 On success, the packet object's trace packet header and stream packet
 context fields are not set. You can set them with resp.
-bt_ctf_packet_set_header() and bt_ctf_packet_set_context().
+bt_packet_set_header() and bt_packet_set_context().
 
 @param[in] stream      Parent CTF IR stream of the packet to create.
 @returns               Created packet, or \c NULL on error.
@@ -111,23 +120,29 @@ bt_ctf_packet_set_header() and bt_ctf_packet_set_context().
 @prenotnull{stream}
 @postsuccessrefcountret1
 */
-extern struct bt_ctf_packet *bt_ctf_packet_create(
-               struct bt_ctf_stream *stream);
+extern struct bt_packet *bt_packet_create(struct bt_stream *stream);
+
+extern struct bt_stream *bt_packet_borrow_stream(struct bt_packet *packet);
 
 /**
 @brief Returns the parent CTF IR stream of the CTF IR packet \p packet.
 
 This function returns a reference to the stream which was used to create
-the packet object in the first place with bt_ctf_packet_create().
+the packet object in the first place with bt_packet_create().
 
 @param[in] packet      Packet of which to get the parent stream.
 @returns               Parent stream of \p packet, or \c NULL on error.
 
 @prenotnull{packet}
+@postrefcountsame{packet}
 @postsuccessrefcountretinc
 */
-extern struct bt_ctf_stream *bt_ctf_packet_get_stream(
-               struct bt_ctf_packet *packet);
+static inline
+struct bt_stream *bt_packet_get_stream(
+               struct bt_packet *packet)
+{
+       return bt_get(bt_packet_borrow_stream(packet));
+}
 
 /** @} */
 
@@ -136,101 +151,21 @@ extern struct bt_ctf_stream *bt_ctf_packet_get_stream(
 @{
 */
 
-/**
-@brief Returns the trace packet header field of the CTF IR packet
-       \p packet.
-
-@param[in] packet      Packet of which to get the trace packet header
-                       field.
-@returns               Trace packet header field of \p packet,
-                       or \c NULL if the trace packet header
-                       field is not set or on error.
-
-@prenotnull{packet}
-@postsuccessrefcountretinc
-
-@sa bt_ctf_packet_set_header(): Sets the trace packet header
-       field of a given packet.
-*/
-extern struct bt_ctf_field *bt_ctf_packet_get_header(
-               struct bt_ctf_packet *packet);
-
-/**
-@brief Sets the trace packet header field of the CTF IR packet
-       \p packet to \p header.
+extern
+struct bt_field *bt_packet_borrow_header(struct bt_packet *packet);
 
-The field type of \p header, as returned by bt_ctf_field_get_type(),
-\em must be equivalent to the field type returned by
-bt_ctf_trace_get_packet_header_type() for the parent trace class
-of \p packet.
+extern
+int bt_packet_move_header(struct bt_packet *packet,
+               struct bt_packet_header_field *header);
 
-@param[in] packet      Packet of which to set the trace packet header
-                       field.
-@param[in] header      Trace packet header field.
-@returns               0 on success, or a negative value on error.
+extern
+struct bt_field *bt_packet_borrow_context(struct bt_packet *packet);
 
-@prenotnull{packet}
-@prenotnull{header}
-@prehot{packet}
-@pre \p header has a field type equivalent to the field type returned by
-       bt_ctf_trace_get_packet_header_type() for the parent trace class
-       of \p packet.
-@postrefcountsame{packet}
-@postsuccessrefcountinc{header}
-
-@sa bt_ctf_packet_get_header(): Returns the trace packet header field
-       of a given packet.
-*/
-extern int bt_ctf_packet_set_header(
-               struct bt_ctf_packet *packet, struct bt_ctf_field *header);
+extern
+int bt_packet_move_context(struct bt_packet *packet,
+               struct bt_packet_context_field *context);
 
-/**
-@brief Returns the stream packet context field of the CTF IR packet
-       \p packet.
-
-@param[in] packet      Packet of which to get the stream packet context
-                       field.
-@returns               Stream packet context field of \p packet,
-                       or \c NULL if the stream packet context
-                       field is not set or on error.
-
-@prenotnull{packet}
-@postsuccessrefcountretinc
-
-@sa bt_ctf_packet_set_context(): Sets the stream packet context
-       field of a given packet.
-*/
-extern struct bt_ctf_field *bt_ctf_packet_get_context(
-               struct bt_ctf_packet *packet);
-
-/**
-@brief Sets the stream packet context field of the CTF IR packet
-       \p packet to \p context.
-
-The field type of \p context, as returned by bt_ctf_field_get_type(),
-\em must be equivalent to the field type returned by
-bt_ctf_stream_class_get_packet_context_type() for the parent stream
-class of \p packet.
-
-@param[in] packet      Packet of which to set the stream packet context
-                       field.
-@param[in] context     Stream packet context field.
-@returns               0 on success, or a negative value on error.
-
-@prenotnull{packet}
-@prenotnull{context}
-@prehot{packet}
-@pre \p context has a field type equivalent to the field type returned
-       by bt_ctf_stream_class_get_packet_context_type() for the parent
-       stream class of \p packet.
-@postrefcountsame{packet}
-@postsuccessrefcountinc{context}
-
-@sa bt_ctf_packet_get_context(): Returns the stream packet context field
-       of a given packet.
-*/
-extern int bt_ctf_packet_set_context(
-               struct bt_ctf_packet *packet, struct bt_ctf_field *context);
+/** @} */
 
 /** @} */
 
This page took 0.02733 seconds and 4 git commands to generate.