Beispiel #1
0
    def _validate_create_params(
        name,
        user_attributes,
        log_level,
        emf_uri,
        specific_context_field_class,
        payload_field_class,
    ):
        if name is not None:
            utils._check_str(name)

        if user_attributes is not None:
            value = bt2_value.create_value(user_attributes)
            utils._check_type(value, bt2_value.MapValue)

        if log_level is not None:
            log_levels = (
                EventClassLogLevel.EMERGENCY,
                EventClassLogLevel.ALERT,
                EventClassLogLevel.CRITICAL,
                EventClassLogLevel.ERROR,
                EventClassLogLevel.WARNING,
                EventClassLogLevel.NOTICE,
                EventClassLogLevel.INFO,
                EventClassLogLevel.DEBUG_SYSTEM,
                EventClassLogLevel.DEBUG_PROGRAM,
                EventClassLogLevel.DEBUG_PROCESS,
                EventClassLogLevel.DEBUG_MODULE,
                EventClassLogLevel.DEBUG_UNIT,
                EventClassLogLevel.DEBUG_FUNCTION,
                EventClassLogLevel.DEBUG_LINE,
                EventClassLogLevel.DEBUG,
            )

            if log_level not in log_levels:
                raise ValueError(
                    "'{}' is not a valid log level".format(log_level))

        if emf_uri is not None:
            utils._check_str(emf_uri)

        if specific_context_field_class is not None:
            utils._check_type(specific_context_field_class,
                              bt2_field_class._StructureFieldClass)

        if payload_field_class is not None:
            utils._check_type(payload_field_class,
                              bt2_field_class._StructureFieldClass)
Beispiel #2
0
 def _user_attributes(self, user_attributes):
     value = bt2_value.create_value(user_attributes)
     utils._check_type(value, bt2_value.MapValue)
     native_bt.trace_class_set_user_attributes(self._ptr, value._ptr)
Beispiel #3
0
 def _user_attributes(self, user_attributes):
     value = bt2_value.create_value(user_attributes)
     native_bt.event_class_set_user_attributes(self._ptr, value._ptr)
Beispiel #4
0
 def _user_attributes(self, user_attributes):
     value = bt2_value.create_value(user_attributes)
     utils._check_type(value, bt2_value.MapValue)
     native_bt.field_class_variant_option_set_user_attributes(self._ptr, value._ptr)
Beispiel #5
0
 def _user_attributes(self, user_attributes):
     value = bt2_value.create_value(user_attributes)
     utils._check_type(value, bt2_value.MapValue)
     native_bt.field_class_structure_member_set_user_attributes(
         self._ptr, value._ptr
     )
Beispiel #6
0
    def _validate_create_params(
        cls,
        name,
        user_attributes,
        packet_context_field_class,
        event_common_context_field_class,
        default_clock_class,
        assigns_automatic_event_class_id,
        assigns_automatic_stream_id,
        supports_packets,
        packets_have_beginning_default_clock_snapshot,
        packets_have_end_default_clock_snapshot,
        supports_discarded_events,
        discarded_events_have_default_clock_snapshots,
        supports_discarded_packets,
        discarded_packets_have_default_clock_snapshots,
    ):
        # Name
        if name is not None:
            utils._check_str(name)

        # User attributes
        if user_attributes is not None:
            value = bt2_value.create_value(user_attributes)
            utils._check_type(value, bt2_value.MapValue)

        # Packet context field class
        if packet_context_field_class is not None:
            if not supports_packets:
                raise ValueError(
                    'cannot have a packet context field class without supporting packets'
                )

            utils._check_type(packet_context_field_class,
                              bt2_field_class._StructureFieldClass)

        # Event common context field class
        if event_common_context_field_class is not None:
            utils._check_type(event_common_context_field_class,
                              bt2_field_class._StructureFieldClass)

        # Default clock class
        if default_clock_class is not None:
            utils._check_type(default_clock_class, bt2_clock_class._ClockClass)

        # Assigns automatic event class id
        utils._check_bool(assigns_automatic_event_class_id)

        # Assigns automatic stream id
        utils._check_bool(assigns_automatic_stream_id)

        # Packets
        utils._check_bool(supports_packets)
        utils._check_bool(packets_have_beginning_default_clock_snapshot)
        utils._check_bool(packets_have_end_default_clock_snapshot)

        if not supports_packets:
            if packets_have_beginning_default_clock_snapshot:
                raise ValueError(
                    'cannot not support packets, but have packet beginning default clock snapshot'
                )
            if packets_have_end_default_clock_snapshot:
                raise ValueError(
                    'cannot not support packets, but have packet end default clock snapshots'
                )

        # Discarded events
        utils._check_bool(supports_discarded_events)
        utils._check_bool(discarded_events_have_default_clock_snapshots)

        if (not supports_discarded_events
                and discarded_events_have_default_clock_snapshots):
            raise ValueError(
                'cannot not support discarded events, but have default clock snapshots for discarded event messages'
            )

        # Discarded packets
        utils._check_bool(supports_discarded_packets)
        utils._check_bool(discarded_packets_have_default_clock_snapshots)

        if supports_discarded_packets and not supports_packets:
            raise ValueError(
                'cannot support discarded packets, but not support packets')

        if (not supports_discarded_packets
                and discarded_packets_have_default_clock_snapshots):
            raise ValueError(
                'cannot not support discarded packets, but have default clock snapshots for discarded packet messages'
            )