A trace has the following properties:
<dl>
+ <dt>
+ \anchor api-tir-trace-prop-ns
+ \bt_dt_opt Namespace
+ (only available when the class of the trace 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 trace.
+
+ Use bt_trace_set_namespace() and
+ bt_trace_get_namespace().
+ </dd>
+
<dt>
\anchor api-tir-trace-prop-name
\bt_dt_opt Name
<tr>
<th>Property
<th>Value
+ <tr>
+ <td>\bt_mip version 1: \ref api-tir-trace-prop-ns "Namespace"
+ <td>\em None
<tr>
<td>\ref api-tir-trace-prop-name "Name"
<td>\em None
@{
*/
+/*!
+@brief
+ Status codes for bt_trace_set_namespace().
+*/
+typedef enum bt_trace_set_namespace_status {
+ /*!
+ @brief
+ Success.
+ */
+ BT_TRACE_SET_NAMESPACE_STATUS_OK = __BT_FUNC_STATUS_OK,
+
+ /*!
+ @brief
+ Out of memory.
+ */
+ BT_TRACE_SET_NAMESPACE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_trace_set_namespace_status;
+
+/*!
+@brief
+ Sets the namespace of the trace \bt_p{trace} to a copy of \bt_p{ns}.
+
+See the \ref api-tir-trace-prop-ns "namespace" property.
+
+@param[in] trace
+ Trace of which to set the namespace to \bt_p{ns}.
+@param[in] name
+ New namespace of \bt_p{trace} (copied).
+
+@retval #BT_TRACE_SET_NAMESPACE_STATUS_OK
+ Success.
+@retval #BT_TRACE_SET_NAMESPACE_STATUS_MEMORY_ERROR
+ Out of memory.
+
+@bt_pre_not_null{trace}
+@bt_pre_hot{trace}
+@bt_pre_trace_with_mip{trace, 1}
+@bt_pre_not_null{ns}
+
+@sa bt_trace_get_namespace() —
+ Returns the namespace of a trace.
+*/
+extern bt_trace_set_namespace_status bt_trace_set_namespace(bt_trace *trace,
+ const char *ns) __BT_NOEXCEPT;
+
+/*!
+@brief
+ Returns the namespace of the trace \bt_p{trace}.
+
+See the \ref api-tir-trace-prop-ns "namespace" property.
+
+If \bt_p{trace} has no namespace, this function returns \c NULL.
+
+@param[in] trace
+ Trace of which to get the namespace.
+
+@returns
+ @parblock
+ Namespace of \bt_p{trace}, or \c NULL if none.
+
+ The returned pointer remains valid as long as \bt_p{trace}
+ is not modified.
+ @endparblock
+
+@bt_pre_not_null{trace}
+@bt_pre_stream_cls_with_mip{trace, 1}
+
+@sa bt_trace_set_namespace() —
+ Sets the namespace of a trace.
+*/
+extern const char *bt_trace_get_namespace(const bt_trace *trace) __BT_NOEXCEPT;
+
/*!
@brief
Status codes for bt_trace_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 `_trace` is greater than or
+ * equal to `_val`.
+ */
+#define BT_ASSERT_PRE_TRACE_MIP_VERSION_GE(_trace, _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`.
}
}
+ g_free(trace->ns);
g_free(trace->name);
if (trace->class->mip_version >= 1) {
return trace;
}
+BT_EXPORT
+const char *bt_trace_get_namespace(const struct bt_trace *trace)
+{
+ BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
+ BT_ASSERT_PRE_TRACE_MIP_VERSION_GE(trace, 1);
+ return trace->ns;
+}
+
+BT_EXPORT
+enum bt_trace_set_namespace_status bt_trace_set_namespace(
+ struct bt_trace *trace, const char *ns)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_TRACE_NON_NULL(trace);
+ BT_ASSERT_PRE_NAME_NON_NULL(ns);
+ BT_ASSERT_PRE_DEV_TRACE_HOT(trace);
+ BT_ASSERT_PRE_TRACE_MIP_VERSION_GE(trace, 1);
+ g_free(trace->ns);
+ trace->ns = g_strdup(ns);
+ BT_LIB_LOGD("Set trace's namespace: %!+t", trace);
+ return BT_FUNC_STATUS_OK;
+}
+
BT_EXPORT
const char *bt_trace_get_name(const struct bt_trace *trace)
{