+ @property
+ def assigns_automatic_stream_class_id(self):
+ return native_bt.trace_class_assigns_automatic_stream_class_id(self._ptr)
+
+ # Add a listener to be called when the trace class is destroyed.
+
+ def add_destruction_listener(self, listener):
+
+ if not callable(listener):
+ raise TypeError("'listener' parameter is not callable")
+
+ fn = native_bt.bt2_trace_class_add_destruction_listener
+ listener_from_native = functools.partial(
+ _trace_class_destruction_listener_from_native, listener
+ )
+
+ status, listener_id = fn(self._ptr, listener_from_native)
+ utils._handle_func_status(
+ status, 'cannot add destruction listener to trace class object'
+ )
+
+ return utils._ListenerHandle(listener_id, self)
+
+
+class _TraceClass(_TraceClassConst):
+ _borrow_stream_class_ptr_by_index = staticmethod(
+ native_bt.trace_class_borrow_stream_class_by_index
+ )
+ _borrow_stream_class_ptr_by_id = staticmethod(
+ native_bt.trace_class_borrow_stream_class_by_id
+ )
+ _borrow_user_attributes_ptr = staticmethod(
+ native_bt.trace_class_borrow_user_attributes
+ )
+ _stream_class_pycls = bt2_stream_class._StreamClass
+ _create_value_from_ptr_and_get_ref = staticmethod(
+ bt2_value._create_from_ptr_and_get_ref
+ )
+
+ # Instantiate a trace of this class.
+
+ def __call__(self, name=None, user_attributes=None, uuid=None, environment=None):
+ trace_ptr = native_bt.trace_create(self._ptr)
+
+ if trace_ptr is None:
+ raise bt2._MemoryError('cannot create trace class object')
+
+ trace = bt2_trace._Trace._create_from_ptr(trace_ptr)
+
+ if name is not None:
+ trace._name = name
+
+ if user_attributes is not None:
+ trace._user_attributes = user_attributes
+
+ if uuid is not None:
+ trace._uuid = uuid
+
+ if environment is not None:
+ for key, value in environment.items():
+ trace.environment[key] = value
+
+ return trace
+