- utils._check_type(payload_field_class, bt2.field_class._FieldClass)
- payload_field_class_ptr = payload_field_class._ptr
-
- ret = native_bt.event_class_set_payload_type(self._ptr, payload_field_class_ptr)
- utils._handle_ret(ret, "cannot set event class object's payload field class")
-
- def __call__(self):
- event_ptr = native_bt.event_create(self._ptr)
-
- if event_ptr is None:
- raise bt2.CreationError('cannot create event field object')
-
- return bt2.event._create_from_ptr(event_ptr)
-
- def __eq__(self, other):
- if type(other) is not type(self):
- return False
-
- if self.addr == other.addr:
- return True
-
- self_props = (
- self.name,
- self.id,
- self.log_level,
- self.emf_uri,
- self.context_field_class,
- self.payload_field_class
- )
- other_props = (
- other.name,
- other.id,
- other.log_level,
- other.emf_uri,
- other.context_field_class,
- other.payload_field_class
- )
- return self_props == other_props
-
- def _copy(self, fc_copy_func):
- cpy = EventClass(self.name)
- cpy.id = self.id
-
- if self.log_level is not None:
- cpy.log_level = self.log_level
-
- if self.emf_uri is not None:
- cpy.emf_uri = self.emf_uri
-
- cpy.context_field_class = fc_copy_func(self.context_field_class)
- cpy.payload_field_class = fc_copy_func(self.payload_field_class)
- return cpy
-
- def __copy__(self):
- return self._copy(lambda fc: fc)
-
- def __deepcopy__(self, memo):
- cpy = self._copy(copy.deepcopy)
- memo[id(self)] = cpy
- return cpy
+ utils._check_type(payload_field_class, bt2.field_class._StructureFieldClass)
+ ret = native_bt.event_class_set_payload_field_class(self._ptr, payload_field_class._ptr)
+ utils._handle_ret(ret, "cannot set event class object's payload field class")
+
+ _payload_field_class = property(fset=_payload_field_class)
+
+
+_EVENT_CLASS_LOG_LEVEL_TO_OBJ = {
+ native_bt.EVENT_CLASS_LOG_LEVEL_EMERGENCY: EventClassLogLevel.EMERGENCY,
+ native_bt.EVENT_CLASS_LOG_LEVEL_ALERT: EventClassLogLevel.ALERT,
+ native_bt.EVENT_CLASS_LOG_LEVEL_CRITICAL: EventClassLogLevel.CRITICAL,
+ native_bt.EVENT_CLASS_LOG_LEVEL_ERROR: EventClassLogLevel.ERROR,
+ native_bt.EVENT_CLASS_LOG_LEVEL_WARNING: EventClassLogLevel.WARNING,
+ native_bt.EVENT_CLASS_LOG_LEVEL_NOTICE: EventClassLogLevel.NOTICE,
+ native_bt.EVENT_CLASS_LOG_LEVEL_INFO: EventClassLogLevel.INFO,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM: EventClassLogLevel.DEBUG_SYSTEM,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM: EventClassLogLevel.DEBUG_PROGRAM,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS: EventClassLogLevel.DEBUG_PROCESS,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE: EventClassLogLevel.DEBUG_MODULE,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT: EventClassLogLevel.DEBUG_UNIT,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION: EventClassLogLevel.DEBUG_FUNCTION,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG_LINE: EventClassLogLevel.DEBUG_LINE,
+ native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG: EventClassLogLevel.DEBUG,
+}