Python: document writer.FieldDeclaration
[babeltrace.git] / bindings / python / writer.py
index fbcd68754745c5144f53c68c35fca09d8f5373e2..2751e4e2a47c95d8e8ccf3aa84c8ba0f6781e5fa 100644 (file)
@@ -35,17 +35,40 @@ _MAX_UINT64 = 0xFFFFFFFFFFFFFFFF
 
 class EnumerationMapping:
     """
-    Enumeration mapping class. start and end values are inclusive.
+    Mapping from an enumeration label to a range of integers.
     """
 
     def __init__(self, name, start, end):
+        """
+        Creates an enumeration mapping, where label *name* is mapped to
+        the [*start*, *end*] range of integers (*end* is included).
+
+        Set *start* and *end* to the same value to create an enumeration
+        mapping to a single value.
+        """
+
         self.name = name
         self.start = start
         self.end = end
 
 
 class Clock:
+    """
+    A CTF clock allows the description of the system's clock topology, as
+    well as the definition of each clock's parameters.
+
+    :class:`Clock` objects must be registered to a :class:`Writer`
+    object (see :meth:`Writer.add_clock`), as well as be registered to
+    a :class:`StreamClass` object (see :attr:`StreamClass.clock`).
+    """
+
     def __init__(self, name):
+        """
+        Creates a default CTF clock named *name*.
+
+        :exc:`ValueError` is raised on error.
+        """
+
         self._c = nbt._bt_ctf_clock_create(name)
 
         if self._c is None:
@@ -57,7 +80,11 @@ class Clock:
     @property
     def name(self):
         """
-        Get the clock's name.
+        Clock name.
+
+        Set this attribute to change the clock's name.
+
+        :exc:`ValueError` is raised on error.
         """
 
         name = nbt._bt_ctf_clock_get_name(self._c)
@@ -70,18 +97,17 @@ class Clock:
     @property
     def description(self):
         """
-        Get the clock's description. None if unset.
+        Clock description (string).
+
+        Set this attribute to change the clock's description.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_clock_get_description(self._c)
 
     @description.setter
     def description(self, desc):
-        """
-        Set the clock's description. The description appears in the clock's TSDL
-        meta-data.
-        """
-
         ret = nbt._bt_ctf_clock_set_description(self._c, str(desc))
 
         if ret < 0:
@@ -90,7 +116,11 @@ class Clock:
     @property
     def frequency(self):
         """
-        Get the clock's frequency (Hz).
+        Clock frequency in Hz (integer).
+
+        Set this attribute to change the clock's frequency.
+
+        :exc:`ValueError` is raised on error.
         """
 
         freq = nbt._bt_ctf_clock_get_frequency(self._c)
@@ -102,10 +132,6 @@ class Clock:
 
     @frequency.setter
     def frequency(self, freq):
-        """
-        Set the clock's frequency (Hz).
-        """
-
         ret = nbt._bt_ctf_clock_set_frequency(self._c, freq)
 
         if ret < 0:
@@ -114,7 +140,11 @@ class Clock:
     @property
     def precision(self):
         """
-        Get the clock's precision (in clock ticks).
+        Clock precision in clock ticks (integer).
+
+        Set this attribute to change the clock's precision.
+
+        :exc:`ValueError` is raised on error.
         """
 
         precision = nbt._bt_ctf_clock_get_precision(self._c)
@@ -126,16 +156,16 @@ class Clock:
 
     @precision.setter
     def precision(self, precision):
-        """
-        Set the clock's precision (in clock ticks).
-        """
-
         ret = nbt._bt_ctf_clock_set_precision(self._c, precision)
 
     @property
     def offset_seconds(self):
         """
-        Get the clock's offset in seconds from POSIX.1 Epoch.
+        Clock offset in seconds since POSIX.1 Epoch (integer).
+
+        Set this attribute to change the clock's offset in seconds.
+
+        :exc:`ValueError` is raised on error.
         """
 
         offset_s = nbt._bt_ctf_clock_get_offset_s(self._c)
@@ -147,10 +177,6 @@ class Clock:
 
     @offset_seconds.setter
     def offset_seconds(self, offset_s):
-        """
-        Set the clock's offset in seconds from POSIX.1 Epoch.
-        """
-
         ret = nbt._bt_ctf_clock_set_offset_s(self._c, offset_s)
 
         if ret < 0:
@@ -159,7 +185,12 @@ class Clock:
     @property
     def offset(self):
         """
-        Get the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
+        Clock offset in ticks since (POSIX.1 Epoch +
+        :attr:`offset_seconds`).
+
+        Set this attribute to change the clock's offset.
+
+        :exc:`ValueError` is raised on error.
         """
 
         offset = nbt._bt_ctf_clock_get_offset(self._c)
@@ -171,10 +202,6 @@ class Clock:
 
     @offset.setter
     def offset(self, offset):
-        """
-        Set the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
-        """
-
         ret = nbt._bt_ctf_clock_set_offset(self._c, offset)
 
         if ret < 0:
@@ -183,8 +210,13 @@ class Clock:
     @property
     def absolute(self):
         """
-        Get a clock's absolute attribute. A clock is absolute if the clock
-        is a global reference across the trace's other clocks.
+        ``True`` if this clock is absolute, i.e. if the clock is a
+        global reference across the other clocks of the trace.
+
+        Set this attribute to change the clock's absolute state
+        (boolean).
+
+        :exc:`ValueError` is raised on error.
         """
 
         is_absolute = nbt._bt_ctf_clock_get_is_absolute(self._c)
@@ -196,20 +228,19 @@ class Clock:
 
     @absolute.setter
     def absolute(self, is_absolute):
-        """
-        Set a clock's absolute attribute. A clock is absolute if the clock
-        is a global reference across the trace's other clocks.
-        """
-
         ret = nbt._bt_ctf_clock_set_is_absolute(self._c, int(is_absolute))
 
         if ret < 0:
-            raise ValueError("Could not set the clock's absolute attribute.")
+            raise ValueError("Could not set the clock absolute attribute.")
 
     @property
     def uuid(self):
         """
-        Get a clock's UUID (an object of type UUID).
+        Clock UUID (an :class:`uuid.UUID` object).
+
+        Set this attribute to change the clock's UUID.
+
+        :exc:`ValueError` is raised on error.
         """
 
         uuid_list = []
@@ -226,10 +257,6 @@ class Clock:
 
     @uuid.setter
     def uuid(self, uuid):
-        """
-        Set a clock's UUID (an object of type UUID).
-        """
-
         uuid_bytes = uuid.bytes
 
         if len(uuid_bytes) != 16:
@@ -245,8 +272,12 @@ class Clock:
     @property
     def time(self):
         """
-        Get the current time in nanoseconds since the clock's origin (offset and
-        offset_s attributes).
+        Clock current time; nanoseconds (integer) since clock origin
+        (POSIX.1 Epoch + :attr:`offset_seconds` + :attr:`offset`).
+
+        Set this attribute to change the clock's current time.
+
+        :exc:`ValueError` is raised on error.
         """
 
         time = nbt._bt_ctf_clock_get_time(self._c)
@@ -258,12 +289,6 @@ class Clock:
 
     @time.setter
     def time(self, time):
-        """
-        Set the current time in nanoseconds since the clock's origin (offset and
-        offset_s attributes). The clock's value will be sampled as events are
-        appended to a stream.
-        """
-
         ret = nbt._bt_ctf_clock_set_time(self._c, time)
 
         if ret < 0:
@@ -272,8 +297,9 @@ class Clock:
 
 class FieldDeclaration:
     """
-    FieldDeclaration should not be instantiated directly. Instantiate
-    one of the concrete FieldDeclaration classes.
+    Base class of all field declarations. This class is not meant to
+    be instantiated by the user; use one of the concrete field
+    declaration subclasses instead.
     """
 
     class IntegerBase:
@@ -320,19 +346,17 @@ class FieldDeclaration:
     @property
     def alignment(self):
         """
-        Get the field declaration's alignment. Returns -1 on error.
+        Field alignment in bits (integer).
+
+        Set this attribute to change this field's alignment.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_field_type_get_alignment(self._ft)
 
     @alignment.setter
     def alignment(self, alignment):
-        """
-        Set the field declaration's alignment. Defaults to 1 (bit-aligned). However,
-        some types, such as structures and string, may impose other alignment
-        constraints.
-        """
-
         ret = nbt._bt_ctf_field_type_set_alignment(self._ft, alignment)
 
         if ret < 0:
@@ -341,18 +365,18 @@ class FieldDeclaration:
     @property
     def byte_order(self):
         """
-        Get the field declaration's byte order. One of the ByteOrder's constant.
+        Field byte order (one of :class:`babeltrace.common.ByteOrder`
+        constants).
+
+        Set this attribute to change this field's byte order.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_field_type_get_byte_order(self._ft)
 
     @byte_order.setter
     def byte_order(self, byte_order):
-        """
-        Set the field declaration's byte order. Use constants defined in the ByteOrder
-        class.
-        """
-
         ret = nbt._bt_ctf_field_type_set_byte_order(self._ft, byte_order)
 
         if ret < 0:
This page took 0.025753 seconds and 4 git commands to generate.