3 # Babeltrace writer interface Python module
5 # Copyright 2012-2015 EfficiOS Inc.
7 # Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 # Permission is hereby granted, free of charge, to any person obtaining a copy
10 # of this software and associated documentation files (the "Software"), to deal
11 # in the Software without restriction, including without limitation the rights
12 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 # copies of the Software, and to permit persons to whom the Software is
14 # furnished to do so, subject to the following conditions:
16 # The above copyright notice and this permission notice shall be included in
17 # all copies or substantial portions of the Software.
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 import babeltrace
.nativebt
as nbt
28 import babeltrace
.common
as common
32 # Used to compare to -1ULL in error checks
33 _MAX_UINT64
= 0xFFFFFFFFFFFFFFFF
36 class EnumerationMapping
:
38 Mapping from an enumeration label to a range of integers.
41 def __init__(self
, name
, start
, end
):
43 Creates an enumeration mapping, where label *name* is mapped to
44 the [*start*, *end*] range of integers (*end* is included).
46 Set *start* and *end* to the same value to create an enumeration
47 mapping to a single value.
57 A CTF clock allows the description of the system's clock topology, as
58 well as the definition of each clock's parameters.
60 :class:`Clock` objects must be registered to a :class:`Writer`
61 object (see :meth:`Writer.add_clock`), as well as be registered to
62 a :class:`StreamClass` object (see :attr:`StreamClass.clock`).
65 def __init__(self
, name
):
67 Creates a default CTF clock named *name*.
69 :exc:`ValueError` is raised on error.
72 self
._c
= nbt
._bt
_ctf
_clock
_create
(name
)
75 raise ValueError("Invalid clock name.")
78 nbt
._bt
_ctf
_clock
_put
(self
._c
)
85 Set this attribute to change the clock's name.
87 :exc:`ValueError` is raised on error.
90 name
= nbt
._bt
_ctf
_clock
_get
_name
(self
._c
)
93 raise ValueError("Invalid clock instance.")
98 def description(self
):
100 Clock description (string).
102 Set this attribute to change the clock's description.
104 :exc:`ValueError` is raised on error.
107 return nbt
._bt
_ctf
_clock
_get
_description
(self
._c
)
110 def description(self
, desc
):
111 ret
= nbt
._bt
_ctf
_clock
_set
_description
(self
._c
, str(desc
))
114 raise ValueError("Invalid clock description.")
119 Clock frequency in Hz (integer).
121 Set this attribute to change the clock's frequency.
123 :exc:`ValueError` is raised on error.
126 freq
= nbt
._bt
_ctf
_clock
_get
_frequency
(self
._c
)
128 if freq
== _MAX_UINT64
:
129 raise ValueError("Invalid clock instance")
134 def frequency(self
, freq
):
135 ret
= nbt
._bt
_ctf
_clock
_set
_frequency
(self
._c
, freq
)
138 raise ValueError("Invalid frequency value.")
143 Clock precision in clock ticks (integer).
145 Set this attribute to change the clock's precision.
147 :exc:`ValueError` is raised on error.
150 precision
= nbt
._bt
_ctf
_clock
_get
_precision
(self
._c
)
152 if precision
== _MAX_UINT64
:
153 raise ValueError("Invalid clock instance")
158 def precision(self
, precision
):
159 ret
= nbt
._bt
_ctf
_clock
_set
_precision
(self
._c
, precision
)
162 def offset_seconds(self
):
164 Clock offset in seconds since POSIX.1 Epoch (integer).
166 Set this attribute to change the clock's offset in seconds.
168 :exc:`ValueError` is raised on error.
171 offset_s
= nbt
._bt
_ctf
_clock
_get
_offset
_s
(self
._c
)
173 if offset_s
== _MAX_UINT64
:
174 raise ValueError("Invalid clock instance")
178 @offset_seconds.setter
179 def offset_seconds(self
, offset_s
):
180 ret
= nbt
._bt
_ctf
_clock
_set
_offset
_s
(self
._c
, offset_s
)
183 raise ValueError("Invalid offset value.")
188 Clock offset in ticks since (POSIX.1 Epoch +
189 :attr:`offset_seconds`).
191 Set this attribute to change the clock's offset.
193 :exc:`ValueError` is raised on error.
196 offset
= nbt
._bt
_ctf
_clock
_get
_offset
(self
._c
)
198 if offset
== _MAX_UINT64
:
199 raise ValueError("Invalid clock instance")
204 def offset(self
, offset
):
205 ret
= nbt
._bt
_ctf
_clock
_set
_offset
(self
._c
, offset
)
208 raise ValueError("Invalid offset value.")
213 ``True`` if this clock is absolute, i.e. if the clock is a
214 global reference across the other clocks of the trace.
216 Set this attribute to change the clock's absolute state
219 :exc:`ValueError` is raised on error.
222 is_absolute
= nbt
._bt
_ctf
_clock
_get
_is
_absolute
(self
._c
)
224 if is_absolute
== -1:
225 raise ValueError("Invalid clock instance")
227 return False if is_absolute
== 0 else True
230 def absolute(self
, is_absolute
):
231 ret
= nbt
._bt
_ctf
_clock
_set
_is
_absolute
(self
._c
, int(is_absolute
))
234 raise ValueError("Could not set the clock absolute attribute.")
239 Clock UUID (an :class:`uuid.UUID` object).
241 Set this attribute to change the clock's UUID.
243 :exc:`ValueError` is raised on error.
249 ret
, value
= nbt
._bt
_python
_ctf
_clock
_get
_uuid
_index
(self
._c
, i
)
252 raise ValueError("Invalid clock instance")
254 uuid_list
.append(value
)
256 return UUID(bytes
=bytes(uuid_list
))
259 def uuid(self
, uuid
):
260 uuid_bytes
= uuid
.bytes
262 if len(uuid_bytes
) != 16:
263 raise ValueError("Invalid UUID provided. UUID length must be 16 bytes")
265 for i
in range(len(uuid_bytes
)):
266 ret
= nbt
._bt
_python
_ctf
_clock
_set
_uuid
_index
(self
._c
, i
,
270 raise ValueError("Invalid clock instance")
275 Clock current time; nanoseconds (integer) since clock origin
276 (POSIX.1 Epoch + :attr:`offset_seconds` + :attr:`offset`).
278 Set this attribute to change the clock's current time.
280 :exc:`ValueError` is raised on error.
283 time
= nbt
._bt
_ctf
_clock
_get
_time
(self
._c
)
285 if time
== _MAX_UINT64
:
286 raise ValueError("Invalid clock instance")
291 def time(self
, time
):
292 ret
= nbt
._bt
_ctf
_clock
_set
_time
(self
._c
, time
)
295 raise ValueError("Invalid time value.")
300 Display base of an integer.
304 INTEGER_BASE_UNKNOWN
= -1
307 INTEGER_BASE_BINARY
= 2
310 INTEGER_BASE_OCTAL
= 8
313 INTEGER_BASE_DECIMAL
= 10
316 INTEGER_BASE_HEXADECIMAL
= 16
319 class FieldDeclaration
:
321 Base class of all field declarations. This class is not meant to
322 be instantiated by the user; use one of the concrete field
323 declaration subclasses instead.
326 class IntegerBase(IntegerBase
):
331 raise ValueError("FieldDeclaration creation failed.")
334 nbt
._bt
_ctf
_field
_type
_put
(self
._ft
)
337 def _create_field_declaration_from_native_instance(
338 native_field_declaration
):
340 common
.CTFTypeId
.INTEGER
: IntegerFieldDeclaration
,
341 common
.CTFTypeId
.FLOAT
: FloatFieldDeclaration
,
342 common
.CTFTypeId
.ENUM
: EnumerationFieldDeclaration
,
343 common
.CTFTypeId
.STRING
: StringFieldDeclaration
,
344 common
.CTFTypeId
.STRUCT
: StructureFieldDeclaration
,
345 common
.CTFTypeId
.VARIANT
: VariantFieldDeclaration
,
346 common
.CTFTypeId
.ARRAY
: ArrayFieldDeclaration
,
347 common
.CTFTypeId
.SEQUENCE
: SequenceFieldDeclaration
350 field_type_id
= nbt
._bt
_ctf
_field
_type
_get
_type
_id
(native_field_declaration
)
352 if field_type_id
== common
.CTFTypeId
.UNKNOWN
:
353 raise TypeError("Invalid field instance")
355 declaration
= Field
.__new
__(Field
)
356 declaration
._ft
= native_field_declaration
357 declaration
.__class
__ = type_dict
[field_type_id
]
364 Field alignment in bits (integer).
366 Set this attribute to change this field's alignment.
368 :exc:`ValueError` is raised on error.
371 return nbt
._bt
_ctf
_field
_type
_get
_alignment
(self
._ft
)
374 def alignment(self
, alignment
):
375 ret
= nbt
._bt
_ctf
_field
_type
_set
_alignment
(self
._ft
, alignment
)
378 raise ValueError("Invalid alignment value.")
381 def byte_order(self
):
383 Field byte order (one of :class:`babeltrace.common.ByteOrder`
386 Set this attribute to change this field's byte order.
388 :exc:`ValueError` is raised on error.
391 return nbt
._bt
_ctf
_field
_type
_get
_byte
_order
(self
._ft
)
394 def byte_order(self
, byte_order
):
395 ret
= nbt
._bt
_ctf
_field
_type
_set
_byte
_order
(self
._ft
, byte_order
)
398 raise ValueError("Could not set byte order value.")
401 class IntegerFieldDeclaration(FieldDeclaration
):
403 Integer field declaration.
406 def __init__(self
, size
):
408 Creates an integer field declaration of size *size* bits.
410 :exc:`ValueError` is raised on error.
413 self
._ft
= nbt
._bt
_ctf
_field
_type
_integer
_create
(size
)
419 Integer size in bits (integer).
421 Set this attribute to change this integer's size.
423 :exc:`ValueError` is raised on error.
426 ret
= nbt
._bt
_ctf
_field
_type
_integer
_get
_size
(self
._ft
)
429 raise ValueError("Could not get Integer size attribute.")
436 ``True`` if this integer is signed.
438 Set this attribute to change this integer's signedness
441 :exc:`ValueError` is raised on error.
444 ret
= nbt
._bt
_ctf
_field
_type
_integer
_get
_signed
(self
._ft
)
447 raise ValueError("Could not get Integer signed attribute.")
454 def signed(self
, signed
):
455 ret
= nbt
._bt
_ctf
_field
_type
_integer
_set
_signed
(self
._ft
, signed
)
458 raise ValueError("Could not set Integer signed attribute.")
463 Integer display base (one of :class:`IntegerBase` constants).
465 Set this attribute to change this integer's display base.
467 :exc:`ValueError` is raised on error.
470 return nbt
._bt
_ctf
_field
_type
_integer
_get
_base
(self
._ft
)
473 def base(self
, base
):
474 ret
= nbt
._bt
_ctf
_field
_type
_integer
_set
_base
(self
._ft
, base
)
477 raise ValueError("Could not set Integer base.")
482 Integer encoding (one of
483 :class:`babeltrace.common.CTFStringEncoding` constants).
485 Set this attribute to change this integer's encoding.
487 :exc:`ValueError` is raised on error.
490 return nbt
._bt
_ctf
_field
_type
_integer
_get
_encoding
(self
._ft
)
493 def encoding(self
, encoding
):
494 ret
= nbt
._bt
_ctf
_field
_type
_integer
_set
_encoding
(self
._ft
, encoding
)
497 raise ValueError("Could not set Integer encoding.")
500 class EnumerationFieldDeclaration(FieldDeclaration
):
502 Enumeration field declaration. A CTF enumeration maps labels to
506 def __init__(self
, integer_type
):
508 Creates an enumeration field declaration, with *integer_type*
509 being the underlying :class:`IntegerFieldDeclaration` for storing
512 :exc:`ValueError` is raised on error.
515 isinst
= isinstance(integer_type
, IntegerFieldDeclaration
)
517 if integer_type
is None or not isinst
:
518 raise TypeError("Invalid integer container.")
520 self
._ft
= nbt
._bt
_ctf
_field
_type
_enumeration
_create
(integer_type
._ft
)
526 Underlying container (:class:`IntegerFieldDeclaration`).
528 :exc:`TypeError` is raised on error.
531 ret
= nbt
._bt
_ctf
_field
_type
_enumeration
_get
_container
_type
(self
._ft
)
534 raise TypeError("Invalid enumeration declaration")
536 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(ret
)
538 def add_mapping(self
, name
, range_start
, range_end
):
540 Adds a mapping to the enumeration field declaration, from the
541 label named *name* to range [*range_start*, *range_end*], where
542 *range_start* and *range_end* are integers included in the
545 :exc:`ValueError` is raised on error.
548 if range_start
< 0 or range_end
< 0:
549 ret
= nbt
._bt
_ctf
_field
_type
_enumeration
_add
_mapping
(self
._ft
,
554 ret
= nbt
._bt
_ctf
_field
_type
_enumeration
_add
_mapping
_unsigned
(self
._ft
,
560 raise ValueError("Could not add mapping to enumeration declaration.")
565 Generates the mappings of this enumeration field declaration
566 (:class:`EnumerationMapping` objects).
568 :exc:`TypeError` is raised on error.
571 signed
= self
.container
.signed
573 count
= nbt
._bt
_ctf
_field
_type
_enumeration
_get
_mapping
_count
(self
._ft
)
575 for i
in range(count
):
577 ret
= nbt
._bt
_python
_ctf
_field
_type
_enumeration
_get
_mapping
(self
._ft
, i
)
579 ret
= nbt
._bt
_python
_ctf
_field
_type
_enumeration
_get
_mapping
_unsigned
(self
._ft
, i
)
582 msg
= "Could not get Enumeration mapping at index {}".format(i
)
585 name
, range_start
, range_end
= ret
586 yield EnumerationMapping(name
, range_start
, range_end
)
588 def get_mapping_by_name(self
, name
):
590 Returns the :class:`EnumerationMapping` object for the label
593 :exc:`TypeError` is raised on error.
596 index
= nbt
._bt
_ctf
_field
_type
_enumeration
_get
_mapping
_index
_by
_name
(self
._ft
, name
)
601 if self
.container
.signed
:
602 ret
= nbt
._bt
_python
_ctf
_field
_type
_enumeration
_get
_mapping
(self
._ft
, index
)
604 ret
= nbt
._bt
_python
_ctf
_field
_type
_enumeration
_get
_mapping
_unsigned
(self
._ft
, index
)
607 msg
= "Could not get Enumeration mapping at index {}".format(i
)
610 name
, range_start
, range_end
= ret
612 return EnumerationMapping(name
, range_start
, range_end
)
614 def get_mapping_by_value(self
, value
):
616 Returns the :class:`EnumerationMapping` object for the value
619 :exc:`TypeError` is raised on error.
623 index
= nbt
._bt
_ctf
_field
_type
_enumeration
_get
_mapping
_index
_by
_value
(self
._ft
, value
)
625 index
= nbt
._bt
_ctf
_field
_type
_enumeration
_get
_mapping
_index
_by
_unsigned
_value
(self
._ft
, value
)
630 if self
.container
.signed
:
631 ret
= nbt
._bt
_python
_ctf
_field
_type
_enumeration
_get
_mapping
(self
._ft
, index
)
633 ret
= nbt
._bt
_python
_ctf
_field
_type
_enumeration
_get
_mapping
_unsigned
(self
._ft
, index
)
636 msg
= "Could not get Enumeration mapping at index {}".format(i
)
639 name
, range_start
, range_end
= ret
641 return EnumerationMapping(name
, range_start
, range_end
)
644 class FloatingPointFieldDeclaration(FieldDeclaration
):
646 Floating point number field declaration.
648 A CTF floating point number is a made of three sections: the sign
649 bit, the exponent bits, and the mantissa bits. The most significant
650 bit of the resulting binary word is the sign bit, and is included
651 in the number of mantissa bits.
654 `IEEE 754 <http://en.wikipedia.org/wiki/IEEE_floating_point>`_
655 single precision floating point number is represented on a 32-bit
656 word using an 8-bit exponent (``e``) and a 24-bit mantissa (``m``),
657 the latter count including the sign bit (``s``)::
659 s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm
661 The IEEE 754 double precision floating point number uses an
662 11-bit exponent and a 53-bit mantissa.
665 #: IEEE 754 single precision floating point number exponent size
668 #: IEEE 754 double precision floating point number exponent size
671 #: IEEE 754 single precision floating point number mantissa size
674 #: IEEE 754 double precision floating point number mantissa size
679 Creates a floating point number field declaration.
681 :exc:`ValueError` is raised on error.
684 self
._ft
= nbt
._bt
_ctf
_field
_type
_floating
_point
_create
()
688 def exponent_digits(self
):
690 Floating point number exponent section size in bits (integer).
692 Set this attribute to change the floating point number's
693 exponent section's size. You may use :attr:`FLT_EXP_DIG` or
694 :attr:`DBL_EXP_DIG` for IEEE 754 floating point numbers.
696 :exc:`ValueError` is raised on error.
699 ret
= nbt
._bt
_ctf
_field
_type
_floating
_point
_get
_exponent
_digits
(self
._ft
)
703 "Could not get Floating point exponent digit count")
707 @exponent_digits.setter
708 def exponent_digits(self
, exponent_digits
):
709 ret
= nbt
._bt
_ctf
_field
_type
_floating
_point
_set
_exponent
_digits
(self
._ft
,
713 raise ValueError("Could not set exponent digit count.")
716 def mantissa_digits(self
):
718 Floating point number mantissa section size in bits (integer).
720 Set this attribute to change the floating point number's
721 mantissa section's size. You may use :attr:`FLT_MANT_DIG` or
722 :attr:`DBL_MANT_DIG` for IEEE 754 floating point numbers.
724 :exc:`ValueError` is raised on error.
727 ret
= nbt
._bt
_ctf
_field
_type
_floating
_point
_get
_mantissa
_digits
(self
._ft
)
730 raise TypeError("Could not get Floating point mantissa digit count")
734 @mantissa_digits.setter
735 def mantissa_digits(self
, mantissa_digits
):
736 ret
= nbt
._bt
_ctf
_field
_type
_floating
_point
_set
_mantissa
_digits
(self
._ft
,
740 raise ValueError("Could not set mantissa digit count.")
743 class FloatFieldDeclaration(FloatingPointFieldDeclaration
):
747 class StructureFieldDeclaration(FieldDeclaration
):
749 Structure field declaration, i.e. an ordered mapping from field
750 names to field declarations.
755 Creates an empty structure field declaration.
757 :exc:`ValueError` is raised on error.
760 self
._ft
= nbt
._bt
_ctf
_field
_type
_structure
_create
()
763 def add_field(self
, field_type
, field_name
):
765 Appends one :class:`FieldDeclaration` *field_type* named
766 *field_name* to the structure's ordered map.
768 :exc:`ValueError` is raised on error.
771 ret
= nbt
._bt
_ctf
_field
_type
_structure
_add
_field
(self
._ft
,
776 raise ValueError("Could not add field to structure.")
781 Generates the (field name, :class:`FieldDeclaration`) pairs
784 :exc:`TypeError` is raised on error.
787 count
= nbt
._bt
_ctf
_field
_type
_structure
_get
_field
_count
(self
._ft
)
790 raise TypeError("Could not get Structure field count")
792 for i
in range(count
):
793 field_name
= nbt
._bt
_python
_ctf
_field
_type
_structure
_get
_field
_name
(self
._ft
, i
)
795 if field_name
is None:
796 msg
= "Could not get Structure field name at index {}".format(i
)
799 field_type_native
= nbt
._bt
_python
_ctf
_field
_type
_structure
_get
_field
_type
(self
._ft
, i
)
801 if field_type_native
is None:
802 msg
= "Could not get Structure field type at index {}".format(i
)
805 field_type
= FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
806 yield (field_name
, field_type
)
808 def get_field_by_name(self
, name
):
810 Returns the :class:`FieldDeclaration` mapped to the field name
811 *name* in this structure.
813 :exc:`TypeError` is raised on error.
816 field_type_native
= nbt
._bt
_ctf
_field
_type
_structure
_get
_field
_type
_by
_name
(self
._ft
, name
)
818 if field_type_native
is None:
819 msg
= "Could not find Structure field with name {}".format(name
)
822 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
825 class VariantFieldDeclaration(FieldDeclaration
):
827 Variant field declaration.
829 A CTF variant is a dynamic selection between different fields.
830 The value of a *tag* (a CTF enumeration) determines what is the
831 current selected field. All the possible fields must be added to
832 its field declaration before using an actual variant field.
835 def __init__(self
, enum_tag
, tag_name
):
837 Creates an empty variant field declaration with tag field
838 declaration *enum_tag* (instance of
839 :class:`EnumerationFieldDeclaration`) named *tag_name*
842 :exc:`ValueError` is raised on error.
845 isinst
= isinstance(enum_tag
, EnumerationFieldDeclaration
)
846 if enum_tag
is None or not isinst
:
847 raise TypeError("Invalid tag type; must be of type EnumerationFieldDeclaration.")
849 self
._ft
= nbt
._bt
_ctf
_field
_type
_variant
_create
(enum_tag
._ft
,
856 Variant field declaration tag name.
858 :exc:`TypeError` is raised on error.
861 ret
= nbt
._bt
_ctf
_field
_type
_variant
_get
_tag
_name
(self
._ft
)
864 raise TypeError("Could not get Variant tag name")
871 Variant field declaration tag field declaration
872 (:class:`EnumerationFieldDeclaration` object).
874 :exc:`TypeError` is raised on error.
877 ret
= nbt
._bt
_ctf
_field
_type
_variant
_get
_tag
_type
(self
._ft
)
880 raise TypeError("Could not get Variant tag type")
882 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(ret
)
884 def add_field(self
, field_type
, field_name
):
886 Registers the :class:`FieldDeclaration` object *field_type*
887 as the variant's selected type when the variant's tag's current
888 label is *field_name*.
890 :exc:`ValueError` is raised on error.
893 ret
= nbt
._bt
_ctf
_field
_type
_variant
_add
_field
(self
._ft
,
898 raise ValueError("Could not add field to variant.")
903 Generates the (field name, :class:`FieldDeclaration`) pairs
904 of this variant field declaration.
906 :exc:`TypeError` is raised on error.
909 count
= nbt
._bt
_ctf
_field
_type
_variant
_get
_field
_count
(self
._ft
)
912 raise TypeError("Could not get Variant field count")
914 for i
in range(count
):
915 field_name
= nbt
._bt
_python
_ctf
_field
_type
_variant
_get
_field
_name
(self
._ft
, i
)
917 if field_name
is None:
918 msg
= "Could not get Variant field name at index {}".format(i
)
921 field_type_native
= nbt
._bt
_python
_ctf
_field
_type
_variant
_get
_field
_type
(self
._ft
, i
)
923 if field_type_native
is None:
924 msg
= "Could not get Variant field type at index {}".format(i
)
927 field_type
= FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
928 yield (field_name
, field_type
)
930 def get_field_by_name(self
, name
):
932 Returns the :class:`FieldDeclaration` selected when the
933 variant's tag's current label is *name*.
935 :exc:`TypeError` is raised on error.
938 field_type_native
= nbt
._bt
_ctf
_field
_type
_variant
_get
_field
_type
_by
_name
(self
._ft
,
941 if field_type_native
is None:
942 msg
= "Could not find Variant field with name {}".format(name
)
945 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
947 def get_field_from_tag(self
, tag
):
949 Returns the :class:`FieldDeclaration` selected by the current
950 label of the :class:`EnumerationField` *tag*.
952 :exc:`TypeError` is raised on error.
955 field_type_native
= nbt
._bt
_ctf
_field
_type
_variant
_get
_field
_type
_from
_tag
(self
._ft
, tag
._f
)
957 if field_type_native
is None:
958 msg
= "Could not find Variant field with tag value {}".format(tag
.value
)
961 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
964 class ArrayFieldDeclaration(FieldDeclaration
):
966 Static array field declaration.
969 def __init__(self
, element_type
, length
):
971 Creates a static array field declaration of *length*
972 elements of type *element_type* (:class:`FieldDeclaration`).
974 :exc:`ValueError` is raised on error.
977 self
._ft
= nbt
._bt
_ctf
_field
_type
_array
_create
(element_type
._ft
,
982 def element_type(self
):
984 Type of the elements of this this static array (subclass of
985 :class:`FieldDeclaration`).
987 :exc:`TypeError` is raised on error.
990 ret
= nbt
._bt
_ctf
_field
_type
_array
_get
_element
_type
(self
._ft
)
993 raise TypeError("Could not get Array element type")
995 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(ret
)
1000 Length of this static array (integer).
1002 :exc:`TypeError` is raised on error.
1005 ret
= nbt
._bt
_ctf
_field
_type
_array
_get
_length
(self
._ft
)
1008 raise TypeError("Could not get Array length")
1013 class SequenceFieldDeclaration(FieldDeclaration
):
1015 Sequence (dynamic array) field declaration.
1018 def __init__(self
, element_type
, length_field_name
):
1020 Creates a sequence field declaration of
1021 elements of type *element_type* (:class:`FieldDeclaration`).
1022 The length of a sequence field based on this sequence field
1023 declaration is obtained by retrieving the dynamic integer
1024 value of the field named *length_field_name*.
1026 :exc:`ValueError` is raised on error.
1029 self
._ft
= nbt
._bt
_ctf
_field
_type
_sequence
_create
(element_type
._ft
,
1030 str(length_field_name
))
1034 def element_type(self
):
1036 Type of the elements of this sequence (subclass of
1037 :class:`FieldDeclaration`).
1039 :exc:`TypeError` is raised on error.
1042 ret
= nbt
._bt
_ctf
_field
_type
_sequence
_get
_element
_type
(self
._ft
)
1045 raise TypeError("Could not get Sequence element type")
1047 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(ret
)
1050 def length_field_name(self
):
1052 Name of the integer field defining the dynamic length of
1053 sequence fields based on this sequence field declaration.
1055 :exc:`TypeError` is raised on error.
1058 ret
= nbt
._bt
_ctf
_field
_type
_sequence
_get
_length
_field
_name
(self
._ft
)
1061 raise TypeError("Could not get Sequence length field name")
1066 class StringFieldDeclaration(FieldDeclaration
):
1068 String (NULL-terminated array of bytes) field declaration.
1073 Creates a string field declaration.
1075 :exc:`ValueError` is raised on error.
1078 self
._ft
= nbt
._bt
_ctf
_field
_type
_string
_create
()
1084 String encoding (one of
1085 :class:`babeltrace.common.CTFStringEncoding` constants).
1087 Set this attribute to change this string's encoding.
1089 :exc:`ValueError` is raised on error.
1092 return nbt
._bt
_ctf
_field
_type
_string
_get
_encoding
(self
._ft
)
1095 def encoding(self
, encoding
):
1096 ret
= nbt
._bt
_ctf
_field
_type
_string
_set
_encoding
(self
._ft
, encoding
)
1098 raise ValueError("Could not set string encoding.")
1102 def create_field(field_type
):
1104 Create an instance of a field.
1106 isinst
= isinstance(field_type
, FieldDeclaration
)
1108 if field_type
is None or not isinst
:
1109 raise TypeError("Invalid field_type. Type must be a FieldDeclaration-derived class.")
1111 if isinstance(field_type
, IntegerFieldDeclaration
):
1112 return IntegerField(field_type
)
1113 elif isinstance(field_type
, EnumerationFieldDeclaration
):
1114 return EnumerationField(field_type
)
1115 elif isinstance(field_type
, FloatFieldDeclaration
):
1116 return FloatingPointField(field_type
)
1117 elif isinstance(field_type
, StructureFieldDeclaration
):
1118 return StructureField(field_type
)
1119 elif isinstance(field_type
, VariantFieldDeclaration
):
1120 return VariantField(field_type
)
1121 elif isinstance(field_type
, ArrayFieldDeclaration
):
1122 return ArrayField(field_type
)
1123 elif isinstance(field_type
, SequenceFieldDeclaration
):
1124 return SequenceField(field_type
)
1125 elif isinstance(field_type
, StringFieldDeclaration
):
1126 return StringField(field_type
)
1131 Base class of all fields. This class is not meant to be
1132 instantiated by the user, and neither are its subclasses. Use
1133 :meth:`Event.payload` to access specific, concrete fields of
1137 def __init__(self
, field_type
):
1138 if not isinstance(field_type
, FieldDeclaration
):
1139 raise TypeError("Invalid field_type argument.")
1141 self
._f
= nbt
._bt
_ctf
_field
_create
(field_type
._ft
)
1144 raise ValueError("Field creation failed.")
1147 nbt
._bt
_ctf
_field
_put
(self
._f
)
1150 def _create_field_from_native_instance(native_field_instance
):
1152 common
.CTFTypeId
.INTEGER
: IntegerField
,
1153 common
.CTFTypeId
.FLOAT
: FloatingPointField
,
1154 common
.CTFTypeId
.ENUM
: EnumerationField
,
1155 common
.CTFTypeId
.STRING
: StringField
,
1156 common
.CTFTypeId
.STRUCT
: StructureField
,
1157 common
.CTFTypeId
.VARIANT
: VariantField
,
1158 common
.CTFTypeId
.ARRAY
: ArrayField
,
1159 common
.CTFTypeId
.SEQUENCE
: SequenceField
1162 field_type
= nbt
._bt
_python
_get
_field
_type
(native_field_instance
)
1164 if field_type
== common
.CTFTypeId
.UNKNOWN
:
1165 raise TypeError("Invalid field instance")
1167 field
= Field
.__new
__(Field
)
1168 field
._f
= native_field_instance
1169 field
.__class
__ = type_dict
[field_type
]
1174 def declaration(self
):
1176 Field declaration (subclass of :class:`FieldDeclaration`).
1178 :exc:`TypeError` is raised on error.
1181 native_field_type
= nbt
._bt
_ctf
_field
_get
_type
(self
._f
)
1183 if native_field_type
is None:
1184 raise TypeError("Invalid field instance")
1185 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(
1189 class IntegerField(Field
):
1191 Integer field, based on an :class:`IntegerFieldDeclaration` object.
1197 Integer value (:class:`int`).
1199 Set this attribute to change the integer field's value.
1201 :exc:`ValueError` or :exc:`TypeError` are raised on error.
1204 signedness
= nbt
._bt
_python
_field
_integer
_get
_signedness
(self
._f
)
1207 raise TypeError("Invalid integer instance.")
1210 ret
, value
= nbt
._bt
_ctf
_field
_unsigned
_integer
_get
_value
(self
._f
)
1212 ret
, value
= nbt
._bt
_ctf
_field
_signed
_integer
_get
_value
(self
._f
)
1215 raise ValueError("Could not get integer field value.")
1220 def value(self
, value
):
1221 if not isinstance(value
, int):
1222 raise TypeError("IntegerField's value must be an int")
1224 signedness
= nbt
._bt
_python
_field
_integer
_get
_signedness
(self
._f
)
1226 raise TypeError("Invalid integer instance.")
1229 ret
= nbt
._bt
_ctf
_field
_unsigned
_integer
_set
_value
(self
._f
, value
)
1231 ret
= nbt
._bt
_ctf
_field
_signed
_integer
_set
_value
(self
._f
, value
)
1234 raise ValueError("Could not set integer field value.")
1237 class EnumerationField(Field
):
1239 Enumeration field, based on an
1240 :class:`EnumerationFieldDeclaration` object.
1244 def container(self
):
1246 Underlying container (:class:`IntegerField`).
1248 :exc:`TypeError` is raised on error.
1251 container
= IntegerField
.__new
__(IntegerField
)
1252 container
._f
= nbt
._bt
_ctf
_field
_enumeration
_get
_container
(self
._f
)
1254 if container
._f
is None:
1255 raise TypeError("Invalid enumeration field type.")
1262 Current label of this enumeration field (:class:`str`).
1264 Set this attribute to an integer (:class:`int`) to change the
1265 enumeration field's value.
1267 :exc:`ValueError` is raised on error.
1270 value
= nbt
._bt
_ctf
_field
_enumeration
_get
_mapping
_name
(self
._f
)
1273 raise ValueError("Could not get enumeration mapping name.")
1278 def value(self
, value
):
1279 if not isinstance(value
, int):
1280 raise TypeError("EnumerationField value must be an int")
1282 self
.container
.value
= value
1285 class FloatingPointField(Field
):
1287 Floating point number field, based on a
1288 :class:`FloatingPointFieldDeclaration` object.
1294 Floating point number value (:class:`float`).
1296 Set this attribute to change the floating point number field's
1299 :exc:`ValueError` or :exc:`TypeError` are raised on error.
1302 ret
, value
= nbt
._bt
_ctf
_field
_floating
_point
_get
_value
(self
._f
)
1305 raise ValueError("Could not get floating point field value.")
1310 def value(self
, value
):
1311 if not isinstance(value
, int) and not isinstance(value
, float):
1312 raise TypeError("Value must be either a float or an int")
1314 ret
= nbt
._bt
_ctf
_field
_floating
_point
_set
_value
(self
._f
, float(value
))
1317 raise ValueError("Could not set floating point field value.")
1320 # oops!! This class is provided to ensure backward-compatibility since
1321 # a stable release publicly exposed this abomination.
1322 class FloatFieldingPoint(FloatingPointField
):
1326 class StructureField(Field
):
1328 Structure field, based on a
1329 :class:`StructureFieldDeclaration` object.
1332 def field(self
, field_name
):
1334 Returns the structure :class:`Field` named *field_name*.
1336 :exc:`ValueError` is raised on error.
1339 native_instance
= nbt
._bt
_ctf
_field
_structure
_get
_field
(self
._f
,
1342 if native_instance
is None:
1343 raise ValueError("Invalid field_name provided.")
1345 return Field
._create
_field
_from
_native
_instance
(native_instance
)
1348 class VariantField(Field
):
1350 Variant field, based on a
1351 :class:`VariantFieldDeclaration` object.
1354 def field(self
, tag
):
1356 Returns the :class:`Field` selected by the current label of
1357 *tag* (:class:`EnumerationField`).
1359 :exc:`ValueError` is raised on error.
1362 native_instance
= nbt
._bt
_ctf
_field
_variant
_get
_field
(self
._f
, tag
._f
)
1364 if native_instance
is None:
1365 raise ValueError("Invalid tag provided.")
1367 return Field
._create
_field
_from
_native
_instance
(native_instance
)
1370 class ArrayField(Field
):
1371 def field(self
, index
):
1373 Return the array's field at position "index".
1376 native_instance
= nbt
._bt
_ctf
_field
_array
_get
_field
(self
._f
, index
)
1378 if native_instance
is None:
1379 raise IndexError("Invalid index provided.")
1381 return Field
._create
_field
_from
_native
_instance
(native_instance
)
1384 class SequenceField(Field
):
1388 Get the sequence's length field (IntegerField).
1391 native_instance
= nbt
._bt
_ctf
_field
_sequence
_get
_length
(self
._f
)
1393 if native_instance
is None:
1396 return Field
._create
_field
_from
_native
_instance
(native_instance
)
1399 def length(self
, length_field
):
1401 Set the sequence's length field (IntegerField).
1404 if not isinstance(length_field
, IntegerField
):
1405 raise TypeError("Invalid length field.")
1407 if length_field
.declaration
.signed
:
1408 raise TypeError("Sequence field length must be unsigned")
1410 ret
= nbt
._bt
_ctf
_field
_sequence
_set
_length
(self
._f
, length_field
._f
)
1413 raise ValueError("Could not set sequence length.")
1415 def field(self
, index
):
1417 Return the sequence's field at position "index".
1420 native_instance
= nbt
._bt
_ctf
_field
_sequence
_get
_field
(self
._f
, index
)
1422 if native_instance
is None:
1423 raise ValueError("Could not get sequence element at index.")
1425 return Field
._create
_field
_from
_native
_instance
(native_instance
)
1428 class StringField(Field
):
1432 Get a string field's value.
1435 return nbt
._bt
_ctf
_field
_string
_get
_value
(self
._f
)
1438 def value(self
, value
):
1440 Set a string field's value.
1443 ret
= nbt
._bt
_ctf
_field
_string
_set
_value
(self
._f
, str(value
))
1446 raise ValueError("Could not set string field value.")
1450 def __init__(self
, name
):
1452 Create a new event class of the given name.
1455 self
._ec
= nbt
._bt
_ctf
_event
_class
_create
(name
)
1457 if self
._ec
is None:
1458 raise ValueError("Event class creation failed.")
1461 nbt
._bt
_ctf
_event
_class
_put
(self
._ec
)
1463 def add_field(self
, field_type
, field_name
):
1465 Add a field of type "field_type" to the event class.
1468 ret
= nbt
._bt
_ctf
_event
_class
_add
_field
(self
._ec
, field_type
._ft
,
1472 raise ValueError("Could not add field to event class.")
1477 Get the event class' name.
1480 name
= nbt
._bt
_ctf
_event
_class
_get
_name
(self
._ec
)
1483 raise TypeError("Could not get EventClass name")
1490 Get the event class' id. Returns a negative value if unset.
1493 id = nbt
._bt
_ctf
_event
_class
_get
_id
(self
._ec
)
1496 raise TypeError("Could not get EventClass id")
1503 Set the event class' id. Throws a TypeError if the event class
1504 is already registered to a stream class.
1507 ret
= nbt
._bt
_ctf
_event
_class
_set
_id
(self
._ec
, id)
1510 raise TypeError("Can't change an Event Class's id after it has been assigned to a stream class")
1513 def stream_class(self
):
1515 Get the event class' stream class. Returns None if unset.
1517 stream_class_native
= nbt
._bt
_ctf
_event
_class
_get
_stream
_class
(self
._ec
)
1519 if stream_class_native
is None:
1522 stream_class
= StreamClass
.__new
__(StreamClass
)
1523 stream_class
._sc
= stream_class_native
1530 Generator returning the event class' fields as tuples of (field name, field declaration).
1533 count
= nbt
._bt
_ctf
_event
_class
_get
_field
_count
(self
._ec
)
1536 raise TypeError("Could not get EventClass' field count")
1538 for i
in range(count
):
1539 field_name
= nbt
._bt
_python
_ctf
_event
_class
_get
_field
_name
(self
._ec
, i
)
1541 if field_name
is None:
1542 msg
= "Could not get EventClass' field name at index {}".format(i
)
1543 raise TypeError(msg
)
1545 field_type_native
= nbt
._bt
_python
_ctf
_event
_class
_get
_field
_type
(self
._ec
, i
)
1547 if field_type_native
is None:
1548 msg
= "Could not get EventClass' field type at index {}".format(i
)
1549 raise TypeError(msg
)
1551 field_type
= FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
1552 yield (field_name
, field_type
)
1554 def get_field_by_name(self
, name
):
1556 Get a field declaration by name (FieldDeclaration).
1559 field_type_native
= nbt
._bt
_ctf
_event
_class
_get
_field
_by
_name
(self
._ec
, name
)
1561 if field_type_native
is None:
1562 msg
= "Could not find EventClass field with name {}".format(name
)
1563 raise TypeError(msg
)
1565 return FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
1569 def __init__(self
, event_class
):
1571 Create a new event of the given event class.
1574 if not isinstance(event_class
, EventClass
):
1575 raise TypeError("Invalid event_class argument.")
1577 self
._e
= nbt
._bt
_ctf
_event
_create
(event_class
._ec
)
1580 raise ValueError("Event creation failed.")
1583 nbt
._bt
_ctf
_event
_put
(self
._e
)
1586 def event_class(self
):
1588 Get the event's class.
1591 event_class_native
= nbt
._bt
_ctf
_event
_get
_class
(self
._e
)
1593 if event_class_native
is None:
1596 event_class
= EventClass
.__new
__(EventClass
)
1597 event_class
._ec
= event_class_native
1603 Get a clock from event. Returns None if the event's class
1604 is not registered to a stream class.
1607 clock_instance
= nbt
._bt
_ctf
_event
_get
_clock
(self
._e
)
1609 if clock_instance
is None:
1612 clock
= Clock
.__new
__(Clock
)
1613 clock
._c
= clock_instance
1617 def payload(self
, field_name
):
1619 Get a field from event.
1622 native_instance
= nbt
._bt
_ctf
_event
_get
_payload
(self
._e
,
1625 if native_instance
is None:
1626 raise ValueError("Could not get event payload.")
1628 return Field
._create
_field
_from
_native
_instance
(native_instance
)
1630 def set_payload(self
, field_name
, value_field
):
1632 Set a manually created field as an event's payload.
1635 if not isinstance(value
, Field
):
1636 raise TypeError("Invalid value type.")
1638 ret
= nbt
._bt
_ctf
_event
_set
_payload
(self
._e
, str(field_name
),
1642 raise ValueError("Could not set event field payload.")
1646 def __init__(self
, name
):
1648 Create a new stream class of the given name.
1651 self
._sc
= nbt
._bt
_ctf
_stream
_class
_create
(name
)
1653 if self
._sc
is None:
1654 raise ValueError("Stream class creation failed.")
1657 nbt
._bt
_ctf
_stream
_class
_put
(self
._sc
)
1662 Get a stream class' name.
1665 name
= nbt
._bt
_ctf
_stream
_class
_get
_name
(self
._sc
)
1668 raise TypeError("Could not get StreamClass name")
1675 Get a stream class' clock.
1678 clock_instance
= nbt
._bt
_ctf
_stream
_class
_get
_clock
(self
._sc
)
1680 if clock_instance
is None:
1683 clock
= Clock
.__new
__(Clock
)
1684 clock
._c
= clock_instance
1689 def clock(self
, clock
):
1691 Assign a clock to a stream class.
1694 if not isinstance(clock
, Clock
):
1695 raise TypeError("Invalid clock type.")
1697 ret
= nbt
._bt
_ctf
_stream
_class
_set
_clock
(self
._sc
, clock
._c
)
1700 raise ValueError("Could not set stream class clock.")
1705 Get a stream class' id.
1708 ret
= nbt
._bt
_ctf
_stream
_class
_get
_id
(self
._sc
)
1711 raise TypeError("Could not get StreamClass id")
1718 Assign an id to a stream class.
1721 ret
= nbt
._bt
_ctf
_stream
_class
_set
_id
(self
._sc
, id)
1724 raise TypeError("Could not set stream class id.")
1727 def event_classes(self
):
1729 Generator returning the stream class' event classes.
1732 count
= nbt
._bt
_ctf
_stream
_class
_get
_event
_class
_count
(self
._sc
)
1735 raise TypeError("Could not get StreamClass' event class count")
1737 for i
in range(count
):
1738 event_class_native
= nbt
._bt
_ctf
_stream
_class
_get
_event
_class
(self
._sc
, i
)
1740 if event_class_native
is None:
1741 msg
= "Could not get StreamClass' event class at index {}".format(i
)
1742 raise TypeError(msg
)
1744 event_class
= EventClass
.__new
__(EventClass
)
1745 event_class
._ec
= event_class_native
1748 def add_event_class(self
, event_class
):
1750 Add an event class to a stream class. New events can be added even after a
1751 stream has been instantiated and events have been appended. However, a stream
1752 will not accept events of a class that has not been added to the stream
1756 if not isinstance(event_class
, EventClass
):
1757 raise TypeError("Invalid event_class type.")
1759 ret
= nbt
._bt
_ctf
_stream
_class
_add
_event
_class
(self
._sc
,
1763 raise ValueError("Could not add event class.")
1766 def packet_context_type(self
):
1768 Get the StreamClass' packet context type (StructureFieldDeclaration)
1771 field_type_native
= nbt
._bt
_ctf
_stream
_class
_get
_packet
_context
_type
(self
._sc
)
1773 if field_type_native
is None:
1774 raise ValueError("Invalid StreamClass")
1776 field_type
= FieldDeclaration
._create
_field
_declaration
_from
_native
_instance
(field_type_native
)
1780 @packet_context_type.setter
1781 def packet_context_type(self
, field_type
):
1783 Set a StreamClass' packet context type. Must be of type
1784 StructureFieldDeclaration.
1787 if not isinstance(field_type
, StructureFieldDeclaration
):
1788 raise TypeError("field_type argument must be of type StructureFieldDeclaration.")
1790 ret
= nbt
._bt
_ctf
_stream
_class
_set
_packet
_context
_type
(self
._sc
,
1794 raise ValueError("Failed to set packet context type.")
1799 raise NotImplementedError("Stream cannot be instantiated; use Writer.create_stream()")
1802 nbt
._bt
_ctf
_stream
_put
(self
._s
)
1805 def discarded_events(self
):
1807 Get a stream's discarded event count.
1810 ret
, count
= nbt
._bt
_ctf
_stream
_get
_discarded
_events
_count
(self
._s
)
1813 raise ValueError("Could not get the stream's discarded events count")
1817 def append_discarded_events(self
, event_count
):
1819 Increase the current packet's discarded event count.
1822 nbt
._bt
_ctf
_stream
_append
_discarded
_events
(self
._s
, event_count
)
1824 def append_event(self
, event
):
1826 Append "event" to the stream's current packet. The stream's associated clock
1827 will be sampled during this call. The event shall not be modified after
1828 being appended to a stream.
1831 ret
= nbt
._bt
_ctf
_stream
_append
_event
(self
._s
, event
._e
)
1834 raise ValueError("Could not append event to stream.")
1837 def packet_context(self
):
1839 Get a Stream's packet context field (a StructureField).
1842 native_field
= nbt
._bt
_ctf
_stream
_get
_packet
_context
(self
._s
)
1844 if native_field
is None:
1845 raise ValueError("Invalid Stream.")
1847 return Field
._create
_field
_from
_native
_instance
(native_field
)
1849 @packet_context.setter
1850 def packet_context(self
, field
):
1852 Set a Stream's packet context field (must be a StructureField).
1855 if not isinstance(field
, StructureField
):
1856 raise TypeError("Argument field must be of type StructureField")
1858 ret
= nbt
._bt
_ctf
_stream
_set
_packet
_context
(self
._s
, field
._f
)
1861 raise ValueError("Invalid packet context field.")
1865 The stream's current packet's events will be flushed to disk. Events
1866 subsequently appended to the stream will be added to a new packet.
1869 ret
= nbt
._bt
_ctf
_stream
_flush
(self
._s
)
1872 raise ValueError("Could not flush stream.")
1876 def __init__(self
, path
):
1878 Create a new writer that will produce a trace in the given path.
1881 self
._w
= nbt
._bt
_ctf
_writer
_create
(path
)
1884 raise ValueError("Writer creation failed.")
1887 nbt
._bt
_ctf
_writer
_put
(self
._w
)
1889 def create_stream(self
, stream_class
):
1891 Create a new stream instance and register it to the writer.
1894 if not isinstance(stream_class
, StreamClass
):
1895 raise TypeError("Invalid stream_class type.")
1897 stream
= Stream
.__new
__(Stream
)
1898 stream
._s
= nbt
._bt
_ctf
_writer
_create
_stream
(self
._w
, stream_class
._sc
)
1902 def add_environment_field(self
, name
, value
):
1904 Add an environment field to the trace.
1907 ret
= nbt
._bt
_ctf
_writer
_add
_environment
_field
(self
._w
, str(name
),
1911 raise ValueError("Could not add environment field to trace.")
1913 def add_clock(self
, clock
):
1915 Add a clock to the trace. Clocks assigned to stream classes must be
1916 registered to the writer.
1919 ret
= nbt
._bt
_ctf
_writer
_add
_clock
(self
._w
, clock
._c
)
1922 raise ValueError("Could not add clock to Writer.")
1927 Get the trace's TSDL meta-data.
1930 return nbt
._bt
_ctf
_writer
_get
_metadata
_string
(self
._w
)
1932 def flush_metadata(self
):
1934 Flush the trace's metadata to the metadata file.
1937 nbt
._bt
_ctf
_writer
_flush
_metadata
(self
._w
)
1940 def byte_order(self
):
1942 Get the trace's byte order. Must be a constant from the ByteOrder
1946 raise NotImplementedError("Getter not implemented.")
1949 def byte_order(self
, byte_order
):
1951 Set the trace's byte order. Must be a constant from the ByteOrder
1952 class. Defaults to the host machine's endianness
1955 ret
= nbt
._bt
_ctf
_writer
_set
_byte
_order
(self
._w
, byte_order
)
1958 raise ValueError("Could not set trace's byte order.")