#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
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;
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)
{