lib: make it mandatory to have seek_X if can_seek_X is defined
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 26 Sep 2019 18:26:29 +0000 (14:26 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 3 Oct 2019 17:27:58 +0000 (13:27 -0400)
It's currently possible for a component class to provide can_seek_X
(can_seek_beginning or can_seek_ns_from_origin) without the
corresponding seek_X.  This doesn't make much sense, as if can_seek_X
returns true, Babeltrace assumes that seek_X can be called (which is
inconvenient if it's not provided).  That only leaves room for the case
where can_seek_X always returns false, which is not useful.

This patch makes it only possible to provide a can_seek_X if the
corresponding seek_X is provided, for both C and Python user component
classes.  It's still possible, however, to provide seek_X without
can_seek_X, in which case Babeltrace assumes that it's always possible
to call seek_X.

In the C API, component class method setters for seek_X and can_seek_X
are merged in a single function that sets both.  Since we assert that
seek_X is not NULL, this ensures that can_seek_X can only provided along
with a seek_X.

In the Python API, this verification is done dynamically when a user
message iterator class is assigned to a source or filter component
class.

Change-Id: If596d35dc3327bfd6e3f1e59f74c43dce3a722e1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2100
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
14 files changed:
include/babeltrace2/graph/component-class-filter.h
include/babeltrace2/graph/component-class-source.h
include/babeltrace2/plugin/plugin-dev.h
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/native_bt_component_class.i.h
src/lib/graph/component-class.c
src/lib/graph/iterator.c
src/lib/graph/message/iterator.h
src/lib/plugin/plugin-so.c
src/plugins/ctf/plugin.c
src/plugins/lttng-utils/plugin.c
src/plugins/text/plugin.c
src/plugins/utils/plugin.c
tests/bindings/python/bt2/test_message_iterator.py

index da06f29cd14b8f014778e1bdeee7a8a3f62b1990..a6a69bea49aa05772d505766bb986108f646ca3e 100644 (file)
@@ -160,24 +160,16 @@ bt_component_class_filter_set_message_iterator_finalize_method(
                bt_component_class_filter_message_iterator_finalize_method method);
 
 extern bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
+bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods(
                bt_component_class_filter *comp_class,
-               bt_component_class_filter_message_iterator_seek_ns_from_origin_method method);
+               bt_component_class_filter_message_iterator_seek_ns_from_origin_method seek_method,
+               bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method can_seek_method);
 
 extern bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_seek_beginning_method(
+bt_component_class_filter_set_message_iterator_seek_beginning_methods(
                bt_component_class_filter *comp_class,
-               bt_component_class_filter_message_iterator_seek_beginning_method method);
-
-extern bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
-               bt_component_class_filter *comp_class,
-               bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method method);
-
-extern bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_can_seek_beginning_method(
-               bt_component_class_filter *comp_class,
-               bt_component_class_filter_message_iterator_can_seek_beginning_method method);
+               bt_component_class_filter_message_iterator_seek_beginning_method seek_method,
+               bt_component_class_filter_message_iterator_can_seek_beginning_method can_seek_method);
 
 #ifdef __cplusplus
 }
index d4872b1c1bc066d65bfd9fa4aadbed81081e58d2..bdc85180b4759113092489ee8a45900f5d908033 100644 (file)
@@ -149,24 +149,16 @@ bt_component_class_source_set_message_iterator_finalize_method(
                bt_component_class_source_message_iterator_finalize_method method);
 
 extern bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
+bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods(
                bt_component_class_source *comp_class,
-               bt_component_class_source_message_iterator_seek_ns_from_origin_method method);
+               bt_component_class_source_message_iterator_seek_ns_from_origin_method seek_method,
+               bt_component_class_source_message_iterator_can_seek_ns_from_origin_method can_seek_method);
 
 extern bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_seek_beginning_method(
+bt_component_class_source_set_message_iterator_seek_beginning_methods(
                bt_component_class_source *comp_class,
-               bt_component_class_source_message_iterator_seek_beginning_method method);
-
-extern bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
-               bt_component_class_source *comp_class,
-               bt_component_class_source_message_iterator_can_seek_ns_from_origin_method method);
-
-extern bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_can_seek_beginning_method(
-               bt_component_class_source *comp_class,
-               bt_component_class_source_message_iterator_can_seek_beginning_method method);
+               bt_component_class_source_message_iterator_seek_beginning_method seek_method,
+               bt_component_class_source_message_iterator_can_seek_beginning_method can_seek_method);
 
 #ifdef __cplusplus
 }
index 0dbe773814bf087a54208858dab5b54360d82022..85c3ef7f52a6e7f3ac7cb9ae01a63ad5ef7ca421 100644 (file)
@@ -877,52 +877,35 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
        __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x)
 
 /*
- * Defines an iterator "seek nanoseconds from origin" 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 nanoseconds from origin" method
- *                 (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an iterator "seek beginning" method attribute attached to a
- * specific source component class descriptor.
+ * Defines an iterator "seek nanoseconds from origin" and "can seek nanoseconds
+ * from origin" method attributes 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 beginning" method
- *                 (bt_component_class_source_message_iterator_seek_beginning_method).
+ * _id:              Plugin descriptor ID (C identifier).
+ * _comp_class_id:   Component class descriptor ID (C identifier).
+ * _seek_method:     Iterator "seek nanoseconds from origin" method
+ *                   (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
+ * _can_seek_method: Iterator "can seek nanoseconds from origin" method
+ *                   (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
  */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _seek_method); \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _can_seek_method)
 
 /*
- * Defines an iterator "can seek nanoseconds from origin" method
- * attribute attached to a specific source component class descriptor.
+ * Defines an iterator "seek beginning" and "can seek beginning" method
+ * attributes 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 "can seek nanoseconds from origin" method
- *                 (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
+ * _id:              Plugin descriptor ID (C identifier).
+ * _comp_class_id:   Component class descriptor ID (C identifier).
+ * _seek_method:     Iterator "seek beginning" method
+ *                   (bt_component_class_source_message_iterator_seek_beginning_method).
+ * _can_seek_method: Iterator "can seek beginning" method
+ *                   (bt_component_class_source_message_iterator_can_seek_beginning_method).
  */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an iterator "can seek beginning" 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 "can seek beginning" method
- *                 (bt_component_class_source_message_iterator_can_seek_beginning_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _seek_method); \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _can_seek_method)
 
 /*
  * Defines an iterator initialization method attribute attached to a
@@ -949,52 +932,34 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
        __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x)
 
 /*
- * Defines an iterator "seek nanoseconds from origin" 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 nanoseconds from origin" method
- *                 (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an iterator "seek beginning" 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 beginning" method
- *                 (bt_component_class_filter_message_iterator_seek_beginning_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an iterator "can seek nanoseconds from origin" method
- * attribute attached to a specific filter component class descriptor.
+ * Defines an iterator "seek nanoseconds" and "can seek nanoseconds from origin"
+ * method attributes 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 "can seek nanoseconds from origin" method
- *                 (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
+ * _id:              Plugin descriptor ID (C identifier).
+ * _comp_class_id:   Component class descriptor ID (C identifier).
+ * _seek_method:     Iterator "seek nanoseconds from origin" method
+ *                   (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
+ * _can_seek_method: Iterator "can seek nanoseconds from origin" method
+ *                   (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
  */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _seek_method); \
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _can_seek_method)
 
 /*
- * Defines an iterator "can seek beginning" method attribute attached to a
- * specific filter component class descriptor.
+ * Defines an iterator "seek beginning" and "can seek beginning" method
+ * attributes 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 "can seek beginning" method
- *                 (bt_component_class_filter_message_iterator_can_seek_beginning_method).
+ * _id:              Plugin descriptor ID (C identifier).
+ * _comp_class_id:   Component class descriptor ID (C identifier).
+ * _seek_method:     Iterator "seek beginning" method
+ *                   (bt_component_class_filter_message_iterator_seek_beginning_method).
+ * _can_seek_method: Iterator "can seek beginning" method
+ *                   (bt_component_class_filter_message_iterator_can_seek_beginning_method).
  */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \
+               __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _seek_method); \
+               __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _can_seek_method);
 
 /*
  * Defines a plugin descriptor with an automatic ID.
@@ -1362,52 +1327,32 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
        BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
 
 /*
- * Defines an iterator "seek nanoseconds from origin" 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 nanoseconds from origin" method
- *        (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
-       BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "seek beginning" 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 beginning" method
- *        (bt_component_class_source_message_iterator_seek_beginning_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(_name, _x) \
-       BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "can seek nanoseconds from origin" method
- * attribute attached to a source component class descriptor which is
- * attached to the automatic plugin descriptor.
+ * Defines an iterator "seek nanoseconds from origin" and "can seek nanoseconds
+ * from origin" method attributes attached to a source component class
+ * descriptor which is attached to the automatic plugin descriptor.
  *
- * _name: Component class name (C identifier).
- * _x:    Iterator "can seek nanoseconds from origin" method
- *        (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
+ * _name:            Component class name (C identifier).
+ * _seek_method:     Iterator "seek nanoseconds from origin" method
+ *                   (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
+ * _can_seek_method: Iterator "can seek nanoseconds from origin" method
+ *                   (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
  */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
-       BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS(_name, _seek_method, _can_seek_method) \
+       BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID(auto, _name, _seek_method, _can_seek_method)
 
 /*
- * Defines an iterator "can seek beginning" method attribute
- * attached to a source component class descriptor which is attached to
- * the automatic plugin descriptor.
+ * Defines an iterator "seek beginning" and "can seek beginning" method
+ * attributes attached to a source component class descriptor which is attached
+ * to the automatic plugin descriptor.
  *
- * _name: Component class name (C identifier).
- * _x:    Iterator "can seek beginning" method
- *        (bt_component_class_source_message_iterator_can_seek_beginning_method).
+ * _name:            Component class name (C identifier).
+ * _seek_method:     Iterator "can seek beginning" method
+ *                   (bt_component_class_source_message_iterator_can_seek_beginning_method).
+ * _can_seek_method: Iterator "can seek beginning" method
+ *                   (bt_component_class_source_message_iterator_seek_beginning_method).
  */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(_name, _x) \
-       BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS(_name, _seek_method, _can_seek_method) \
+       BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS_WITH_ID(auto, _name, _seek_method, _can_seek_method)
 
 /*
  * Defines an iterator initialization method attribute attached to a
@@ -1434,52 +1379,32 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
        BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
 
 /*
- * Defines an iterator "seek nanoseconds from origin" method attribute
- * attached to a filter component class descriptor which is attached to
- * the automatic plugin descriptor.
+ * Defines an iterator "seek nanosecconds from origin" and "can seek
+ * nanoseconds from origin" method attributes attached to a filter component
+ * class descriptor which is attached to the automatic plugin descriptor.
  *
- * _name: Component class name (C identifier).
- * _x:    Iterator "seek nanoseconds from origin" method
- *        (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
+ * _name:            Component class name (C identifier).
+ * _seek_method:     Iterator "seek nanoseconds from origin" method
+ *                   (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
+ * _can_seek_method: Iterator "can seek nanoseconds from origin" method
+ *                   (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
  */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
-       BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS(_name, _seek_method, _can_seek_method) \
+       BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID(auto, _name, _seek_method, _can_seek_method)
 
 /*
- * Defines an iterator "seek beginning" method attribute
- * attached to a filter component class descriptor which is attached to
- * the automatic plugin descriptor.
+ * Defines an iterator "seek beginning" and "can seek beginning" method
+ * attributes attached to a filter component class descriptor which is attached
+ * to the automatic plugin descriptor.
  *
- * _name: Component class name (C identifier).
- * _x:    Iterator "seek beginning" method
- *        (bt_component_class_filter_message_iterator_seek_beginning_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(_name, _x) \
-       BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "can seek nanoseconds from origin" 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 "can seek nanoseconds from origin" method
- *        (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
-       BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "can seek beginning" 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 "can seek beginning" method
- *        (bt_component_class_filter_message_iterator_can_seek_beginning_method).
+ * _name:            Component class name (C identifier).
+ * _seek_method:     Iterator "seek beginning" method
+ *                   (bt_component_class_filter_message_iterator_seek_beginning_method).
+ * _can_seek_method: Iterator "can seek beginning" method
+ *                   (bt_component_class_filter_message_iterator_can_seek_beginning_method).
  */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(_name, _x) \
-       BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS(_name, _seek_method, _can_seek_method) \
+       BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS_WITH_ID(auto, _name, _seek_method, _can_seek_method)
 
 #define BT_PLUGIN_MODULE() \
        static struct __bt_plugin_descriptor const * const __bt_plugin_descriptor_dummy __BT_PLUGIN_DESCRIPTOR_ATTRS = NULL; \
index c4be7368121d6b1393b05c3db30adb7261e2e2ce..9d27e6e09093ca546edbbc523950b240d0e8f7ae 100644 (file)
@@ -553,6 +553,24 @@ class _UserComponentType(type):
                 )
             )
 
+        if hasattr(iter_cls, '_user_can_seek_ns_from_origin') and not hasattr(
+            iter_cls, '_user_seek_ns_from_origin'
+        ):
+            raise bt2._IncompleteUserClass(
+                "cannot create component class '{}': message iterator class implements _user_can_seek_ns_from_origin but not _user_seek_ns_from_origin".format(
+                    cls.__name__
+                )
+            )
+
+        if hasattr(iter_cls, '_user_can_seek_beginning') and not hasattr(
+            iter_cls, '_user_seek_beginning'
+        ):
+            raise bt2._IncompleteUserClass(
+                "cannot create component class '{}': message iterator class implements _user_can_seek_beginning but not _user_seek_beginning".format(
+                    cls.__name__
+                )
+            )
+
         cls._iter_cls = iter_cls
 
     @property
index 4a0fdbcd45ebdb26e518ad750dba08efcad6ebfc..b29f3fa9d491b438647b80fb69a2eadba8658f50 100644 (file)
@@ -1267,16 +1267,11 @@ bt_component_class_source *bt_bt2_component_class_source_create(
        BT_ASSERT(ret == 0);
        ret = bt_component_class_source_set_finalize_method(component_class_source, component_class_source_finalize);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_source_set_message_iterator_can_seek_beginning_method(component_class_source,
-               component_class_can_seek_beginning);
-       BT_ASSERT(ret == 0);
-       ret = bt_component_class_source_set_message_iterator_seek_beginning_method(component_class_source,
-               component_class_seek_beginning);
-       ret = bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
-               component_class_source, component_class_can_seek_ns_from_origin);
-       BT_ASSERT(ret == 0);
-       ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
-               component_class_source, component_class_seek_ns_from_origin);
+       ret = bt_component_class_source_set_message_iterator_seek_beginning_methods(component_class_source,
+               component_class_seek_beginning, component_class_can_seek_beginning);
+       ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods(
+               component_class_source, component_class_seek_ns_from_origin,
+               component_class_can_seek_ns_from_origin);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_source_set_output_port_connected_method(component_class_source,
                component_class_source_output_port_connected);
@@ -1324,17 +1319,12 @@ bt_component_class_filter *bt_bt2_component_class_filter_create(
        BT_ASSERT(ret == 0);
        ret = bt_component_class_filter_set_finalize_method (component_class_filter, component_class_filter_finalize);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_filter_set_message_iterator_can_seek_beginning_method(component_class_filter,
-               component_class_can_seek_beginning);
-       BT_ASSERT(ret == 0);
-       ret = bt_component_class_filter_set_message_iterator_seek_beginning_method(component_class_filter,
-               component_class_seek_beginning);
-       BT_ASSERT(ret == 0);
-       ret = bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
-               component_class_filter, component_class_can_seek_ns_from_origin);
+       ret = bt_component_class_filter_set_message_iterator_seek_beginning_methods(component_class_filter,
+               component_class_seek_beginning, component_class_can_seek_beginning);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
-               component_class_filter, component_class_seek_ns_from_origin);
+       ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods(
+               component_class_filter, component_class_seek_ns_from_origin,
+               component_class_can_seek_ns_from_origin);
        ret = bt_component_class_filter_set_input_port_connected_method(component_class_filter,
                component_class_filter_input_port_connected);
        BT_ASSERT(ret == 0);
index be4bbe7aef53186b6e84a137e3eb3e028f00b2aa..9bbf4172e751845d0c1afc2b32fe11457249fef4 100644 (file)
@@ -556,113 +556,65 @@ bt_component_class_filter_set_message_iterator_finalize_method(
 }
 
 enum bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
+bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods(
                struct bt_component_class_filter *comp_cls,
-               bt_component_class_filter_message_iterator_seek_ns_from_origin_method method)
+               bt_component_class_filter_message_iterator_seek_ns_from_origin_method seek_method,
+               bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method can_seek_method)
 {
        BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
+       BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
        BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_seek_ns_from_origin = method;
+       comp_cls->methods.msg_iter_seek_ns_from_origin = seek_method;
+       comp_cls->methods.msg_iter_can_seek_ns_from_origin = can_seek_method;
        BT_LIB_LOGD("Set filter component class's message iterator \"seek nanoseconds from origin\" method"
                ": %!+C", comp_cls);
        return BT_FUNC_STATUS_OK;
 }
 
 enum bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
-               struct bt_component_class_source *comp_cls,
-               bt_component_class_source_message_iterator_seek_ns_from_origin_method method)
-{
-       BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
-       BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_seek_ns_from_origin = method;
-       BT_LIB_LOGD("Set source component class's message iterator \"seek nanoseconds from origin\" method"
-               ": %!+C", comp_cls);
-       return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_seek_beginning_method(
-               struct bt_component_class_filter *comp_cls,
-               bt_component_class_filter_message_iterator_seek_beginning_method method)
-{
-       BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
-       BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_seek_beginning = method;
-       BT_LIB_LOGD("Set filter component class's message iterator \"seek beginning\" method"
-               ": %!+C", comp_cls);
-       return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_seek_beginning_method(
-               struct bt_component_class_source *comp_cls,
-               bt_component_class_source_message_iterator_seek_beginning_method method)
-{
-       BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
-       BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_seek_beginning = method;
-       BT_LIB_LOGD("Set source component class's message iterator \"seek beginning\" method"
-               ": %!+C", comp_cls);
-       return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_can_seek_beginning_method(
-               struct bt_component_class_filter *comp_cls,
-               bt_component_class_filter_message_iterator_can_seek_beginning_method method)
-{
-       BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
-       BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_can_seek_beginning = method;
-       BT_LIB_LOGD("Set filter component class's message iterator \"can seek beginning\" method"
-               ": %!+C", comp_cls);
-       return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_can_seek_beginning_method(
+bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods(
                struct bt_component_class_source *comp_cls,
-               bt_component_class_source_message_iterator_can_seek_beginning_method method)
+               bt_component_class_source_message_iterator_seek_ns_from_origin_method seek_method,
+               bt_component_class_source_message_iterator_can_seek_ns_from_origin_method can_seek_method)
 {
        BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
+       BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
        BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_can_seek_beginning = method;
-       BT_LIB_LOGD("Set source component class's message iterator \"can seek beginning\" method"
+       comp_cls->methods.msg_iter_seek_ns_from_origin = seek_method;
+       comp_cls->methods.msg_iter_can_seek_ns_from_origin = can_seek_method;
+       BT_LIB_LOGD("Set source component class's message iterator \"seek nanoseconds from origin\" methods"
                ": %!+C", comp_cls);
        return BT_FUNC_STATUS_OK;
 }
 
 enum bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
+bt_component_class_filter_set_message_iterator_seek_beginning_methods(
                struct bt_component_class_filter *comp_cls,
-               bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method method)
+               bt_component_class_filter_message_iterator_seek_beginning_method seek_method,
+               bt_component_class_filter_message_iterator_can_seek_beginning_method can_seek_method)
 {
        BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
+       BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
        BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_can_seek_ns_from_origin = method;
-       BT_LIB_LOGD("Set filter component class's message iterator \"can seek nanoseconds from origin\" method"
+       comp_cls->methods.msg_iter_seek_beginning = seek_method;
+       comp_cls->methods.msg_iter_can_seek_beginning = can_seek_method;
+       BT_LIB_LOGD("Set filter component class's message iterator \"seek beginning\" methods"
                ": %!+C", comp_cls);
        return BT_FUNC_STATUS_OK;
 }
 
 enum bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
+bt_component_class_source_set_message_iterator_seek_beginning_methods(
                struct bt_component_class_source *comp_cls,
-               bt_component_class_source_message_iterator_can_seek_ns_from_origin_method method)
+               bt_component_class_source_message_iterator_seek_beginning_method seek_method,
+               bt_component_class_source_message_iterator_can_seek_beginning_method can_seek_method)
 {
        BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
-       BT_ASSERT_PRE_NON_NULL(method, "Method");
+       BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
        BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
-       comp_cls->methods.msg_iter_can_seek_ns_from_origin = method;
-       BT_LIB_LOGD("Set source component class's message iterator \"can seek nanoseconds from origin\" method"
+       comp_cls->methods.msg_iter_seek_beginning = seek_method;
+       comp_cls->methods.msg_iter_can_seek_beginning = can_seek_method;
+       BT_LIB_LOGD("Set source component class's message iterator \"seek beginning\" methods"
                ": %!+C", comp_cls);
        return BT_FUNC_STATUS_OK;
 }
index 951776a11539082f0dac903c1209e1b375197092..511a1f981ba020c18c91285ba4e139d17b806f64 100644 (file)
@@ -1748,9 +1748,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
 
        if (can_seek_by_itself) {
                /* The iterator knows how to seek to a particular time, let it handle this. */
-               BT_ASSERT_PRE_DEV(iterator->methods.seek_ns_from_origin,
-                       "Message iterator does not implement `seek_ns_from_origin` method: %!+i",
-                       iterator);
+               BT_ASSERT(iterator->methods.seek_ns_from_origin);
                BT_LIB_LOGD("Calling user's \"seek nanoseconds from origin\" method: "
                        "%![iter-]+i, ns=%" PRId64, iterator, ns_from_origin);
                status = iterator->methods.seek_ns_from_origin(iterator,
index 412fe9041046aab97c600eac0b2145970774c25d..52a1c046530c3e018d23a44a5dae88c90b78f33e 100644 (file)
@@ -122,9 +122,13 @@ struct bt_self_component_port_input_message_iterator {
 
        struct {
                bt_self_component_port_input_message_iterator_next_method next;
+
+               /* These two are always both set or both unset. */
                bt_self_component_port_input_message_iterator_seek_ns_from_origin_method seek_ns_from_origin;
-               bt_self_component_port_input_message_iterator_seek_beginning_method seek_beginning;
                bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method can_seek_ns_from_origin;
+
+               /* These two are always both set or both unset. */
+               bt_self_component_port_input_message_iterator_seek_beginning_method seek_beginning;
                bt_self_component_port_input_message_iterator_can_seek_beginning_method can_seek_beginning;
        } methods;
 
index 0f6ec1c6fb5140466a80866880873d9b16e69ed6..b33f2053b92c583cd2885c7ef6decec202e07d58 100644 (file)
@@ -959,51 +959,27 @@ int bt_plugin_so_init(struct bt_plugin *plugin,
                        }
 
                        if (cc_full_descr->methods.source.msg_iter_seek_ns_from_origin) {
-                               ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_seek_ns_from_origin);
-                               if (ret) {
-                                       BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set source component class's message iterator \"seek nanoseconds from origin\" method.");
-                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.source.msg_iter_seek_beginning) {
-                               ret = bt_component_class_source_set_message_iterator_seek_beginning_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_seek_beginning);
-                               if (ret) {
-                                       BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set source component class's message iterator \"seek beginning\" method.");
-                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin) {
-                               ret = bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
+                               ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods(
                                        src_comp_class,
+                                       cc_full_descr->methods.source.msg_iter_seek_ns_from_origin,
                                        cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin);
                                if (ret) {
                                        BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set source component class's message iterator \"can seek nanoseconds from origin\" method.");
+                                               "Cannot set source component class's message iterator \"seek nanoseconds from origin\" methods.");
                                        status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
                                        goto end;
                                }
                        }
 
-                       if (cc_full_descr->methods.source.msg_iter_can_seek_beginning) {
-                               ret = bt_component_class_source_set_message_iterator_can_seek_beginning_method(
+                       if (cc_full_descr->methods.source.msg_iter_seek_beginning) {
+                               ret = bt_component_class_source_set_message_iterator_seek_beginning_methods(
                                        src_comp_class,
+                                       cc_full_descr->methods.source.msg_iter_seek_beginning,
                                        cc_full_descr->methods.source.msg_iter_can_seek_beginning);
                                if (ret) {
                                        BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set source component class's message iterator \"can seek beginning\" method.");
+                                               "Cannot set source component class's message iterator \"seek beginning\" methods.");
                                        status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
                                        goto end;
@@ -1117,51 +1093,27 @@ int bt_plugin_so_init(struct bt_plugin *plugin,
                        }
 
                        if (cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin) {
-                               ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin);
-                               if (ret) {
-                                       BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set filter component class's message iterator \"seek nanoseconds from origin\" method.");
-                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.filter.msg_iter_seek_beginning) {
-                               ret = bt_component_class_filter_set_message_iterator_seek_beginning_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_seek_beginning);
-                               if (ret) {
-                                       BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set filter component class's message iterator \"seek beginning\" method.");
-                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin) {
-                               ret = bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
+                               ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods(
                                        flt_comp_class,
+                                       cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin,
                                        cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin);
                                if (ret) {
                                        BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set filter component class's message iterator \"can seek nanoseconds from origin\" method.");
+                                               "Cannot set filter component class's message iterator \"seek nanoseconds from origin\" methods.");
                                        status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
                                }
                        }
 
-                       if (cc_full_descr->methods.filter.msg_iter_can_seek_beginning) {
-                               ret = bt_component_class_filter_set_message_iterator_can_seek_beginning_method(
+                       if (cc_full_descr->methods.filter.msg_iter_seek_beginning) {
+                               ret = bt_component_class_filter_set_message_iterator_seek_beginning_methods(
                                        flt_comp_class,
+                                       cc_full_descr->methods.filter.msg_iter_seek_beginning,
                                        cc_full_descr->methods.filter.msg_iter_can_seek_beginning);
                                if (ret) {
                                        BT_LIB_LOGE_APPEND_CAUSE(
-                                               "Cannot set filter component class's message iterator \"can seek beginning\" method.");
+                                               "Cannot set filter component class's message iterator \"seek beginning\" methods.");
                                        status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
index 96758b0133db37581aaecf945feb6e5f757381a7..f4b2b5060b6106f076ca7e866804481db1463ef3 100644 (file)
@@ -55,8 +55,8 @@ BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD(fs,
        ctf_fs_iterator_init);
 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(fs,
        ctf_fs_iterator_finalize);
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(fs,
-       ctf_fs_iterator_seek_beginning);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS(fs,
+       ctf_fs_iterator_seek_beginning, NULL);
 
 /* ctf.fs sink */
 BT_PLUGIN_SINK_COMPONENT_CLASS(fs, ctf_fs_sink_consume);
index c295c9bbac974b42ac3a2687b68084e7f586d544..6b180cffaa56b3449f7b6acdbb8b027f0440ee07 100644 (file)
@@ -51,9 +51,9 @@ BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(lttng_utils,
        debug_info, debug_info_comp_finalize);
 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_WITH_ID(
        lttng_utils, debug_info, debug_info_msg_iter_init);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(
-       lttng_utils, debug_info, debug_info_msg_iter_seek_beginning);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(
-       lttng_utils, debug_info, debug_info_msg_iter_can_seek_beginning);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS_WITH_ID(
+       lttng_utils, debug_info,
+       debug_info_msg_iter_seek_beginning,
+       debug_info_msg_iter_can_seek_beginning);
 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(
        lttng_utils, debug_info, debug_info_msg_iter_finalize);
index 24e187c333eddaa5a75be011fc8369310c60f98e..e21ff92d28aceb65feed1476a9f64ec88a8bb7bf 100644 (file)
@@ -57,10 +57,8 @@ BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD(dmesg,
        dmesg_msg_iter_init);
 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(dmesg,
        dmesg_msg_iter_finalize);
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(dmesg,
-       dmesg_msg_iter_seek_beginning);
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(dmesg,
-       dmesg_msg_iter_can_seek_beginning);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS(dmesg,
+       dmesg_msg_iter_seek_beginning, dmesg_msg_iter_can_seek_beginning);
 
 /* details sink */
 BT_PLUGIN_SINK_COMPONENT_CLASS(details, details_consume);
index 3f46fb65aa9efe26429d9a56a8297d7dc94e5713..6ae2fd9553f599ccf9f7cfbbf9b221b3c9f49cf8 100644 (file)
@@ -84,7 +84,5 @@ BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD(muxer,
        muxer_msg_iter_init);
 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(muxer,
        muxer_msg_iter_finalize);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(muxer,
-       muxer_msg_iter_seek_beginning);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(muxer,
-       muxer_msg_iter_can_seek_beginning);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS(muxer,
+       muxer_msg_iter_seek_beginning, muxer_msg_iter_can_seek_beginning);
index 37f6dc87798dcda7b32b4ef72b8e36b40b56b0f5..d03cdb302757b4b0b698bc94b5ce9755921b6daf 100644 (file)
@@ -465,6 +465,13 @@ def _setup_seek_test(
 
 
 class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase):
+    def test_can_seek_beginning_without_seek_beginning(self):
+        with self.assertRaisesRegex(
+            bt2._IncompleteUserClass,
+            "cannot create component class 'MySource': message iterator class implements _user_can_seek_beginning but not _user_seek_beginning",
+        ):
+            _setup_seek_test(SimpleSink, user_can_seek_beginning=lambda: None)
+
     def test_can_seek_beginning(self):
         class MySink(bt2._UserSinkComponent):
             def __init__(self, config, params, obj):
@@ -484,7 +491,9 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase):
             return input_port_iter_can_seek_beginning
 
         graph = _setup_seek_test(
-            MySink, user_can_seek_beginning=_user_can_seek_beginning
+            MySink,
+            user_can_seek_beginning=_user_can_seek_beginning,
+            user_seek_beginning=lambda: None,
         )
 
         input_port_iter_can_seek_beginning = True
@@ -560,7 +569,9 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase):
             raise ValueError('moustiquaire')
 
         graph = _setup_seek_test(
-            MySink, user_can_seek_beginning=_user_can_seek_beginning
+            MySink,
+            user_can_seek_beginning=_user_can_seek_beginning,
+            user_seek_beginning=lambda: None,
         )
 
         with self.assertRaises(bt2._Error) as ctx:
@@ -587,7 +598,9 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase):
             return 'Amqui'
 
         graph = _setup_seek_test(
-            MySink, user_can_seek_beginning=_user_can_seek_beginning
+            MySink,
+            user_can_seek_beginning=_user_can_seek_beginning,
+            user_seek_beginning=lambda: None,
         )
 
         with self.assertRaises(bt2._Error) as ctx:
@@ -663,25 +676,47 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase):
 
 
 class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase):
+    def test_can_seek_ns_from_origin_without_seek_ns_from_origin(self):
+        # Test the case where:
+        #
+        #   - can_seek_ns_from_origin: Returns True (don't really care, as long
+        #     as it's provided)
+        #   - seek_ns_from_origin provided: No
+        #   - can the iterator seek beginning: Don't care
+        #   - can the iterator seek forward: Don't care
+        for can_seek_ns_from_origin in (False, True):
+            for iter_can_seek_beginning in (False, True):
+                for iter_can_seek_forward in (False, True):
+                    with self.assertRaisesRegex(
+                        bt2._IncompleteUserClass,
+                        "cannot create component class 'MySource': message iterator class implements _user_can_seek_ns_from_origin but not _user_seek_ns_from_origin",
+                    ):
+                        self._can_seek_ns_from_origin_test(
+                            None,
+                            user_can_seek_ns_from_origin_ret_val=True,
+                            user_seek_ns_from_origin_provided=False,
+                            iter_can_seek_beginning=iter_can_seek_beginning,
+                            iter_can_seek_forward=iter_can_seek_forward,
+                        )
+
     def test_can_seek_ns_from_origin_returns_true(self):
         # Test the case where:
         #
         #   - can_seek_ns_from_origin: returns True
-        #   - seek_ns_from_origin provided: Don't care
+        #   - seek_ns_from_origin provided: Yes
         #   - can the iterator seek beginning: Don't care
         #   - can the iterator seek forward: Don't care
         #
         # We expect iter.can_seek_ns_from_origin to return True.
-        for user_seek_ns_from_origin_provided in (False, True):
-            for iter_can_seek_beginning in (False, True):
-                for iter_can_seek_forward in (False, True):
-                    self._can_seek_ns_from_origin_test(
-                        expected_outcome=True,
-                        user_can_seek_ns_from_origin_ret_val=True,
-                        user_seek_ns_from_origin_provided=user_seek_ns_from_origin_provided,
-                        iter_can_seek_beginning=iter_can_seek_beginning,
-                        iter_can_seek_forward=iter_can_seek_forward,
-                    )
+        for iter_can_seek_beginning in (False, True):
+            for iter_can_seek_forward in (False, True):
+                self._can_seek_ns_from_origin_test(
+                    expected_outcome=True,
+                    user_can_seek_ns_from_origin_ret_val=True,
+                    user_seek_ns_from_origin_provided=True,
+                    iter_can_seek_beginning=iter_can_seek_beginning,
+                    iter_can_seek_forward=iter_can_seek_forward,
+                )
 
     def test_can_seek_ns_from_origin_returns_false_can_seek_beginning_forward_seekable(
         self
@@ -689,19 +724,18 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase):
         # Test the case where:
         #
         #   - can_seek_ns_from_origin: returns False
-        #   - seek_ns_from_origin provided: Don't care
+        #   - seek_ns_from_origin provided: Yes
         #   - can the iterator seek beginning: Yes
         #   - can the iterator seek forward: Yes
         #
         # We expect iter.can_seek_ns_from_origin to return True.
-        for user_seek_ns_from_origin_provided in (False, True):
-            self._can_seek_ns_from_origin_test(
-                expected_outcome=True,
-                user_can_seek_ns_from_origin_ret_val=False,
-                user_seek_ns_from_origin_provided=user_seek_ns_from_origin_provided,
-                iter_can_seek_beginning=True,
-                iter_can_seek_forward=True,
-            )
+        self._can_seek_ns_from_origin_test(
+            expected_outcome=True,
+            user_can_seek_ns_from_origin_ret_val=False,
+            user_seek_ns_from_origin_provided=True,
+            iter_can_seek_beginning=True,
+            iter_can_seek_forward=True,
+        )
 
     def test_can_seek_ns_from_origin_returns_false_can_seek_beginning_not_forward_seekable(
         self
@@ -709,19 +743,18 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase):
         # Test the case where:
         #
         #   - can_seek_ns_from_origin: returns False
-        #   - seek_ns_from_origin provided: Don't care
+        #   - seek_ns_from_origin provided: Yes
         #   - can the iterator seek beginning: Yes
         #   - can the iterator seek forward: No
         #
         # We expect iter.can_seek_ns_from_origin to return False.
-        for user_seek_ns_from_origin_provided in (False, True):
-            self._can_seek_ns_from_origin_test(
-                expected_outcome=False,
-                user_can_seek_ns_from_origin_ret_val=False,
-                user_seek_ns_from_origin_provided=user_seek_ns_from_origin_provided,
-                iter_can_seek_beginning=True,
-                iter_can_seek_forward=False,
-            )
+        self._can_seek_ns_from_origin_test(
+            expected_outcome=False,
+            user_can_seek_ns_from_origin_ret_val=False,
+            user_seek_ns_from_origin_provided=True,
+            iter_can_seek_beginning=True,
+            iter_can_seek_forward=False,
+        )
 
     def test_can_seek_ns_from_origin_returns_false_cant_seek_beginning_forward_seekable(
         self
@@ -729,16 +762,15 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase):
         # Test the case where:
         #
         #   - can_seek_ns_from_origin: returns False
-        #   - seek_ns_from_origin provided: Don't care
+        #   - seek_ns_from_origin provided: Yes
         #   - can the iterator seek beginning: No
         #   - can the iterator seek forward: Yes
         #
         # We expect iter.can_seek_ns_from_origin to return False.
-        # for user_seek_ns_from_origin_provided in (False, True):
         self._can_seek_ns_from_origin_test(
             expected_outcome=False,
             user_can_seek_ns_from_origin_ret_val=False,
-            user_seek_ns_from_origin_provided=False,
+            user_seek_ns_from_origin_provided=True,
             iter_can_seek_beginning=False,
             iter_can_seek_forward=True,
         )
@@ -749,19 +781,18 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase):
         # Test the case where:
         #
         #   - can_seek_ns_from_origin: returns False
-        #   - seek_ns_from_origin provided: Don't care
+        #   - seek_ns_from_origin provided: Yes
         #   - can the iterator seek beginning: No
         #   - can the iterator seek forward: No
         #
         # We expect iter.can_seek_ns_from_origin to return False.
-        for user_seek_ns_from_origin_provided in (False, True):
-            self._can_seek_ns_from_origin_test(
-                expected_outcome=False,
-                user_can_seek_ns_from_origin_ret_val=False,
-                user_seek_ns_from_origin_provided=user_seek_ns_from_origin_provided,
-                iter_can_seek_beginning=False,
-                iter_can_seek_forward=False,
-            )
+        self._can_seek_ns_from_origin_test(
+            expected_outcome=False,
+            user_can_seek_ns_from_origin_ret_val=False,
+            user_seek_ns_from_origin_provided=True,
+            iter_can_seek_beginning=False,
+            iter_can_seek_forward=False,
+        )
 
     def test_no_can_seek_ns_from_origin_seek_ns_from_origin(self):
         # Test the case where:
@@ -942,7 +973,9 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase):
             raise ValueError('Joutel')
 
         graph = _setup_seek_test(
-            MySink, user_can_seek_ns_from_origin=_user_can_seek_ns_from_origin
+            MySink,
+            user_can_seek_ns_from_origin=_user_can_seek_ns_from_origin,
+            user_seek_ns_from_origin=lambda: None,
         )
 
         with self.assertRaises(bt2._Error) as ctx:
@@ -969,7 +1002,9 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase):
             return 'Nitchequon'
 
         graph = _setup_seek_test(
-            MySink, user_can_seek_ns_from_origin=_user_can_seek_ns_from_origin
+            MySink,
+            user_can_seek_ns_from_origin=_user_can_seek_ns_from_origin,
+            user_seek_ns_from_origin=lambda: None,
         )
 
         with self.assertRaises(bt2._Error) as ctx:
This page took 0.041845 seconds and 4 git commands to generate.