ALIASES += bt_pre_field_with_mip{2}="@pre The class of \bt_p{\1} was created from a \bt_trace_cls which was created from a \bt_comp which belongs to a trace processing \bt_graph with the effective \bt_mip version \2."
ALIASES += bt_pre_trace_with_mip{2}="@pre The \link api-tir-trace-cls class\endlink of \bt_p{\1} was created from a \bt_comp which belongs to a trace processing \bt_graph with the effective \bt_mip version \2."
ALIASES += bt_pre_clock_cls_with_mip{2}="@pre \bt_p{\1} was created from a \bt_comp which belongs to a trace processing \bt_graph with the effective \bt_mip version \2."
+ALIASES += bt_pre_stream_cls_with_mip{2}="@pre \bt_p{\1} was created from a \bt_trace_cls which was created from a \bt_comp which belongs to a trace processing \bt_graph with the effective \bt_mip version \2."
# Aliases: field class object types: singular
ALIASES += bt_fc="\link api-tir-fc field class\endlink"
Get a stream class's numeric ID with bt_stream_class_get_id().
</dd>
+ <dt>
+ \anchor api-tir-stream-cls-prop-ns
+ \bt_dt_opt Namespace
+ (only available when the parent \bt_trace_cls was created
+ from a \bt_comp which belongs to a trace processing \bt_graph
+ with the effective \bt_mip version 1)
+ </dt>
+ <dd>
+ Namespace of the stream class.
+
+ Use bt_stream_class_set_namespace() and
+ bt_stream_class_get_namespace().
+ </dd>
+
<dt>\anchor api-tir-stream-cls-prop-name \bt_dt_opt Name</dt>
<dd>
Name of the stream class.
<tr>
<td>\ref api-tir-stream-cls-prop-id "Numeric ID"
<td>Automatically assigned by \bt_p{trace_class}
+ <tr>
+ <td>\bt_mip version 1: \ref api-tir-stream-cls-prop-ns "namespace"
+ <td>\em None
<tr>
<td>\ref api-tir-stream-cls-prop-name "Name"
<td>\em None
<tr>
<td>\ref api-tir-stream-cls-prop-id "Numeric ID"
<td>\bt_p{id}
+ <tr>
+ <td>\bt_mip version 1: \ref api-tir-stream-cls-prop-ns "namespace"
+ <td>\em None
<tr>
<td>\ref api-tir-stream-cls-prop-name "Name"
<td>\em None
extern uint64_t bt_stream_class_get_id(
const bt_stream_class *stream_class) __BT_NOEXCEPT;
+/*!
+@brief
+ Status codes for bt_stream_class_set_namespace().
+*/
+typedef enum bt_stream_class_set_namespace_status {
+ /*!
+ @brief
+ Success.
+ */
+ BT_STREAM_CLASS_SET_NAMESPACE_STATUS_OK = __BT_FUNC_STATUS_OK,
+
+ /*!
+ @brief
+ Out of memory.
+ */
+ BT_STREAM_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_stream_class_set_namespace_status;
+
+/*!
+@brief
+ Sets the namespace of the stream class \bt_p{stream_class} to
+ a copy of \bt_p{ns}.
+
+See the \ref api-tir-stream-cls-prop-ns "namespace" property.
+
+@param[in] stream_class
+ Stream class of which to set the namespace to \bt_p{ns}.
+@param[in] name
+ New namespace of \bt_p{stream_class} (copied).
+
+@retval #BT_STREAM_CLASS_SET_NAMESPACE_STATUS_OK
+ Success.
+@retval #BT_STREAM_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR
+ Out of memory.
+
+@bt_pre_not_null{stream_class}
+@bt_pre_hot{stream_class}
+@bt_pre_stream_cls_with_mip{stream_class, 1}
+@bt_pre_not_null{ns}
+
+@sa bt_stream_class_get_namespace() —
+ Returns the namespace of a stream class.
+*/
+extern bt_stream_class_set_namespace_status bt_stream_class_set_namespace(
+ bt_stream_class *stream_class, const char *ns) __BT_NOEXCEPT;
+
+/*!
+@brief
+ Returns the namespace of the stream class \bt_p{stream_class}.
+
+See the \ref api-tir-stream-cls-prop-ns "namespace" property.
+
+If \bt_p{stream_class} has no namespace, this function returns \c NULL.
+
+@param[in] stream_class
+ Stream class of which to get the namespace.
+
+@returns
+ @parblock
+ Namespace of \bt_p{stream_class}, or \c NULL if none.
+
+ The returned pointer remains valid as long as \bt_p{stream_class}
+ is not modified.
+ @endparblock
+
+@bt_pre_not_null{stream_class}
+@bt_pre_stream_cls_with_mip{stream_class, 1}
+
+@sa bt_stream_class_set_namespace() —
+ Sets the namespace of a stream class.
+*/
+extern const char *bt_stream_class_get_namespace(
+ const bt_stream_class *stream_class) __BT_NOEXCEPT;
+
/*!
@brief
Status codes for bt_stream_class_set_name().
#define BT_ASSERT_PRE_TC_MIP_VERSION_GE(_trace_class, _val) \
BT_ASSERT_PRE_MIP_VERSION_GE((_trace_class)->mip_version, _val)
+/*
+ * Asserts that the effective MIP version for `_stream_class` is greater than or
+ * equal to `_val`.
+ */
+#define BT_ASSERT_PRE_SC_MIP_VERSION_GE(_stream_class, _val) \
+ BT_ASSERT_PRE_TC_MIP_VERSION_GE( \
+ bt_stream_class_borrow_trace_class_inline(_stream_class), \
+ _val)
+
/*
* Asserts that the effective MIP version for `_field_class` is equal to `_val`.
*/
#define BT_ASSERT_PRE_FC_MIP_VERSION_EQ(_field_class, _val) \
BT_ASSERT_PRE_MIP_VERSION_EQ((_field_class)->mip_version, _val)
-/* Asserts that the effective MIP version for `_field_class` is equal to `_val`. */
+/*
+ * Asserts that the effective MIP version for `_field_class` is equal to `_val`.
+ */
#define BT_ASSERT_PRE_DEV_FC_MIP_VERSION_EQ(_field_class, _val) \
BT_ASSERT_PRE_DEV_MIP_VERSION_EQ((_field_class)->mip_version, _val)
#define _BT_ASSERT_PRE_NAMESPACE_NAME "Namespace"
#define _BT_ASSERT_PRE_NAMESPACE_ID "namespace"
-#define BT_ASSERT_PRE_NAMESPACE_NON_NULL(_name) \
- BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAMESPACE_ID, (_name), \
+#define BT_ASSERT_PRE_NAMESPACE_NON_NULL(_namespace) \
+ BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAMESPACE_ID, (_namespace), \
_BT_ASSERT_PRE_NAMESPACE_NAME)
#define _BT_ASSERT_PRE_DESCR_NAME "Description"
BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id));
+ if (stream_class->ns) {
+ BUF_APPEND(", %snamespace=\"%s\"", PRFIELD(stream_class->ns));
+ }
+
if (stream_class->name) {
- BUF_APPEND(", %sname=\"%s\"",
- PRFIELD(stream_class->name));
+ BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream_class->name));
}
if (!extended) {
stream_class->event_classes = NULL;
}
+ g_free(stream_class->ns);
g_free(stream_class->name);
BT_LOGD_STR("Putting packet context field class.");
BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc);
return bt_stream_class_borrow_trace_class((void *) stream_class);
}
+BT_EXPORT
+const char *bt_stream_class_get_namespace(
+ const struct bt_stream_class *stream_class)
+{
+ BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
+ BT_ASSERT_PRE_SC_MIP_VERSION_GE(stream_class, 1);
+ return stream_class->ns;
+}
+
+BT_EXPORT
+enum bt_stream_class_set_namespace_status bt_stream_class_set_namespace(
+ struct bt_stream_class *stream_class,
+ const char *ns)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_SC_NON_NULL(stream_class);
+ BT_ASSERT_PRE_SC_MIP_VERSION_GE(stream_class, 1);
+ BT_ASSERT_PRE_NAMESPACE_NON_NULL(ns);
+ BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
+ g_free(stream_class->ns);
+ stream_class->ns = g_strdup(ns);
+ BT_LIB_LOGD("Set stream class's namespace: %!+S", stream_class);
+ return BT_FUNC_STATUS_OK;
+}
+
BT_EXPORT
const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class)
{
/* Owned by this */
struct bt_value *user_attributes;
+ gchar *ns;
gchar *name;
uint64_t id;