+ return self._clock_class_cls._create_from_ptr_and_get_ref(cc_ptr)
+
+
+class _StreamClass(_StreamClassConst):
+ _get_ref = staticmethod(native_bt.stream_class_get_ref)
+ _put_ref = staticmethod(native_bt.stream_class_put_ref)
+ _borrow_event_class_ptr_by_id = staticmethod(
+ native_bt.stream_class_borrow_event_class_by_id
+ )
+ _borrow_event_class_ptr_by_index = staticmethod(
+ native_bt.stream_class_borrow_event_class_by_index
+ )
+ _borrow_trace_class_ptr = staticmethod(native_bt.stream_class_borrow_trace_class)
+ _borrow_packet_context_field_class_ptr = staticmethod(
+ native_bt.stream_class_borrow_packet_context_field_class
+ )
+ _borrow_event_common_context_field_class_ptr = staticmethod(
+ native_bt.stream_class_borrow_event_common_context_field_class
+ )
+ _borrow_default_clock_class_ptr = staticmethod(
+ native_bt.stream_class_borrow_default_clock_class
+ )
+ _borrow_user_attributes_ptr = staticmethod(
+ native_bt.stream_class_borrow_user_attributes
+ )
+
+ _event_class_cls = property(lambda s: bt2_event_class._EventClass)
+ _trace_class_cls = property(lambda s: _bt2_trace_class()._TraceClass)
+ _clock_class_cls = property(lambda s: bt2_clock_class._ClockClass)
+
+ def create_event_class(
+ self,
+ id=None,
+ name=None,
+ user_attributes=None,
+ log_level=None,
+ emf_uri=None,
+ specific_context_field_class=None,
+ payload_field_class=None,
+ ):
+ if self.assigns_automatic_event_class_id:
+ if id is not None:
+ raise ValueError(
+ 'id provided, but stream class assigns automatic event class ids'
+ )
+
+ ec_ptr = native_bt.event_class_create(self._ptr)
+ else:
+ if id is None:
+ raise ValueError(
+ 'id not provided, but stream class does not assign automatic event class ids'
+ )
+
+ utils._check_uint64(id)
+ ec_ptr = native_bt.event_class_create_with_id(self._ptr, id)
+
+ event_class = bt2_event_class._EventClass._create_from_ptr(ec_ptr)
+
+ if name is not None:
+ event_class._name = name
+
+ if user_attributes is not None:
+ event_class._user_attributes = user_attributes
+
+ if log_level is not None:
+ event_class._log_level = log_level
+
+ if emf_uri is not None:
+ event_class._emf_uri = emf_uri
+
+ if specific_context_field_class is not None:
+ event_class._specific_context_field_class = specific_context_field_class
+
+ if payload_field_class is not None:
+ event_class._payload_field_class = payload_field_class
+
+ return event_class
+
+ def _user_attributes(self, user_attributes):
+ value = bt2_value.create_value(user_attributes)
+ native_bt.stream_class_set_user_attributes(self._ptr, value._ptr)
+
+ _user_attributes = property(fset=_user_attributes)
+
+ def _name(self, name):
+ status = native_bt.stream_class_set_name(self._ptr, name)
+ utils._handle_func_status(status, "cannot set stream class object's name")
+
+ _name = property(fset=_name)
+
+ def _assigns_automatic_event_class_id(self, auto_id):
+ native_bt.stream_class_set_assigns_automatic_event_class_id(self._ptr, auto_id)
+
+ _assigns_automatic_event_class_id = property(fset=_assigns_automatic_event_class_id)
+
+ def _assigns_automatic_stream_id(self, auto_id):
+ native_bt.stream_class_set_assigns_automatic_stream_id(self._ptr, auto_id)
+
+ _assigns_automatic_stream_id = property(fset=_assigns_automatic_stream_id)
+
+ def _set_supports_packets(self, supports, with_begin_cs=False, with_end_cs=False):
+ native_bt.stream_class_set_supports_packets(
+ self._ptr, supports, with_begin_cs, with_end_cs
+ )
+
+ def _set_supports_discarded_events(self, supports, with_cs=False):
+ native_bt.stream_class_set_supports_discarded_events(
+ self._ptr, supports, with_cs
+ )
+
+ _supports_discarded_events = property(fset=_set_supports_discarded_events)
+
+ def _set_supports_discarded_packets(self, supports, with_cs):
+ native_bt.stream_class_set_supports_discarded_packets(
+ self._ptr, supports, with_cs
+ )
+
+ _supports_discarded_packets = property(fset=_set_supports_discarded_packets)
+
+ def _packet_context_field_class(self, packet_context_field_class):
+ status = native_bt.stream_class_set_packet_context_field_class(
+ self._ptr, packet_context_field_class._ptr
+ )
+ utils._handle_func_status(
+ status, "cannot set stream class' packet context field class"
+ )
+
+ _packet_context_field_class = property(fset=_packet_context_field_class)
+
+ def _event_common_context_field_class(self, event_common_context_field_class):
+ set_context_fn = native_bt.stream_class_set_event_common_context_field_class
+ status = set_context_fn(self._ptr, event_common_context_field_class._ptr)
+ utils._handle_func_status(
+ status, "cannot set stream class' event context field type"
+ )
+
+ _event_common_context_field_class = property(fset=_event_common_context_field_class)