Move remaining protorectoral files to ctf fs plugin
[babeltrace.git] / lib / plugin-system / source.c
index ed3b1642b56c2d76e5b8032771acdfa0a67009c0..333139f51f17e6c5f74ad35b228325aa9c7af9d6 100644 (file)
 #include <babeltrace/plugin/notification/iterator.h>
 #include <babeltrace/plugin/notification/iterator-internal.h>
 
-static
-void bt_component_source_destroy(struct bt_component *component)
-{
-       return;
-}
-
 BT_HIDDEN
 enum bt_component_status bt_component_source_validate(
                struct bt_component *component)
 {
-       return BT_COMPONENT_STATUS_OK;
+       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       struct bt_component_source *source;
+
+       if (!component) {
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+
+       if (!component->class) {
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+
+       if (component->class->type != BT_COMPONENT_TYPE_SOURCE) {
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+
+       source = container_of(component, struct bt_component_source, parent);
+       if (!source->init_iterator) {
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+end:
+       return ret;
 }
 
 BT_HIDDEN
@@ -58,7 +76,8 @@ struct bt_component *bt_component_source_create(
                goto end;
        }
 
-       ret = bt_component_init(&source->parent, bt_component_source_destroy);
+       source->parent.class = bt_get(class);
+       ret = bt_component_init(&source->parent, NULL);
        if (ret != BT_COMPONENT_STATUS_OK) {
                BT_PUT(source);
                goto end;
@@ -67,6 +86,24 @@ end:
        return source ? &source->parent : NULL;
 }
 
+enum bt_component_status
+bt_component_source_set_iterator_init_cb(struct bt_component *component,
+               bt_component_source_init_iterator_cb init_iterator)
+{
+       struct bt_component_source *source;
+       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+       if (component->class->type != BT_COMPONENT_TYPE_SOURCE) {
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+
+       source = container_of(component, struct bt_component_source, parent);
+       source->init_iterator = init_iterator;
+end:
+       return ret;
+}
+
 struct bt_notification_iterator *bt_component_source_create_iterator(
                struct bt_component *component)
 {
This page took 0.028264 seconds and 4 git commands to generate.