cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[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 import numbers
6 import functools
7
8 from bt2 import utils as bt2_utils
9 from bt2 import object as bt2_object
10 from bt2 import native_bt
11 from bt2 import clock_class as bt2_clock_class
12
13
14 @functools.total_ordering
15 class _ClockSnapshotConst(bt2_object._UniqueObject):
16 @property
17 def clock_class(self):
18 cc_ptr = native_bt.clock_snapshot_borrow_clock_class_const(self._ptr)
19 assert cc_ptr is not None
20 return bt2_clock_class._ClockClassConst._create_from_ptr_and_get_ref(cc_ptr)
21
22 @property
23 def value(self):
24 return native_bt.clock_snapshot_get_value(self._ptr)
25
26 @property
27 def ns_from_origin(self):
28 status, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr)
29 bt2_utils._handle_func_status(
30 status, "cannot get clock snapshot's nanoseconds from origin"
31 )
32 return ns
33
34 def __eq__(self, other):
35 if not isinstance(other, numbers.Integral):
36 return NotImplemented
37
38 return self.value == int(other)
39
40 def __lt__(self, other):
41 if not isinstance(other, numbers.Integral):
42 return NotImplemented
43
44 return self.value < int(other)
45
46
47 class _UnknownClockSnapshot:
48 pass
This page took 0.030391 seconds and 4 git commands to generate.