X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fcomponent%2Ffilter.c;h=53c0091e97c147dae80c8cee6515cba0d3608e8d;hb=d3e4dcd8e7a601e0aa063455147f29fbe051582b;hp=2c9fb471aba62fc5e6f0bec0c6ba1aac5156e548;hpb=d1b057f5b2954339b0b48fdc5973ec59a641f5a9;p=babeltrace.git diff --git a/lib/component/filter.c b/lib/component/filter.c index 2c9fb471..53c0091e 100644 --- a/lib/component/filter.c +++ b/lib/component/filter.c @@ -31,56 +31,10 @@ #include #include #include +#include #include #include -enum bt_component_status bt_component_filter_set_iterator_init_cb( - struct bt_component *component, - bt_component_filter_init_iterator_cb init_iterator) -{ - struct bt_component_filter *filter; - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - - if (component->class->type != BT_COMPONENT_TYPE_FILTER || - !component->initializing) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - filter = container_of(component, struct bt_component_filter, parent); - filter->init_iterator = init_iterator; -end: - return ret; -} - -enum bt_component_status bt_component_filter_set_add_iterator_cb( - struct bt_component *component, - bt_component_filter_add_iterator_cb add_iterator) -{ - struct bt_component_filter *filter; - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - - if (!component) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) { - ret = BT_COMPONENT_STATUS_UNSUPPORTED; - goto end; - } - - if (!component->initializing) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - filter = container_of(component, struct bt_component_filter, parent); - filter->add_iterator = add_iterator; -end: - return ret; -} - enum bt_component_status bt_component_filter_set_minimum_input_count( struct bt_component *component, unsigned int minimum) @@ -93,7 +47,7 @@ enum bt_component_status bt_component_filter_set_minimum_input_count( goto end; } - if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) { + if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) { ret = BT_COMPONENT_STATUS_UNSUPPORTED; goto end; } @@ -121,7 +75,7 @@ enum bt_component_status bt_component_filter_set_maximum_input_count( goto end; } - if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) { + if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) { ret = BT_COMPONENT_STATUS_UNSUPPORTED; goto end; } @@ -149,7 +103,7 @@ bt_component_filter_get_input_count(struct bt_component *component, goto end; } - if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) { + if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) { ret = BT_COMPONENT_STATUS_UNSUPPORTED; goto end; } @@ -172,7 +126,7 @@ bt_component_filter_get_input_iterator(struct bt_component *component, goto end; } - if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) { + if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) { ret = BT_COMPONENT_STATUS_UNSUPPORTED; goto end; } @@ -194,13 +148,14 @@ enum bt_component_status bt_component_filter_add_iterator( { struct bt_component_filter *filter; enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + struct bt_component_class_filter *filter_class; if (!component || !iterator) { ret = BT_COMPONENT_STATUS_INVALID; goto end; } - if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) { + if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) { ret = BT_COMPONENT_STATUS_UNSUPPORTED; goto end; } @@ -211,8 +166,10 @@ enum bt_component_status bt_component_filter_add_iterator( goto end; } - if (filter->add_iterator) { - ret = filter->add_iterator(component, iterator); + filter_class = container_of(component->class, struct bt_component_class_filter, parent); + + if (filter_class->methods.add_iterator) { + ret = filter_class->methods.add_iterator(component, iterator); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } @@ -283,18 +240,12 @@ enum bt_component_status bt_component_filter_validate( goto end; } - if (component->class->type != BT_COMPONENT_TYPE_FILTER) { + if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) { ret = BT_COMPONENT_STATUS_INVALID; goto end; } filter = container_of(component, struct bt_component_filter, parent); - if (!filter->init_iterator) { - printf_error("Invalid filter component; no iterator initialization callback defined."); - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - ret = component_input_validate(&filter->input); if (ret) { goto end;