+BT_HIDDEN
+void bt_notification_iterator_finalize(
+ struct bt_notification_iterator *iterator)
+{
+ struct bt_component_class *comp_class = NULL;
+ bt_component_class_notification_iterator_finalize_method
+ finalize_method = NULL;
+
+ assert(iterator);
+
+ switch (iterator->state) {
+ case BT_NOTIFICATION_ITERATOR_STATE_FINALIZED:
+ case BT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED:
+ /* Already finalized */
+ return;
+ default:
+ break;
+ }
+
+ if (iterator->state == BT_NOTIFICATION_ITERATOR_STATE_ENDED) {
+ iterator->state = BT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED;
+ } else {
+ iterator->state = BT_NOTIFICATION_ITERATOR_STATE_FINALIZED;
+ }
+
+ assert(iterator->upstream_component);
+ comp_class = iterator->upstream_component->class;
+
+ /* Call user-defined destroy method */
+ switch (comp_class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ struct bt_component_class_source *source_class;
+
+ source_class = container_of(comp_class, struct bt_component_class_source, parent);
+ finalize_method = source_class->methods.iterator.finalize;
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ struct bt_component_class_filter *filter_class;
+
+ filter_class = container_of(comp_class, struct bt_component_class_filter, parent);
+ finalize_method = filter_class->methods.iterator.finalize;
+ break;
+ }
+ default:
+ /* Unreachable */
+ assert(0);
+ }
+
+ if (finalize_method) {
+ finalize_method(
+ bt_private_notification_iterator_from_notification_iterator(iterator));
+ }
+
+ iterator->upstream_component = NULL;
+ iterator->upstream_port = NULL;
+}
+
+BT_HIDDEN
+void bt_notification_iterator_set_connection(
+ struct bt_notification_iterator *iterator,
+ struct bt_connection *connection)
+{
+ assert(iterator);
+ iterator->connection = connection;
+}
+