lib: add internal object pool API and use it; adapt plugins/tests
[babeltrace.git] / include / babeltrace / ctf-ir / stream-class.h
index 175bb68850f5db89964fe55f924fff7c231a1720..225ea45079a28c4d023194975ea9acc39adb56db 100644 (file)
@@ -32,6 +32,9 @@
 
 #include <stdint.h>
 
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
 /* For bt_visitor */
 #include <babeltrace/ctf-ir/visitor.h>
 
@@ -139,34 +142,14 @@ except for:
 struct bt_stream_class;
 struct bt_event_class;
 struct bt_clock;
+struct bt_event_header_field;
+struct bt_packet_context_field;
 
 /**
 @name Creation and parent access functions
 @{
 */
 
-/**
-@brief Creates an empty CTF IR stream class named \p name, or an
-       unnamed empty stream class if \p name is \c NULL.
-
-On success, the packet context, event header, and event context field
-types are empty structure field types. You can modify those default
-field types after the stream class is created with
-bt_stream_class_set_packet_context_type(),
-bt_stream_class_set_event_header_type(), and
-bt_stream_class_set_event_context_type().
-
-@param[in] name        Name of the stream class to create (copied on success),
-               or \c NULL to create an unnamed stream class.
-@returns       Created empty stream class, or \c NULL on error.
-
-@postsuccessrefcountret1
-
-@sa bt_stream_class_create(): Creates a default stream class.
-*/
-extern struct bt_stream_class *bt_stream_class_create_empty(
-               const char *name);
-
 /**
 @brief Creates a default CTF IR stream class named \p nameĀ­, or a
        default unnamed stream class if \p name is \c NULL.
@@ -187,8 +170,8 @@ has the following fields:
 - <code>timestamp</code>: a 64-bit unsigned integer field type.
 
 You can modify those default field types after the stream class is
-created with bt_stream_class_set_packet_context_type() and
-bt_stream_class_set_event_header_type().
+created with bt_stream_class_set_packet_context_field_type() and
+bt_stream_class_set_event_header_field_type().
 
 @param[in] name        Name of the stream class to create (copied on success),
                or \c NULL to create an unnamed stream class.
@@ -200,6 +183,9 @@ bt_stream_class_set_event_header_type().
 */
 extern struct bt_stream_class *bt_stream_class_create(const char *name);
 
+extern struct bt_trace *bt_stream_class_borrow_trace(
+               struct bt_stream_class *stream_class);
+
 /**
 @brief Returns the parent CTF IR trace class of the CTF IR stream
        class \p stream_class.
@@ -222,8 +208,12 @@ bt_trace_add_stream_class().
 @sa bt_trace_add_stream_class(): Add a stream class to
        a trace class.
 */
-extern struct bt_trace *bt_stream_class_get_trace(
-               struct bt_stream_class *stream_class);
+static inline
+struct bt_trace *bt_stream_class_get_trace(
+               struct bt_stream_class *stream_class)
+{
+       return bt_get(bt_stream_class_borrow_trace(stream_class));
+}
 
 /** @} */
 
@@ -322,6 +312,9 @@ extern int bt_stream_class_set_id(
 @{
 */
 
+extern struct bt_field_type *bt_stream_class_borrow_packet_context_field_type(
+               struct bt_stream_class *stream_class);
+
 /**
 @brief Returns the packet context field type of the CTF IR stream class
        \p stream_class.
@@ -337,10 +330,19 @@ extern int bt_stream_class_set_id(
 @post <strong>On success, if the return value is a field type</strong>, its
        reference count is incremented.
 
-@sa bt_stream_class_set_packet_context_type(): Sets the packet
+@sa bt_stream_class_set_packet_context_field_type(): Sets the packet
        context field type of a given stream class.
 */
-extern struct bt_field_type *bt_stream_class_get_packet_context_type(
+static inline
+struct bt_field_type *bt_stream_class_get_packet_context_field_type(
+               struct bt_stream_class *stream_class)
+{
+       return bt_get(bt_stream_class_borrow_packet_context_field_type(
+               stream_class));
+}
+
+extern
+struct bt_packet_context_field *bt_stream_class_create_packet_context_field(
                struct bt_stream_class *stream_class);
 
 /**
@@ -369,13 +371,17 @@ As of Babeltrace \btversion, if \p packet_context_type is not \c NULL,
 @post <strong>On success, if \p packet_context_type is not \c NULL</strong>,
        the reference count of \p packet_context_type is incremented.
 
-@sa bt_stream_class_get_packet_context_type(): Returns the packet
+@sa bt_stream_class_get_packet_context_field_type(): Returns the packet
        context field type of a given stream class.
 */
-extern int bt_stream_class_set_packet_context_type(
+extern int bt_stream_class_set_packet_context_field_type(
                struct bt_stream_class *stream_class,
                struct bt_field_type *packet_context_type);
 
+extern struct bt_field_type *
+bt_stream_class_borrow_event_header_field_type(
+               struct bt_stream_class *stream_class);
+
 /**
 @brief Returns the event header field type of the CTF IR stream class
        \p stream_class.
@@ -391,12 +397,16 @@ extern int bt_stream_class_set_packet_context_type(
 @post <strong>On success, if the return value is a field type</strong>, its
        reference count is incremented.
 
-@sa bt_stream_class_set_event_header_type(): Sets the event
+@sa bt_stream_class_set_event_header_field_type(): Sets the event
        header field type of a given stream class.
 */
-extern struct bt_field_type *
-bt_stream_class_get_event_header_type(
-               struct bt_stream_class *stream_class);
+static inline
+struct bt_field_type *bt_stream_class_get_event_header_field_type(
+               struct bt_stream_class *stream_class)
+{
+       return bt_get(bt_stream_class_borrow_event_header_field_type(
+               stream_class));
+}
 
 /**
 @brief Sets the event header field type of the CTF IR stream class
@@ -424,13 +434,20 @@ As of Babeltrace \btversion, if \p event_header_type is not \c NULL,
 @post <strong>On success, if \p event_header_type is not \c NULL</strong>,
        the reference count of \p event_header_type is incremented.
 
-@sa bt_stream_class_get_event_header_type(): Returns the event
+@sa bt_stream_class_get_event_header_field_type(): Returns the event
        header field type of a given stream class.
 */
-extern int bt_stream_class_set_event_header_type(
+extern int bt_stream_class_set_event_header_field_type(
                struct bt_stream_class *stream_class,
                struct bt_field_type *event_header_type);
 
+extern struct bt_event_header_field *bt_stream_class_create_event_header_field(
+               struct bt_stream_class *stream_class);
+
+extern struct bt_field_type *
+bt_stream_class_borrow_event_context_field_type(
+               struct bt_stream_class *stream_class);
+
 /**
 @brief Returns the event context field type of the CTF IR stream class
        \p stream_class.
@@ -447,12 +464,17 @@ extern int bt_stream_class_set_event_header_type(
        its reference count is incremented.
 
 
-@sa bt_stream_class_set_event_context_type(): Sets the event
+@sa bt_stream_class_set_event_context_field_type(): Sets the event
        context field type of a given stream class.
 */
-extern struct bt_field_type *
-bt_stream_class_get_event_context_type(
-               struct bt_stream_class *stream_class);
+static inline
+struct bt_field_type *
+bt_stream_class_get_event_context_field_type(
+               struct bt_stream_class *stream_class)
+{
+       return bt_get(bt_stream_class_borrow_event_context_field_type(
+               stream_class));
+}
 
 /**
 @brief Sets the event context field type of the CTF IR stream class
@@ -480,10 +502,10 @@ As of Babeltrace \btversion, if \p event_context_type is not \c NULL,
 @post <strong>On success, if \p event_context_type is not \c NULL</strong>,
        the reference count of \p event_context_type is incremented.
 
-@sa bt_stream_class_get_event_context_type(): Returns the event context
+@sa bt_stream_class_get_event_context_field_type(): Returns the event context
        field type of a given stream class.
 */
-extern int bt_stream_class_set_event_context_type(
+extern int bt_stream_class_set_event_context_field_type(
                struct bt_stream_class *stream_class,
                struct bt_field_type *event_context_type);
 
@@ -510,6 +532,9 @@ extern int bt_stream_class_set_event_context_type(
 extern int64_t bt_stream_class_get_event_class_count(
                struct bt_stream_class *stream_class);
 
+extern struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
+               struct bt_stream_class *stream_class, uint64_t index);
+
 /**
 @brief  Returns the event class at index \p index in the CTF IR stream
        class \p stream_class.
@@ -529,8 +554,16 @@ extern int64_t bt_stream_class_get_event_class_count(
 @sa bt_stream_class_get_event_class_by_id(): Finds an event class
        by ID.
 */
-extern struct bt_event_class *bt_stream_class_get_event_class_by_index(
-               struct bt_stream_class *stream_class, uint64_t index);
+static inline
+struct bt_event_class *bt_stream_class_get_event_class_by_index(
+               struct bt_stream_class *stream_class, uint64_t index)
+{
+       return bt_get(bt_stream_class_borrow_event_class_by_index(stream_class,
+               index));
+}
+
+extern struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
+               struct bt_stream_class *stream_class, uint64_t id);
 
 /**
 @brief  Returns the event class with ID \c id found in the CTF IR stream
@@ -545,8 +578,13 @@ extern struct bt_event_class *bt_stream_class_get_event_class_by_index(
 @postrefcountsame{stream_class}
 @postsuccessrefcountretinc
 */
-extern struct bt_event_class *bt_stream_class_get_event_class_by_id(
-               struct bt_stream_class *stream_class, uint64_t id);
+static inline
+struct bt_event_class *bt_stream_class_get_event_class_by_id(
+               struct bt_stream_class *stream_class, uint64_t id)
+{
+       return bt_get(bt_stream_class_borrow_event_class_by_id(stream_class,
+               id));
+}
 
 /**
 @brief Adds the CTF IR event class \p event_class to the
@@ -621,12 +659,6 @@ extern int bt_stream_class_visit(struct bt_stream_class *stream_class,
 
 /** @} */
 
-/* Pre-2.0 CTF writer compatibility */
-#define bt_ctf_stream_class bt_stream_class
-#define bt_ctf_stream_class_create bt_stream_class_create
-#define bt_ctf_stream_class_add_event_class bt_stream_class_add_event_class
-#define bt_ctf_stream_class_get_packet_context_type bt_stream_class_get_packet_context_type
-
 #ifdef __cplusplus
 }
 #endif
This page took 0.026547 seconds and 4 git commands to generate.