bt2: add user attributes property support
[babeltrace.git] / src / bindings / python / bt2 / bt2 / component.py
index 49aed23f14db8a56ba198b633c72aa331c30495b..a0d29e272f43d5286cad50f47ff400c68eb33a2f 100644 (file)
@@ -27,11 +27,9 @@ from bt2 import value as bt2_value
 from bt2 import trace_class as bt2_trace_class
 from bt2 import clock_class as bt2_clock_class
 from bt2 import query_executor as bt2_query_executor
-import traceback
 from bt2 import port as bt2_port
 import sys
 import bt2
-import os
 
 
 # This class wraps a component class pointer. This component class could
@@ -573,9 +571,29 @@ class _UserComponentType(type):
     def addr(cls):
         return int(cls._bt_cc_ptr)
 
+    def _bt_get_supported_mip_versions_from_native(cls, params_ptr, obj, log_level):
+        # this can raise, but the native side checks the exception
+        if params_ptr is not None:
+            params = bt2_value._create_from_ptr_and_get_ref(params_ptr)
+        else:
+            params = None
+
+        # this can raise, but the native side checks the exception
+        range_set = cls._user_get_supported_mip_versions(params, obj, log_level)
+
+        if type(range_set) is not bt2.UnsignedIntegerRangeSet:
+            # this can raise, but the native side checks the exception
+            range_set = bt2.UnsignedIntegerRangeSet(range_set)
+
+        # return new reference
+        range_set._get_ref(range_set._ptr)
+        return int(range_set._ptr)
+
+    def _user_get_supported_mip_versions(cls, params, obj, log_level):
+        return [0]
+
     def _bt_query_from_native(cls, priv_query_exec_ptr, object, params_ptr, method_obj):
-        # this can raise, in which case the native call to
-        # bt_component_class_query() returns NULL
+        # this can raise, but the native side checks the exception
         if params_ptr is not None:
             params = bt2_value._create_from_ptr_and_get_ref(params_ptr)
         else:
@@ -659,6 +677,11 @@ class _UserComponent(metaclass=_UserComponentType):
     def addr(self):
         return int(self._bt_ptr)
 
+    @property
+    def _graph_mip_version(self):
+        ptr = self._bt_as_self_component_ptr(self._bt_ptr)
+        return native_bt.self_component_get_graph_mip_version(ptr)
+
     def __init__(self, params=None, obj=None):
         pass
 
@@ -683,7 +706,9 @@ class _UserComponent(metaclass=_UserComponentType):
         )
         self._user_port_connected(port, other_port)
 
-    def _create_trace_class(self, assigns_automatic_stream_class_id=True):
+    def _create_trace_class(
+        self, user_attributes=None, assigns_automatic_stream_class_id=True
+    ):
         ptr = self._bt_as_self_component_ptr(self._bt_ptr)
         tc_ptr = native_bt.trace_class_create(ptr)
 
@@ -693,12 +718,16 @@ class _UserComponent(metaclass=_UserComponentType):
         tc = bt2_trace_class._TraceClass._create_from_ptr(tc_ptr)
         tc._assigns_automatic_stream_class_id = assigns_automatic_stream_class_id
 
+        if user_attributes is not None:
+            tc._user_attributes = user_attributes
+
         return tc
 
     def _create_clock_class(
         self,
         frequency=None,
         name=None,
+        user_attributes=None,
         description=None,
         precision=None,
         offset=None,
@@ -719,6 +748,9 @@ class _UserComponent(metaclass=_UserComponentType):
         if name is not None:
             cc._name = name
 
+        if user_attributes is not None:
+            cc._user_attributes = user_attributes
+
         if description is not None:
             cc._description = description
 
This page took 0.0237 seconds and 4 git commands to generate.