Example #1
0
 def __init__(self, element_field_class, length):
     utils._check_type(element_field_class, _FieldClass)
     utils._check_uint64(length)
     ptr = native_bt.field_class_array_create(element_field_class._ptr,
                                              length)
     self._check_create_status(ptr)
     super().__init__(ptr)
Example #2
0
    def __init__(self, size, alignment=None, byte_order=None, is_signed=None,
                 base=None, encoding=None, mapped_clock_class=None):
        utils._check_uint64(size)

        if size == 0:
            raise ValueError('size is 0 bits')

        ptr = native_bt.field_class_integer_create(size)
        self._check_create_status(ptr)
        super().__init__(ptr)

        if alignment is not None:
            self.alignment = alignment

        if byte_order is not None:
            self.byte_order = byte_order

        if is_signed is not None:
            self.is_signed = is_signed

        if base is not None:
            self.base = base

        if encoding is not None:
            self.encoding = encoding

        if mapped_clock_class is not None:
            self.mapped_clock_class = mapped_clock_class
    def __init__(self, name, frequency, description=None, precision=None,
                 offset=None, is_absolute=None, uuid=None):
        utils._check_str(name)
        utils._check_uint64(frequency)
        ptr = native_bt.clock_class_create(name, frequency)

        if ptr is None:
            raise bt2.CreationError('cannot create clock class object')

        super().__init__(ptr)

        if description is not None:
            self.description = description

        if frequency is not None:
            self.frequency = frequency

        if precision is not None:
            self.precision = precision

        if offset is not None:
            self.offset = offset

        if is_absolute is not None:
            self.is_absolute = is_absolute

        if uuid is not None:
            self.uuid = uuid
Example #4
0
 def cycles_to_ns_from_origin(self, cycles):
     utils._check_uint64(cycles)
     status, ns = native_bt.clock_class_cycles_to_ns_from_origin(
         self._ptr, cycles)
     error_msg = "cannot convert clock value to nanoseconds from origin for given clock class"
     utils._handle_func_status(status, error_msg)
     return ns
Example #5
0
    def __init__(self, name, frequency, description=None, precision=None,
                 offset=None, is_absolute=None, uuid=None):
        utils._check_str(name)
        utils._check_uint64(frequency)
        ptr = native_bt.clock_class_create(name, frequency)

        if ptr is None:
            raise bt2.CreationError('cannot create clock class object')

        super().__init__(ptr)

        if description is not None:
            self.description = description

        if frequency is not None:
            self.frequency = frequency

        if precision is not None:
            self.precision = precision

        if offset is not None:
            self.offset = offset

        if is_absolute is not None:
            self.is_absolute = is_absolute

        if uuid is not None:
            self.uuid = uuid
Example #6
0
 def at_index(self, index):
     utils._check_uint64(index)
     field_ptr = native_bt.ctf_field_structure_get_field_by_index(
         self._ptr, index)
     utils._handle_ptr(field_ptr,
                       "cannot get structure field object's field")
     return _create_from_ptr(field_ptr)
Example #7
0
    def _create_packet_end_message(self, packet, default_clock_snapshot=None):
        utils._check_type(packet, bt2_packet._Packet)

        if packet.stream.cls.packets_have_end_default_clock_snapshot:
            if default_clock_snapshot is None:
                raise ValueError(
                    "packet end messages in this stream must have a default clock snapshot"
                )

            utils._check_uint64(default_clock_snapshot)
            ptr = native_bt.message_packet_end_create_with_default_clock_snapshot(
                self._bt_ptr, packet._ptr, default_clock_snapshot)
        else:
            if default_clock_snapshot is not None:
                raise ValueError(
                    "packet end messages in this stream must not have a default clock snapshot"
                )

            ptr = native_bt.message_packet_end_create(self._bt_ptr,
                                                      packet._ptr)

        if ptr is None:
            raise bt2._MemoryError('cannot create packet end message object')

        return bt2_message._PacketEndMessage(ptr)
Example #8
0
    def create_stream(self, stream_class, id=None, name=None):
        utils._check_type(stream_class, bt2_stream_class._StreamClass)

        if stream_class.assigns_automatic_stream_id:
            if id is not None:
                raise ValueError(
                    "id provided, but stream class assigns automatic stream ids"
                )

            stream_ptr = native_bt.stream_create(stream_class._ptr, self._ptr)
        else:
            if id is None:
                raise ValueError(
                    "id not provided, but stream class does not assign automatic stream ids"
                )

            utils._check_uint64(id)
            stream_ptr = native_bt.stream_create_with_id(
                stream_class._ptr, self._ptr, id
            )

        if stream_ptr is None:
            raise bt2._MemoryError('cannot create stream object')

        stream = bt2_stream._Stream._create_from_ptr(stream_ptr)

        if name is not None:
            stream._name = name

        return stream
Example #9
0
    def __init__(self,
                 size,
                 alignment=None,
                 byte_order=None,
                 is_signed=None,
                 base=None,
                 encoding=None,
                 mapped_clock_class=None):
        utils._check_uint64(size)

        if size == 0:
            raise ValueError('size is 0 bits')

        ptr = native_bt.field_class_integer_create(size)
        self._check_create_status(ptr)
        super().__init__(ptr)

        if alignment is not None:
            self.alignment = alignment

        if byte_order is not None:
            self.byte_order = byte_order

        if is_signed is not None:
            self.is_signed = is_signed

        if base is not None:
            self.base = base

        if encoding is not None:
            self.encoding = encoding

        if mapped_clock_class is not None:
            self.mapped_clock_class = mapped_clock_class
 def __setitem__(self, key, value):
     utils._check_type(key, bt2.ClockClass)
     utils._check_uint64(value)
     ret = native_bt.clock_class_priority_map_add_clock_class(self._ptr,
                                                              key._ptr,
                                                              value)
     utils._handle_ret(ret, "cannot set clock class's priority in clock class priority map object")
Example #11
0
    def _set_count(self, count):
        utils._check_uint64(count)

        if count == 0:
            raise ValueError('discarded {} count is 0'.format(self._item_name))

        self._set_count(self._ptr, count)
Example #12
0
    def __getitem__(self, key):
        utils._check_uint64(key)

        sc_ptr = self._borrow_stream_class_ptr_by_id(self._ptr, key)
        if sc_ptr is None:
            raise KeyError(key)

        return self._stream_class_pycls._create_from_ptr_and_get_ref(sc_ptr)
Example #13
0
    def _value_to_int(self, value):
        if not isinstance(value, numbers.Integral):
            raise TypeError('expecting an integral number object')

        value = int(value)
        utils._check_uint64(value)

        return value
Example #14
0
 def _set_maximum_input_notification_iterator_count(self, count):
     utils._check_uint64(count)
     status = native_bt.component_sink_set_maximum_input_count(
         self._ptr, count)
     self._handle_status(
         status,
         "unexpected error: cannot set sink component object's maximum input notification iterator count"
     )
Example #15
0
    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)
Example #16
0
    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)
Example #17
0
 def mantissa_size(self, mantissa_size):
     utils._check_uint64(mantissa_size)
     ret = native_bt.field_class_floating_point_set_mantissa_digits(
         self._ptr, mantissa_size)
     utils._handle_ret(
         ret,
         "cannot set floating point number field class object's mantissa size"
     )
Example #18
0
 def exponent_size(self, exponent_size):
     utils._check_uint64(exponent_size)
     ret = native_bt.field_class_floating_point_set_exponent_digits(
         self._ptr, exponent_size)
     utils._handle_ret(
         ret,
         "cannot set floating point number field class object's exponent size"
     )
Example #19
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        plugin_ptr = native_bt.plugin_set_get_plugin(self._ptr, index)
        assert(plugin_ptr)
        return _Plugin._create_from_ptr(plugin_ptr)
Example #20
0
    def create_event_class(
        self,
        id=None,
        name=None,
        user_attributes=None,
        log_level=None,
        emf_uri=None,
        specific_context_field_class=None,
        payload_field_class=None,
    ):
        # Validate parameters before we create the object.
        bt2_event_class._EventClass._validate_create_params(
            name,
            user_attributes,
            log_level,
            emf_uri,
            specific_context_field_class,
            payload_field_class,
        )

        if self.assigns_automatic_event_class_id:
            if id is not None:
                raise ValueError(
                    'id provided, but stream class assigns automatic event class ids'
                )

            ec_ptr = native_bt.event_class_create(self._ptr)
        else:
            if id is None:
                raise ValueError(
                    'id not provided, but stream class does not assign automatic event class ids'
                )

            utils._check_uint64(id)
            ec_ptr = native_bt.event_class_create_with_id(self._ptr, id)

        event_class = bt2_event_class._EventClass._create_from_ptr(ec_ptr)

        if name is not None:
            event_class._name = name

        if user_attributes is not None:
            event_class._user_attributes = user_attributes

        if log_level is not None:
            event_class._log_level = log_level

        if emf_uri is not None:
            event_class._emf_uri = emf_uri

        if specific_context_field_class is not None:
            event_class._specific_context_field_class = specific_context_field_class

        if payload_field_class is not None:
            event_class._payload_field_class = payload_field_class

        return event_class
Example #21
0
    def mappings_by_value(self, value):
        if self.is_signed:
            utils._check_int64(value)
            iter_ptr = native_bt.ctf_field_type_enumeration_find_mappings_by_signed_value(self._ptr, value)
        else:
            utils._check_uint64(value)
            iter_ptr = native_bt.ctf_field_type_enumeration_find_mappings_by_unsigned_value(self._ptr, value)

        return self._get_mapping_iter(iter_ptr)
Example #22
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        plugin_ptr = native_bt.plugin_set_borrow_plugin_by_index_const(self._ptr, index)
        assert plugin_ptr is not None
        return _Plugin._create_from_ptr_and_get_ref(plugin_ptr)
Example #23
0
    def __getitem__(self, id):
        utils._check_uint64(id)

        stream_ptr = self._borrow_stream_ptr_by_id(self._ptr, id)

        if stream_ptr is None:
            raise KeyError(id)

        return self._stream_pycls._create_from_ptr_and_get_ref(stream_ptr)
Example #24
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        plugin_ptr = native_bt.plugin_set_borrow_plugin_by_index_const(self._ptr, index)
        assert plugin_ptr is not None
        return _Plugin._create_from_ptr_and_get_ref(plugin_ptr)
Example #25
0
 def __setitem__(self, key, value):
     utils._check_type(key, bt2.ClockClass)
     utils._check_uint64(value)
     ret = native_bt.clock_class_priority_map_add_clock_class(
         self._ptr, key._ptr, value)
     utils._handle_ret(
         ret,
         "cannot set clock class's priority in clock class priority map object"
     )
Example #26
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        plugin_ptr = native_bt.plugin_set_get_plugin(self._ptr, index)
        assert (plugin_ptr)
        return _Plugin._create_from_ptr(plugin_ptr)
Example #27
0
    def at_index(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        field_ptr = native_bt.field_structure_get_field_by_index(self._ptr, index)
        assert(field_ptr)
        return _create_from_ptr(field_ptr)
Example #28
0
    def option_at_index(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        opt_ptr = self._borrow_option_ptr_by_index(self._ptr, index)
        assert opt_ptr is not None
        return self._create_option_from_ptr(opt_ptr)
Example #29
0
    def member_at_index(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        member_ptr = self._borrow_member_ptr_by_index(self._ptr, index)
        assert member_ptr is not None
        return self._structure_member_field_class_pycls(self, member_ptr)
Example #30
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        cc_ptr = native_bt.plugin_get_component_class(self._ptr, index)
        utils._handle_ptr(cc_ptr, "cannot get plugin object's component class object")
        return bt2.component._create_generic_component_class_from_ptr(cc_ptr)
Example #31
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        notif_iter_ptr = self._get_func(self._comp._ptr, index)
        utils._handle_ptr(notif_iter_ptr, "cannot get component object's input notification iterator")
        return bt2.notification_iterator._GenericNotificationIterator._create_from_ptr(notif_iter_ptr)
Example #32
0
    def __getitem__(self, id):
        utils._check_uint64(id)

        stream_ptr = native_bt.trace_borrow_stream_by_id_const(self._ptr, id)

        if stream_ptr is None:
            raise KeyError(id)

        return bt2_stream._Stream._create_from_ptr_and_get_ref(stream_ptr)
Example #33
0
    def mappings_by_value(self, value):
        if self.is_signed:
            utils._check_int64(value)
            iter_ptr = native_bt.field_class_enumeration_find_mappings_by_signed_value(self._ptr, value)
        else:
            utils._check_uint64(value)
            iter_ptr = native_bt.field_class_enumeration_find_mappings_by_unsigned_value(self._ptr, value)

        return self._get_mapping_iter(iter_ptr)
Example #34
0
    def create_static_array_field_class(self, elem_fc, length):
        utils._check_type(elem_fc, bt2_field_class._FieldClass)
        utils._check_uint64(length)
        ptr = native_bt.field_class_array_static_create(
            self._ptr, elem_fc._ptr, length)
        self._check_create_status(ptr, 'static array')

        return bt2_field_class._StaticArrayFieldClass._create_from_ptr_and_get_ref(
            ptr)
Example #35
0
    def member_at_index(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError
        field_ptr = self._borrow_member_field_ptr_by_index(self._ptr, index)
        assert field_ptr is not None
        return self._create_field_from_ptr(field_ptr, self._owner_ptr,
                                           self._owner_get_ref,
                                           self._owner_put_ref)
Example #36
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        stream_ptr = native_bt.trace_get_stream_by_index(self._trace._ptr,
                                                         index)
        assert(stream_ptr)
        return bt2.stream._create_from_ptr(stream_ptr)
Example #37
0
    def __getitem__(self, key):
        utils._check_uint64(key)

        sc_ptr = native_bt.trace_class_borrow_stream_class_by_id_const(
            self._ptr, key)
        if sc_ptr is None:
            raise KeyError(key)

        return bt2_stream_class._StreamClass._create_from_ptr_and_get_ref(
            sc_ptr)
Example #38
0
    def member_at_index(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        member_ptr = native_bt.field_class_structure_borrow_member_by_index_const(
            self._ptr, index)
        assert member_ptr is not None
        return self._create_member_from_ptr(member_ptr)
Example #39
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        stream_ptr = native_bt.trace_get_stream_by_index(self._trace._ptr,
                                                         index)
        assert(stream_ptr)
        return bt2.stream._create_from_ptr(stream_ptr)
Example #40
0
    def _value_to_int(self, value):
        if not isinstance(value, numbers.Real):
            raise TypeError('expecting a real number object')

        value = int(value)

        if self.field_type.is_signed:
            utils._check_int64(value)
        else:
            utils._check_uint64(value)

        return value
Example #41
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        if self.is_signed:
            get_fn = native_bt.field_class_enumeration_get_mapping_signed
        else:
            get_fn = native_bt.field_class_enumeration_get_mapping_unsigned

        ret, name, lower, upper = get_fn(self._ptr, index)
        assert(ret == 0)
        return _EnumerationFieldClassMapping(name, lower, upper)
Example #42
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        if self.is_signed:
            get_fn = native_bt.ctf_field_type_enumeration_get_mapping_signed
        else:
            get_fn = native_bt.ctf_field_type_enumeration_get_mapping_unsigned

        ret, name, lower, upper = get_fn(self._ptr, index)
        utils._handle_ret(ret, "cannot get enumeration field type object's mapping")
        return _EnumerationFieldTypeMapping(name, lower, upper)
Example #43
0
    def add_mapping(self, name, lower, upper=None):
        utils._check_str(name)

        if upper is None:
            upper = lower

        if self.is_signed:
            add_fn = native_bt.field_class_enumeration_add_mapping_signed
            utils._check_int64(lower)
            utils._check_int64(upper)
        else:
            add_fn = native_bt.field_class_enumeration_add_mapping_unsigned
            utils._check_uint64(lower)
            utils._check_uint64(upper)

        ret = add_fn(self._ptr, name, lower, upper)
        utils._handle_ret(ret, "cannot add mapping to enumeration field class object")
Example #44
0
 def __init__(self, element_field_class, length):
     utils._check_type(element_field_class, _FieldClass)
     utils._check_uint64(length)
     ptr = native_bt.field_class_array_create(element_field_class._ptr, length)
     self._check_create_status(ptr)
     super().__init__(ptr)
Example #45
0
 def __init__(self, element_field_type, length):
     utils._check_type(element_field_type, _FieldType)
     utils._check_uint64(length)
     ptr = native_bt.ctf_field_type_array_create(element_field_type._ptr, length)
     self._check_create_status(ptr)
     super().__init__(ptr)
Example #46
0
 def at_index(self, index):
     utils._check_uint64(index)
     field_ptr = native_bt.ctf_field_structure_get_field_by_index(self._ptr, index)
     utils._handle_ptr(field_ptr, "cannot get structure field object's field")
     return _create_from_ptr(field_ptr)
Example #47
0
 def exponent_size(self, exponent_size):
     utils._check_uint64(exponent_size)
     ret = native_bt.field_class_floating_point_set_exponent_digits(self._ptr, exponent_size)
     utils._handle_ret(ret, "cannot set floating point number field class object's exponent size")
Example #48
0
 def mantissa_size(self, mantissa_size):
     utils._check_uint64(mantissa_size)
     ret = native_bt.field_class_floating_point_set_mantissa_digits(self._ptr, mantissa_size)
     utils._handle_ret(ret, "cannot set floating point number field class object's mantissa size")
Example #49
0
 def precision(self, precision):
     utils._check_uint64(precision)
     ret = native_bt.ctf_clock_class_set_precision(self._ptr, precision)
     utils._handle_ret(ret, "cannot set clock class object's precision")
Example #50
0
 def frequency(self, frequency):
     utils._check_uint64(frequency)
     ret = native_bt.ctf_clock_class_set_frequency(self._ptr, frequency)
     utils._handle_ret(ret, "cannot set clock class object's frequency")
Example #51
0
 def at_index(self, index):
     utils._check_uint64(index)
     return self._at(index)
Example #52
0
 def append_discarded_events(self, count):
     utils._check_uint64(count)
     native_bt.stream_append_discarded_events(self._ptr, count)
Example #53
0
 def _set_maximum_input_notification_iterator_count(self, count):
     utils._check_uint64(count)
     status = native_bt.component_sink_set_maximum_input_count(self._ptr, count)
     self._handle_status(status, "unexpected error: cannot set sink component object's maximum input notification iterator count")