X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fstream_class.py;h=8a65fac7f8ba92a2c94c500975001ba79d81cf15;hp=2c33dae8ddfa8d8a11ded5eedaadce48bd646139;hb=f0a42b33ac3951cd5cb2ee0f66ac04437a681621;hpb=eddea57540fc76d56c8d38bdfc330c8b9f5b4961 diff --git a/src/bindings/python/bt2/bt2/stream_class.py b/src/bindings/python/bt2/bt2/stream_class.py index 2c33dae8..8a65fac7 100644 --- a/src/bindings/python/bt2/bt2/stream_class.py +++ b/src/bindings/python/bt2/bt2/stream_class.py @@ -29,18 +29,40 @@ from bt2 import value as bt2_value import collections.abc -class _StreamClass(object._SharedObject, collections.abc.Mapping): +class _StreamClassConst(object._SharedObject, collections.abc.Mapping): _get_ref = staticmethod(native_bt.stream_class_get_ref) _put_ref = staticmethod(native_bt.stream_class_put_ref) + _borrow_event_class_ptr_by_id = staticmethod( + native_bt.stream_class_borrow_event_class_by_id_const + ) + _borrow_event_class_ptr_by_index = staticmethod( + native_bt.stream_class_borrow_event_class_by_index_const + ) + _borrow_trace_class_ptr = staticmethod( + native_bt.stream_class_borrow_trace_class_const + ) + _borrow_packet_context_field_class_ptr = staticmethod( + native_bt.stream_class_borrow_packet_context_field_class_const + ) + _borrow_event_common_context_field_class_ptr = staticmethod( + native_bt.stream_class_borrow_event_common_context_field_class_const + ) + _borrow_default_clock_class_ptr = staticmethod( + native_bt.stream_class_borrow_default_clock_class_const + ) + + _event_class_cls = property(lambda _: bt2_event_class._EventClassConst) + _trace_class_cls = property(lambda _: bt2_trace_class._TraceClassConst) + _clock_class_cls = property(lambda _: bt2_clock_class._ClockClassConst) def __getitem__(self, key): utils._check_int64(key) - ec_ptr = native_bt.stream_class_borrow_event_class_by_id(self._ptr, key) + ec_ptr = self._borrow_event_class_ptr_by_id(self._ptr, key) if ec_ptr is None: raise KeyError(key) - return bt2_event_class._EventClass._create_from_ptr_and_get_ref(ec_ptr) + return self._event_class_cls._create_from_ptr_and_get_ref(ec_ptr) def __len__(self): count = native_bt.stream_class_get_event_class_count(self._ptr) @@ -49,9 +71,7 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): def __iter__(self): for idx in range(len(self)): - ec_ptr = native_bt.stream_class_borrow_event_class_by_index_const( - self._ptr, idx - ) + ec_ptr = self._borrow_event_class_ptr_by_index(self._ptr, idx) assert ec_ptr is not None id = native_bt.event_class_get_id(ec_ptr) @@ -59,6 +79,124 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): yield id + @property + def trace_class(self): + tc_ptr = self._borrow_trace_class_ptr(self._ptr) + + if tc_ptr is not None: + return self._trace_class_cls._create_from_ptr_and_get_ref(tc_ptr) + + @property + def user_attributes(self): + ptr = native_bt.stream_class_borrow_user_attributes(self._ptr) + assert ptr is not None + return bt2_value._create_from_ptr_and_get_ref(ptr) + + @property + def name(self): + return native_bt.stream_class_get_name(self._ptr) + + @property + def assigns_automatic_event_class_id(self): + return native_bt.stream_class_assigns_automatic_event_class_id(self._ptr) + + @property + def assigns_automatic_stream_id(self): + return native_bt.stream_class_assigns_automatic_stream_id(self._ptr) + + @property + def supports_packets(self): + return native_bt.stream_class_supports_packets(self._ptr) + + @property + def packets_have_beginning_default_clock_snapshot(self): + return native_bt.stream_class_packets_have_beginning_default_clock_snapshot( + self._ptr + ) + + @property + def packets_have_end_default_clock_snapshot(self): + return native_bt.stream_class_packets_have_end_default_clock_snapshot(self._ptr) + + @property + def supports_discarded_events(self): + return native_bt.stream_class_supports_discarded_events(self._ptr) + + @property + def discarded_events_have_default_clock_snapshots(self): + return native_bt.stream_class_discarded_events_have_default_clock_snapshots( + self._ptr + ) + + @property + def supports_discarded_packets(self): + return native_bt.stream_class_supports_discarded_packets(self._ptr) + + @property + def discarded_packets_have_default_clock_snapshots(self): + return native_bt.stream_class_discarded_packets_have_default_clock_snapshots( + self._ptr + ) + + @property + def id(self): + id = native_bt.stream_class_get_id(self._ptr) + + if id < 0: + return + + return id + + @property + def packet_context_field_class(self): + fc_ptr = self._borrow_packet_context_field_class_ptr(self._ptr) + + if fc_ptr is None: + return + + return bt2_field_class._create_field_class_from_ptr_and_get_ref(fc_ptr) + + @property + def event_common_context_field_class(self): + fc_ptr = self._borrow_event_common_context_field_class_ptr(self._ptr) + + if fc_ptr is None: + return + + return bt2_field_class._create_field_class_from_ptr_and_get_ref(fc_ptr) + + @property + def default_clock_class(self): + cc_ptr = self._borrow_default_clock_class_ptr(self._ptr) + if cc_ptr is None: + return + + return self._clock_class_cls._create_from_ptr_and_get_ref(cc_ptr) + + +class _StreamClass(_StreamClassConst): + _get_ref = staticmethod(native_bt.stream_class_get_ref) + _put_ref = staticmethod(native_bt.stream_class_put_ref) + _borrow_event_class_ptr_by_id = staticmethod( + native_bt.stream_class_borrow_event_class_by_id + ) + _borrow_event_class_ptr_by_index = staticmethod( + native_bt.stream_class_borrow_event_class_by_index + ) + _borrow_trace_class_ptr = staticmethod(native_bt.stream_class_borrow_trace_class) + _borrow_packet_context_field_class_ptr = staticmethod( + native_bt.stream_class_borrow_packet_context_field_class + ) + _borrow_event_common_context_field_class_ptr = staticmethod( + native_bt.stream_class_borrow_event_common_context_field_class + ) + _borrow_default_clock_class_ptr = staticmethod( + native_bt.stream_class_borrow_default_clock_class + ) + _event_class_cls = property(lambda s: bt2_event_class._EventClass) + _trace_class_cls = property(lambda s: bt2_trace_class._TraceClass) + _clock_class_cls = property(lambda s: bt2_clock_class._ClockClass) + def create_event_class( self, id=None, @@ -107,19 +245,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): return event_class - @property - def trace_class(self): - tc_ptr = native_bt.stream_class_borrow_trace_class_const(self._ptr) - - if tc_ptr is not None: - return bt2_trace_class._TraceClass._create_from_ptr_and_get_ref(tc_ptr) - - @property - def user_attributes(self): - ptr = native_bt.stream_class_borrow_user_attributes(self._ptr) - assert ptr is not None - return bt2_value._create_from_ptr_and_get_ref(ptr) - def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) utils._check_type(value, bt2_value.MapValue) @@ -127,10 +252,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): _user_attributes = property(fset=_user_attributes) - @property - def name(self): - return native_bt.stream_class_get_name(self._ptr) - def _name(self, name): utils._check_str(name) status = native_bt.stream_class_set_name(self._ptr, name) @@ -138,10 +259,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): _name = property(fset=_name) - @property - def assigns_automatic_event_class_id(self): - return native_bt.stream_class_assigns_automatic_event_class_id(self._ptr) - def _assigns_automatic_event_class_id(self, auto_id): utils._check_bool(auto_id) return native_bt.stream_class_set_assigns_automatic_event_class_id( @@ -150,10 +267,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): _assigns_automatic_event_class_id = property(fset=_assigns_automatic_event_class_id) - @property - def assigns_automatic_stream_id(self): - return native_bt.stream_class_assigns_automatic_stream_id(self._ptr) - def _assigns_automatic_stream_id(self, auto_id): utils._check_bool(auto_id) return native_bt.stream_class_set_assigns_automatic_stream_id( @@ -162,20 +275,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): _assigns_automatic_stream_id = property(fset=_assigns_automatic_stream_id) - @property - def supports_packets(self): - return native_bt.stream_class_supports_packets(self._ptr) - - @property - def packets_have_beginning_default_clock_snapshot(self): - return native_bt.stream_class_packets_have_beginning_default_clock_snapshot( - self._ptr - ) - - @property - def packets_have_end_default_clock_snapshot(self): - return native_bt.stream_class_packets_have_end_default_clock_snapshot(self._ptr) - def _set_supports_packets(self, supports, with_begin_cs=False, with_end_cs=False): utils._check_bool(supports) utils._check_bool(with_begin_cs) @@ -193,10 +292,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): self._ptr, supports, with_begin_cs, with_end_cs ) - @property - def supports_discarded_events(self): - return native_bt.stream_class_supports_discarded_events(self._ptr) - def _set_supports_discarded_events(self, supports, with_cs=False): utils._check_bool(supports) utils._check_bool(with_cs) @@ -210,15 +305,7 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): self._ptr, supports, with_cs ) - @property - def discarded_events_have_default_clock_snapshots(self): - return native_bt.stream_class_discarded_events_have_default_clock_snapshots( - self._ptr - ) - - @property - def supports_discarded_packets(self): - return native_bt.stream_class_supports_discarded_packets(self._ptr) + _supports_discarded_events = property(fset=_set_supports_discarded_events) def _set_supports_discarded_packets(self, supports, with_cs): utils._check_bool(supports) @@ -238,31 +325,7 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): self._ptr, supports, with_cs ) - @property - def discarded_packets_have_default_clock_snapshots(self): - return native_bt.stream_class_discarded_packets_have_default_clock_snapshots( - self._ptr - ) - - @property - def id(self): - id = native_bt.stream_class_get_id(self._ptr) - - if id < 0: - return - - return id - - @property - def packet_context_field_class(self): - fc_ptr = native_bt.stream_class_borrow_packet_context_field_class_const( - self._ptr - ) - - if fc_ptr is None: - return - - return bt2_field_class._create_field_class_from_ptr_and_get_ref(fc_ptr) + _supports_discarded_packets = property(fset=_set_supports_discarded_packets) def _packet_context_field_class(self, packet_context_field_class): if packet_context_field_class is not None: @@ -282,17 +345,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): _packet_context_field_class = property(fset=_packet_context_field_class) - @property - def event_common_context_field_class(self): - fc_ptr = native_bt.stream_class_borrow_event_common_context_field_class_const( - self._ptr - ) - - if fc_ptr is None: - return - - return bt2_field_class._create_field_class_from_ptr_and_get_ref(fc_ptr) - def _event_common_context_field_class(self, event_common_context_field_class): if event_common_context_field_class is not None: utils._check_type( @@ -307,14 +359,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): _event_common_context_field_class = property(fset=_event_common_context_field_class) - @property - def default_clock_class(self): - cc_ptr = native_bt.stream_class_borrow_default_clock_class(self._ptr) - if cc_ptr is None: - return - - return bt2_clock_class._ClockClass._create_from_ptr_and_get_ref(cc_ptr) - def _default_clock_class(self, clock_class): utils._check_type(clock_class, bt2_clock_class._ClockClass) native_bt.stream_class_set_default_clock_class(self._ptr, clock_class._ptr)