- def __init__(self, name, frequency, description=None, precision=None,
- offset=None, is_absolute=None, uuid=None):
- utils._check_str(name)
- utils._check_uint64(frequency)
- ptr = native_bt.clock_class_create(name, frequency)
-
- if ptr is None:
- raise bt2.CreationError('cannot create clock class object')
-
- super().__init__(ptr)
-
- if description is not None:
- self.description = description
-
- if frequency is not None:
- self.frequency = frequency
-
- if precision is not None:
- self.precision = precision
-
- if offset is not None:
- self.offset = offset
-
- if is_absolute is not None:
- self.is_absolute = is_absolute
-
- if uuid is not None:
- self.uuid = uuid
-
- def __eq__(self, other):
- if type(self) is not type(other):
- # not comparing apples to apples
- return False
-
- self_props = (
- self.name,
- self.description,
- self.frequency,
- self.precision,
- self.offset,
- self.is_absolute,
- self.uuid
- )
- other_props = (
- other.name,
- other.description,
- other.frequency,
- other.precision,
- other.offset,
- other.is_absolute,
- other.uuid
- )
- return self_props == other_props
-
- def __copy__(self):
- return ClockClass(name=self.name, description=self.description,
- frequency=self.frequency, precision=self.precision,
- offset=self.offset, is_absolute=self.is_absolute,
- uuid=self.uuid)
-
- def __deepcopy__(self, memo):
- cpy = self.__copy__()
- memo[id(self)] = cpy
- return cpy
-
- def __hash__(self):
- return hash((
- self.name,
- self.description,
- self.frequency,
- self.precision,
- self.offset.seconds,
- self.offset.cycles,
- self.is_absolute,
- self.uuid))
-