src/cpp-common/bt2/trace-ir.hpp: add nameSpace() methods where needed
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 26 Mar 2024 20:02:15 +0000 (16:02 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
The bt2::CommonEventClass::nameSpace() and
bt2::CommonStreamClass::nameSpace() methods make it possible to set and
get the namespace of event classes and stream classes (new feature
starting with MIP 1).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6bd37d130fe8aaa8180181e41127e1ebfeb1ea4b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8003
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12698

src/cpp-common/bt2/trace-ir.hpp

index 07c65924d931b4a27dd3d7da6402b8dbe10fccdd..02d1e548ae0a2b6f4aed50d19ee949e29a8f697a 100644 (file)
@@ -925,6 +925,23 @@ public:
         return bt_event_class_get_id(this->libObjPtr());
     }
 
+    CommonEventClass nameSpace(const bt2c::CStringView nameSpace) const
+    {
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
+
+        if (bt_event_class_set_namespace(this->libObjPtr(), nameSpace) ==
+            BT_EVENT_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR) {
+            throw MemoryError {};
+        }
+
+        return *this;
+    }
+
+    bt2c::CStringView nameSpace() const noexcept
+    {
+        return bt_event_class_get_namespace(this->libObjPtr());
+    }
+
     CommonEventClass name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
@@ -1268,6 +1285,24 @@ public:
         return bt_stream_class_get_id(this->libObjPtr());
     }
 
+    CommonStreamClass nameSpace(const bt2c::CStringView nameSpace) const
+    {
+        static_assert(!std::is_const<LibObjT>::value,
+                      "Not available with `bt2::ConstStreamClass`.");
+
+        if (bt_stream_class_set_namespace(this->libObjPtr(), nameSpace) ==
+            BT_STREAM_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR) {
+            throw MemoryError {};
+        }
+
+        return *this;
+    }
+
+    bt2c::CStringView nameSpace() const noexcept
+    {
+        return bt_stream_class_get_namespace(this->libObjPtr());
+    }
+
     CommonStreamClass name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value,
This page took 0.026224 seconds and 4 git commands to generate.