Fix: allow NULL (unnamed) in bt_ctf_stream_class_{get,set}_name()
[babeltrace.git] / include / babeltrace / ctf-ir / stream-class.h
index 80febe3d086f7d06b012b0e7608cb0db9d25078c..64400f5201e794bf17c300ae6f66f60a4f664c3d 100644 (file)
@@ -110,7 +110,10 @@ You cannot modify a frozen stream class: it is considered immutable,
 except for:
 
 - Adding an event class to it with
-  bt_ctf_stream_class_add_event_class().
+  bt_ctf_stream_class_add_event_class(). If the stream class's parent
+  \link ctfirtraceclass trace class\endlink is static, however,
+  you cannot call bt_ctf_stream_class_add_event_class()
+  (see bt_ctf_trace_is_static() and bt_ctf_trace_set_is_static()).
 - \link refs Reference counting\endlink.
 
 @sa ctfirstream
@@ -140,6 +143,28 @@ struct bt_ctf_clock;
 @{
 */
 
+/**
+@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_ctf_stream_class_set_packet_context_type(),
+bt_ctf_stream_class_set_event_header_type(), and
+bt_ctf_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_ctf_stream_class_create(): Creates a default stream class.
+*/
+extern struct bt_ctf_stream_class *bt_ctf_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.
@@ -163,11 +188,13 @@ You can modify those default field types after the stream class is
 created with bt_ctf_stream_class_set_packet_context_type() and
 bt_ctf_stream_class_set_event_header_type().
 
-@param[in] name        Name of the stream class to create (can be \c NULL to
-               create an unnamed stream class).
-@returns       Created stream class, or \c NULL on error.
+@param[in] name        Name of the stream class to create (copied on success),
+               or \c NULL to create an unnamed stream class.
+@returns       Created default stream class, or \c NULL on error.
 
 @postsuccessrefcountret1
+
+@sa bt_ctf_stream_class_create_empty(): Creates an empty stream class.
 */
 extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name);
 
@@ -225,17 +252,20 @@ extern const char *bt_ctf_stream_class_get_name(
 
 /**
 @brief Sets the name of the CTF IR stream class
-       \p stream_class to \p name.
+       \p stream_class to \p name, or resets the name of
+       \p stream_class.
 
-\p name must be unique amongst the names of all the stream classes
-of the trace class to which you eventually add \p stream_class.
+If \p name is not \c NULL, it must be unique amongst the names of all
+the stream classes of the trace class to which you eventually add
+\p stream_class.
 
 @param[in] stream_class        Stream class of which to set the name.
-@param[in] name                Name of the stream class (copied on success).
+@param[in] name                Name of the stream class (copied on success), or
+                       \c NULL to reset the name of \p stream_class
+                       (make it unnamed).
 @returns               0 on success, or a negative value on error.
 
 @prenotnull{stream_class}
-@prenotnull{name}
 @prehot{stream_class}
 @postrefcountsame{stream_class}
 
@@ -274,13 +304,14 @@ of the trace class to which you eventually add \p stream_class.
 
 @prenotnull{stream_class}
 @prehot{stream_class}
+@pre \p id is lesser than or equal to 9223372036854775807 (\c INT64_MAX).
 @postrefcountsame{stream_class}
 
 @sa bt_ctf_stream_class_get_id(): Returns the numeric ID of a given
        stream class.
 */
 extern int bt_ctf_stream_class_set_id(
-               struct bt_ctf_stream_class *stream_class, uint32_t id);
+               struct bt_ctf_stream_class *stream_class, uint64_t id);
 
 /** @} */
 
@@ -377,7 +408,7 @@ a stream class without a event header field type.
 As of Babeltrace \btversion, if \p event_header_type is not \c NULL,
 \p event_header_type \em must be a CTF IR structure field type object.
 
-@param[in] trace_class         Trace class of which to set the packet
+@param[in] stream_class                Stream class of which to set the event
                                header field type.
 @param[in] event_header_type   Event header field type, or \c NULL to unset
                                the current event header field type.
@@ -391,8 +422,8 @@ 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_ctf_trace_get_packet_header_type(): Returns the packet
-       header field type of a given trace class.
+@sa bt_ctf_stream_class_get_event_header_type(): Returns the event
+       header field type of a given stream class.
 */
 extern int bt_ctf_stream_class_set_event_header_type(
                struct bt_ctf_stream_class *stream_class,
@@ -474,7 +505,7 @@ extern int bt_ctf_stream_class_set_event_context_type(
 @prenotnull{stream_class}
 @postrefcountsame{stream_class}
 */
-extern int bt_ctf_stream_class_get_event_class_count(
+extern int64_t bt_ctf_stream_class_get_event_class_count(
                struct bt_ctf_stream_class *stream_class);
 
 /**
@@ -493,33 +524,11 @@ extern int bt_ctf_stream_class_get_event_class_count(
 @postrefcountsame{stream_class}
 @postsuccessrefcountretinc
 
-@sa bt_ctf_stream_class_get_event_class_by_id(): Finds an event class
-       by ID.
-@sa bt_ctf_stream_class_get_event_class_by_name(): Finds an event class
-       by name.
-*/
-extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
-               struct bt_ctf_stream_class *stream_class, int index);
-
-/**
-@brief  Returns the event class named \c name found in the CTF IR stream
-       class \p stream_class.
-
-@param[in] stream_class        Stream class of which to get the event class.
-@param[in] name                Name of the event class to find.
-@returns               Event class named \p name, or \c NULL
-                       on error.
-
-@prenotnull{stream_class}
-@prenotnull{name}
-@postrefcountsame{stream_class}
-@postsuccessrefcountretinc
-
 @sa bt_ctf_stream_class_get_event_class_by_id(): Finds an event class
        by ID.
 */
-extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
-               struct bt_ctf_stream_class *stream_class, const char *name);
+extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
+               struct bt_ctf_stream_class *stream_class, uint64_t index);
 
 /**
 @brief  Returns the event class with ID \c id found in the CTF IR stream
@@ -533,12 +542,9 @@ extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
 @prenotnull{stream_class}
 @postrefcountsame{stream_class}
 @postsuccessrefcountretinc
-
-@sa bt_ctf_stream_class_get_event_class_by_name(): Finds an event class
-       by name.
 */
 extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
-               struct bt_ctf_stream_class *stream_class, uint32_t id);
+               struct bt_ctf_stream_class *stream_class, uint64_t id);
 
 /**
 @brief Adds the CTF IR event class \p event_class to the
This page took 0.026576 seconds and 4 git commands to generate.