* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
-#include <babeltrace/component/component.h>
-#include <babeltrace/component/component-source-internal.h>
-#include <babeltrace/component/component-class-internal.h>
-#include <babeltrace/component/notification/iterator.h>
-#include <babeltrace/component/notification/iterator-internal.h>
+#include <babeltrace/graph/component.h>
+#include <babeltrace/graph/component-source-internal.h>
+#include <babeltrace/graph/component-class-internal.h>
+#include <babeltrace/graph/notification-iterator.h>
+#include <babeltrace/graph/notification-iterator-internal.h>
+#include <babeltrace/graph/notification-internal.h>
static
void bt_notification_iterator_destroy(struct bt_object *obj)
assert(0);
}
+ BT_PUT(iterator->current_notification);
BT_PUT(iterator->component);
g_free(iterator);
}
struct bt_notification *bt_notification_iterator_get_notification(
struct bt_notification_iterator *iterator)
{
- struct bt_private_notification_iterator *priv_iterator =
- bt_private_notification_iterator_from_notification_iterator(iterator);
- bt_component_class_notification_iterator_get_method get_method = NULL;
-
- assert(iterator);
- assert(iterator->component);
- assert(iterator->component->class);
-
- switch (iterator->component->class->type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- {
- struct bt_component_class_source *source_class =
- container_of(iterator->component->class,
- struct bt_component_class_source, parent);
+ struct bt_notification *notification = NULL;
- assert(source_class->methods.iterator.get);
- get_method = source_class->methods.iterator.get;
- break;
+ if (!iterator) {
+ goto end;
}
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- {
- struct bt_component_class_filter *filter_class =
- container_of(iterator->component->class,
- struct bt_component_class_filter, parent);
- assert(filter_class->methods.iterator.get);
- get_method = filter_class->methods.iterator.get;
- break;
- }
- default:
- assert(false);
- break;
- }
+ notification = bt_get(iterator->current_notification);
- assert(get_method);
- return get_method(priv_iterator);
+end:
+ return notification;
}
enum bt_notification_iterator_status
struct bt_private_notification_iterator *priv_iterator =
bt_private_notification_iterator_from_notification_iterator(iterator);
bt_component_class_notification_iterator_next_method next_method = NULL;
+ struct bt_notification_iterator_next_return next_return;
+ enum bt_notification_iterator_status status =
+ BT_NOTIFICATION_ITERATOR_STATUS_OK;
+
+ if (!iterator) {
+ status = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
+ goto end;
+ }
- assert(iterator);
assert(iterator->component);
assert(iterator->component->class);
}
assert(next_method);
- return next_method(priv_iterator);
+ next_return = next_method(priv_iterator);
+ if (next_return.status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ if (!next_return.notification) {
+ status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ goto end;
+ }
+
+ BT_MOVE(iterator->current_notification,
+ next_return.notification);
+ bt_notification_freeze(iterator->current_notification);
+ }
+
+end:
+ return next_return.status;
}
struct bt_component *bt_notification_iterator_get_component(
return bt_get(iterator->component);
}
+struct bt_private_component *
+bt_private_notification_iterator_get_private_component(
+ struct bt_private_notification_iterator *private_iterator)
+{
+ return bt_private_component_from_component(
+ bt_notification_iterator_get_component(
+ bt_notification_iterator_from_private(private_iterator)));
+}
+
enum bt_notification_iterator_status bt_notification_iterator_seek_time(
struct bt_notification_iterator *iterator,
enum bt_notification_iterator_seek_origin seek_origin,