3118d996d1685c26259260368b29c648e8378a96
[babeltrace.git] / src / bindings / python / bt2 / bt2 / clock_snapshot.py
1 # SPDX-License-Identifier: MIT
2 #
3 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
4
5 from bt2 import native_bt
6 from bt2 import object as bt2_object
7 from bt2 import utils as bt2_utils
8 import numbers
9 from bt2 import clock_class as bt2_clock_class
10 import functools
11
12
13 @functools.total_ordering
14 class _ClockSnapshotConst(bt2_object._UniqueObject):
15 @property
16 def clock_class(self):
17 cc_ptr = native_bt.clock_snapshot_borrow_clock_class_const(self._ptr)
18 assert cc_ptr is not None
19 return bt2_clock_class._ClockClassConst._create_from_ptr_and_get_ref(cc_ptr)
20
21 @property
22 def value(self):
23 return native_bt.clock_snapshot_get_value(self._ptr)
24
25 @property
26 def ns_from_origin(self):
27 status, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr)
28 bt2_utils._handle_func_status(
29 status, "cannot get clock snapshot's nanoseconds from origin"
30 )
31 return ns
32
33 def __eq__(self, other):
34 if not isinstance(other, numbers.Integral):
35 return NotImplemented
36
37 return self.value == int(other)
38
39 def __lt__(self, other):
40 if not isinstance(other, numbers.Integral):
41 return NotImplemented
42
43 return self.value < int(other)
44
45
46 class _UnknownClockSnapshot:
47 pass
This page took 0.032632 seconds and 3 git commands to generate.