Get an event class's numeric ID with bt_event_class_get_id().
</dd>
+ <dt>
+ \anchor api-tir-ev-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 event class.
+
+ Use bt_event_class_set_namespace() and
+ bt_event_class_get_namespace().
+ </dd>
+
<dt>\anchor api-tir-ev-cls-prop-name \bt_dt_opt Name</dt>
<dd>
Name of the event class.
<tr>
<td>\ref api-tir-ev-cls-prop-id "Numeric ID"
<td>Automatically assigned by \bt_p{stream_class}
+ <tr>
+ <td>\bt_mip version 1: \ref api-tir-ev-cls-prop-ns "namespace"
+ <td>\em None
<tr>
<td>\ref api-tir-ev-cls-prop-name "Name"
<td>\em None
<tr>
<td>\ref api-tir-ev-cls-prop-id "Numeric ID"
<td>\bt_p{id}
+ <tr>
+ <td>\bt_mip version 1: \ref api-tir-ev-cls-prop-ns "namespace"
+ <td>\em None
<tr>
<td>\ref api-tir-ev-cls-prop-name "Name"
<td>\em None
extern uint64_t bt_event_class_get_id(
const bt_event_class *event_class) __BT_NOEXCEPT;
+/*!
+@brief
+ Status codes for bt_event_class_set_namespace().
+*/
+typedef enum bt_event_class_set_namespace_status {
+ /*!
+ @brief
+ Success.
+ */
+ BT_EVENT_CLASS_SET_NAMESPACE_STATUS_OK = __BT_FUNC_STATUS_OK,
+
+ /*!
+ @brief
+ Out of memory.
+ */
+ BT_EVENT_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_event_class_set_namespace_status;
+
+/*!
+@brief
+ Sets the namespace of the event class \bt_p{event_class} to
+ a copy of \bt_p{ns}.
+
+See the \ref api-tir-ev-cls-prop-ns "namespace" property.
+
+@param[in] event_class
+ Event class of which to set the namespace to \bt_p{ns}.
+@param[in] name
+ New namespace of \bt_p{event_class} (copied).
+
+@retval #BT_EVENT_CLASS_SET_NAMESPACE_STATUS_OK
+ Success.
+@retval #BT_EVENT_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR
+ Out of memory.
+
+@bt_pre_not_null{event_class}
+@bt_pre_hot{event_class}
+@bt_pre_ev_cls_with_mip{event_class, 1}
+@bt_pre_not_null{ns}
+
+@sa bt_event_class_get_namespace() —
+ Returns the namespace of an event class.
+*/
+extern bt_event_class_set_namespace_status bt_event_class_set_namespace(
+ bt_event_class *event_class, const char *ns) __BT_NOEXCEPT;
+
+/*!
+@brief
+ Returns the namespace of the event class \bt_p{event_class}.
+
+See the \ref api-tir-ev-cls-prop-ns "namespace" property.
+
+If \bt_p{event_class} has no namespace, this function returns \c NULL.
+
+@param[in] event_class
+ Event class of which to get the namespace.
+
+@returns
+ @parblock
+ Namespace of \bt_p{event_class}, or \c NULL if none.
+
+ The returned pointer remains valid as long as \bt_p{event_class}
+ is not modified.
+ @endparblock
+
+@bt_pre_not_null{event_class}
+@bt_pre_ev_cls_with_mip{event_class, 1}
+
+@sa bt_event_class_set_namespace() —
+ Sets the namespace of a event class.
+*/
+extern const char *
+bt_event_class_get_namespace(const bt_event_class *event_class) __BT_NOEXCEPT;
+
/*!
@brief
Status codes for bt_event_class_set_name().
#define BABELTRACE_LIB_ASSERT_COND_H
#include "assert-cond-base.h"
+#include "trace-ir/trace-class.h" /* IWYU pragma: keep */
#include <inttypes.h>
bt_stream_class_borrow_trace_class_inline(_stream_class), \
_val)
+/*
+ * Asserts that the effective MIP version for `_event_class` is greater than or
+ * equal to `_val`.
+ */
+#define BT_ASSERT_PRE_EC_MIP_VERSION_GE(_event_class, _val) \
+ BT_ASSERT_PRE_SC_MIP_VERSION_GE( \
+ bt_event_class_borrow_stream_class_inline(_event_class), \
+ _val)
+
/*
* Asserts that the effective MIP version for `_field_class` is equal to `_val`.
*/
BT_LIB_LOGD("Destroying event class: %!+E", event_class);
BT_OBJECT_PUT_REF_AND_RESET(event_class->user_attributes);
+ g_free(event_class->ns);
g_free(event_class->name);
g_free(event_class->emf_uri);
BT_LOGD_STR("Putting context field class.");
return create_event_class_with_id(stream_class, id);
}
+BT_EXPORT
+const char *bt_event_class_get_namespace(const struct bt_event_class *event_class)
+{
+ BT_ASSERT_PRE_DEV_EC_NON_NULL(event_class);
+ BT_ASSERT_PRE_EC_MIP_VERSION_GE(event_class, 1);
+ return event_class->ns;
+}
+
+BT_EXPORT
+enum bt_event_class_set_namespace_status bt_event_class_set_namespace(
+ struct bt_event_class *event_class, const char *ns)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_EC_NON_NULL(event_class);
+ BT_ASSERT_PRE_EC_MIP_VERSION_GE(event_class, 1);
+ BT_ASSERT_PRE_NAMESPACE_NON_NULL(ns);
+ BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class);
+ g_free(event_class->ns);
+ event_class->ns = g_strdup(ns);
+ BT_LIB_LOGD("Set event class's namespace: %!+E", event_class);
+ return BT_FUNC_STATUS_OK;
+}
+
BT_EXPORT
const char *bt_event_class_get_name(const struct bt_event_class *event_class)
{