Implement bt_notification_iterator_set_seek_time_cb
[babeltrace.git] / lib / plugin-system / source.c
index 5ec8e4007b63449ae77a76ef5760839fab077aef..7a19bc5500d0e5f840b783c5a8e731939014e246 100644 (file)
@@ -56,7 +56,7 @@ enum bt_component_status bt_component_source_validate(
        }
 
        source = container_of(component, struct bt_component_source, parent);
-       if (source->init_iterator) {
+       if (!source->init_iterator) {
                ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
@@ -86,41 +86,27 @@ end:
        return source ? &source->parent : NULL;
 }
 
-struct bt_notification_iterator *bt_component_source_create_iterator(
-               struct bt_component *component)
+enum bt_component_status
+bt_component_source_set_iterator_init_cb(struct bt_component *component,
+               bt_component_source_init_iterator_cb init_iterator)
 {
-       enum bt_component_status ret_component;
-       enum bt_notification_iterator_status ret_iterator;
        struct bt_component_source *source;
-       struct bt_notification_iterator *iterator = NULL;
-
-       if (!component) {
-               goto end;
-       }
-
-       if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SOURCE) {
-               goto end;
-       }
+       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
-       iterator = bt_notification_iterator_create(component);
-       if (!iterator) {
+       if (component->class->type != BT_COMPONENT_TYPE_SOURCE ||
+                       !component->initializing) {
+               ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
 
        source = container_of(component, struct bt_component_source, parent);
-       assert(source->init_iterator);
-       ret_component = source->init_iterator(component, iterator);
-       if (ret_component != BT_COMPONENT_STATUS_OK) {
-               goto error;
-       }
-
-       ret_iterator = bt_notification_iterator_validate(iterator);
-       if (ret_iterator != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
-               goto error;
-       }
+       source->init_iterator = init_iterator;
 end:
-       return iterator;
-error:
-       BT_PUT(iterator);
-       return iterator;
+       return ret;
+}
+
+struct bt_notification_iterator *bt_component_source_create_iterator(
+               struct bt_component *component)
+{
+       return bt_component_create_iterator(component);
 }
This page took 0.024479 seconds and 4 git commands to generate.