+class _StructureFieldClass(_StructureFieldClassConst, _FieldClass):
+ _NAME = 'Structure'
+ _borrow_member_by_index = staticmethod(
+ native_bt.field_class_structure_borrow_member_by_index
+ )
+ _borrow_member_ptr_by_name = staticmethod(
+ native_bt.field_class_structure_borrow_member_by_name
+ )
+ _structure_member_field_class_pycls = property(lambda _: _StructureFieldClassMember)
+
+ def append_member(self, name, field_class, user_attributes=None):
+ utils._check_str(name)
+ utils._check_type(field_class, _FieldClass)
+
+ if name in self:
+ raise ValueError("duplicate member name '{}'".format(name))
+
+ user_attributes_value = None
+
+ if user_attributes is not None:
+ # check now that user attributes are valid
+ user_attributes_value = bt2.create_value(user_attributes)
+
+ status = native_bt.field_class_structure_append_member(
+ self._ptr, name, field_class._ptr
+ )
+ utils._handle_func_status(
+ status, 'cannot append member to structure field class object'
+ )
+
+ if user_attributes is not None:
+ self[name]._user_attributes = user_attributes_value
+
+ def __iadd__(self, members):
+ for name, field_class in members:
+ self.append_member(name, field_class)
+
+ return self
+
+
+class _OptionFieldClassConst(_FieldClassConst):
+ _NAME = 'Const Option'
+ _create_field_class_from_ptr_and_get_ref = staticmethod(
+ _create_field_class_from_const_ptr_and_get_ref
+ )
+ _borrow_field_class_ptr = staticmethod(
+ native_bt.field_class_option_borrow_field_class_const
+ )
+ _borrow_selector_field_path = staticmethod(
+ native_bt.field_class_option_borrow_selector_field_path_const
+ )
+