- if type(other) is not self.__class__:
- return False
-
- return (self.name, self.lower, self.upper) == (other.name, other.lower, other.upper)
-
-
-class _EnumerationFieldClassMappingIterator(object._SharedObject,
- collections.abc.Iterator):
- def __init__(self, iter_ptr, is_signed):
- super().__init__(iter_ptr)
- self._is_signed = is_signed
- self._done = (iter_ptr is None)
-
- def __next__(self):
- if self._done:
- raise StopIteration
-
- ret = native_bt.field_class_enumeration_mapping_iterator_next(self._ptr)
- if ret < 0:
- self._done = True
- raise StopIteration
-
- if self._is_signed:
- ret, name, lower, upper = native_bt.field_class_enumeration_mapping_iterator_get_signed(self._ptr)
- else:
- ret, name, lower, upper = native_bt.field_class_enumeration_mapping_iterator_get_unsigned(self._ptr)
-
- assert(ret == 0)
- mapping = _EnumerationFieldClassMapping(name, lower, upper)
-
- return mapping
-
-
-class EnumerationFieldClass(_IntegerFieldClass, collections.abc.Sequence):
- _NAME = 'Enumeration'
-
- def __init__(self, int_field_class=None, size=None, alignment=None,
- byte_order=None, is_signed=None, base=None, encoding=None,
- mapped_clock_class=None):
- if int_field_class is None:
- int_field_class = IntegerFieldClass(size=size, alignment=alignment,
- byte_order=byte_order,
- is_signed=is_signed, base=base,
- encoding=encoding,
- mapped_clock_class=mapped_clock_class)
-
- utils._check_type(int_field_class, IntegerFieldClass)
- ptr = native_bt.field_class_enumeration_create(int_field_class._ptr)
- self._check_create_status(ptr)
- _FieldClass.__init__(self, ptr)
-
- @property
- def integer_field_class(self):
- ptr = native_bt.field_class_enumeration_get_container_type(self._ptr)
- assert(ptr)
- return _create_from_ptr(ptr)
-
- @property
- def size(self):
- return self.integer_field_class.size