- set_self_comp_port_input_msg_iterator_state(iterator,
- BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED);
-
- switch (iterator->upstream_component->class->type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- {
- struct bt_component_class_source *src_comp_cls =
- (void *) iterator->upstream_component->class;
-
- iterator->methods.next =
- (bt_self_component_port_input_message_iterator_next_method)
- src_comp_cls->methods.msg_iter_next;
- iterator->methods.seek_ns_from_origin =
- (bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)
- src_comp_cls->methods.msg_iter_seek_ns_from_origin;
- iterator->methods.seek_beginning =
- (bt_self_component_port_input_message_iterator_seek_beginning_method)
- src_comp_cls->methods.msg_iter_seek_beginning;
- iterator->methods.can_seek_ns_from_origin =
- (bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)
- src_comp_cls->methods.msg_iter_can_seek_ns_from_origin;
- iterator->methods.can_seek_beginning =
- (bt_self_component_port_input_message_iterator_can_seek_beginning_method)
- src_comp_cls->methods.msg_iter_can_seek_beginning;
- break;
- }
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- {
- struct bt_component_class_filter *flt_comp_cls =
- (void *) iterator->upstream_component->class;
-
- iterator->methods.next =
- (bt_self_component_port_input_message_iterator_next_method)
- flt_comp_cls->methods.msg_iter_next;
- iterator->methods.seek_ns_from_origin =
- (bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)
- flt_comp_cls->methods.msg_iter_seek_ns_from_origin;
- iterator->methods.seek_beginning =
- (bt_self_component_port_input_message_iterator_seek_beginning_method)
- flt_comp_cls->methods.msg_iter_seek_beginning;
- iterator->methods.can_seek_ns_from_origin =
- (bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)
- flt_comp_cls->methods.msg_iter_can_seek_ns_from_origin;
- iterator->methods.can_seek_beginning =
- (bt_self_component_port_input_message_iterator_can_seek_beginning_method)
- flt_comp_cls->methods.msg_iter_can_seek_beginning;
- break;
- }
- default:
- bt_common_abort();
- }
+ set_msg_iterator_state(iterator,
+ BT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED);
+
+ /* Copy methods from the message iterator class to the message iterator. */
+ BT_ASSERT(bt_component_class_has_message_iterator_class(upstream_comp_cls));
+ upstream_comp_cls_with_iter_cls = container_of(upstream_comp_cls,
+ struct bt_component_class_with_iterator_class, parent);
+
+ iterator->methods.next =
+ (bt_message_iterator_next_method)
+ upstream_comp_cls_with_iter_cls->msg_iter_cls->methods.next;
+ iterator->methods.seek_ns_from_origin =
+ (bt_message_iterator_seek_ns_from_origin_method)
+ upstream_comp_cls_with_iter_cls->msg_iter_cls->methods.seek_ns_from_origin;
+ iterator->methods.seek_beginning =
+ (bt_message_iterator_seek_beginning_method)
+ upstream_comp_cls_with_iter_cls->msg_iter_cls->methods.seek_beginning;
+ iterator->methods.can_seek_ns_from_origin =
+ (bt_message_iterator_can_seek_ns_from_origin_method)
+ upstream_comp_cls_with_iter_cls->msg_iter_cls->methods.can_seek_ns_from_origin;
+ iterator->methods.can_seek_beginning =
+ (bt_message_iterator_can_seek_beginning_method)
+ upstream_comp_cls_with_iter_cls->msg_iter_cls->methods.can_seek_beginning;