The order of a notification iterator's "get" method is to return the
"current notification", set by the last "next" method call. Since all
source and filter plugins do the same in their "get" method, let's
remove the need to implement it at all.
The bt_notification_iterator_next() and
bt_notification_iterator_get_notification() public functions are still
available for the iterator's user, but the iterator object itself keeps
the current notification returned by the last "next" method call.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 files changed:
extern
struct bt_component_class *bt_component_class_filter_create(const char *name,
extern
struct bt_component_class *bt_component_class_filter_create(const char *name,
- bt_component_class_notification_iterator_get_method notification_iterator_get_method,
bt_component_class_notification_iterator_next_method notification_iterator_next_method);
extern
bt_component_class_notification_iterator_next_method notification_iterator_next_method);
extern
struct bt_component_class_iterator_methods {
bt_component_class_notification_iterator_init_method init;
bt_component_class_notification_iterator_finalize_method finalize;
struct bt_component_class_iterator_methods {
bt_component_class_notification_iterator_init_method init;
bt_component_class_notification_iterator_finalize_method finalize;
- bt_component_class_notification_iterator_get_method get;
bt_component_class_notification_iterator_next_method next;
bt_component_class_notification_iterator_seek_time_method seek_time;
};
bt_component_class_notification_iterator_next_method next;
bt_component_class_notification_iterator_seek_time_method seek_time;
};
extern
struct bt_component_class *bt_component_class_source_create(const char *name,
extern
struct bt_component_class *bt_component_class_source_create(const char *name,
- bt_component_class_notification_iterator_get_method notification_iterator_get_method,
bt_component_class_notification_iterator_next_method notification_iterator_next_method);
extern
bt_component_class_notification_iterator_next_method notification_iterator_next_method);
extern
typedef void (*bt_component_class_notification_iterator_finalize_method)(
struct bt_private_notification_iterator *private_notification_iterator);
typedef void (*bt_component_class_notification_iterator_finalize_method)(
struct bt_private_notification_iterator *private_notification_iterator);
-typedef struct bt_notification *(*bt_component_class_notification_iterator_get_method)(
- struct bt_private_notification_iterator *private_notification_iterator);
-
-typedef enum bt_notification_iterator_status (*bt_component_class_notification_iterator_next_method)(
+typedef struct bt_notification_iterator_next_return (*bt_component_class_notification_iterator_next_method)(
struct bt_private_notification_iterator *private_notification_iterator);
typedef enum bt_notification_iterator_status
struct bt_private_notification_iterator *private_notification_iterator);
typedef enum bt_notification_iterator_status
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/ref-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/ref-internal.h>
+#include <babeltrace/component/notification/notification.h>
#include <babeltrace/component/notification/iterator.h>
#include <babeltrace/component/notification/private-iterator.h>
struct bt_notification_iterator {
struct bt_object base;
struct bt_component *component;
#include <babeltrace/component/notification/iterator.h>
#include <babeltrace/component/notification/private-iterator.h>
struct bt_notification_iterator {
struct bt_object base;
struct bt_component *component;
+ struct bt_notification *current_notification;
BT_NOTIFICATION_ITERATOR_SEEK_ORIGIN_EPOCH = 3,
};
BT_NOTIFICATION_ITERATOR_SEEK_ORIGIN_EPOCH = 3,
};
+struct bt_notification_iterator_next_return {
+ struct bt_notification *notification;
+ enum bt_notification_iterator_status status;
+};
+
/**
* Get current notification at iterator's position.
*
/**
* Get current notification at iterator's position.
*
union {
/* BT_COMPONENT_CLASS_TYPE_SOURCE */
struct {
union {
/* BT_COMPONENT_CLASS_TYPE_SOURCE */
struct {
- bt_component_class_notification_iterator_get_method notif_iter_get;
bt_component_class_notification_iterator_next_method notif_iter_next;
} source;
/* BT_COMPONENT_CLASS_TYPE_FILTER */
struct {
bt_component_class_notification_iterator_next_method notif_iter_next;
} source;
/* BT_COMPONENT_CLASS_TYPE_FILTER */
struct {
- bt_component_class_notification_iterator_get_method notif_iter_get;
bt_component_class_notification_iterator_next_method notif_iter_next;
} filter;
bt_component_class_notification_iterator_next_method notif_iter_next;
} filter;
* _id: ID (any valid C identifier except `auto`).
* _comp_class_id: Component class ID (C identifier).
* _name: Component class name (C string).
* _id: ID (any valid C identifier except `auto`).
* _comp_class_id: Component class ID (C identifier).
* _name: Component class name (C string).
- * _notif_iter_get_method: Component class's iterator get method
- * (bt_component_class_notification_iterator_get_method).
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_get_method, _notif_iter_next_method) \
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_next_method) \
static struct __bt_plugin_component_class_descriptor __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id = { \
.plugin_descriptor = &__bt_plugin_descriptor_##_id, \
.name = _name, \
.type = BT_COMPONENT_CLASS_TYPE_SOURCE, \
.methods.source = { \
static struct __bt_plugin_component_class_descriptor __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id = { \
.plugin_descriptor = &__bt_plugin_descriptor_##_id, \
.name = _name, \
.type = BT_COMPONENT_CLASS_TYPE_SOURCE, \
.methods.source = { \
- .notif_iter_get = _notif_iter_get_method, \
.notif_iter_next = _notif_iter_next_method, \
}, \
}; \
.notif_iter_next = _notif_iter_next_method, \
}, \
}; \
* _id: ID (any valid C identifier except `auto`).
* _comp_class_id: Component class ID (C identifier).
* _name: Component class name (C string).
* _id: ID (any valid C identifier except `auto`).
* _comp_class_id: Component class ID (C identifier).
* _name: Component class name (C string).
- * _notif_iter_get_method: Component class's iterator get method
- * (bt_component_class_notification_iterator_get_method).
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_get_method, _notif_iter_next_method) \
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_next_method) \
static struct __bt_plugin_component_class_descriptor __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id = { \
.plugin_descriptor = &__bt_plugin_descriptor_##_id, \
.name = _name, \
.type = BT_COMPONENT_CLASS_TYPE_FILTER, \
.methods.filter = { \
static struct __bt_plugin_component_class_descriptor __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id = { \
.plugin_descriptor = &__bt_plugin_descriptor_##_id, \
.name = _name, \
.type = BT_COMPONENT_CLASS_TYPE_FILTER, \
.methods.filter = { \
- .notif_iter_get = _notif_iter_get_method, \
.notif_iter_next = _notif_iter_next_method, \
}, \
}; \
.notif_iter_next = _notif_iter_next_method, \
}, \
}; \
* C identifier in this version.
*
* _name: Component class name (C identifier).
* C identifier in this version.
*
* _name: Component class name (C identifier).
- * _notif_iter_get_method: Component class's iterator get method
- * (bt_component_class_notification_iterator_get_method).
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _notif_iter_get_method, _notif_iter_next_method) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_get_method, _notif_iter_next_method)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _notif_iter_next_method) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_next_method)
/*
* Defines a filter component class attached to the automatic plugin
/*
* Defines a filter component class attached to the automatic plugin
* C identifier in this version.
*
* _name: Component class name (C identifier).
* C identifier in this version.
*
* _name: Component class name (C identifier).
- * _notif_iter_get_method: Component class's iterator get method
- * (bt_component_class_notification_iterator_get_method).
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
* _notif_iter_next_method: Component class's iterator next method
* (bt_component_class_notification_iterator_next_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _notif_iter_get_method, _notif_iter_next_method) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_get_method, _notif_iter_next_method)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _notif_iter_next_method) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_next_method)
/*
* Defines a sink component class attached to the automatic plugin
/*
* Defines a sink component class attached to the automatic plugin
}
struct bt_component_class *bt_component_class_source_create(const char *name,
}
struct bt_component_class *bt_component_class_source_create(const char *name,
- bt_component_class_notification_iterator_get_method notification_iterator_get_method,
bt_component_class_notification_iterator_next_method notification_iterator_next_method)
{
struct bt_component_class_source *source_class = NULL;
int ret;
bt_component_class_notification_iterator_next_method notification_iterator_next_method)
{
struct bt_component_class_source *source_class = NULL;
int ret;
- if (!name || !notification_iterator_get_method ||
- !notification_iterator_next_method) {
+ if (!name || !notification_iterator_next_method) {
- source_class->methods.iterator.get = notification_iterator_get_method;
source_class->methods.iterator.next = notification_iterator_next_method;
end:
source_class->methods.iterator.next = notification_iterator_next_method;
end:
}
struct bt_component_class *bt_component_class_filter_create(const char *name,
}
struct bt_component_class *bt_component_class_filter_create(const char *name,
- bt_component_class_notification_iterator_get_method notification_iterator_get_method,
bt_component_class_notification_iterator_next_method notification_iterator_next_method)
{
struct bt_component_class_filter *filter_class = NULL;
int ret;
bt_component_class_notification_iterator_next_method notification_iterator_next_method)
{
struct bt_component_class_filter *filter_class = NULL;
int ret;
- if (!name || !notification_iterator_get_method ||
- !notification_iterator_next_method) {
+ if (!name || !notification_iterator_next_method) {
- filter_class->methods.iterator.get = notification_iterator_get_method;
filter_class->methods.iterator.next = notification_iterator_next_method;
end:
filter_class->methods.iterator.next = notification_iterator_next_method;
end:
+ BT_PUT(iterator->current_notification);
BT_PUT(iterator->component);
g_free(iterator);
}
BT_PUT(iterator->component);
g_free(iterator);
}
struct bt_notification *bt_notification_iterator_get_notification(
struct bt_notification_iterator *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
}
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_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->component);
assert(iterator->component->class);
assert(iterator->component);
assert(iterator->component->class);
- 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);
+ }
+
+end:
+ return next_return.status;
}
struct bt_component *bt_notification_iterator_get_component(
}
struct bt_component *bt_notification_iterator_get_component(
case BT_COMPONENT_CLASS_TYPE_SOURCE:
comp_class = bt_component_class_source_create(
cc_full_descr->descriptor->name,
case BT_COMPONENT_CLASS_TYPE_SOURCE:
comp_class = bt_component_class_source_create(
cc_full_descr->descriptor->name,
- cc_full_descr->descriptor->methods.source.notif_iter_get,
cc_full_descr->descriptor->methods.source.notif_iter_next);
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
comp_class = bt_component_class_filter_create(
cc_full_descr->descriptor->name,
cc_full_descr->descriptor->methods.source.notif_iter_next);
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
comp_class = bt_component_class_filter_create(
cc_full_descr->descriptor->name,
- cc_full_descr->descriptor->methods.source.notif_iter_get,
cc_full_descr->descriptor->methods.source.notif_iter_next);
break;
case BT_COMPONENT_CLASS_TYPE_SINK:
cc_full_descr->descriptor->methods.source.notif_iter_next);
break;
case BT_COMPONENT_CLASS_TYPE_SINK:
BT_HIDDEN
bool ctf_fs_debug;
BT_HIDDEN
bool ctf_fs_debug;
-enum bt_notification_iterator_status ctf_fs_iterator_next(
+struct bt_notification_iterator_next_return ctf_fs_iterator_next(
struct bt_private_notification_iterator *iterator);
struct bt_private_notification_iterator *iterator);
-struct bt_notification *ctf_fs_iterator_get(
- struct bt_private_notification_iterator *iterator)
-{
- struct ctf_fs_iterator *ctf_it =
- bt_private_notification_iterator_get_user_data(
- iterator);
-
- if (!ctf_it->current_notification) {
- (void) ctf_fs_iterator_next(iterator);
- }
-
- return bt_get(ctf_it->current_notification);
-}
-
static
enum bt_notification_iterator_status ctf_fs_iterator_get_next_notification(
struct ctf_fs_iterator *it,
static
enum bt_notification_iterator_status ctf_fs_iterator_get_next_notification(
struct ctf_fs_iterator *it,
-enum bt_notification_iterator_status ctf_fs_iterator_next(
+struct bt_notification_iterator_next_return ctf_fs_iterator_next(
struct bt_private_notification_iterator *iterator)
{
int heap_ret;
struct bt_ctf_stream *stream = NULL;
struct ctf_fs_stream *fs_stream;
struct bt_private_notification_iterator *iterator)
{
int heap_ret;
struct bt_ctf_stream *stream = NULL;
struct ctf_fs_stream *fs_stream;
- struct bt_notification *notification;
struct bt_notification *next_stream_notification;
struct bt_notification *next_stream_notification;
- enum bt_notification_iterator_status ret =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
struct ctf_fs_iterator *ctf_it =
bt_private_notification_iterator_get_user_data(
iterator);
struct ctf_fs_iterator *ctf_it =
bt_private_notification_iterator_get_user_data(
iterator);
+ struct bt_notification_iterator_next_return ret = {
+ .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
+ .notification = NULL,
+ };
- notification = bt_notification_heap_pop(ctf_it->pending_notifications);
- if (!notification && !ctf_it->pending_streams) {
- ret = BT_NOTIFICATION_ITERATOR_STATUS_END;
+ ret.notification =
+ bt_notification_heap_pop(ctf_it->pending_notifications);
+ if (!ret.notification && !ctf_it->pending_streams) {
+ ret.status = BT_NOTIFICATION_ITERATOR_STATUS_END;
- if (!notification && ctf_it->pending_streams) {
+ if (!ret.notification && ctf_it->pending_streams) {
/*
* Insert at one notification per stream in the heap and pop
* one.
*/
/*
* Insert at one notification per stream in the heap and pop
* one.
*/
- ret = populate_heap(ctf_it);
- if (ret) {
+ ret.status = populate_heap(ctf_it);
+ if (ret.status) {
- notification = bt_notification_heap_pop(
+ ret.notification = bt_notification_heap_pop(
ctf_it->pending_notifications);
ctf_it->pending_notifications);
- if (!notification) {
- ret = BT_NOTIFICATION_ITERATOR_STATUS_END;
+ if (!ret.notification) {
+ ret.status = BT_NOTIFICATION_ITERATOR_STATUS_END;
goto end;
}
}
/* notification is set from here. */
goto end;
}
}
/* notification is set from here. */
- stream = internal_bt_notification_get_stream(notification);
+ stream = internal_bt_notification_get_stream(ret.notification);
if (!stream) {
/*
* The current notification is not associated to a particular
if (!stream) {
/*
* The current notification is not associated to a particular
- ret = ctf_fs_iterator_get_next_notification(ctf_it, fs_stream,
+ ret.status = ctf_fs_iterator_get_next_notification(ctf_it, fs_stream,
&next_stream_notification);
&next_stream_notification);
- if ((ret && ret != BT_NOTIFICATION_ITERATOR_STATUS_END)) {
+ if ((ret.status && ret.status != BT_NOTIFICATION_ITERATOR_STATUS_END)) {
heap_ret = bt_notification_heap_insert(
heap_ret = bt_notification_heap_insert(
- ctf_it->pending_notifications, notification);
+ ctf_it->pending_notifications,
+ ret.notification);
assert(!next_stream_notification);
if (heap_ret) {
assert(!next_stream_notification);
if (heap_ret) {
* We're dropping the most recent notification, but at
* this point, something is seriously wrong...
*/
* We're dropping the most recent notification, but at
* this point, something is seriously wrong...
*/
- ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+ ret.status = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+ BT_PUT(ret.notification);
- if (ret == BT_NOTIFICATION_ITERATOR_STATUS_END) {
+ if (ret.status == BT_NOTIFICATION_ITERATOR_STATUS_END) {
gboolean success;
/* Remove stream. */
success = g_hash_table_remove(ctf_it->stream_ht, stream);
assert(success);
gboolean success;
/* Remove stream. */
success = g_hash_table_remove(ctf_it->stream_ht, stream);
assert(success);
- ret = BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ ret.status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
} else {
heap_ret = bt_notification_heap_insert(ctf_it->pending_notifications,
next_stream_notification);
} else {
heap_ret = bt_notification_heap_insert(ctf_it->pending_notifications,
next_stream_notification);
/*
* We're dropping the most recent notification...
*/
/*
* We're dropping the most recent notification...
*/
- ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+ ret.status = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
- BT_MOVE(ctf_it->current_notification, notification);
bt_put(stream);
return ret;
}
bt_put(stream);
return ret;
}
- bt_put(ctf_it->current_notification);
bt_put(ctf_it->pending_notifications);
if (ctf_it->pending_streams) {
g_ptr_array_free(ctf_it->pending_streams, TRUE);
bt_put(ctf_it->pending_notifications);
if (ctf_it->pending_streams) {
g_ptr_array_free(ctf_it->pending_streams, TRUE);
struct ctf_fs_iterator {
struct bt_notification_heap *pending_notifications;
struct ctf_fs_iterator {
struct bt_notification_heap *pending_notifications;
- struct bt_notification *current_notification;
/*
* struct ctf_fs_data_stream* which have not yet been associated to a
* bt_ctf_stream. The association is performed on the first packet
/*
* struct ctf_fs_data_stream* which have not yet been associated to a
* bt_ctf_stream. The association is performed on the first packet
void ctf_fs_iterator_finalize(struct bt_private_notification_iterator *it);
void ctf_fs_iterator_finalize(struct bt_private_notification_iterator *it);
-enum bt_notification_iterator_status ctf_fs_iterator_next(
- struct bt_private_notification_iterator *iterator);
-
-struct bt_notification *ctf_fs_iterator_get(
+struct bt_notification_iterator_next_return ctf_fs_iterator_next(
struct bt_private_notification_iterator *iterator);
BT_HIDDEN
struct bt_private_notification_iterator *iterator);
BT_HIDDEN
struct bt_value *params, void *init_method_data);
BT_HIDDEN
struct bt_value *params, void *init_method_data);
BT_HIDDEN
-struct bt_notification *lttng_live_iterator_get(
- struct bt_private_notification_iterator *iterator);
-
-BT_HIDDEN
-enum bt_notification_iterator_status lttng_live_iterator_next(
+struct bt_notification_iterator_next_return lttng_live_iterator_next(
struct bt_private_notification_iterator *iterator);
#endif /* BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_INTERNAL_H */
struct bt_private_notification_iterator *iterator);
#endif /* BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_INTERNAL_H */
-enum bt_notification_iterator_status lttng_live_iterator_next(
+struct bt_notification_iterator_next_return lttng_live_iterator_next(
struct bt_private_notification_iterator *iterator)
{
struct bt_private_notification_iterator *iterator)
{
- return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ struct bt_notification_iterator_next_return ret = {
+ .status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR,
+ };
+
+ return ret;
BT_PLUGIN_LICENSE("MIT");
/* Declare component classes implemented by this plug-in. */
BT_PLUGIN_LICENSE("MIT");
/* Declare component classes implemented by this plug-in. */
-BT_PLUGIN_SOURCE_COMPONENT_CLASS(fs, ctf_fs_iterator_get, ctf_fs_iterator_next);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS(fs, ctf_fs_iterator_next);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(fs, CTF_FS_COMPONENT_DESCRIPTION);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(fs, ctf_fs_init);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(fs, ctf_fs_query);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(fs, CTF_FS_COMPONENT_DESCRIPTION);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(fs, ctf_fs_init);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(fs, ctf_fs_query);
ctf_fs_iterator_finalize);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, lttng_live, "lttng-live",
ctf_fs_iterator_finalize);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, lttng_live, "lttng-live",
- lttng_live_iterator_get, lttng_live_iterator_next);
+ lttng_live_iterator_next);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, lttng_live,
lttng_live_init);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, lttng_live,
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, lttng_live,
lttng_live_init);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, lttng_live,
-struct bt_notification *muxer_iterator_get(
+struct bt_notification_iterator_next_return muxer_iterator_next(
struct bt_private_notification_iterator *iterator)
{
struct bt_private_notification_iterator *iterator)
{
+ struct bt_notification_iterator_next_return ret = {
+ .status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR,
+ };
-static
-enum bt_notification_iterator_status muxer_iterator_next(
- struct bt_private_notification_iterator *iterator)
-{
- return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
/* Initialize plug-in entry points. */
}
/* Initialize plug-in entry points. */
BT_PLUGIN_DESCRIPTION("Babeltrace Trace Muxer Plug-In.");
BT_PLUGIN_AUTHOR("Jérémie Galarneau");
BT_PLUGIN_LICENSE("MIT");
BT_PLUGIN_DESCRIPTION("Babeltrace Trace Muxer Plug-In.");
BT_PLUGIN_AUTHOR("Jérémie Galarneau");
BT_PLUGIN_LICENSE("MIT");
-BT_PLUGIN_FILTER_COMPONENT_CLASS(muxer, muxer_iterator_get,
- muxer_iterator_next);
+BT_PLUGIN_FILTER_COMPONENT_CLASS(muxer, muxer_iterator_next);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(muxer,
"Time-correlate multiple traces.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(muxer, muxer_component_init);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(muxer,
"Time-correlate multiple traces.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(muxer, muxer_component_init);
struct bt_notification_iterator *it;
struct text_component *text =
bt_private_component_get_user_data(component);
struct bt_notification_iterator *it;
struct text_component *text =
bt_private_component_get_user_data(component);
+ enum bt_notification_iterator_status it_ret;
it = text->input_iterator;
it = text->input_iterator;
- if (likely(text->processed_first_event)) {
- enum bt_notification_iterator_status it_ret;
-
- it_ret = bt_notification_iterator_next(it);
- switch (it_ret) {
- case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
- case BT_NOTIFICATION_ITERATOR_STATUS_END:
- ret = BT_COMPONENT_STATUS_END;
- BT_PUT(text->input_iterator);
- goto end;
- default:
- break;
- }
- }
- notification = bt_notification_iterator_get_notification(it);
- if (!notification) {
+ it_ret = bt_notification_iterator_next(it);
+ switch (it_ret) {
+ case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
+ case BT_NOTIFICATION_ITERATOR_STATUS_END:
+ ret = BT_COMPONENT_STATUS_END;
+ BT_PUT(text->input_iterator);
+ goto end;
+ default:
+ break;
+ notification = bt_notification_iterator_get_notification(it);
+ assert(notification);
ret = handle_notification(text, notification);
text->processed_first_event = true;
end:
ret = handle_notification(text, notification);
text->processed_first_event = true;
end:
"Dummy sink component class: does absolutely nothing!");
/* trimmer filter */
"Dummy sink component class: does absolutely nothing!");
/* trimmer filter */
-BT_PLUGIN_FILTER_COMPONENT_CLASS(trimmer, trimmer_iterator_get,
- trimmer_iterator_next);
+BT_PLUGIN_FILTER_COMPONENT_CLASS(trimmer, trimmer_iterator_next);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(trimmer,
"Ensure that trace notifications outside of a given range are filtered-out.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(trimmer, trimmer_component_init);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(trimmer,
"Ensure that trace notifications outside of a given range are filtered-out.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(trimmer, trimmer_component_init);
it_data = bt_private_notification_iterator_get_user_data(it);
assert(it_data);
it_data = bt_private_notification_iterator_get_user_data(it);
assert(it_data);
- bt_put(it_data->current_notification);
bt_put(it_data->input_iterator);
g_free(it_data);
}
bt_put(it_data->input_iterator);
g_free(it_data);
}
-BT_HIDDEN
-struct bt_notification *trimmer_iterator_get(
- struct bt_private_notification_iterator *iterator)
-{
- struct trimmer_iterator *trim_it;
-
- trim_it = bt_private_notification_iterator_get_user_data(iterator);
- assert(trim_it);
-
- if (!trim_it->current_notification) {
- enum bt_notification_iterator_status it_ret;
-
- it_ret = trimmer_iterator_next(iterator);
- if (it_ret) {
- goto end;
- }
- }
-end:
- return bt_get(trim_it->current_notification);
-}
-
static
int update_lazy_bound(struct trimmer_bound *bound, const char *name,
int64_t ts, bool *lazy_update)
static
int update_lazy_bound(struct trimmer_bound *bound, const char *name,
int64_t ts, bool *lazy_update)
-enum bt_notification_iterator_status trimmer_iterator_next(
+struct bt_notification_iterator_next_return trimmer_iterator_next(
struct bt_private_notification_iterator *iterator)
{
struct trimmer_iterator *trim_it = NULL;
struct bt_private_component *component = NULL;
struct trimmer *trimmer = NULL;
struct bt_notification_iterator *source_it = NULL;
struct bt_private_notification_iterator *iterator)
{
struct trimmer_iterator *trim_it = NULL;
struct bt_private_component *component = NULL;
struct trimmer *trimmer = NULL;
struct bt_notification_iterator *source_it = NULL;
- enum bt_notification_iterator_status ret =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ struct bt_notification_iterator_next_return ret = {
+ .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
+ .notification = NULL,
+ };
bool notification_in_range = false;
trim_it = bt_private_notification_iterator_get_user_data(iterator);
bool notification_in_range = false;
trim_it = bt_private_notification_iterator_get_user_data(iterator);
assert(source_it);
while (!notification_in_range) {
assert(source_it);
while (!notification_in_range) {
- struct bt_notification *notification;
-
- ret = bt_notification_iterator_next(source_it);
- if (ret != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ ret.status = bt_notification_iterator_next(source_it);
+ if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
- notification = bt_notification_iterator_get_notification(
+ ret.notification = bt_notification_iterator_get_notification(
- if (!notification) {
- ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ if (!ret.notification) {
+ ret.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
- ret = evaluate_notification(notification,
+ ret.status = evaluate_notification(ret.notification,
&trimmer->begin, &trimmer->end,
¬ification_in_range);
&trimmer->begin, &trimmer->end,
¬ification_in_range);
- if (notification_in_range) {
- BT_MOVE(trim_it->current_notification, notification);
- } else {
- bt_put(notification);
+ if (!notification_in_range) {
+ bt_put(ret.notification);
- if (ret != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
struct trimmer_iterator {
/* Input iterator associated with this output iterator. */
struct bt_notification_iterator *input_iterator;
struct trimmer_iterator {
/* Input iterator associated with this output iterator. */
struct bt_notification_iterator *input_iterator;
- struct bt_notification *current_notification;
void trimmer_iterator_finalize(struct bt_private_notification_iterator *it);
BT_HIDDEN
void trimmer_iterator_finalize(struct bt_private_notification_iterator *it);
BT_HIDDEN
-struct bt_notification *trimmer_iterator_get(
- struct bt_private_notification_iterator *iterator);
-
-BT_HIDDEN
-enum bt_notification_iterator_status trimmer_iterator_next(
+struct bt_notification_iterator_next_return trimmer_iterator_next(
struct bt_private_notification_iterator *iterator);
BT_HIDDEN
struct bt_private_notification_iterator *iterator);
BT_HIDDEN
-static struct bt_notification *dummy_iterator_get_method(
+static struct bt_notification_iterator_next_return dummy_iterator_next_method(
struct bt_private_notification_iterator *private_iterator)
{
struct bt_private_notification_iterator *private_iterator)
{
+ struct bt_notification_iterator_next_return next_return = {
+ .notification = NULL,
+ .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
+ };
-static enum bt_notification_iterator_status dummy_iterator_next_method(
- struct bt_private_notification_iterator *private_iterator)
-{
- return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
static enum bt_notification_iterator_status dummy_iterator_seek_time_method(
}
static enum bt_notification_iterator_status dummy_iterator_seek_time_method(
BT_PLUGIN_LICENSE("Beerware");
BT_PLUGIN_VERSION(1, 2, 3, "yes");
BT_PLUGIN_LICENSE("Beerware");
BT_PLUGIN_VERSION(1, 2, 3, "yes");
-BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_get_method,
- dummy_iterator_next_method);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source,
dummy_iterator_init_method);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source,
dummy_iterator_init_method);
"ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
);
"ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
);
-BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_get_method,
- dummy_iterator_next_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter,
dummy_iterator_init_method);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter,
dummy_iterator_init_method);