bt2: split clock value module from clock class module
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 5 Sep 2017 23:01:03 +0000 (19:01 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 17 Sep 2017 18:10:50 +0000 (14:10 -0400)
This doesn't change anything from the package's user's perspective, but
it's more in line with the C API.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bindings/python/bt2/bt2/__init__.py.in
bindings/python/bt2/bt2/clock_class.py
bindings/python/bt2/bt2/clock_value.py [new file with mode: 0644]

index 0a49b7948a72317baa7ef44c8f2deed5e7d11192..f12d9553408455ad8a180d610cc92a3ab1231746 100644 (file)
@@ -26,6 +26,7 @@ __version__ = '@PACKAGE_VERSION@'
 from bt2.clock_class import *
 from bt2.clock_class import _ClockValue
 from bt2.clock_class_priority_map import *
+from bt2.clock_value import *
 from bt2.component import *
 from bt2.component import _FilterComponent
 from bt2.component import _GenericFilterComponentClass
index 24b1db680783341aca38b764f0dce08eb42aa80d..552ac61da6f515aac7d57ef7d9bc95376342007e 100644 (file)
@@ -221,59 +221,3 @@ class ClockClass(object._Object):
     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
diff --git a/bindings/python/bt2/bt2/clock_value.py b/bindings/python/bt2/bt2/clock_value.py
new file mode 100644 (file)
index 0000000..e35bc8e
--- /dev/null
@@ -0,0 +1,83 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+from bt2 import native_bt, object, utils
+import uuid as uuidp
+import numbers
+import bt2
+
+
+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
This page took 0.025963 seconds and 4 git commands to generate.