def __call__(self, cycles):
return _ClockValue(self._ptr, cycles)
-
-def _create_clock_value_from_ptr(ptr):
- clock_value = _ClockValue._create_from_ptr(ptr)
- return clock_value
-
-
-class _ClockValue(object._Object):
- def __init__(self, clock_class_ptr, cycles):
- utils._check_uint64(cycles)
- ptr = native_bt.ctf_clock_value_create(clock_class_ptr, cycles)
-
- if ptr is None:
- raise bt2.CreationError('cannot create clock value object')
-
- super().__init__(ptr)
-
- @property
- def clock_class(self):
- ptr = native_bt.ctf_clock_value_get_class(self._ptr)
- assert(ptr)
- return ClockClass._create_from_ptr(ptr)
-
- @property
- def cycles(self):
- ret, cycles = native_bt.ctf_clock_value_get_value(self._ptr)
- assert(ret == 0)
- return cycles
-
- @property
- def ns_from_epoch(self):
- ret, ns = native_bt.ctf_clock_value_get_value_ns_from_epoch(self._ptr)
- utils._handle_ret(ret, "cannot get clock value object's nanoseconds from Epoch")
- return ns
-
- def __eq__(self, other):
- if isinstance(other, numbers.Integral):
- return int(other) == self.cycles
-
- if not isinstance(other, self.__class__):
- # not comparing apples to apples
- return False
-
- if self.addr == other.addr:
- return True
-
- self_props = self.clock_class, self.cycles
- other_props = other.clock_class, other.cycles
- return self_props == other_props
-
- def __copy__(self):
- return self.clock_class(self.cycles)
-
- def __deepcopy__(self, memo):
- cpy = self.__copy__()
- memo[id(self)] = cpy
- return cpy