- if event_context_field_type is not None:
- utils._check_type(event_context_field_type, bt2.field_types._FieldType)
- event_context_field_type_ptr = event_context_field_type._ptr
-
- ret = native_bt.stream_class_set_event_context_type(self._ptr,
- event_context_field_type_ptr)
- utils._handle_ret(ret, "cannot set stream class object's event context field type")
-
- def __call__(self, name=None, id=None):
- if name is not None:
- utils._check_str(name)
-
- if id is None:
- stream_ptr = native_bt.stream_create(self._ptr, name)
- else:
- stream_ptr = native_bt.stream_create_with_id(self._ptr, name, id)
-
- if stream_ptr is None:
- raise bt2.CreationError('cannot create stream object')
-
- return bt2.stream._create_from_ptr(stream_ptr)
-
- def __eq__(self, other):
- if type(other) is not type(self):
- return False
-
- if self.addr == other.addr:
- return True
-
- self_event_classes = list(self.values())
- other_event_classes = list(other.values())
- self_props = (
- self_event_classes,
- self.name,
- self.id,
- self.packet_context_field_type,
- self.event_header_field_type,
- self.event_context_field_type,
- self.clock,
- )
- other_props = (
- other_event_classes,
- other.name,
- other.id,
- other.packet_context_field_type,
- other.event_header_field_type,
- other.event_context_field_type,
- other.clock,
- )
-
- return self_props == other_props
-
- def _copy(self, ft_copy_func, ev_copy_func):
- cpy = StreamClass()
-
- if self.id is not None:
- cpy.id = self.id
-
- if self.name is not None:
- cpy.name = self.name
-
- if self.clock is not None:
- cpy.clock = self.clock
-
- cpy.packet_context_field_type = ft_copy_func(self.packet_context_field_type)
- cpy.event_header_field_type = ft_copy_func(self.event_header_field_type)
- cpy.event_context_field_type = ft_copy_func(self.event_context_field_type)
-
- for event_class in self.values():
- cpy.add_event_class(ev_copy_func(event_class))
-
- return cpy
-
- def __copy__(self):
- return self._copy(lambda ft: ft, copy.copy)
-
- def __deepcopy__(self, memo):
- cpy = self._copy(copy.deepcopy, copy.deepcopy)
- memo[id(self)] = cpy
- return cpy