Set notification iterator methods to the component class
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 27 Jan 2017 08:34:18 +0000 (03:34 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:37 +0000 (12:57 -0400)
This follows the spirit of the previous refactorings by assigning
notification iterator methods to the component class instead of setting
them during their initialization method.

Conceptually here, a (source and filter) component class defines one,
and only one notification iterator class. Therefore the concept of an
iterator "class" is hidden to the user here, since there's no
one-to-many relationship. In any OO language, an iterator class would be
a class nested under a component class.

Source and filter component classes are created with two mandatory
iterator methods: get and next.

The initialization, destroy, and seek time iterator methods are
optional.

New functions:

* bt_component_class_source_set_notification_iterator_init_method()
* bt_component_class_source_set_notification_iterator_destroy_method()
* bt_component_class_source_set_notification_iterator_seek_time_method()
* bt_component_class_filter_set_notification_iterator_init_method()
* bt_component_class_filter_set_notification_iterator_destroy_method()
* bt_component_class_filter_set_notification_iterator_seek_time_method()

The plugin development interface (babeltrace/plugin/plugin-dev.h) is
updated accordingly.

Tests and existing plugins are updated accordingly.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 files changed:
include/babeltrace/component/component-class-filter.h
include/babeltrace/component/component-class-internal.h
include/babeltrace/component/component-class-source.h
include/babeltrace/component/component-class.h
include/babeltrace/component/notification/iterator-internal.h
include/babeltrace/component/notification/iterator.h
include/babeltrace/plugin/plugin-dev.h
lib/component/component-class.c
lib/component/component.c
lib/component/iterator.c
lib/plugin/plugin.c
plugins/ctf/fs/fs.c
plugins/ctf/fs/fs.h
plugins/ctf/lttng-live/lttng-live-internal.h
plugins/ctf/lttng-live/lttng-live.c
plugins/ctf/plugin.c
plugins/muxer/muxer.c
plugins/trimmer/iterator.c
plugins/trimmer/iterator.h
plugins/trimmer/trimmer.c
tests/lib/test-plugin-plugins/sfs.c

index 9eaf4a09b0966c1c684284d5db8df85fe180f1b4..161d13ec742262e16828cf1684f18993c93be276 100644 (file)
@@ -41,10 +41,30 @@ typedef enum bt_component_status (*bt_component_class_filter_add_iterator_method
 
 extern
 struct bt_component_class *bt_component_class_filter_create(const char *name,
-               bt_component_class_filter_init_iterator_method init_iterator_method);
+               bt_component_class_notification_iterator_get_method notification_iterator_get_method,
+               bt_component_class_notification_iterator_next_method notification_iterator_next_method);
 
 extern int bt_component_class_filter_set_add_iterator_method(
                struct bt_component_class *component_class,
                bt_component_class_filter_add_iterator_method add_iterator_method);
 
+extern
+int bt_component_class_filter_set_notification_iterator_init_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_init_method notification_iterator_init_method);
+
+extern
+int bt_component_class_filter_set_notification_iterator_destroy_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_destroy_method notification_iterator_destroy_method);
+
+extern
+int bt_component_class_filter_set_notification_iterator_seek_time_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_seek_time_method notification_iterator_seek_time_method);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* BABELTRACE_COMPONENT_COMPONENT_CLASS_FILTER_H */
index 2dacc8f0c5d312020b7af96305b924b508e71a2c..fcfe539f6a4960619ae953de0f0f203da6c0f358 100644 (file)
@@ -62,10 +62,18 @@ struct bt_component_class {
        bool frozen;
 };
 
+struct bt_component_class_iterator_methods {
+       bt_component_class_notification_iterator_init_method init;
+       bt_component_class_notification_iterator_destroy_method destroy;
+       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;
+};
+
 struct bt_component_class_source {
        struct bt_component_class parent;
        struct {
-               bt_component_class_source_init_iterator_method init_iterator;
+               struct bt_component_class_iterator_methods iterator;
        } methods;
 };
 
@@ -80,7 +88,7 @@ struct bt_component_class_sink {
 struct bt_component_class_filter {
        struct bt_component_class parent;
        struct {
-               bt_component_class_filter_init_iterator_method init_iterator;
+               struct bt_component_class_iterator_methods iterator;
                bt_component_class_filter_add_iterator_method add_iterator;
        } methods;
 };
index d0b94872fa23e5b70a1084deb5c7bbb2366ad08f..5ca39b1b1c6a3ca318e3b0936ff611d14f26ac64 100644 (file)
@@ -33,12 +33,25 @@ extern "C" {
 
 struct bt_component_class;
 
-typedef enum bt_component_status (*bt_component_class_source_init_iterator_method)(
-               struct bt_component *, struct bt_notification_iterator *);
-
 extern
 struct bt_component_class *bt_component_class_source_create(const char *name,
-               bt_component_class_source_init_iterator_method init_iterator_method);
+               bt_component_class_notification_iterator_get_method notification_iterator_get_method,
+               bt_component_class_notification_iterator_next_method notification_iterator_next_method);
+
+extern
+int bt_component_class_source_set_notification_iterator_init_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_init_method notification_iterator_init_method);
+
+extern
+int bt_component_class_source_set_notification_iterator_destroy_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_destroy_method notification_iterator_destroy_method);
+
+extern
+int bt_component_class_source_set_notification_iterator_seek_time_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_seek_time_method notification_iterator_seek_time_method);
 
 #ifdef __cplusplus
 }
index d6f76ca831f00315a33592da6dd9cb5367681b16..ac78ce3463a010e9c8e6aac1968a5f16cb52f1f1 100644 (file)
@@ -55,6 +55,24 @@ typedef enum bt_component_status (*bt_component_class_init_method)(
 
 typedef void (*bt_component_class_destroy_method)(struct bt_component *component);
 
+typedef enum bt_notification_iterator_status
+               (*bt_component_class_notification_iterator_init_method)(
+               struct bt_component *component,
+               struct bt_notification_iterator *iterator);
+
+typedef void (*bt_component_class_notification_iterator_destroy_method)(
+               struct bt_notification_iterator *iterator);
+
+typedef struct bt_notification *(*bt_component_class_notification_iterator_get_method)(
+               struct bt_notification_iterator *iterator);
+
+typedef enum bt_notification_iterator_status (*bt_component_class_notification_iterator_next_method)(
+               struct bt_notification_iterator *iterator);
+
+typedef enum bt_notification_iterator_status
+               (*bt_component_class_notification_iterator_seek_time_method)(
+               struct bt_notification_iterator *iterator, int64_t time);
+
 extern int bt_component_class_set_init_method(
                struct bt_component_class *component_class,
                bt_component_class_init_method init_method);
index 29a5ff0f6061d1f83cc98760878be2dcad241acd..8bad9f937b654f1f1fc5a33f871fcc3001c1206d 100644 (file)
 struct bt_notification_iterator {
        struct bt_object base;
        struct bt_component *component;
-       bt_notification_iterator_get_cb get;
-       bt_notification_iterator_next_cb next;
-       bt_notification_iterator_seek_time_cb seek_time;
        void *user_data;
-       bt_notification_iterator_destroy_cb user_destroy;
 };
 
 /**
index 69c9b39a6b80d1acec402b3e55ad905b1ca60f71..26583c3a8cd7878e9c34a14fd3068c3e26f22a61 100644 (file)
@@ -126,90 +126,6 @@ extern enum bt_notification_iterator_status bt_notification_iterator_seek_time(
 extern struct bt_component *bt_notification_iterator_get_component(
                struct bt_notification_iterator *iterator);
 
-/** bt_notification_iterator */
-/**
- * Function returning an iterator's current notification.
- *
- * @param iterator     Notification iterator instance
- * @returns            A notification instance
- */
-typedef struct bt_notification *(*bt_notification_iterator_get_cb)(
-               struct bt_notification_iterator *iterator);
-
-/**
- * Function advancing an iterator's position of one element.
- *
- * @param iterator     Notification iterator instance
- * @returns            One of #bt_notification_iterator_status values
- */
-typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb)(
-               struct bt_notification_iterator *iterator);
-
-/**
- * Function advancing an iterator's position to a given time (relative to Epoch).
- *
- * @param iterator     Notification iterator instance
- * @param time         Time at which to seek, expressed in ns since Epoch
- * @returns            One of #bt_notification_iterator_status values
- */
-typedef enum bt_notification_iterator_status
-               (*bt_notification_iterator_seek_time_cb)(
-               struct bt_notification_iterator *iterator, int64_t time);
-
-/**
- * Function cleaning-up an iterator's private data on destruction.
- *
- * @param iterator     Notification iterator instance
- */
-typedef void (*bt_notification_iterator_destroy_cb)(
-               struct bt_notification_iterator *iterator);
-
-/**
- * Set an iterator's "get" callback which return the current notification.
- *
- * @param iterator     Notification iterator instance
- * @param get          Notification return callback
- * @returns            One of #bt_notification_iterator_status values
- */
-extern enum bt_notification_iterator_status
-bt_notification_iterator_set_get_cb(struct bt_notification_iterator *iterator,
-               bt_notification_iterator_get_cb get);
-
-/**
- * Set an iterator's "next" callback which advances the iterator's position.
- *
- * @param iterator     Notification iterator instance
- * @param next         Iterator "next" callback
- * @returns            One of #bt_notification_iterator_status values
- */
-extern enum bt_notification_iterator_status
-bt_notification_iterator_set_next_cb(struct bt_notification_iterator *iterator,
-               bt_notification_iterator_next_cb next);
-
-/**
- * Set an iterator's "seek_time" callback which sets the iterator's position to
- *     provided time (in ns since Epoch).
- *
- * @param iterator     Notification iterator instance
- * @param seek_timetime        Iterator "seek_time" callback
- * @returns            One of #bt_notification_iterator_status values
- */
-extern enum bt_notification_iterator_status
-bt_notification_iterator_set_seek_time_cb(struct bt_notification_iterator *iterator,
-               bt_notification_iterator_seek_time_cb seek_time);
-
-/**
- * Set an iterator's "destroy" callback.
- *
- * @param iterator     Notification iterator instance
- * @param next         Iterator destruction callback
- * @returns            One of #bt_notification_iterator_status values
- */
-extern enum bt_notification_iterator_status
-bt_notification_iterator_set_destroy_cb(
-               struct bt_notification_iterator *iterator,
-               bt_notification_iterator_destroy_cb destroy);
-
 /**
  * Set an iterator's private data.
  *
@@ -230,7 +146,6 @@ bt_notification_iterator_set_private_data(
 extern void *bt_notification_iterator_get_private_data(
                struct bt_notification_iterator *iterator);
 
-
 #ifdef __cplusplus
 }
 #endif
index 76e58e67ac26329c3a43fb7034d0a930f7672ee6..c8ea1c8509d5594bf1fda5e1a77fd90fd59870f5 100644 (file)
@@ -145,12 +145,14 @@ struct __bt_plugin_component_class_descriptor {
        union {
                /* BT_COMPONENT_CLASS_TYPE_SOURCE */
                struct {
-                       bt_component_class_source_init_iterator_method init_iterator;
+                       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_filter_init_iterator_method init_iterator;
+                       bt_component_class_notification_iterator_get_method notif_iter_get;
+                       bt_component_class_notification_iterator_next_method notif_iter_next;
                } filter;
 
                /* BT_COMPONENT_CLASS_TYPE_SINK */
@@ -167,6 +169,9 @@ enum __bt_plugin_component_class_descriptor_attribute_type {
        BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD              = 2,
        BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD  = 3,
        BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD    = 4,
+       BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD      = 5,
+       BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_DESTROY_METHOD   = 6,
+       BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_SEEK_TIME_METHOD = 7,
 };
 
 /* Component class attribute (internal use) */
@@ -199,6 +204,15 @@ struct __bt_plugin_component_class_descriptor_attribute {
 
                /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD */
                bt_component_class_sink_add_iterator_method sink_add_iterator_method;
+
+               /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD */
+               bt_component_class_notification_iterator_init_method notif_iter_init_method;
+
+               /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_DESTROY_METHOD */
+               bt_component_class_notification_iterator_destroy_method notif_iter_destroy_method;
+
+               /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_SEEK_TIME_METHOD */
+               bt_component_class_notification_iterator_seek_time_method notif_iter_seek_time_method;
        } value;
 } __attribute__((packed));
 
@@ -347,19 +361,22 @@ struct __bt_plugin_component_class_descriptor_attribute {
 /*
  * Defines a source component class descriptor with a custom ID.
  *
- * _id:                   ID (any valid C identifier except `auto`).
- * _comp_class_id:        Component class ID (C identifier).
- * _name:                 Component class name (C string).
- * _init_iterator_method: Component class's iterator initialization method
- *                        (bt_component_class_source_init_iterator_method).
+ * _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).
  */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _init_iterator_method) \
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_get_method, _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 = {                                     \
-                       .init_iterator = _init_iterator_method,         \
+                       .notif_iter_get = _notif_iter_get_method,       \
+                       .notif_iter_next = _notif_iter_next_method,     \
                },                                                      \
        };                                                              \
        static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id; \
@@ -371,16 +388,19 @@ struct __bt_plugin_component_class_descriptor_attribute {
  * _id:                   ID (any valid C identifier except `auto`).
  * _comp_class_id:        Component class ID (C identifier).
  * _name:                 Component class name (C string).
- * _init_iterator_method: Component class's iterator initialization method
- *                        (bt_component_class_filter_init_iterator_method).
+ * _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).
  */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _init_iterator_method) \
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_get_method, _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 = {                                     \
-                       .init_iterator = _init_iterator_method,         \
+                       .notif_iter_get = _notif_iter_get_method,       \
+                       .notif_iter_next = _notif_iter_next_method,     \
                },                                                      \
        };                                                              \
        static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id; \
@@ -553,6 +573,78 @@ struct __bt_plugin_component_class_descriptor_attribute {
 #define BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(_id, _comp_class_id, _x) \
        __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_add_iterator_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD, _id, _comp_class_id, sink, _x)
 
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * specific source component class descriptor.
+ *
+ * _id:            Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x:             Iterator initialization method
+ *                 (bt_component_class_notification_iterator_init_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an iterator destroy method attribute attached to a specific
+ * source component class descriptor.
+ *
+ * _id:            Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x:             Iterator destroy method
+ *                 (bt_component_class_notification_iterator_destroy_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_DESTROY_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an iterator seek time method attribute attached to a specific
+ * source component class descriptor.
+ *
+ * _id:            Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x:             Iterator seek time method
+ *                 (bt_component_class_notification_iterator_seek_time_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_seek_time_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_SEEK_TIME_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * specific filter component class descriptor.
+ *
+ * _id:            Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x:             Iterator initialization method
+ *                 (bt_component_class_notification_iterator_init_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an iterator destroy method attribute attached to a specific
+ * filter component class descriptor.
+ *
+ * _id:            Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x:             Iterator destroy method
+ *                 (bt_component_class_notification_iterator_destroy_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_DESTROY_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an iterator seek time method attribute attached to a specific
+ * filter component class descriptor.
+ *
+ * _id:            Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x:             Iterator seek time method
+ *                 (bt_component_class_notification_iterator_seek_time_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_seek_time_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_SEEK_TIME_METHOD, _id, _comp_class_id, filter, _x)
+
 /*
  * Defines a plugin descriptor with an automatic ID.
  *
@@ -616,24 +708,28 @@ struct __bt_plugin_component_class_descriptor_attribute {
  * descriptor. Its ID is the same as its name, hence its name must be a
  * C identifier in this version.
  *
- * _name:                 Component class name (C identifier).
- * _init_iterator_method: Component class's iterator initialization method
- *                        (bt_component_class_source_init_iterator_method).
+ * _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).
  */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _init_iterator_method) \
-       BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _init_iterator_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)
 
 /*
  * Defines a filter component class attached to the automatic plugin
  * descriptor. Its ID is the same as its name, hence its name must be a
  * C identifier in this version.
  *
- * _name:                 Component class name (C identifier).
- * _init_iterator_method: Component class's iterator initialization method
- *                        (bt_component_class_filter_init_iterator_method).
+ * _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).
  */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _init_iterator_method) \
-       BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _init_iterator_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)
 
 /*
  * Defines a sink component class attached to the automatic plugin
@@ -764,6 +860,78 @@ struct __bt_plugin_component_class_descriptor_attribute {
 #define BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD(_name, _x) \
        BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(auto, _name, _x)
 
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * source component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x:    Iterator initialization method
+ *        (bt_component_class_notification_iterator_init_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(_name, _x) \
+       BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator destroy method attribute attached to a source
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x:    Iterator destroy method
+ *        (bt_component_class_notification_iterator_destroy_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD(_name, _x) \
+       BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator seek time method attribute attached to a source
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x:    Iterator seek time method
+ *        (bt_component_class_notification_iterator_seek_time_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(_name, _x) \
+       BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * filter component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x:    Iterator initialization method
+ *        (bt_component_class_notification_iterator_init_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(_name, _x) \
+       BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator destroy method attribute attached to a filter
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x:    Iterator destroy method
+ *        (bt_component_class_notification_iterator_destroy_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD(_name, _x) \
+       BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator seek time method attribute attached to a filter
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x:    Iterator seek time method
+ *        (bt_component_class_notification_iterator_seek_time_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(_name, _x) \
+       BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD_WITH_ID(auto, _name, _x)
+
 #ifdef __cplusplus
 }
 #endif
index 55f020d219efa424313d4f3c39b2692500b5a1ad..1f6e680aa7efb01d2115764f6c8befffa52e3320 100644 (file)
@@ -99,12 +99,14 @@ end:
 }
 
 struct bt_component_class *bt_component_class_source_create(const char *name,
-               bt_component_class_source_init_iterator_method init_iterator_method)
+               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;
 
-       if (!name || !init_iterator_method) {
+       if (!name || !notification_iterator_get_method ||
+                       !notification_iterator_next_method) {
                goto end;
        }
 
@@ -125,19 +127,22 @@ struct bt_component_class *bt_component_class_source_create(const char *name,
                goto end;
        }
 
-       source_class->methods.init_iterator = init_iterator_method;
+       source_class->methods.iterator.get = notification_iterator_get_method;
+       source_class->methods.iterator.next = notification_iterator_next_method;
 
 end:
        return &source_class->parent;
 }
 
 struct bt_component_class *bt_component_class_filter_create(const char *name,
-               bt_component_class_filter_init_iterator_method init_iterator_method)
+               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;
 
-       if (!name || !init_iterator_method) {
+       if (!name || !notification_iterator_get_method ||
+                       !notification_iterator_next_method) {
                goto end;
        }
 
@@ -158,7 +163,8 @@ struct bt_component_class *bt_component_class_filter_create(const char *name,
                goto end;
        }
 
-       filter_class->methods.init_iterator = init_iterator_method;
+       filter_class->methods.iterator.get = notification_iterator_get_method;
+       filter_class->methods.iterator.next = notification_iterator_next_method;
 
 end:
        return &filter_class->parent;
@@ -231,7 +237,143 @@ end:
        return ret;
 }
 
-extern int bt_component_class_set_description(
+int bt_component_class_source_set_notification_iterator_init_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_init_method notification_iterator_init_method)
+{
+       struct bt_component_class_source *source_class;
+       int ret = 0;
+
+       if (!component_class || component_class->frozen ||
+                       !notification_iterator_init_method ||
+                       component_class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
+               ret = -1;
+               goto end;
+       }
+
+       source_class = container_of(component_class,
+               struct bt_component_class_source, parent);
+       source_class->methods.iterator.init = notification_iterator_init_method;
+
+end:
+       return ret;
+}
+
+int bt_component_class_source_set_notification_iterator_destroy_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_destroy_method notification_iterator_destroy_method)
+{
+       struct bt_component_class_source *source_class;
+       int ret = 0;
+
+       if (!component_class || component_class->frozen ||
+                       !notification_iterator_destroy_method ||
+                       component_class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
+               ret = -1;
+               goto end;
+       }
+
+       source_class = container_of(component_class,
+               struct bt_component_class_source, parent);
+       source_class->methods.iterator.destroy =
+               notification_iterator_destroy_method;
+
+end:
+       return ret;
+}
+
+int bt_component_class_source_set_notification_iterator_seek_time_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_seek_time_method notification_iterator_seek_time_method)
+{
+       struct bt_component_class_source *source_class;
+       int ret = 0;
+
+       if (!component_class || component_class->frozen ||
+                       !notification_iterator_seek_time_method ||
+                       component_class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
+               ret = -1;
+               goto end;
+       }
+
+       source_class = container_of(component_class,
+               struct bt_component_class_source, parent);
+       source_class->methods.iterator.seek_time =
+               notification_iterator_seek_time_method;
+
+end:
+       return ret;
+}
+
+int bt_component_class_filter_set_notification_iterator_init_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_init_method notification_iterator_init_method)
+{
+       struct bt_component_class_filter *filter_class;
+       int ret = 0;
+
+       if (!component_class || component_class->frozen ||
+                       !notification_iterator_init_method ||
+                       component_class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
+               ret = -1;
+               goto end;
+       }
+
+       filter_class = container_of(component_class,
+               struct bt_component_class_filter, parent);
+       filter_class->methods.iterator.init = notification_iterator_init_method;
+
+end:
+       return ret;
+}
+
+int bt_component_class_filter_set_notification_iterator_destroy_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_destroy_method notification_iterator_destroy_method)
+{
+       struct bt_component_class_filter *filter_class;
+       int ret = 0;
+
+       if (!component_class || component_class->frozen ||
+                       !notification_iterator_destroy_method ||
+                       component_class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
+               ret = -1;
+               goto end;
+       }
+
+       filter_class = container_of(component_class,
+               struct bt_component_class_filter, parent);
+       filter_class->methods.iterator.destroy =
+               notification_iterator_destroy_method;
+
+end:
+       return ret;
+}
+
+int bt_component_class_filter_set_notification_iterator_seek_time_method(
+               struct bt_component_class *component_class,
+               bt_component_class_notification_iterator_seek_time_method notification_iterator_seek_time_method)
+{
+       struct bt_component_class_filter *filter_class;
+       int ret = 0;
+
+       if (!component_class || component_class->frozen ||
+                       !notification_iterator_seek_time_method ||
+                       component_class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
+               ret = -1;
+               goto end;
+       }
+
+       filter_class = container_of(component_class,
+               struct bt_component_class_filter, parent);
+       filter_class->methods.iterator.seek_time =
+               notification_iterator_seek_time_method;
+
+end:
+       return ret;
+}
+
+int bt_component_class_set_description(
                struct bt_component_class *component_class,
                const char *description)
 {
index c3ccd95c57edf569498c3b725c4be2d6e0de6e49..d6921a42da4b2e7235b0661be163df38330d9556 100644 (file)
@@ -134,29 +134,27 @@ struct bt_notification_iterator *bt_component_create_iterator(
        case BT_COMPONENT_CLASS_TYPE_SOURCE:
        {
                struct bt_component_class_source *source_class;
-               enum bt_component_status ret_component;
+               enum bt_notification_iterator_status status;
 
                source_class = container_of(class, struct bt_component_class_source, parent);
-               assert(source_class->methods.init_iterator);
-               ret_component =
-                       source_class->methods.init_iterator(component, iterator);
-               if (ret_component != BT_COMPONENT_STATUS_OK) {
+               assert(source_class->methods.iterator.init);
+               status = source_class->methods.iterator.init(component,
+                               iterator);
+               if (status < 0) {
                        goto error;
                }
                break;
-
-               break;
        }
        case BT_COMPONENT_CLASS_TYPE_FILTER:
        {
                struct bt_component_class_filter *filter_class;
-               enum bt_component_status ret_component;
+               enum bt_notification_iterator_status status;
 
                filter_class = container_of(class, struct bt_component_class_filter, parent);
-               assert(filter_class->methods.init_iterator);
-               ret_component =
-                       filter_class->methods.init_iterator(component, iterator);
-               if (ret_component != BT_COMPONENT_STATUS_OK) {
+               assert(filter_class->methods.iterator.init);
+               status = filter_class->methods.iterator.init(component,
+                               iterator);
+               if (status < 0) {
                        goto error;
                }
                break;
index c8c41a0b5b901d2bc7dfc38f993ab0ada40b429c..cffa0d91a2570aa2fa768d575ffdb27aefd65cfd 100644 (file)
@@ -30,6 +30,7 @@
 #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>
 
@@ -37,14 +38,43 @@ static
 void bt_notification_iterator_destroy(struct bt_object *obj)
 {
        struct bt_notification_iterator *iterator;
+       struct bt_component_class *comp_class;
 
        assert(obj);
        iterator = container_of(obj, struct bt_notification_iterator,
                        base);
-       assert(iterator->user_destroy || !iterator->user_data);
-       if (iterator->user_destroy) {
-               iterator->user_destroy(iterator);
+       assert(iterator->component);
+       comp_class = iterator->component->class;
+
+       /* Call user-defined destroy method */
+       switch (comp_class->type) {
+       case BT_COMPONENT_CLASS_TYPE_SOURCE:
+       {
+               struct bt_component_class_source *source_class;
+
+               source_class = container_of(comp_class, struct bt_component_class_source, parent);
+
+               if (source_class->methods.iterator.destroy) {
+                       source_class->methods.iterator.destroy(iterator);
+               }
+               break;
        }
+       case BT_COMPONENT_CLASS_TYPE_FILTER:
+       {
+               struct bt_component_class_filter *filter_class;
+
+               filter_class = container_of(comp_class, struct bt_component_class_filter, parent);
+
+               if (filter_class->methods.iterator.destroy) {
+                       filter_class->methods.iterator.destroy(iterator);
+               }
+               break;
+       }
+       default:
+               /* Unreachable */
+               assert(0);
+       }
+
        BT_PUT(iterator->component);
        g_free(iterator);
 }
@@ -87,80 +117,10 @@ enum bt_notification_iterator_status bt_notification_iterator_validate(
        enum bt_notification_iterator_status ret =
                        BT_NOTIFICATION_ITERATOR_STATUS_OK;
 
-       if (!iterator || !iterator->get || !iterator->next) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
-               goto end;
-       }
-end:
-       return ret;
-}
-
-enum bt_notification_iterator_status bt_notification_iterator_set_get_cb(
-               struct bt_notification_iterator *iterator,
-               bt_notification_iterator_get_cb get)
-{
-       enum bt_notification_iterator_status ret =
-                       BT_NOTIFICATION_ITERATOR_STATUS_OK;
-
-       if (!iterator || !get) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
-               goto end;
-       }
-
-       iterator->get = get;
-end:
-       return ret;
-}
-
-enum bt_notification_iterator_status
-bt_notification_iterator_set_next_cb(struct bt_notification_iterator *iterator,
-               bt_notification_iterator_next_cb next)
-{
-       enum bt_notification_iterator_status ret =
-                       BT_NOTIFICATION_ITERATOR_STATUS_OK;
-
-       if (!iterator || !next) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
-               goto end;
-       }
-
-       iterator->next = next;
-end:
-       return ret;
-}
-
-enum bt_notification_iterator_status
-bt_notification_iterator_set_seek_time_cb(
-               struct bt_notification_iterator *iterator,
-               bt_notification_iterator_seek_time_cb seek_time)
-{
-       enum bt_notification_iterator_status ret =
-                       BT_NOTIFICATION_ITERATOR_STATUS_OK;
-
-       if (!iterator || !seek_time) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
-               goto end;
-       }
-
-       iterator->seek_time = seek_time;
-end:
-       return ret;
-}
-
-enum bt_notification_iterator_status
-bt_notification_iterator_set_destroy_cb(
-               struct bt_notification_iterator *iterator,
-               bt_notification_iterator_destroy_cb destroy)
-{
-       enum bt_notification_iterator_status ret =
-                       BT_NOTIFICATION_ITERATOR_STATUS_OK;
-
-       if (!iterator || !destroy) {
+       if (!iterator) {
                ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
                goto end;
        }
-
-       iterator->user_destroy = destroy;
 end:
        return ret;
 }
@@ -178,7 +138,7 @@ bt_notification_iterator_set_private_data(
        enum bt_notification_iterator_status ret =
                        BT_NOTIFICATION_ITERATOR_STATUS_OK;
 
-       if (!iterator || !data) {
+       if (!iterator) {
                ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
                goto end;
        }
@@ -191,17 +151,79 @@ end:
 struct bt_notification *bt_notification_iterator_get_notification(
                struct bt_notification_iterator *iterator)
 {
+       bt_component_class_notification_iterator_get_method get_method = NULL;
+
        assert(iterator);
-       assert(iterator->get);
-       return iterator->get(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);
+
+               assert(source_class->methods.iterator.get);
+               get_method = source_class->methods.iterator.get;
+               break;
+       }
+       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;
+       }
+
+       assert(get_method);
+       return get_method(iterator);
 }
 
 enum bt_notification_iterator_status
 bt_notification_iterator_next(struct bt_notification_iterator *iterator)
 {
+       bt_component_class_notification_iterator_next_method next_method = NULL;
+
        assert(iterator);
-       assert(iterator->next);
-       return iterator->next(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);
+
+               assert(source_class->methods.iterator.next);
+               next_method = source_class->methods.iterator.next;
+               break;
+       }
+       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.next);
+               next_method = filter_class->methods.iterator.next;
+               break;
+       }
+       default:
+               assert(false);
+               break;
+       }
+
+       assert(next_method);
+       return next_method(iterator);
 }
 
 struct bt_component *bt_notification_iterator_get_component(
index 707fe4e74595646702aa7f6f4ed7c6f703973d2c..ce4e43492865ee56e0e8b43249ae3f211987606e 100644 (file)
@@ -286,6 +286,7 @@ enum bt_plugin_status bt_plugin_init(
                bt_component_class_destroy_method destroy_method;
                bt_component_class_filter_add_iterator_method filter_add_iterator_method;
                bt_component_class_sink_add_iterator_method sink_add_iterator_method;
+               struct bt_component_class_iterator_methods iterator_methods;
        };
 
        enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
@@ -408,6 +409,18 @@ enum bt_plugin_status bt_plugin_init(
                                        cc_full_descr->sink_add_iterator_method =
                                                cur_cc_descr_attr->value.sink_add_iterator_method;
                                        break;
+                               case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD:
+                                       cc_full_descr->iterator_methods.init =
+                                               cur_cc_descr_attr->value.notif_iter_init_method;
+                                       break;
+                               case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_DESTROY_METHOD:
+                                       cc_full_descr->iterator_methods.destroy =
+                                               cur_cc_descr_attr->value.notif_iter_destroy_method;
+                                       break;
+                               case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_SEEK_TIME_METHOD:
+                                       cc_full_descr->iterator_methods.seek_time =
+                                               cur_cc_descr_attr->value.notif_iter_seek_time_method;
+                                       break;
                                default:
                                        printf_verbose("WARNING: Unknown attribute \"%s\" (type %d) for component class %s (type %d) in plugin %s\n",
                                                cur_cc_descr_attr->type_name,
@@ -444,12 +457,14 @@ enum bt_plugin_status bt_plugin_init(
                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                        comp_class = bt_component_class_source_create(
                                cc_full_descr->descriptor->name,
-                               cc_full_descr->descriptor->methods.source.init_iterator);
+                               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.filter.init_iterator);
+                               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:
                        comp_class = bt_component_class_sink_create(
@@ -499,28 +514,101 @@ enum bt_plugin_status bt_plugin_init(
                        }
                }
 
-               if (cc_full_descr->descriptor->type ==
-                               BT_COMPONENT_CLASS_TYPE_FILTER &&
-                               cc_full_descr->filter_add_iterator_method) {
-                       ret = bt_component_class_filter_set_add_iterator_method(comp_class,
-                               cc_full_descr->filter_add_iterator_method);
-                       if (ret) {
-                               status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
-                               goto end;
+               switch (cc_full_descr->descriptor->type) {
+               case BT_COMPONENT_CLASS_TYPE_SOURCE:
+                       if (cc_full_descr->iterator_methods.init) {
+                               ret = bt_component_class_source_set_notification_iterator_init_method(
+                                       comp_class,
+                                       cc_full_descr->iterator_methods.init);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
                        }
-               }
 
-               if (cc_full_descr->descriptor->type ==
-                               BT_COMPONENT_CLASS_TYPE_SINK &&
-                               cc_full_descr->sink_add_iterator_method) {
-                       ret = bt_component_class_sink_set_add_iterator_method(comp_class,
-                               cc_full_descr->sink_add_iterator_method);
-                       if (ret) {
-                               status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
-                               goto end;
+                       if (cc_full_descr->iterator_methods.destroy) {
+                               ret = bt_component_class_source_set_notification_iterator_destroy_method(
+                                       comp_class,
+                                       cc_full_descr->iterator_methods.destroy);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
                        }
+
+                       if (cc_full_descr->iterator_methods.seek_time) {
+                               ret = bt_component_class_source_set_notification_iterator_seek_time_method(
+                                       comp_class,
+                                       cc_full_descr->iterator_methods.seek_time);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
+                       }
+                       break;
+               case BT_COMPONENT_CLASS_TYPE_FILTER:
+                       if (cc_full_descr->filter_add_iterator_method) {
+                               ret = bt_component_class_filter_set_add_iterator_method(
+                                       comp_class,
+                                       cc_full_descr->filter_add_iterator_method);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
+                       }
+
+                       if (cc_full_descr->iterator_methods.init) {
+                               ret = bt_component_class_filter_set_notification_iterator_init_method(
+                                       comp_class,
+                                       cc_full_descr->iterator_methods.init);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
+                       }
+
+                       if (cc_full_descr->iterator_methods.destroy) {
+                               ret = bt_component_class_filter_set_notification_iterator_destroy_method(
+                                       comp_class,
+                                       cc_full_descr->iterator_methods.destroy);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
+                       }
+
+                       if (cc_full_descr->iterator_methods.seek_time) {
+                               ret = bt_component_class_filter_set_notification_iterator_seek_time_method(
+                                       comp_class,
+                                       cc_full_descr->iterator_methods.seek_time);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
+                       }
+                       break;
+               case BT_COMPONENT_CLASS_TYPE_SINK:
+                       if (cc_full_descr->sink_add_iterator_method) {
+                               ret = bt_component_class_sink_set_add_iterator_method(
+                                       comp_class,
+                                       cc_full_descr->sink_add_iterator_method);
+                               if (ret) {
+                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_PUT(comp_class);
+                                       goto end;
+                               }
+                       }
+                       break;
+               default:
+                       assert(false);
+                       break;
                }
 
                /* Add component class to the plugin object */
index 450627d7bb60258b101590fadb31858df9e94443..61cac172fd2c4efce1c67f5008ea9bd87f84721b 100644 (file)
 BT_HIDDEN
 bool ctf_fs_debug;
 
-static
 enum bt_notification_iterator_status ctf_fs_iterator_next(
                struct bt_notification_iterator *iterator);
 
-static
 struct bt_notification *ctf_fs_iterator_get(
                struct bt_notification_iterator *iterator)
 {
@@ -246,7 +244,6 @@ end:
        return ret;
 }
 
-static
 enum bt_notification_iterator_status ctf_fs_iterator_next(
                struct bt_notification_iterator *iterator)
 {
@@ -364,7 +361,6 @@ void ctf_fs_iterator_destroy_data(struct ctf_fs_iterator *ctf_it)
        g_free(ctf_it);
 }
 
-static
 void ctf_fs_iterator_destroy(struct bt_notification_iterator *it)
 {
        void *data = bt_notification_iterator_get_private_data(it);
@@ -584,24 +580,24 @@ end:
        return ret;
 }
 
-enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
+enum bt_notification_iterator_status ctf_fs_iterator_init(struct bt_component *source,
                struct bt_notification_iterator *it)
 {
        struct ctf_fs_iterator *ctf_it;
        struct ctf_fs_component *ctf_fs;
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       enum bt_notification_iterator_status ret = BT_NOTIFICATION_ITERATOR_STATUS_OK;
 
        assert(source && it);
 
        ctf_fs = bt_component_get_private_data(source);
        if (!ctf_fs) {
-               ret = BT_COMPONENT_STATUS_INVALID;
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
                goto end;
        }
 
        ctf_it = g_new0(struct ctf_fs_iterator, 1);
        if (!ctf_it) {
-               ret = BT_COMPONENT_STATUS_NOMEM;
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
                goto end;
        }
 
@@ -626,22 +622,6 @@ enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
                goto error;
        }
 
-       ret = bt_notification_iterator_set_get_cb(it, ctf_fs_iterator_get);
-       if (ret) {
-               goto error;
-       }
-
-       ret = bt_notification_iterator_set_next_cb(it, ctf_fs_iterator_next);
-       if (ret) {
-               goto error;
-       }
-
-       ret = bt_notification_iterator_set_destroy_cb(it,
-                       ctf_fs_iterator_destroy);
-       if (ret) {
-               goto error;
-       }
-
        ret = bt_notification_iterator_set_private_data(it, ctf_it);
        if (ret) {
                goto error;
index 7ade621f89f65ff626e008906053ad67629b9e07..4c165676b287eaa6fab2f9adf1f59245208cb373 100644 (file)
@@ -113,7 +113,16 @@ BT_HIDDEN
 void ctf_fs_destroy(struct bt_component *component);
 
 BT_HIDDEN
-enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
+enum bt_notification_iterator_status ctf_fs_iterator_init(
+               struct bt_component *source,
                struct bt_notification_iterator *it);
 
+void ctf_fs_iterator_destroy(struct bt_notification_iterator *it);
+
+enum bt_notification_iterator_status ctf_fs_iterator_next(
+               struct bt_notification_iterator *iterator);
+
+struct bt_notification *ctf_fs_iterator_get(
+               struct bt_notification_iterator *iterator);
+
 #endif /* BABELTRACE_PLUGIN_CTF_FS_H */
index bb3c4e43cad020b8fd6888d8e4bed7ba1ba4f332..17d8e87eb4ac7efaeca71e36d91cedab6159c44f 100644 (file)
 
 #define LTTNG_LIVE_COMPONENT_DESCRIPTION "Component implementing an LTTng-live client."
 
-BT_HIDDEN
-enum bt_component_status lttng_live_iterator_init(struct bt_component *source,
-        struct bt_notification_iterator *it);
-
 BT_HIDDEN
 enum bt_component_status lttng_live_init(struct bt_component *source,
                struct bt_value *params, void *init_method_data);
 
+BT_HIDDEN
+struct bt_notification *lttng_live_iterator_get(
+        struct bt_notification_iterator *iterator);
+
+BT_HIDDEN
+enum bt_notification_iterator_status lttng_live_iterator_next(
+        struct bt_notification_iterator *iterator);
+
 #endif /* BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_INTERNAL_H */
index add91ccb0005ac294c6fc7ad3f2efdef1782f9a8..5f082fcc5ef0f4a49016052cd24797f7005f8adf 100644 (file)
 #include <plugins-common.h>
 
 BT_HIDDEN
-enum bt_component_status lttng_live_iterator_init(struct bt_component *source,
-               struct bt_notification_iterator *it)
+struct bt_notification *lttng_live_iterator_get(
+               struct bt_notification_iterator *iterator)
 {
-    return BT_COMPONENT_STATUS_OK;
+       return NULL;
+}
+
+BT_HIDDEN
+enum bt_notification_iterator_status lttng_live_iterator_next(
+               struct bt_notification_iterator *iterator)
+{
+       return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
 
 BT_HIDDEN
index 77f5057bf650cf534317fce68071fdb96af7adbc..b79e5073a9dbf3bb797d6e5f14be462a6d004766 100644 (file)
@@ -37,13 +37,17 @@ BT_PLUGIN_AUTHOR("Jérémie Galarneau");
 BT_PLUGIN_LICENSE("MIT");
 
 /* Declare component classes implemented by this plug-in. */
-BT_PLUGIN_SOURCE_COMPONENT_CLASS(fs, ctf_fs_iterator_init);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS(fs, ctf_fs_iterator_get, 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_DESTROY_METHOD(fs, ctf_fs_destroy);
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(fs, CTF_FS_COMPONENT_DESCRIPTION);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(fs,
+       ctf_fs_iterator_init);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD(fs,
+       ctf_fs_iterator_destroy);
 
 BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, lttng_live, "lttng-live",
-       lttng_live_iterator_init);
+       lttng_live_iterator_get, 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,
index f8eb7d30c9f82ec96d2b9d44d04266295e96a946..745e0803f6b1c7cac5e1332aeaf5cdd78f9b9a5e 100644 (file)
@@ -85,11 +85,18 @@ error:
        return ret;
 }
 
-enum bt_component_status muxer_init_iterator(
-               struct bt_component *component,
-               struct bt_notification_iterator *iter)
+static
+struct bt_notification *muxer_iterator_get(
+               struct bt_notification_iterator *iterator)
+{
+       return NULL;
+}
+
+static
+enum bt_notification_iterator_status muxer_iterator_next(
+               struct bt_notification_iterator *iterator)
 {
-       return BT_COMPONENT_STATUS_OK;
+       return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
 
 /* Initialize plug-in entry points. */
@@ -97,7 +104,8 @@ BT_PLUGIN(muxer);
 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_init_iterator);
+BT_PLUGIN_FILTER_COMPONENT_CLASS(muxer, muxer_iterator_get,
+       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);
index d7633a9c395148a63838411b0a7faaf0f82e8eec..614748a2f76349f869afbe1602134f8e2ff93ce2 100644 (file)
@@ -43,7 +43,7 @@
 #include <babeltrace/ctf-ir/fields.h>
 #include <assert.h>
 
-static
+BT_HIDDEN
 void trimmer_iterator_destroy(struct bt_notification_iterator *it)
 {
        struct trimmer_iterator *it_data;
@@ -59,15 +59,17 @@ void trimmer_iterator_destroy(struct bt_notification_iterator *it)
 }
 
 BT_HIDDEN
-enum bt_component_status trimmer_iterator_init(struct bt_component *component,
+enum bt_notification_iterator_status trimmer_iterator_init(
+               struct bt_component *component,
                struct bt_notification_iterator *iterator)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       enum bt_notification_iterator_status ret =
+               BT_NOTIFICATION_ITERATOR_STATUS_OK;
        enum bt_notification_iterator_status it_ret;
        struct trimmer_iterator *it_data = g_new0(struct trimmer_iterator, 1);
 
        if (!it_data) {
-               ret = BT_COMPONENT_STATUS_NOMEM;
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
                goto end;
        }
 
@@ -76,34 +78,6 @@ enum bt_component_status trimmer_iterator_init(struct bt_component *component,
        if (it_ret) {
                goto end;
        }
-
-       it_ret = bt_notification_iterator_set_destroy_cb(iterator,
-                       trimmer_iterator_destroy);
-       if (it_ret) {
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
-       }
-
-       it_ret = bt_notification_iterator_set_next_cb(iterator,
-                       trimmer_iterator_next);
-       if (it_ret) {
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
-       }
-
-       it_ret = bt_notification_iterator_set_get_cb(iterator,
-                       trimmer_iterator_get);
-       if (it_ret) {
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
-       }
-
-       it_ret = bt_notification_iterator_set_seek_time_cb(iterator,
-                       trimmer_iterator_seek_time);
-       if (it_ret) {
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
-       }
 end:
        return ret;
 }
index 1ab0b6f5db12e77ecea99f3f4815bdb87d19427a..9bebf45982c1b507813d4e6fed186c8182c13cc0 100644 (file)
@@ -38,10 +38,13 @@ struct trimmer_iterator {
 };
 
 BT_HIDDEN
-enum bt_component_status trimmer_iterator_init(
+enum bt_notification_iterator_status trimmer_iterator_init(
                struct bt_component *component,
                struct bt_notification_iterator *iterator);
 
+BT_HIDDEN
+void trimmer_iterator_destroy(struct bt_notification_iterator *it);
+
 BT_HIDDEN
 struct bt_notification *trimmer_iterator_get(
                struct bt_notification_iterator *iterator);
index fd028d027cce40ba74cd41ef41fb36dfff347d4a..06814ef82be408e6459bcbf6e86576ef7923b397 100644 (file)
@@ -379,8 +379,15 @@ BT_PLUGIN(utils);
 BT_PLUGIN_DESCRIPTION("Babeltrace Trace Trimmer Plug-In.");
 BT_PLUGIN_AUTHOR("Jérémie Galarneau");
 BT_PLUGIN_LICENSE("MIT");
-BT_PLUGIN_FILTER_COMPONENT_CLASS(trimmer, trimmer_iterator_init);
+BT_PLUGIN_FILTER_COMPONENT_CLASS(trimmer, trimmer_iterator_get,
+       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_DESTROY_METHOD(trimmer, destroy_trimmer);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(trimmer,
+       trimmer_iterator_init);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD(trimmer,
+       trimmer_iterator_destroy);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(trimmer,
+       trimmer_iterator_seek_time);
index a9d58ce677a00d4500c053b8b7fa8bb1dd16c5e5..52d3bf9f2bba319658726e4819799e4f5dce1515 100644 (file)
@@ -23,10 +23,34 @@ static enum bt_component_status sink_consume(struct bt_component *component)
        return BT_COMPONENT_STATUS_OK;
 }
 
-enum bt_component_status dummy_init_iterator_method(
-               struct bt_component *component, struct bt_notification_iterator *iter)
+static enum bt_notification_iterator_status dummy_iterator_init_method(
+               struct bt_component *component,
+               struct bt_notification_iterator *iterator)
 {
-       return BT_COMPONENT_STATUS_OK;
+       return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+}
+
+static void dummy_iterator_destroy_method(
+               struct bt_notification_iterator *iterator)
+{
+}
+
+static struct bt_notification *dummy_iterator_get_method(
+               struct bt_notification_iterator *iterator)
+{
+       return NULL;
+}
+
+static enum bt_notification_iterator_status dummy_iterator_next_method(
+               struct bt_notification_iterator *iterator)
+{
+       return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+}
+
+static enum bt_notification_iterator_status dummy_iterator_seek_time_method(
+               struct bt_notification_iterator *iterator, int64_t time)
+{
+       return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
 
 BT_PLUGIN(test_sfs);
@@ -35,11 +59,25 @@ BT_PLUGIN_AUTHOR("Janine Sutto");
 BT_PLUGIN_LICENSE("Beerware");
 BT_PLUGIN_VERSION(1, 2, 3, "yes");
 
-BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_init_iterator_method);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_get_method,
+       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_NOTIFICATION_ITERATOR_DESTROY_METHOD(source,
+       dummy_iterator_destroy_method);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(source,
+       dummy_iterator_seek_time_method);
 
 BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
 BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
 
-BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_init_iterator_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_get_method,
+       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_NOTIFICATION_ITERATOR_DESTROY_METHOD(filter,
+       dummy_iterator_destroy_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(filter,
+       dummy_iterator_seek_time_method);
This page took 0.045851 seconds and 4 git commands to generate.