packet_context_type.add_field(uint16_type, "a_custom_packet_context_field")
stream_class.packet_context_type = packet_context_type
+# Set a stream event context
+stream_event_context_type = btw.StructureFieldDeclaration()
+stream_event_context_type.add_field(int32_type, "field_in_stream_event_context")
+stream_class.event_context_type = stream_event_context_type
+
# Create a string type
string_type = btw.StringFieldDeclaration()
integer_field = enumeration_field.container
enumeration_field.value = i % 10
+ event.stream_context.field("field_in_stream_event_context").value = i * 10
+
stream.append_event(event)
# Populate custom packet context field before flushing
%rename("_bt_ctf_event_get_payload_by_index") bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, int index);
%rename("_bt_ctf_event_get") bt_ctf_event_get(struct bt_ctf_event *event);
%rename("_bt_ctf_event_put") bt_ctf_event_put(struct bt_ctf_event *event);
+%rename("_bt_ctf_event_get_stream_event_context") bt_ctf_event_get_stream_event_context(struct bt_ctf_event *event);
+%rename("_bt_ctf_event_set_stream_event_context") bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event, struct bt_ctf_field *stream_event_context);
struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class);
struct bt_ctf_event_class *bt_ctf_event_get_class(struct bt_ctf_event *event);
struct bt_ctf_field *bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, int index);
void bt_ctf_event_get(struct bt_ctf_event *event);
void bt_ctf_event_put(struct bt_ctf_event *event);
+struct bt_ctf_field *bt_ctf_event_get_stream_event_context(struct bt_ctf_event *event);
+int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event, struct bt_ctf_field *stream_event_context);
/* stream-class.h */
%rename("_bt_ctf_stream_class_get_event_class_by_name") bt_ctf_stream_class_get_event_class_by_name(struct bt_ctf_stream_class *stream_class, const char *name);
%rename("_bt_ctf_stream_class_get_packet_context_type") bt_ctf_stream_class_get_packet_context_type(struct bt_ctf_stream_class *stream_class);
%rename("_bt_ctf_stream_class_set_packet_context_type") bt_ctf_stream_class_set_packet_context_type(struct bt_ctf_stream_class *stream_class, struct bt_ctf_field_type *packet_context_type);
+%rename("_bt_ctf_stream_class_get_event_context_type") bt_ctf_stream_class_get_event_context_type(struct bt_ctf_stream_class *stream_class);
+%rename("_bt_ctf_stream_class_set_event_context_type") bt_ctf_stream_class_set_event_context_type(struct bt_ctf_stream_class *stream_class, struct bt_ctf_field_type *event_context_type);
%rename("_bt_ctf_stream_class_get") bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
%rename("_bt_ctf_stream_class_put") bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(struct bt_ctf_stream_class *stream_class, const char *name);
struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(struct bt_ctf_stream_class *stream_class);
int bt_ctf_stream_class_set_packet_context_type(struct bt_ctf_stream_class *stream_class, struct bt_ctf_field_type *packet_context_type);
+struct bt_ctf_field_type *bt_ctf_stream_class_get_event_context_type(struct bt_ctf_stream_class *stream_class);
+int bt_ctf_stream_class_set_event_context_type(struct bt_ctf_stream_class *stream_class, struct bt_ctf_field_type *event_context_type);
void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
if ret < 0:
raise ValueError("Could not set event field payload.")
+ @property
+ def stream_context(self):
+ """
+ Stream event context field (instance of
+ :class:`StructureField`).
+
+ Set this attribute to assign a stream event context field
+ to this stream.
+
+ :exc:`ValueError` is raised on error.
+ """
+
+ native_field = nbt._bt_ctf_event_get_stream_event_context(self._e)
+
+ if native_field is None:
+ raise ValueError("Invalid Stream.")
+
+ return Field._create_field_from_native_instance(native_field)
+
+ @stream_context.setter
+ def stream_context(self, field):
+ if not isinstance(field, StructureField):
+ raise TypeError("Argument field must be of type StructureField")
+
+ ret = nbt._bt_ctf_event_set_stream_event_context(self._e, field._f)
+
+ if ret < 0:
+ raise ValueError("Invalid stream context field.")
class StreamClass:
"""
if ret < 0:
raise ValueError("Failed to set packet context type.")
+ @property
+ def event_context_type(self):
+ """
+ Stream event context declaration.
+
+ Set this attribute to change the stream event context
+ declaration (must be an instance of
+ :class:`StructureFieldDeclaration`).
+
+ :exc:`ValueError` is raised on error.
+
+ """
+
+ field_type_native = nbt._bt_ctf_stream_class_get_event_context_type(self._sc)
+
+ if field_type_native is None:
+ raise ValueError("Invalid StreamClass")
+
+ field_type = FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+
+ return field_type
+
+ @event_context_type.setter
+ def event_context_type(self, field_type):
+ if not isinstance(field_type, StructureFieldDeclaration):
+ raise TypeError("field_type argument must be of type StructureFieldDeclaration.")
+
+ ret = nbt._bt_ctf_stream_class_set_event_context_type(self._sc,
+ field_type._ft)
+
+ if ret < 0:
+ raise ValueError("Failed to set event context type.")
+
class Stream:
"""