|Message
|`+const struct bt_message *+`
+|`I`
+|Message iterator class
+|`struct bt_message_iterator_class *`
+
|`i`
|Message iterator
|`struct bt_message_iterator *`
babeltrace2/graph/message-message-iterator-inactivity-const.h \
babeltrace2/graph/message-message-iterator-inactivity.h \
babeltrace2/graph/message-iterator.h \
+ babeltrace2/graph/message-iterator-class.h \
babeltrace2/graph/message-packet-beginning-const.h \
babeltrace2/graph/message-packet-beginning.h \
babeltrace2/graph/message-packet-end-const.h \
typedef void (*bt_component_class_filter_finalize_method)(
bt_self_component_filter *self_component);
-typedef bt_component_class_message_iterator_initialize_method_status
-(*bt_component_class_filter_message_iterator_initialize_method)(
- bt_self_message_iterator *message_iterator,
- bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_component,
- bt_self_component_port_output *port);
-
-typedef void
-(*bt_component_class_filter_message_iterator_finalize_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_component_class_message_iterator_next_method_status
-(*bt_component_class_filter_message_iterator_next_method)(
- bt_self_message_iterator *message_iterator,
- bt_message_array_const msgs, uint64_t capacity,
- uint64_t *count);
-
-typedef bt_component_class_message_iterator_seek_ns_from_origin_method_status
-(*bt_component_class_filter_message_iterator_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin);
-
-typedef bt_component_class_message_iterator_seek_beginning_method_status
-(*bt_component_class_filter_message_iterator_seek_beginning_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_component_class_message_iterator_can_seek_ns_from_origin_method_status
-(*bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin, bt_bool *can_seek);
-
-typedef bt_component_class_message_iterator_can_seek_beginning_method_status
-(*bt_component_class_filter_message_iterator_can_seek_beginning_method)(
- bt_self_message_iterator *message_iterator, bt_bool *can_seek);
-
typedef bt_component_class_query_method_status
(*bt_component_class_filter_query_method)(
bt_self_component_class_filter *comp_class,
extern
bt_component_class_filter *bt_component_class_filter_create(
const char *name,
- bt_component_class_filter_message_iterator_next_method method);
+ bt_message_iterator_class *message_iterator_class);
extern bt_component_class_set_method_status
bt_component_class_filter_set_get_supported_mip_versions_method(
bt_component_class_filter *comp_class,
bt_component_class_filter_query_method method);
-extern bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_initialize_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_message_iterator_initialize_method method);
-
-extern bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_finalize_method(
- bt_component_class_filter *comp_class,
- 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_methods(
- bt_component_class_filter *comp_class,
- 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_methods(
- bt_component_class_filter *comp_class,
- 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
}
#endif
typedef void (*bt_component_class_source_finalize_method)(
bt_self_component_source *self_component);
-typedef bt_component_class_message_iterator_initialize_method_status
-(*bt_component_class_source_message_iterator_initialize_method)(
- bt_self_message_iterator *message_iterator,
- bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_component,
- bt_self_component_port_output *port);
-
-typedef void
-(*bt_component_class_source_message_iterator_finalize_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_component_class_message_iterator_next_method_status
-(*bt_component_class_source_message_iterator_next_method)(
- bt_self_message_iterator *message_iterator,
- bt_message_array_const msgs, uint64_t capacity,
- uint64_t *count);
-
-typedef bt_component_class_message_iterator_seek_ns_from_origin_method_status
-(*bt_component_class_source_message_iterator_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin);
-
-typedef bt_component_class_message_iterator_seek_beginning_method_status
-(*bt_component_class_source_message_iterator_seek_beginning_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_component_class_message_iterator_can_seek_ns_from_origin_method_status
-(*bt_component_class_source_message_iterator_can_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin, bt_bool *can_seek);
-
-typedef bt_component_class_message_iterator_can_seek_beginning_method_status
-(*bt_component_class_source_message_iterator_can_seek_beginning_method)(
- bt_self_message_iterator *message_iterator, bt_bool *can_seek);
-
typedef bt_component_class_query_method_status
(*bt_component_class_source_query_method)(
bt_self_component_class_source *comp_class,
extern
bt_component_class_source *bt_component_class_source_create(
const char *name,
- bt_component_class_source_message_iterator_next_method method);
+ bt_message_iterator_class *message_iterator_class);
extern bt_component_class_set_method_status
bt_component_class_source_set_get_supported_mip_versions_method(
bt_component_class_source *comp_class,
bt_component_class_source_query_method method);
-extern bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_initialize_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_message_iterator_initialize_method method);
-
-extern bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_finalize_method(
- bt_component_class_source *comp_class,
- 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_methods(
- bt_component_class_source *comp_class,
- 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_methods(
- bt_component_class_source *comp_class,
- 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
}
#endif
BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_UNKNOWN_OBJECT = __BT_FUNC_STATUS_UNKNOWN_OBJECT,
} bt_component_class_query_method_status;
-typedef enum bt_component_class_message_iterator_initialize_method_status {
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
-} bt_component_class_message_iterator_initialize_method_status;
-
-typedef enum bt_component_class_message_iterator_next_method_status {
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END = __BT_FUNC_STATUS_END,
-} bt_component_class_message_iterator_next_method_status;
-
-typedef enum bt_component_class_message_iterator_seek_beginning_method_status {
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
-} bt_component_class_message_iterator_seek_beginning_method_status;
-
-typedef enum bt_component_class_message_iterator_seek_ns_from_origin_method_status {
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
-} bt_component_class_message_iterator_seek_ns_from_origin_method_status;
-
-typedef enum bt_component_class_message_iterator_can_seek_beginning_method_status {
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
-} bt_component_class_message_iterator_can_seek_beginning_method_status;
-
-typedef enum bt_component_class_message_iterator_can_seek_ns_from_origin_method_status {
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
-} bt_component_class_message_iterator_can_seek_ns_from_origin_method_status;
-
typedef enum bt_component_class_set_method_status {
BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
} bt_component_class_set_method_status;
--- /dev/null
+#ifndef BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H
+#define BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H
+
+/*
+ * Copyright (c) 2019 EfficiOS Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __BT_IN_BABELTRACE_H
+# error "Please include <babeltrace2/babeltrace.h> instead."
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_message_iterator_class_set_method_status {
+ BT_MESSAGE_ITERATOR_CLASS_SET_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
+} bt_message_iterator_class_set_method_status;
+
+typedef enum bt_message_iterator_class_initialize_method_status {
+ BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
+ BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
+ BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_message_iterator_class_initialize_method_status;
+
+typedef enum bt_message_iterator_class_next_method_status {
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END = __BT_FUNC_STATUS_END,
+} bt_message_iterator_class_next_method_status;
+
+typedef enum bt_message_iterator_class_seek_ns_from_origin_method_status {
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_message_iterator_class_seek_ns_from_origin_method_status;
+
+typedef enum bt_message_iterator_class_can_seek_ns_from_origin_method_status {
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_message_iterator_class_can_seek_ns_from_origin_method_status;
+
+typedef enum bt_message_iterator_class_seek_beginning_method_status {
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_message_iterator_class_seek_beginning_method_status;
+
+typedef enum bt_message_iterator_class_can_seek_beginning_method_status {
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK,
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN,
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
+} bt_message_iterator_class_can_seek_beginning_method_status;
+
+typedef bt_message_iterator_class_initialize_method_status
+(*bt_message_iterator_class_initialize_method)(
+ bt_self_message_iterator *message_iterator,
+ bt_self_message_iterator_configuration *config,
+ bt_self_component *self_component,
+ bt_self_component_port_output *port);
+
+typedef void
+(*bt_message_iterator_class_finalize_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef bt_message_iterator_class_next_method_status
+(*bt_message_iterator_class_next_method)(
+ bt_self_message_iterator *message_iterator,
+ bt_message_array_const msgs, uint64_t capacity,
+ uint64_t *count);
+
+typedef bt_message_iterator_class_seek_ns_from_origin_method_status
+(*bt_message_iterator_class_seek_ns_from_origin_method)(
+ bt_self_message_iterator *message_iterator,
+ int64_t ns_from_origin);
+
+typedef bt_message_iterator_class_can_seek_ns_from_origin_method_status
+(*bt_message_iterator_class_can_seek_ns_from_origin_method)(
+ bt_self_message_iterator *message_iterator,
+ int64_t ns_from_origin, bt_bool *can_seek);
+
+typedef bt_message_iterator_class_seek_beginning_method_status
+(*bt_message_iterator_class_seek_beginning_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef bt_message_iterator_class_can_seek_beginning_method_status
+(*bt_message_iterator_class_can_seek_beginning_method)(
+ bt_self_message_iterator *message_iterator, bt_bool *can_seek);
+
+extern void bt_message_iterator_class_get_ref(
+ const bt_message_iterator_class *message_iterator_class);
+
+extern void bt_message_iterator_class_put_ref(
+ const bt_message_iterator_class *message_iterator_class);
+
+#define BT_MESSAGE_ITERATOR_CLASS_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_message_iterator_class_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_MESSAGE_ITERATOR_CLASS_MOVE_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_message_iterator_class_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+extern bt_message_iterator_class *
+bt_message_iterator_class_create(
+ bt_message_iterator_class_next_method next_method);
+
+extern bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_initialize_method(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_initialize_method method);
+
+extern bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_finalize_method(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_finalize_method method);
+
+extern bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_seek_ns_from_origin_methods(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_seek_ns_from_origin_method seek_method,
+ bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_method);
+
+extern bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_seek_beginning_methods(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_seek_beginning_method seek_method,
+ bt_message_iterator_class_can_seek_beginning_method can_seek_method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H */
#include <babeltrace2/graph/component-class-source.h>
#include <babeltrace2/graph/component-class-filter.h>
#include <babeltrace2/graph/component-class-sink.h>
+#include <babeltrace2/graph/message-iterator-class.h>
#include <babeltrace2/types.h>
/*
union {
/* BT_COMPONENT_CLASS_TYPE_SOURCE */
struct {
- bt_component_class_source_message_iterator_next_method msg_iter_next;
+ bt_message_iterator_class_next_method msg_iter_next;
} source;
/* BT_COMPONENT_CLASS_TYPE_FILTER */
struct {
- bt_component_class_filter_message_iterator_next_method msg_iter_next;
+ bt_message_iterator_class_next_method msg_iter_next;
} filter;
/* BT_COMPONENT_CLASS_TYPE_SINK */
bt_component_class_sink_graph_is_configured_method sink_graph_is_configured_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD */
- bt_component_class_source_message_iterator_initialize_method source_msg_iter_initialize_method;
- bt_component_class_filter_message_iterator_initialize_method filter_msg_iter_initialize_method;
+ bt_message_iterator_class_initialize_method msg_iter_initialize_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD */
- bt_component_class_source_message_iterator_finalize_method source_msg_iter_finalize_method;
- bt_component_class_filter_message_iterator_finalize_method filter_msg_iter_finalize_method;
+ bt_message_iterator_class_finalize_method msg_iter_finalize_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD */
- bt_component_class_source_message_iterator_seek_ns_from_origin_method source_msg_iter_seek_ns_from_origin_method;
- bt_component_class_filter_message_iterator_seek_ns_from_origin_method filter_msg_iter_seek_ns_from_origin_method;
+ bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD */
- bt_component_class_source_message_iterator_seek_beginning_method source_msg_iter_seek_beginning_method;
- bt_component_class_filter_message_iterator_seek_beginning_method filter_msg_iter_seek_beginning_method;
+ bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD */
- bt_component_class_source_message_iterator_can_seek_ns_from_origin_method source_msg_iter_can_seek_ns_from_origin_method;
- bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method filter_msg_iter_can_seek_ns_from_origin_method;
+ bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD */
- bt_component_class_source_message_iterator_can_seek_beginning_method source_msg_iter_can_seek_beginning_method;
- bt_component_class_filter_message_iterator_can_seek_beginning_method filter_msg_iter_can_seek_beginning_method;
+ bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning_method;
} value;
} __attribute__((packed));
* (bt_component_class_source_message_iterator_initialize_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, source, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, source, _x)
/*
* Defines an iterator finalize method attribute attached to a specific
* (bt_component_class_source_message_iterator_finalize_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __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)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(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" and "can seek nanoseconds
* (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
*/
#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)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(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(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 "seek beginning" and "can seek beginning" method
* (bt_component_class_source_message_iterator_can_seek_beginning_method).
*/
#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)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(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(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
* (bt_component_class_filter_message_iterator_initialize_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, filter, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, filter, _x)
/*
* Defines an iterator finalize method attribute attached to a specific
* (bt_component_class_filter_message_iterator_finalize_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __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)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(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" and "can seek nanoseconds from origin"
* (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
*/
#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)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(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(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 "seek beginning" and "can seek beginning" method
* (bt_component_class_filter_message_iterator_can_seek_beginning_method).
*/
#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);
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(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(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.
typedef struct bt_interrupter bt_interrupter;
typedef struct bt_message bt_message;
typedef struct bt_message_iterator bt_message_iterator;
+typedef struct bt_message_iterator_class bt_message_iterator_class;
typedef struct bt_object bt_object;
typedef struct bt_packet bt_packet;
typedef struct bt_plugin bt_plugin;
}
static
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
component_class_can_seek_beginning(
bt_self_message_iterator *self_message_iterator, bt_bool *can_seek)
{
PyObject *py_iter;
PyObject *py_result = NULL;
- bt_component_class_message_iterator_can_seek_beginning_method_status status;
+ bt_message_iterator_class_can_seek_beginning_method_status status;
py_iter = bt_self_message_iterator_get_data(self_message_iterator);
BT_ASSERT(py_iter);
BT_ASSERT(PyBool_Check(py_result));
*can_seek = PyObject_IsTrue(py_result);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
end:
Py_XDECREF(py_result);
}
static
-bt_component_class_message_iterator_seek_beginning_method_status
+bt_message_iterator_class_seek_beginning_method_status
component_class_seek_beginning(bt_self_message_iterator *self_message_iterator)
{
PyObject *py_iter;
PyObject *py_result;
- bt_component_class_message_iterator_seek_beginning_method_status status;
+ bt_message_iterator_class_seek_beginning_method_status status;
py_iter = bt_self_message_iterator_get_data(self_message_iterator);
BT_ASSERT(py_iter);
BT_ASSERT(py_result == Py_None);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
end:
Py_XDECREF(py_result);
}
static
-bt_component_class_message_iterator_can_seek_ns_from_origin_method_status
+bt_message_iterator_class_can_seek_ns_from_origin_method_status
component_class_can_seek_ns_from_origin(
bt_self_message_iterator *self_message_iterator,
int64_t ns_from_origin, bt_bool *can_seek)
{
PyObject *py_iter;
PyObject *py_result = NULL;
- bt_component_class_message_iterator_can_seek_ns_from_origin_method_status status;
+ bt_message_iterator_class_can_seek_ns_from_origin_method_status status;
py_iter = bt_self_message_iterator_get_data(self_message_iterator);
BT_ASSERT(py_iter);
BT_ASSERT(PyBool_Check(py_result));
*can_seek = PyObject_IsTrue(py_result);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
end:
Py_XDECREF(py_result);
}
static
-bt_component_class_message_iterator_seek_ns_from_origin_method_status
+bt_message_iterator_class_seek_ns_from_origin_method_status
component_class_seek_ns_from_origin(
bt_self_message_iterator *self_message_iterator,
int64_t ns_from_origin)
{
PyObject *py_iter;
PyObject *py_result;
- bt_component_class_message_iterator_seek_ns_from_origin_method_status status;
+ bt_message_iterator_class_seek_ns_from_origin_method_status status;
py_iter = bt_self_message_iterator_get_data(self_message_iterator);
BT_ASSERT(py_iter);
BT_ASSERT(py_result == Py_None);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
end:
Py_XDECREF(py_result);
}
static
-bt_component_class_message_iterator_initialize_method_status
+bt_message_iterator_class_initialize_method_status
component_class_message_iterator_init(
bt_self_message_iterator *self_message_iterator,
bt_self_message_iterator_configuration *config,
bt_self_component *self_component,
bt_self_component_port_output *self_component_port_output)
{
- bt_component_class_message_iterator_initialize_method_status status = __BT_FUNC_STATUS_OK;
+ bt_message_iterator_class_initialize_method_status status = __BT_FUNC_STATUS_OK;
PyObject *py_comp_cls = NULL;
PyObject *py_iter_cls = NULL;
PyObject *py_iter_ptr = NULL;
return status;
}
-static
-bt_component_class_message_iterator_initialize_method_status
-component_class_source_message_iterator_init(
- bt_self_message_iterator *self_message_iterator,
- bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_component_source,
- bt_self_component_port_output *self_component_port_output)
-{
- bt_self_component *self_component =
- bt_self_component_source_as_self_component(self_component_source);
-
- return component_class_message_iterator_init(self_message_iterator,
- config, self_component, self_component_port_output);
-}
-
-static
-bt_component_class_message_iterator_initialize_method_status
-component_class_filter_message_iterator_init(
- bt_self_message_iterator *self_message_iterator,
- bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_component_filter,
- bt_self_component_port_output *self_component_port_output)
-{
- bt_self_component *self_component =
- bt_self_component_filter_as_self_component(self_component_filter);
-
- return component_class_message_iterator_init(self_message_iterator,
- config, self_component, self_component_port_output);
-}
-
static
void component_class_message_iterator_finalize(
bt_self_message_iterator *message_iterator)
/* Valid for both sources and filters. */
static
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
component_class_message_iterator_next(
bt_self_message_iterator *message_iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
PyObject *py_message_iter = bt_self_message_iterator_get_data(message_iterator);
PyObject *py_method_result = NULL;
/* Overflow errors should never happen. */
BT_ASSERT_DBG(!PyErr_Occurred());
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
end:
Py_XDECREF(py_method_result);
return ret;
}
+static
+bt_message_iterator_class *create_message_iterator_class(void)
+{
+ bt_message_iterator_class *message_iterator_class;
+ bt_message_iterator_class_set_method_status ret;
+
+ message_iterator_class = bt_message_iterator_class_create(
+ component_class_message_iterator_next);
+ if (!message_iterator_class) {
+ BT_LOGE_STR("Cannot create message iterator class.");
+ goto end;
+ }
+
+ ret = bt_message_iterator_class_set_seek_beginning_methods(
+ message_iterator_class, component_class_seek_beginning,
+ component_class_can_seek_beginning);
+ BT_ASSERT(ret == 0);
+ ret = bt_message_iterator_class_set_seek_ns_from_origin_methods(
+ message_iterator_class, component_class_seek_ns_from_origin,
+ component_class_can_seek_ns_from_origin);
+ BT_ASSERT(ret == 0);
+ ret = bt_message_iterator_class_set_initialize_method(
+ message_iterator_class, component_class_message_iterator_init);
+ BT_ASSERT(ret == 0);
+ ret = bt_message_iterator_class_set_finalize_method(
+ message_iterator_class, component_class_message_iterator_finalize);
+ BT_ASSERT(ret == 0);
+
+end:
+ return message_iterator_class;
+}
+
static
bt_component_class_source *bt_bt2_component_class_source_create(
PyObject *py_cls, const char *name, const char *description,
const char *help)
{
- bt_component_class_source *component_class_source;
+ bt_component_class_source *component_class_source = NULL;
+ bt_message_iterator_class *message_iterator_class;
bt_component_class *component_class;
int ret;
BT_ASSERT(py_cls);
+
+ message_iterator_class = create_message_iterator_class();
+ if (!message_iterator_class) {
+ goto end;
+ }
+
component_class_source = bt_component_class_source_create(name,
- component_class_message_iterator_next);
+ message_iterator_class);
if (!component_class_source) {
BT_LOGE_STR("Cannot create source component class.");
goto end;
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_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);
BT_ASSERT(ret == 0);
BT_ASSERT(ret == 0);
ret = bt_component_class_source_set_get_supported_mip_versions_method(component_class_source, component_class_source_get_supported_mip_versions);
BT_ASSERT(ret == 0);
- ret = bt_component_class_source_set_message_iterator_initialize_method(
- component_class_source, component_class_source_message_iterator_init);
- BT_ASSERT(ret == 0);
- ret = bt_component_class_source_set_message_iterator_finalize_method(
- component_class_source, component_class_message_iterator_finalize);
- BT_ASSERT(ret == 0);
register_cc_ptr_to_py_cls(component_class, py_cls);
end:
+ bt_message_iterator_class_put_ref(message_iterator_class);
return component_class_source;
}
PyObject *py_cls, const char *name, const char *description,
const char *help)
{
+ bt_component_class_filter *component_class_filter = NULL;
+ bt_message_iterator_class *message_iterator_class;
bt_component_class *component_class;
- bt_component_class_filter *component_class_filter;
int ret;
BT_ASSERT(py_cls);
+
+ message_iterator_class = create_message_iterator_class();
+ if (!message_iterator_class) {
+ goto end;
+ }
+
component_class_filter = bt_component_class_filter_create(name,
- component_class_message_iterator_next);
+ message_iterator_class);
if (!component_class_filter) {
BT_LOGE_STR("Cannot create filter component class.");
goto end;
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_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_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);
BT_ASSERT(ret == 0);
ret = bt_component_class_filter_set_get_supported_mip_versions_method(component_class_filter, component_class_filter_get_supported_mip_versions);
BT_ASSERT(ret == 0);
- ret = bt_component_class_filter_set_message_iterator_initialize_method(
- component_class_filter, component_class_filter_message_iterator_init);
- BT_ASSERT(ret == 0);
- ret = bt_component_class_filter_set_message_iterator_finalize_method(
- component_class_filter, component_class_message_iterator_finalize);
- BT_ASSERT(ret == 0);
register_cc_ptr_to_py_cls(component_class, py_cls);
end:
+ bt_message_iterator_class_put_ref(message_iterator_class);
return component_class_filter;
}
interrupter.c \
interrupter.h \
iterator.c \
+ message-iterator-class.c \
+ message-iterator-class.h \
mip.c \
port.c \
port.h \
#include "component-class.h"
#include "lib/func-status.h"
+#include "lib/graph/message-iterator-class.h"
#define BT_ASSERT_PRE_DEV_COMP_CLS_HOT(_cc) \
BT_ASSERT_PRE_DEV_HOT(((const struct bt_component_class *) (_cc)), \
class->destroy_listeners = NULL;
}
+ if (class->type == BT_COMPONENT_CLASS_TYPE_SOURCE) {
+ struct bt_component_class_source *class_src
+ = container_of(class, struct bt_component_class_source,
+ parent);
+
+ BT_ASSERT(class_src->msg_iter_cls);
+ bt_message_iterator_class_put_ref(class_src->msg_iter_cls);
+ class_src->msg_iter_cls = NULL;
+ } else if (class->type == BT_COMPONENT_CLASS_TYPE_FILTER) {
+ struct bt_component_class_filter *class_flt
+ = container_of(class, struct bt_component_class_filter,
+ parent);
+
+ BT_ASSERT(class_flt->msg_iter_cls);
+ bt_message_iterator_class_put_ref(class_flt->msg_iter_cls);
+ class_flt->msg_iter_cls = NULL;
+ }
+
g_free(class);
}
struct bt_component_class_source *bt_component_class_source_create(
const char *name,
- bt_component_class_source_message_iterator_next_method method)
+ struct bt_message_iterator_class *message_iterator_class)
{
struct bt_component_class_source *source_class = NULL;
int ret;
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method");
- BT_LOGI("Creating source component class: "
- "name=\"%s\", msg-iter-next-method-addr=%p",
- name, method);
+ BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_LIB_LOGI("Creating source component class: "
+ "name=\"%s\", %![msg-iter-cls-]+I",
+ name, message_iterator_class);
source_class = g_new0(struct bt_component_class_source, 1);
if (!source_class) {
BT_LIB_LOGE_APPEND_CAUSE(
goto end;
}
- source_class->methods.msg_iter_next = method;
+ source_class->msg_iter_cls = message_iterator_class;
+ bt_message_iterator_class_get_ref(source_class->msg_iter_cls);
+ bt_message_iterator_class_freeze(source_class->msg_iter_cls);
+
BT_LIB_LOGI("Created source component class: %!+C", source_class);
end:
struct bt_component_class_filter *bt_component_class_filter_create(
const char *name,
- bt_component_class_filter_message_iterator_next_method method)
+ struct bt_message_iterator_class *message_iterator_class)
{
struct bt_component_class_filter *filter_class = NULL;
int ret;
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method");
- BT_LOGI("Creating filter component class: "
- "name=\"%s\", msg-iter-next-method-addr=%p",
- name, method);
+ BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_LIB_LOGI("Creating filter component class: "
+ "name=\"%s\", %![msg-iter-cls-]+I",
+ name, message_iterator_class);
filter_class = g_new0(struct bt_component_class_filter, 1);
if (!filter_class) {
BT_LIB_LOGE_APPEND_CAUSE(
goto end;
}
- filter_class->methods.msg_iter_next = method;
+ filter_class->msg_iter_cls = message_iterator_class;
+ bt_message_iterator_class_get_ref(filter_class->msg_iter_cls);
+ bt_message_iterator_class_freeze(filter_class->msg_iter_cls);
+
BT_LIB_LOGI("Created filter component class: %!+C", filter_class);
end:
return BT_FUNC_STATUS_OK;
}
-enum bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_initialize_method(
- struct bt_component_class_source *comp_cls,
- bt_component_class_source_message_iterator_initialize_method method)
-{
- BT_ASSERT_PRE_NO_ERROR();
- 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_initialize = method;
- BT_LIB_LOGD("Set source component class's message iterator initialization method"
- ": %!+C", comp_cls);
- return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_initialize_method(
- struct bt_component_class_filter *comp_cls,
- bt_component_class_filter_message_iterator_initialize_method method)
-{
- BT_ASSERT_PRE_NO_ERROR();
- 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_initialize = method;
- BT_LIB_LOGD("Set filter component class's message iterator initialization method"
- ": %!+C", comp_cls);
- return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-bt_component_class_source_set_message_iterator_finalize_method(
- struct bt_component_class_source *comp_cls,
- bt_component_class_source_message_iterator_finalize_method method)
-{
- BT_ASSERT_PRE_NO_ERROR();
- 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_finalize = method;
- BT_LIB_LOGD("Set source component class's message iterator finalization method"
- ": %!+C", comp_cls);
- return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-bt_component_class_filter_set_message_iterator_finalize_method(
- struct bt_component_class_filter *comp_cls,
- bt_component_class_filter_message_iterator_finalize_method method)
-{
- BT_ASSERT_PRE_NO_ERROR();
- 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_finalize = method;
- BT_LIB_LOGD("Set filter component class's message iterator finalization method"
- ": %!+C", comp_cls);
- return BT_FUNC_STATUS_OK;
-}
-
-enum bt_component_class_set_method_status
-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 seek_method,
- bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method can_seek_method)
-{
- BT_ASSERT_PRE_NO_ERROR();
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- 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 = 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_methods(
- struct bt_component_class_source *comp_cls,
- 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_NO_ERROR();
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- 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 = 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_seek_beginning_methods(
- struct bt_component_class_filter *comp_cls,
- 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_NO_ERROR();
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
- BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
- 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_seek_beginning_methods(
- struct bt_component_class_source *comp_cls,
- 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_NO_ERROR();
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
- BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
- 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;
-}
-
enum bt_component_class_set_description_status
bt_component_class_set_description(
struct bt_component_class *comp_cls,
bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions;
bt_component_class_source_initialize_method init;
bt_component_class_source_finalize_method finalize;
- bt_component_class_source_message_iterator_initialize_method msg_iter_initialize;
- bt_component_class_source_message_iterator_finalize_method msg_iter_finalize;
- bt_component_class_source_message_iterator_next_method msg_iter_next;
- bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
- bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning;
- bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
- bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
bt_component_class_source_query_method query;
bt_component_class_source_output_port_connected_method output_port_connected;
} methods;
+ bt_message_iterator_class *msg_iter_cls;
};
struct bt_component_class_sink {
bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions;
bt_component_class_filter_initialize_method init;
bt_component_class_filter_finalize_method finalize;
- bt_component_class_filter_message_iterator_initialize_method msg_iter_initialize;
- bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize;
- bt_component_class_filter_message_iterator_next_method msg_iter_next;
- bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
- bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning;
- bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
- bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
bt_component_class_filter_query_method query;
bt_component_class_filter_input_port_connected_method input_port_connected;
bt_component_class_filter_output_port_connected_method output_port_connected;
} methods;
+ bt_message_iterator_class *msg_iter_cls;
};
BT_HIDDEN
#include "component-source.h"
#include "connection.h"
#include "graph.h"
+#include "message-iterator-class.h"
#include "message/discarded-items.h"
#include "message/event.h"
#include "message/iterator.h"
struct bt_self_component_port_input_message_iterator *iterator)
{
uint64_t i;
- typedef void (*method_t)(void *);
bool call_user_finalize = true;
BT_ASSERT(iterator);
/* Call user-defined destroy method */
if (call_user_finalize) {
+ typedef void (*method_t)(void *);
method_t method = NULL;
struct bt_component_class *comp_class =
iterator->upstream_component->class;
struct bt_component_class_source *src_comp_cls =
(void *) comp_class;
- method = (method_t) src_comp_cls->methods.msg_iter_finalize;
+ method = (method_t) src_comp_cls->msg_iter_cls->methods.finalize;
break;
}
case BT_COMPONENT_CLASS_TYPE_FILTER:
struct bt_component_class_filter *flt_comp_cls =
(void *) comp_class;
- method = (method_t) flt_comp_cls->methods.msg_iter_finalize;
+ method = (method_t) flt_comp_cls->msg_iter_cls->methods.finalize;
break;
}
default:
struct bt_self_component_port_input *self_port,
struct bt_self_component_port_input_message_iterator **message_iterator)
{
- typedef enum bt_component_class_message_iterator_initialize_method_status (*init_method_t)(
- void *, void *, void *, void *);
-
- init_method_t init_method = NULL;
+ bt_message_iterator_class_initialize_method init_method = NULL;
struct bt_self_component_port_input_message_iterator *iterator =
NULL;
struct bt_self_component_port_input_message_iterator *downstream_msg_iter =
iterator->methods.next =
(bt_self_component_port_input_message_iterator_next_method)
- src_comp_cls->methods.msg_iter_next;
+ src_comp_cls->msg_iter_cls->methods.next;
iterator->methods.seek_ns_from_origin =
(bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)
- src_comp_cls->methods.msg_iter_seek_ns_from_origin;
+ src_comp_cls->msg_iter_cls->methods.seek_ns_from_origin;
iterator->methods.seek_beginning =
(bt_self_component_port_input_message_iterator_seek_beginning_method)
- src_comp_cls->methods.msg_iter_seek_beginning;
+ src_comp_cls->msg_iter_cls->methods.seek_beginning;
iterator->methods.can_seek_ns_from_origin =
(bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)
- src_comp_cls->methods.msg_iter_can_seek_ns_from_origin;
+ src_comp_cls->msg_iter_cls->methods.can_seek_ns_from_origin;
iterator->methods.can_seek_beginning =
(bt_self_component_port_input_message_iterator_can_seek_beginning_method)
- src_comp_cls->methods.msg_iter_can_seek_beginning;
+ src_comp_cls->msg_iter_cls->methods.can_seek_beginning;
break;
}
case BT_COMPONENT_CLASS_TYPE_FILTER:
iterator->methods.next =
(bt_self_component_port_input_message_iterator_next_method)
- flt_comp_cls->methods.msg_iter_next;
+ flt_comp_cls->msg_iter_cls->methods.next;
iterator->methods.seek_ns_from_origin =
(bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)
- flt_comp_cls->methods.msg_iter_seek_ns_from_origin;
+ flt_comp_cls->msg_iter_cls->methods.seek_ns_from_origin;
iterator->methods.seek_beginning =
(bt_self_component_port_input_message_iterator_seek_beginning_method)
- flt_comp_cls->methods.msg_iter_seek_beginning;
+ flt_comp_cls->msg_iter_cls->methods.seek_beginning;
iterator->methods.can_seek_ns_from_origin =
(bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)
- flt_comp_cls->methods.msg_iter_can_seek_ns_from_origin;
+ flt_comp_cls->msg_iter_cls->methods.can_seek_ns_from_origin;
iterator->methods.can_seek_beginning =
(bt_self_component_port_input_message_iterator_can_seek_beginning_method)
- flt_comp_cls->methods.msg_iter_can_seek_beginning;
+ flt_comp_cls->msg_iter_cls->methods.can_seek_beginning;
break;
}
default:
struct bt_component_class_source *src_comp_cls =
(void *) upstream_comp_cls;
- init_method =
- (init_method_t) src_comp_cls->methods.msg_iter_initialize;
+ init_method = src_comp_cls->msg_iter_cls->methods.initialize;
break;
}
case BT_COMPONENT_CLASS_TYPE_FILTER:
struct bt_component_class_filter *flt_comp_cls =
(void *) upstream_comp_cls;
- init_method =
- (init_method_t) flt_comp_cls->methods.msg_iter_initialize;
+ init_method = flt_comp_cls->msg_iter_cls->methods.initialize;
break;
}
default:
}
if (init_method) {
- enum bt_component_class_message_iterator_initialize_method_status iter_status;
+ enum bt_message_iterator_class_initialize_method_status iter_status;
BT_LIB_LOGD("Calling user's initialization method: %!+i", iterator);
- iter_status = init_method(iterator, &iterator->config, upstream_comp,
- upstream_port);
+ iter_status = init_method(
+ (struct bt_self_message_iterator *) iterator,
+ &iterator->config,
+ (struct bt_self_component *) upstream_comp,
+ (struct bt_self_component_port_output *) upstream_port);
BT_LOGD("User method returned: status=%s",
bt_common_func_status_string(iter_status));
BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(iter_status);
*/
static
-enum bt_component_class_message_iterator_next_method_status
+enum bt_message_iterator_class_next_method_status
call_iterator_next_method(
struct bt_self_component_port_input_message_iterator *iterator,
bt_message_array_const msgs, uint64_t capacity, uint64_t *user_count)
{
- enum bt_component_class_message_iterator_next_method_status status;
+ enum bt_message_iterator_class_next_method_status status;
BT_ASSERT_DBG(iterator->methods.next);
BT_LOGD_STR("Calling user's \"next\" method.");
*/
static
-enum bt_component_class_message_iterator_next_method_status post_auto_seek_next(
+enum bt_message_iterator_class_next_method_status post_auto_seek_next(
struct bt_self_component_port_input_message_iterator *iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
/* Check if the iterator can seek by itself. If not we'll use autoseek. */
if (iterator->methods.can_seek_ns_from_origin) {
- bt_component_class_message_iterator_can_seek_ns_from_origin_method_status
+ bt_message_iterator_class_can_seek_ns_from_origin_method_status
can_seek_status;
can_seek_status =
* particular time. We will seek to the beginning and fast
* forward to the right place.
*/
- enum bt_component_class_message_iterator_can_seek_beginning_method_status
- can_seek_status;
+ enum bt_message_iterator_class_can_seek_beginning_method_status can_seek_status;
bt_bool can_seek_beginning;
can_seek_status = iterator->methods.can_seek_beginning(iterator,
--- /dev/null
+/*
+ * Copyright 2019 EfficiOS, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_TAG "LIB/MESSAGE-ITERATOR-CLASS"
+#include "lib/logging.h"
+
+#include "message-iterator-class.h"
+
+#include "compat/compiler.h"
+#include "lib/assert-pre.h"
+#include "lib/func-status.h"
+
+#define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(_msg_iter_cls) \
+ BT_ASSERT_PRE_DEV_HOT((_msg_iter_cls), \
+ "Message iterator class", ": %!+I", (_msg_iter_cls))
+
+BT_HIDDEN
+void _bt_message_iterator_class_freeze(
+ const struct bt_message_iterator_class *msg_iter_cls)
+{
+ BT_ASSERT(msg_iter_cls);
+ BT_LIB_LOGD("Freezing message iterator class: %!+I", msg_iter_cls);
+ ((struct bt_message_iterator_class *) msg_iter_cls)->frozen = true;
+}
+
+void bt_message_iterator_class_get_ref(
+ const bt_message_iterator_class *message_iterator_class)
+{
+ bt_object_get_ref(message_iterator_class);
+}
+
+void bt_message_iterator_class_put_ref(
+ const bt_message_iterator_class *message_iterator_class)
+{
+ bt_object_put_ref(message_iterator_class);
+}
+
+static
+void destroy_iterator_class(struct bt_object *obj)
+{
+ struct bt_message_iterator_class *class;
+
+ BT_ASSERT(obj);
+ class = container_of(obj, struct bt_message_iterator_class, base);
+
+ BT_LIB_LOGI("Destroying message iterator class: %!+I", class);
+
+ g_free(class);
+}
+
+struct bt_message_iterator_class *bt_message_iterator_class_create(
+ bt_message_iterator_class_next_method next_method)
+{
+ struct bt_message_iterator_class *message_iterator_class;
+
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_NON_NULL(next_method, "Next method");
+ BT_LOGI("Creating message iterator class: next-method-addr=%p",
+ next_method);
+
+ message_iterator_class = g_new0(struct bt_message_iterator_class, 1);
+ if (!message_iterator_class) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one message iterator class.");
+ goto end;
+ }
+
+ bt_object_init_shared(&message_iterator_class->base, destroy_iterator_class);
+
+ message_iterator_class->methods.next = next_method;
+
+end:
+ return message_iterator_class;
+}
+
+bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_initialize_method(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_initialize_method method)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_ASSERT_PRE_NON_NULL(method, "Method");
+ BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+ message_iterator_class->methods.initialize = method;
+ BT_LIB_LOGD("Set message iterator class's iterator initialization method"
+ ": %!+I", message_iterator_class);
+ return BT_FUNC_STATUS_OK;
+}
+
+bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_finalize_method(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_finalize_method method)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_ASSERT_PRE_NON_NULL(method, "Method");
+ BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+ message_iterator_class->methods.finalize = method;
+ BT_LIB_LOGD("Set message iterator class's finalization method"
+ ": %!+I", message_iterator_class);
+ return BT_FUNC_STATUS_OK;
+}
+
+bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_seek_ns_from_origin_methods(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_seek_ns_from_origin_method seek_method,
+ bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_method)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
+ BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+ message_iterator_class->methods.seek_ns_from_origin = seek_method;
+ message_iterator_class->methods.can_seek_ns_from_origin = can_seek_method;
+ BT_LIB_LOGD("Set message iterator class's \"seek nanoseconds from origin\" method"
+ ": %!+I", message_iterator_class);
+ return BT_FUNC_STATUS_OK;
+}
+
+bt_message_iterator_class_set_method_status
+bt_message_iterator_class_set_seek_beginning_methods(
+ bt_message_iterator_class *message_iterator_class,
+ bt_message_iterator_class_seek_beginning_method seek_method,
+ bt_message_iterator_class_can_seek_beginning_method can_seek_method)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
+ BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+ message_iterator_class->methods.seek_beginning = seek_method;
+ message_iterator_class->methods.can_seek_beginning = can_seek_method;
+ BT_LIB_LOGD("Set message iterator class's \"seek beginning\" methods"
+ ": %!+C", message_iterator_class);
+ return BT_FUNC_STATUS_OK;
+}
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_CLASS_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace2/graph/message-iterator-class.h>
+#include <babeltrace2/types.h>
+#include "common/macros.h"
+#include "lib/object.h"
+#include <stdbool.h>
+#include <glib.h>
+
+struct bt_message_iterator_class {
+ struct bt_object base;
+ bool frozen;
+
+ struct {
+ bt_message_iterator_class_initialize_method initialize;
+ bt_message_iterator_class_finalize_method finalize;
+ bt_message_iterator_class_next_method next;
+ bt_message_iterator_class_seek_ns_from_origin_method seek_ns_from_origin;
+ bt_message_iterator_class_seek_beginning_method seek_beginning;
+ bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_ns_from_origin;
+ bt_message_iterator_class_can_seek_beginning_method can_seek_beginning;
+ } methods;
+};
+
+BT_HIDDEN
+void _bt_message_iterator_class_freeze(
+ const struct bt_message_iterator_class *message_iterator_class);
+
+#ifdef BT_DEV_MODE
+# define bt_message_iterator_class_freeze _bt_message_iterator_class_freeze
+#else
+# define bt_message_iterator_class_freeze(_cls)
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_CLASS_INTERNAL_H */
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR,
};
-typedef enum bt_component_class_message_iterator_next_method_status
+typedef enum bt_message_iterator_class_next_method_status
(*bt_self_component_port_input_message_iterator_next_method)(
void *, bt_message_array_const, uint64_t, uint64_t *);
-typedef enum bt_component_class_message_iterator_seek_ns_from_origin_method_status
+typedef enum bt_message_iterator_class_seek_ns_from_origin_method_status
(*bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)(
void *, int64_t);
-typedef enum bt_component_class_message_iterator_seek_beginning_method_status
+typedef enum bt_message_iterator_class_seek_beginning_method_status
(*bt_self_component_port_input_message_iterator_seek_beginning_method)(
void *);
-typedef enum bt_component_class_message_iterator_can_seek_ns_from_origin_method_status
+typedef enum bt_message_iterator_class_can_seek_ns_from_origin_method_status
(*bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)(
void *, int64_t, bt_bool *);
-typedef enum bt_component_class_message_iterator_can_seek_beginning_method_status
+typedef enum bt_message_iterator_class_can_seek_beginning_method_status
(*bt_self_component_port_input_message_iterator_can_seek_beginning_method)(
void *, bt_bool *);
&graph->packet_end_msg_pool);
}
+static inline void format_message_iterator_class(char **buf_ch,
+ bool extended, const char *prefix,
+ const struct bt_message_iterator_class *iterator_class)
+{
+ /* Empty, the address is automatically printed. */
+}
+
static inline void format_message_iterator(char **buf_ch,
bool extended, const char *prefix,
const struct bt_message_iterator *iterator)
case 'n':
format_message(buf_ch, extended, prefix, obj);
break;
+ case 'I':
+ format_message_iterator_class(buf_ch, extended, prefix, obj);
+ break;
case 'i':
format_message_iterator(buf_ch, extended, prefix, obj);
break;
bt_component_class_source_finalize_method finalize;
bt_component_class_source_query_method query;
bt_component_class_source_output_port_connected_method output_port_connected;
- bt_component_class_source_message_iterator_initialize_method msg_iter_initialize;
- bt_component_class_source_message_iterator_finalize_method msg_iter_finalize;
- bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
- bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning;
- bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
- bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
+ bt_message_iterator_class_initialize_method msg_iter_initialize;
+ bt_message_iterator_class_finalize_method msg_iter_finalize;
+ bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+ bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning;
+ bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+ bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning;
} source;
struct {
bt_component_class_filter_query_method query;
bt_component_class_filter_input_port_connected_method input_port_connected;
bt_component_class_filter_output_port_connected_method output_port_connected;
- bt_component_class_filter_message_iterator_initialize_method msg_iter_initialize;
- bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize;
- bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
- bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning;
- bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
- bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
+ bt_message_iterator_class_initialize_method msg_iter_initialize;
+ bt_message_iterator_class_finalize_method msg_iter_finalize;
+ bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+ bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning;
+ bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+ bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning;
} filter;
struct {
GArray *comp_class_full_descriptors;
size_t i;
int ret;
+ struct bt_message_iterator_class *msg_iter_class = NULL;
BT_LOGI("Initializing plugin object from descriptors found in sections: "
"plugin-addr=%p, plugin-path=\"%s\", "
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
cc_full_descr->methods.source.msg_iter_initialize =
- cur_cc_descr_attr->value.source_msg_iter_initialize_method;
+ cur_cc_descr_attr->value.msg_iter_initialize_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
cc_full_descr->methods.filter.msg_iter_initialize =
- cur_cc_descr_attr->value.filter_msg_iter_initialize_method;
+ cur_cc_descr_attr->value.msg_iter_initialize_method;
break;
default:
bt_common_abort();
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
cc_full_descr->methods.source.msg_iter_finalize =
- cur_cc_descr_attr->value.source_msg_iter_finalize_method;
+ cur_cc_descr_attr->value.msg_iter_finalize_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
cc_full_descr->methods.filter.msg_iter_finalize =
- cur_cc_descr_attr->value.filter_msg_iter_finalize_method;
+ cur_cc_descr_attr->value.msg_iter_finalize_method;
break;
default:
bt_common_abort();
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
cc_full_descr->methods.source.msg_iter_seek_ns_from_origin =
- cur_cc_descr_attr->value.source_msg_iter_seek_ns_from_origin_method;
+ cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin =
- cur_cc_descr_attr->value.filter_msg_iter_seek_ns_from_origin_method;
+ cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method;
break;
default:
bt_common_abort();
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
cc_full_descr->methods.source.msg_iter_seek_beginning =
- cur_cc_descr_attr->value.source_msg_iter_seek_beginning_method;
+ cur_cc_descr_attr->value.msg_iter_seek_beginning_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
cc_full_descr->methods.filter.msg_iter_seek_beginning =
- cur_cc_descr_attr->value.filter_msg_iter_seek_beginning_method;
+ cur_cc_descr_attr->value.msg_iter_seek_beginning_method;
break;
default:
bt_common_abort();
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin =
- cur_cc_descr_attr->value.source_msg_iter_can_seek_ns_from_origin_method;
+ cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin =
- cur_cc_descr_attr->value.filter_msg_iter_can_seek_ns_from_origin_method;
+ cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method;
break;
default:
bt_common_abort();
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
cc_full_descr->methods.source.msg_iter_can_seek_beginning =
- cur_cc_descr_attr->value.source_msg_iter_can_seek_beginning_method;
+ cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
cc_full_descr->methods.filter.msg_iter_can_seek_beginning =
- cur_cc_descr_attr->value.filter_msg_iter_can_seek_beginning_method;
+ cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method;
break;
default:
bt_common_abort();
bt_component_class_type_string(
cc_full_descr->descriptor->type));
+ if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
+ cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_FILTER) {
+ bt_message_iterator_class_next_method next_method;
+ bt_message_iterator_class_initialize_method init_method;
+ bt_message_iterator_class_finalize_method fini_method;
+ bt_message_iterator_class_seek_ns_from_origin_method seek_ns_from_origin_method;
+ bt_message_iterator_class_seek_beginning_method seek_beginning_method;
+ bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_ns_from_origin_method;
+ bt_message_iterator_class_can_seek_beginning_method can_seek_beginning_method;
+
+ if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE) {
+ next_method = cc_full_descr->descriptor->methods.source.msg_iter_next;
+ init_method = cc_full_descr->methods.source.msg_iter_initialize;
+ fini_method = cc_full_descr->methods.source.msg_iter_finalize;
+ seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_seek_ns_from_origin;
+ can_seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin;
+ seek_beginning_method = cc_full_descr->methods.source.msg_iter_seek_beginning;
+ can_seek_beginning_method = cc_full_descr->methods.source.msg_iter_can_seek_beginning;
+ } else {
+ next_method = cc_full_descr->descriptor->methods.filter.msg_iter_next;
+ init_method = cc_full_descr->methods.filter.msg_iter_initialize;
+ fini_method = cc_full_descr->methods.filter.msg_iter_finalize;
+ seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin;
+ can_seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin;
+ seek_beginning_method = cc_full_descr->methods.filter.msg_iter_seek_beginning;
+ can_seek_beginning_method = cc_full_descr->methods.filter.msg_iter_can_seek_beginning;
+ }
+
+ msg_iter_class = bt_message_iterator_class_create(next_method);
+ if (!msg_iter_class) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Cannot create message iterator class.");
+ status = BT_FUNC_STATUS_MEMORY_ERROR;
+ goto end;
+ }
+
+ if (init_method) {
+ ret = bt_message_iterator_class_set_initialize_method(
+ msg_iter_class, init_method);
+ if (ret) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Cannot set message iterator initialization method.");
+ status = BT_FUNC_STATUS_MEMORY_ERROR;
+ goto end;
+ }
+ }
+
+ if (fini_method) {
+ ret = bt_message_iterator_class_set_finalize_method(
+ msg_iter_class, fini_method);
+ if (ret) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Cannot set message iterator finalization method.");
+ status = BT_FUNC_STATUS_MEMORY_ERROR;
+ goto end;
+ }
+ }
+
+ if (seek_ns_from_origin_method) {
+ ret = bt_message_iterator_class_set_seek_ns_from_origin_methods(
+ msg_iter_class,
+ seek_ns_from_origin_method,
+ can_seek_ns_from_origin_method);
+ if (ret) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Cannot set message iterator \"seek nanoseconds from origin\" methods.");
+ status = BT_FUNC_STATUS_MEMORY_ERROR;
+ goto end;
+ }
+ }
+
+ if (seek_beginning_method) {
+ ret = bt_message_iterator_class_set_seek_beginning_methods(
+ msg_iter_class,
+ seek_beginning_method,
+ can_seek_beginning_method);
+ if (ret) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Cannot set message iterator \"seek beginning\" methods.");
+ status = BT_FUNC_STATUS_MEMORY_ERROR;
+ goto end;
+ }
+ }
+ }
+
switch (cc_full_descr->descriptor->type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ BT_ASSERT(msg_iter_class);
+
src_comp_class = bt_component_class_source_create(
- cc_full_descr->descriptor->name,
- cc_full_descr->descriptor->methods.source.msg_iter_next);
+ cc_full_descr->descriptor->name, msg_iter_class);
comp_class = bt_component_class_source_as_component_class(
src_comp_class);
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
+ BT_ASSERT(msg_iter_class);
+
flt_comp_class = bt_component_class_filter_create(
- cc_full_descr->descriptor->name,
- cc_full_descr->descriptor->methods.source.msg_iter_next);
+ cc_full_descr->descriptor->name, msg_iter_class);
comp_class = bt_component_class_filter_as_component_class(
flt_comp_class);
break;
case BT_COMPONENT_CLASS_TYPE_SINK:
+ BT_ASSERT(!msg_iter_class);
+
sink_comp_class = bt_component_class_sink_create(
cc_full_descr->descriptor->name,
cc_full_descr->descriptor->methods.sink.consume);
goto end;
}
+ /*
+ * The component class has taken a reference on the message
+ * iterator class, so we can drop ours. The message iterator
+ * class will get destroyed at the same time as the component
+ * class.
+ */
+ bt_message_iterator_class_put_ref(msg_iter_class);
+ msg_iter_class = NULL;
+
if (cc_full_descr->description) {
ret = bt_component_class_set_description(
comp_class, cc_full_descr->description);
}
}
- if (cc_full_descr->methods.source.msg_iter_initialize) {
- ret = bt_component_class_source_set_message_iterator_initialize_method(
- src_comp_class,
- cc_full_descr->methods.source.msg_iter_initialize);
- if (ret) {
- BT_LIB_LOGE_APPEND_CAUSE(
- "Cannot set source component class's message iterator initialization 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_finalize) {
- ret = bt_component_class_source_set_message_iterator_finalize_method(
- src_comp_class,
- cc_full_descr->methods.source.msg_iter_finalize);
- if (ret) {
- BT_LIB_LOGE_APPEND_CAUSE(
- "Cannot set source component class's message iterator finalization 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_ns_from_origin) {
- 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 \"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_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 \"seek beginning\" methods.");
- status = BT_FUNC_STATUS_MEMORY_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
- goto end;
- }
- }
-
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
if (cc_full_descr->methods.filter.get_supported_mip_versions) {
}
}
- if (cc_full_descr->methods.filter.msg_iter_initialize) {
- ret = bt_component_class_filter_set_message_iterator_initialize_method(
- flt_comp_class,
- cc_full_descr->methods.filter.msg_iter_initialize);
- if (ret) {
- BT_LIB_LOGE_APPEND_CAUSE(
- "Cannot set filter component class's message iterator initialization 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_finalize) {
- ret = bt_component_class_filter_set_message_iterator_finalize_method(
- flt_comp_class,
- cc_full_descr->methods.filter.msg_iter_finalize);
- if (ret) {
- BT_LIB_LOGE_APPEND_CAUSE(
- "Cannot set filter component class's message iterator finalization 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_ns_from_origin) {
- 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 \"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_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 \"seek beginning\" methods.");
- status = BT_FUNC_STATUS_MEMORY_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
- goto end;
- }
- }
-
break;
case BT_COMPONENT_CLASS_TYPE_SINK:
if (cc_full_descr->methods.sink.get_supported_mip_versions) {
}
end:
+ bt_message_iterator_class_put_ref(msg_iter_class);
g_array_free(comp_class_full_descriptors, TRUE);
return status;
}
}
static
-bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one(
+bt_message_iterator_class_next_method_status ctf_fs_iterator_next_one(
struct ctf_fs_msg_iter_data *msg_iter_data,
const bt_message **out_msg)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
enum ctf_msg_iter_status msg_iter_status;
bt_logging_level log_level = msg_iter_data->log_level;
switch (msg_iter_status) {
case CTF_MSG_ITER_STATUS_OK:
/* Cool, message has been written to *out_msg. */
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
break;
case CTF_MSG_ITER_STATUS_EOF:
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
break;
case CTF_MSG_ITER_STATUS_AGAIN:
case CTF_MSG_ITER_MEDIUM_STATUS_ERROR:
BT_MSG_ITER_LOGE_APPEND_CAUSE(msg_iter_data->self_msg_iter,
"Failed to get next message from CTF message iterator.");
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
break;
case CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR:
BT_MSG_ITER_LOGE_APPEND_CAUSE(msg_iter_data->self_msg_iter,
"Failed to get next message from CTF message iterator.");
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
break;
default:
}
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next(
+bt_message_iterator_class_next_method_status ctf_fs_iterator_next(
bt_self_message_iterator *iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
struct ctf_fs_msg_iter_data *msg_iter_data =
bt_self_message_iterator_get_data(iterator);
uint64_t i = 0;
do {
status = ctf_fs_iterator_next_one(msg_iter_data, &msgs[i]);
- if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
i++;
}
} while (i < capacity &&
- status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK);
+ status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK);
if (i > 0) {
/*
* Even if ctf_fs_iterator_next_one() returned something
- * else than BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK, we
+ * else than BT_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK, we
* accumulated message objects in the output
* message array, so we need to return
- * BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK so that they are
+ * BT_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK so that they are
* transfered to downstream. This other status occurs
* again the next time muxer_msg_iter_do_next() is
* called, possibly without any accumulated
}
*count = i;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
}
end:
}
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status
+bt_message_iterator_class_seek_beginning_method_status
ctf_fs_iterator_seek_beginning(bt_self_message_iterator *it)
{
struct ctf_fs_msg_iter_data *msg_iter_data =
ctf_msg_iter_reset(msg_iter_data->msg_iter);
ctf_fs_ds_group_medops_data_reset(msg_iter_data->msg_iter_medops_data);
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK;
+ return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
}
BT_HIDDEN
}
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status ctf_fs_iterator_init(
+bt_message_iterator_class_initialize_method_status ctf_fs_iterator_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_comp_src,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port)
{
struct ctf_fs_port_data *port_data;
struct ctf_fs_msg_iter_data *msg_iter_data = NULL;
- bt_component_class_message_iterator_initialize_method_status status;
+ bt_message_iterator_class_initialize_method_status status;
bt_logging_level log_level;
- bt_self_component *self_comp =
- bt_self_component_source_as_self_component(self_comp_src);
enum ctf_msg_iter_medium_status medium_status;
port_data = bt_self_component_port_get_data(
log_level = port_data->ctf_fs->log_level;
msg_iter_data = g_new0(struct ctf_fs_msg_iter_data, 1);
if (!msg_iter_data) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
self_comp, self_msg_iter);
if (!msg_iter_data->msg_iter) {
BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot create a CTF message iterator.");
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
msg_iter_data);
msg_iter_data = NULL;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
goto end;
error:
* messages ready to return, we save the error here and return it on
* the next _next call.
*/
- bt_component_class_message_iterator_next_method_status next_saved_status;
+ bt_message_iterator_class_next_method_status next_saved_status;
const struct bt_error *next_saved_error;
struct ctf_fs_ds_group_medops_data *msg_iter_medops_data;
void *method_data, const bt_value **result);
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status ctf_fs_iterator_init(
+bt_message_iterator_class_initialize_method_status ctf_fs_iterator_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port);
BT_HIDDEN
void ctf_fs_iterator_finalize(bt_self_message_iterator *it);
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next(
+bt_message_iterator_class_next_method_status ctf_fs_iterator_next(
bt_self_message_iterator *iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count);
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status ctf_fs_iterator_seek_beginning(
+bt_message_iterator_class_seek_beginning_method_status ctf_fs_iterator_seek_beginning(
bt_self_message_iterator *message_iterator);
/* Create and initialize a new, empty ctf_fs_component. */
}
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next(
+bt_message_iterator_class_next_method_status lttng_live_msg_iter_next(
bt_self_message_iterator *self_msg_it,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
enum lttng_live_viewer_status viewer_status;
struct lttng_live_msg_iter *lttng_live_msg_iter =
bt_self_message_iterator_get_data(self_msg_it);
* is to prevent other graph users from using this live
* iterator in an messed up internal state.
*/
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
BT_COMP_LOGE_APPEND_CAUSE(self_comp,
"Message iterator was interrupted during a previous call to the `next()` and currently does not support continuing after such event.");
goto end;
if (lttng_live_msg_iter->sessions->len == 0) {
if (lttng_live->params.sess_not_found_act !=
SESSION_NOT_FOUND_ACTION_CONTINUE) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
goto end;
} else {
/*
viewer_status = lttng_live_create_viewer_session(lttng_live_msg_iter);
if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
if (viewer_status == LTTNG_LIVE_VIEWER_STATUS_ERROR) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
BT_COMP_LOGE_APPEND_CAUSE(self_comp,
"Error creating LTTng live viewer session");
} else if (viewer_status == LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
} else {
bt_common_abort();
}
* doesn't support restarting after an interruption.
*/
if (*count > 0) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
} else {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
}
break;
case LTTNG_LIVE_ITERATOR_STATUS_END:
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
break;
case LTTNG_LIVE_ITERATOR_STATUS_NOMEM:
BT_COMP_LOGE_APPEND_CAUSE(self_comp,
"Memory error preparing the next batch of messages: "
"live-iter-status=%s",
lttng_live_iterator_status_string(stream_iter_status));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
break;
case LTTNG_LIVE_ITERATOR_STATUS_ERROR:
case LTTNG_LIVE_ITERATOR_STATUS_INVAL:
"live-iter-status=%s",
lttng_live_iterator_status_string(stream_iter_status));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
/* Put all existing messages on error. */
put_messages(msgs, *count);
break;
}
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter_init(
+bt_message_iterator_class_initialize_method_status lttng_live_msg_iter_init(
bt_self_message_iterator *self_msg_it,
bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_comp_src,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port)
{
- bt_component_class_message_iterator_initialize_method_status status;
- bt_self_component *self_comp =
- bt_self_component_source_as_self_component(self_comp_src);
+ bt_message_iterator_class_initialize_method_status status;
struct lttng_live_component *lttng_live;
struct lttng_live_msg_iter *lttng_live_msg_iter;
enum lttng_live_viewer_status viewer_status;
lttng_live_msg_iter = lttng_live_msg_iter_create(lttng_live,
self_msg_it);
if (!lttng_live_msg_iter) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
BT_COMP_LOGE_APPEND_CAUSE(self_comp,
"Failed to create lttng_live_msg_iter");
goto error;
}
bt_self_message_iterator_set_data(self_msg_it, lttng_live_msg_iter);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
goto end;
error:
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
lttng_live_msg_iter_destroy(lttng_live_msg_iter);
end:
return status;
void lttng_live_component_finalize(bt_self_component_source *component);
-bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next(
+bt_message_iterator_class_next_method_status lttng_live_msg_iter_next(
bt_self_message_iterator *iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count);
-bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter_init(
+bt_message_iterator_class_initialize_method_status lttng_live_msg_iter_init(
bt_self_message_iterator *self_msg_it,
bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port);
void lttng_live_msg_iter_finalize(bt_self_message_iterator *it);
struct debug_info_component {
bt_logging_level log_level;
bt_self_component *self_comp;
+ bt_self_component_filter *self_comp_filter;
gchar *arg_debug_dir;
gchar *arg_debug_info_field_name;
gchar *arg_target_prefix;
debug_info_comp->log_level = log_level;
debug_info_comp->self_comp = self_comp;
+ debug_info_comp->self_comp_filter = self_comp_flt;
bt_self_component_set_data(self_comp, debug_info_comp);
add_port_status = bt_self_component_filter_add_input_port(
}
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next(
+bt_message_iterator_class_next_method_status debug_info_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
const bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
bt_message_iterator_next_status upstream_iterator_ret_status;
struct debug_info_msg_iter *debug_info_msg_iter;
struct debug_info_component *debug_info = NULL;
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
bt_self_component *self_comp = NULL;
bt_message_array_const input_msgs;
const bt_message *out_message;
uint64_t curr_msg_idx, i;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
self_comp = bt_self_message_iterator_borrow_component(self_msg_iter);
BT_ASSERT_DBG(self_comp);
bt_message_put_ref(input_msgs[i]);
}
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
end:
return status;
}
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter_init(
+bt_message_iterator_class_initialize_method_status debug_info_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_comp_flt,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port)
{
- bt_component_class_message_iterator_initialize_method_status status;
+ bt_message_iterator_class_initialize_method_status status;
bt_self_component_port_input_message_iterator_create_from_message_iterator_status
msg_iter_status;
struct bt_self_component_port_input *input_port = NULL;
struct debug_info_msg_iter *debug_info_msg_iter = NULL;
gchar *debug_info_field_name;
int ret;
- bt_self_component *self_comp =
- bt_self_component_filter_as_self_component(self_comp_flt);
bt_logging_level log_level = bt_component_get_logging_level(
bt_self_component_as_component(self_comp));
- /* Borrow the upstream input port. */
- input_port = bt_self_component_filter_borrow_input_port_by_name(
- self_comp_flt, "in");
- if (!input_port) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR;
- goto error;
- }
-
debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1);
if (!debug_info_msg_iter) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
debug_info_msg_iter->log_level = log_level;
debug_info_msg_iter->self_comp = self_comp;
+ debug_info_msg_iter->debug_info_component =
+ bt_self_component_get_data(self_comp);
+
+ /* Borrow the upstream input port. */
+ input_port = bt_self_component_filter_borrow_input_port_by_name(
+ debug_info_msg_iter->debug_info_component->self_comp_filter,
+ "in");
+ if (!input_port) {
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
+ goto error;
+ }
+
/* Create an iterator on the upstream component. */
msg_iter_status = bt_self_component_port_input_message_iterator_create_from_message_iterator(
self_msg_iter, input_port, &upstream_iterator);
g_direct_hash, g_direct_equal, (GDestroyNotify) NULL,
(GDestroyNotify) debug_info_destroy);
if (!debug_info_msg_iter->debug_info_map) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
- debug_info_msg_iter->debug_info_component =
- bt_self_component_get_data(self_comp);
-
debug_info_field_name =
debug_info_msg_iter->debug_info_component->arg_debug_info_field_name;
debug_info_msg_iter->ir_maps = trace_ir_maps_create(self_comp,
debug_info_field_name, log_level);
if (!debug_info_msg_iter->ir_maps) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level);
if (ret) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
bt_self_message_iterator_set_data(self_msg_iter, debug_info_msg_iter);
debug_info_msg_iter->input_iterator = self_msg_iter;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
goto end;
error:
}
BT_HIDDEN
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
debug_info_msg_iter_can_seek_beginning(bt_self_message_iterator *self_msg_iter,
bt_bool *can_seek)
{
}
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status
+bt_message_iterator_class_seek_beginning_method_status
debug_info_msg_iter_seek_beginning(bt_self_message_iterator *self_msg_iter)
{
struct debug_info_msg_iter *debug_info_msg_iter =
bt_self_message_iterator_get_data(self_msg_iter);
- bt_component_class_message_iterator_seek_beginning_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK;
+ bt_message_iterator_class_seek_beginning_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
bt_message_iterator_seek_beginning_status seek_beg_status;
BT_ASSERT(debug_info_msg_iter);
void debug_info_comp_finalize(bt_self_component_filter *self_comp);
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter_init(
+bt_message_iterator_class_initialize_method_status debug_info_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port);
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next(
+bt_message_iterator_class_next_method_status debug_info_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
const bt_message_array_const msgs, uint64_t capacity,
uint64_t *count);
BT_HIDDEN
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
debug_info_msg_iter_can_seek_beginning(
bt_self_message_iterator *message_iterator,
bt_bool *can_seek);
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status debug_info_msg_iter_seek_beginning(
+bt_message_iterator_class_seek_beginning_method_status debug_info_msg_iter_seek_beginning(
bt_self_message_iterator *message_iterator);
BT_HIDDEN
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status dmesg_msg_iter_init(
+bt_message_iterator_class_initialize_method_status dmesg_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port)
{
- struct dmesg_component *dmesg_comp = bt_self_component_get_data(
- bt_self_component_source_as_self_component(self_comp));
+ struct dmesg_component *dmesg_comp = bt_self_component_get_data(self_comp);
struct dmesg_msg_iter *dmesg_msg_iter =
g_new0(struct dmesg_msg_iter, 1);
- bt_component_class_message_iterator_initialize_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ bt_message_iterator_class_initialize_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
if (!dmesg_msg_iter) {
BT_COMP_LOGE_STR("Failed to allocate on dmesg message iterator structure.");
destroy_dmesg_msg_iter(dmesg_msg_iter);
bt_self_message_iterator_set_data(self_msg_iter, NULL);
if (status >= 0) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
}
end:
}
static
-bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next_one(
+bt_message_iterator_class_next_method_status dmesg_msg_iter_next_one(
struct dmesg_msg_iter *dmesg_msg_iter,
bt_message **msg)
{
ssize_t len;
struct dmesg_component *dmesg_comp;
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
BT_ASSERT_DBG(dmesg_msg_iter);
dmesg_comp = dmesg_msg_iter->dmesg_comp;
BT_ASSERT_DBG(dmesg_comp);
if (dmesg_msg_iter->state == STATE_DONE) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
goto end;
}
&dmesg_msg_iter->linebuf_len, dmesg_msg_iter->fp);
if (len < 0) {
if (errno == EINVAL) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
} else if (errno == ENOMEM) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
} else {
if (dmesg_msg_iter->state == STATE_EMIT_STREAM_BEGINNING) {
/* Stream did not even begin */
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
goto end;
} else {
/* End stream now */
if (!*msg) {
BT_COMP_LOGE("Cannot create message: dmesg-comp-addr=%p",
dmesg_comp);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
}
end:
}
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next(
+bt_message_iterator_class_next_method_status dmesg_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
struct dmesg_msg_iter *dmesg_msg_iter =
bt_self_message_iterator_get_data(
self_msg_iter);
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
uint64_t i = 0;
while (i < capacity &&
- status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
bt_message *priv_msg = NULL;
status = dmesg_msg_iter_next_one(dmesg_msg_iter,
&priv_msg);
msgs[i] = priv_msg;
- if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
i++;
}
}
* message, in which case we'll return it.
*/
*count = i;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
}
return status;
}
BT_HIDDEN
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
dmesg_msg_iter_can_seek_beginning(
bt_self_message_iterator *self_msg_iter, bt_bool *can_seek)
{
/* Can't seek the beginning of the standard input stream */
*can_seek = !dmesg_msg_iter->dmesg_comp->params.read_from_stdin;
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
+ return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
}
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status
+bt_message_iterator_class_seek_beginning_method_status
dmesg_msg_iter_seek_beginning(
bt_self_message_iterator *self_msg_iter)
{
BT_MESSAGE_PUT_REF_AND_RESET(dmesg_msg_iter->tmp_event_msg);
dmesg_msg_iter->last_clock_value = 0;
dmesg_msg_iter->state = STATE_EMIT_STREAM_BEGINNING;
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK;
+ return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
}
void dmesg_finalize(bt_self_component_source *self_comp);
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status dmesg_msg_iter_init(
+bt_message_iterator_class_initialize_method_status dmesg_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port);
BT_HIDDEN
bt_self_message_iterator *self_msg_iter);
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next(
+bt_message_iterator_class_next_method_status dmesg_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count);
BT_HIDDEN
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
dmesg_msg_iter_can_seek_beginning(
bt_self_message_iterator *message_iterator, bt_bool *can_seek);
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status dmesg_msg_iter_seek_beginning(
+bt_message_iterator_class_seek_beginning_method_status dmesg_msg_iter_seek_beginning(
bt_self_message_iterator *message_iterator);
#endif /* BABELTRACE_PLUGIN_TEXT_DMESG_DMESG_H */
}
static
-bt_component_class_message_iterator_next_method_status handle_message(
+bt_message_iterator_class_next_method_status handle_message(
struct pretty_component *pretty,
const bt_message *message)
{
- bt_component_class_message_iterator_next_method_status ret =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status ret =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
BT_ASSERT_DBG(pretty);
switch (bt_message_get_type(message)) {
case BT_MESSAGE_TYPE_EVENT:
if (pretty_print_event(pretty, message)) {
- ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ ret = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
}
break;
case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
if (pretty_print_discarded_items(pretty, message)) {
- ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ ret = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
}
break;
default:
* messages ready to return, we save the error here and return it on
* the next _next call.
*/
- bt_component_class_message_iterator_next_method_status next_saved_status;
+ bt_message_iterator_class_next_method_status next_saved_status;
const struct bt_error *next_saved_error;
};
}
static
-bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_next(
+bt_message_iterator_class_next_method_status muxer_upstream_msg_iter_next(
struct muxer_upstream_msg_iter *muxer_upstream_msg_iter,
bool *is_ended)
{
struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp;
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
bt_message_iterator_next_status input_port_iter_status;
bt_message_array_const msgs;
uint64_t i;
g_queue_push_tail(muxer_upstream_msg_iter->msgs,
(void *) msgs[i]);
}
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
break;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
/*
* valid anymore. Return
* BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN immediately.
*/
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
break;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: /* Fall-through. */
/*
* message.
*/
*is_ended = true;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
break;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Unsupported status code: status=%s",
bt_common_func_status_string(input_port_iter_status));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
break;
}
* the youngest, and sets *ts_ns to its time.
*/
static
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
muxer_msg_iter_youngest_upstream_msg_iter(
struct muxer_comp *muxer_comp,
struct muxer_msg_iter *muxer_msg_iter,
size_t i;
int ret;
int64_t youngest_ts_ns = INT64_MAX;
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
BT_ASSERT_DBG(muxer_comp);
BT_ASSERT_DBG(muxer_msg_iter);
* validate_new_stream_clock_class() logs
* errors.
*/
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
} else if (G_UNLIKELY(bt_message_get_type(msg) ==
bt_clock_snapshot_borrow_clock_class_const(cs));
if (ret) {
/* validate_clock_class() logs errors */
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
}
if (ret) {
/* get_msg_ts_ns() logs errors */
*muxer_upstream_msg_iter = NULL;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
}
if (!*muxer_upstream_msg_iter) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
*ts_ns = INT64_MIN;
}
}
static
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
validate_muxer_upstream_msg_iter(
struct muxer_upstream_msg_iter *muxer_upstream_msg_iter,
bool *is_ended)
{
struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp;
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
BT_COMP_LOGD("Validating muxer's upstream message iterator wrapper: "
"muxer-upstream-msg-iter-wrap-addr=%p",
"queue-len=%u, upstream-msg-iter-addr=%p",
muxer_upstream_msg_iter->msgs->length,
muxer_upstream_msg_iter->msg_iter);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
goto end;
}
}
static
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
validate_muxer_upstream_msg_iters(
struct muxer_msg_iter *muxer_msg_iter)
{
struct muxer_comp *muxer_comp = muxer_msg_iter->muxer_comp;
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
size_t i;
BT_COMP_LOGD("Validating muxer's upstream message iterator wrappers: "
status = validate_muxer_upstream_msg_iter(
muxer_upstream_msg_iter, &is_ended);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
if (status < 0) {
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Cannot validate muxer's upstream message iterator wrapper: "
}
}
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
end:
return status;
}
static inline
-bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_one(
+bt_message_iterator_class_next_method_status muxer_msg_iter_do_next_one(
struct muxer_comp *muxer_comp,
struct muxer_msg_iter *muxer_msg_iter,
const bt_message **msg)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = NULL;
int64_t next_return_ts;
status = validate_muxer_upstream_msg_iters(muxer_msg_iter);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
/* validate_muxer_upstream_msg_iters() logs details */
goto end;
}
status = muxer_msg_iter_youngest_upstream_msg_iter(muxer_comp,
muxer_msg_iter, &muxer_upstream_msg_iter,
&next_return_ts);
- if (status < 0 || status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END) {
+ if (status < 0 || status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END) {
if (status < 0) {
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Cannot find the youngest upstream message iterator wrapper: "
"last-returned-ts=%" PRId64,
muxer_msg_iter, next_return_ts,
muxer_msg_iter->last_returned_ts_ns);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
"ts=%" PRId64,
muxer_msg_iter, muxer_upstream_msg_iter, next_return_ts);
BT_ASSERT_DBG(status ==
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK);
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK);
BT_ASSERT_DBG(muxer_upstream_msg_iter);
/*
}
static
-bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next(
+bt_message_iterator_class_next_method_status muxer_msg_iter_do_next(
struct muxer_comp *muxer_comp,
struct muxer_msg_iter *muxer_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
uint64_t i = 0;
if (G_UNLIKELY(muxer_msg_iter->next_saved_error)) {
do {
status = muxer_msg_iter_do_next_one(muxer_comp,
muxer_msg_iter, &msgs[i]);
- if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
i++;
}
- } while (i < capacity && status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK);
+ } while (i < capacity && status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK);
if (i > 0) {
/*
}
*count = i;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
}
end:
}
static
-bt_component_class_message_iterator_initialize_method_status
+bt_message_iterator_class_initialize_method_status
muxer_msg_iter_init_upstream_iterators(struct muxer_comp *muxer_comp,
struct muxer_msg_iter *muxer_msg_iter,
struct bt_self_message_iterator_configuration *config)
{
int64_t count;
int64_t i;
- bt_component_class_message_iterator_initialize_method_status status;
+ bt_message_iterator_class_initialize_method_status status;
bool can_seek_forward = true;
count = bt_component_filter_get_input_port_count(
BT_COMP_LOGD("No input port to initialize for muxer component's message iterator: "
"muxer-comp-addr=%p, muxer-msg-iter-addr=%p",
muxer_comp, muxer_msg_iter);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
goto end;
}
bt_self_component_port_input_message_iterator_put_ref(
upstream_msg_iter);
if (int_status) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
/* muxer_msg_iter_add_upstream_msg_iter() logs errors */
goto end;
}
bt_self_message_iterator_configuration_set_can_seek_forward(
config, can_seek_forward);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
end:
return status;
}
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init(
+bt_message_iterator_class_initialize_method_status muxer_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *port)
{
struct muxer_comp *muxer_comp = NULL;
struct muxer_msg_iter *muxer_msg_iter = NULL;
- bt_component_class_message_iterator_initialize_method_status status;
+ bt_message_iterator_class_initialize_method_status status;
- muxer_comp = bt_self_component_get_data(
- bt_self_component_filter_as_self_component(self_comp));
+ muxer_comp = bt_self_component_get_data(self_comp);
BT_ASSERT(muxer_comp);
BT_COMP_LOGD("Initializing muxer component's message iterator: "
"comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p",
BT_COMP_LOGE("Recursive initialization of muxer component's message iterator: "
"comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p",
self_comp, muxer_comp, self_msg_iter);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
goto error;
}
muxer_msg_iter = g_new0(struct muxer_msg_iter, 1);
if (!muxer_msg_iter) {
BT_COMP_LOGE_STR("Failed to allocate one muxer component's message iterator.");
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
(GDestroyNotify) destroy_muxer_upstream_msg_iter);
if (!muxer_msg_iter->active_muxer_upstream_msg_iters) {
BT_COMP_LOGE_STR("Failed to allocate a GPtrArray.");
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
(GDestroyNotify) destroy_muxer_upstream_msg_iter);
if (!muxer_msg_iter->ended_muxer_upstream_msg_iters) {
BT_COMP_LOGE_STR("Failed to allocate a GPtrArray.");
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
}
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status muxer_msg_iter_next(
+bt_message_iterator_class_next_method_status muxer_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
struct muxer_msg_iter *muxer_msg_iter =
bt_self_message_iterator_get_data(self_msg_iter);
bt_self_component *self_comp = NULL;
}
static inline
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
muxer_upstream_msg_iters_can_all_seek_beginning(
GPtrArray *muxer_upstream_msg_iters, bt_bool *can_seek)
{
- bt_component_class_message_iterator_can_seek_beginning_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
+ bt_message_iterator_class_can_seek_beginning_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
uint64_t i;
for (i = 0; i < muxer_upstream_msg_iters->len; i++) {
muxer_upstream_msg_iters->pdata[i];
status = (int) bt_self_component_port_input_message_iterator_can_seek_beginning(
upstream_msg_iter->msg_iter, can_seek);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) {
goto end;
}
}
BT_HIDDEN
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
muxer_msg_iter_can_seek_beginning(
bt_self_message_iterator *self_msg_iter, bt_bool *can_seek)
{
struct muxer_msg_iter *muxer_msg_iter =
bt_self_message_iterator_get_data(self_msg_iter);
- bt_component_class_message_iterator_can_seek_beginning_method_status status;
+ bt_message_iterator_class_can_seek_beginning_method_status status;
status = muxer_upstream_msg_iters_can_all_seek_beginning(
muxer_msg_iter->active_muxer_upstream_msg_iters, can_seek);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) {
goto end;
}
}
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status muxer_msg_iter_seek_beginning(
+bt_message_iterator_class_seek_beginning_method_status muxer_msg_iter_seek_beginning(
bt_self_message_iterator *self_msg_iter)
{
struct muxer_msg_iter *muxer_msg_iter =
bt_self_message_iterator_get_data(self_msg_iter);
- bt_component_class_message_iterator_seek_beginning_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK;
+ bt_message_iterator_class_seek_beginning_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
bt_message_iterator_seek_beginning_status seek_beg_status;
uint64_t i;
void muxer_finalize(bt_self_component_filter *self_comp);
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init(
+bt_message_iterator_class_initialize_method_status muxer_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port);
BT_HIDDEN
bt_self_message_iterator *self_msg_iter);
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status muxer_msg_iter_next(
+bt_message_iterator_class_next_method_status muxer_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count);
const bt_port_output *other_port);
BT_HIDDEN
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
muxer_msg_iter_can_seek_beginning(
bt_self_message_iterator *message_iterator, bt_bool *can_seek);
BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status muxer_msg_iter_seek_beginning(
+bt_message_iterator_class_seek_beginning_method_status muxer_msg_iter_seek_beginning(
bt_self_message_iterator *message_iterator);
#endif /* BABELTRACE_PLUGINS_UTILS_MUXER_H */
bool is_gmt;
bt_logging_level log_level;
bt_self_component *self_comp;
+ bt_self_component_filter *self_comp_filter;
};
enum trimmer_iterator_state {
trimmer_comp->log_level = bt_component_get_logging_level(
bt_self_component_as_component(self_comp));
trimmer_comp->self_comp = self_comp;
+ trimmer_comp->self_comp_filter = self_comp_flt;
add_port_status = bt_self_component_filter_add_input_port(
self_comp_flt, in_port_name, NULL, NULL);
}
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_init(
+bt_message_iterator_class_initialize_method_status trimmer_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *port)
{
- bt_component_class_message_iterator_initialize_method_status status;
+ bt_message_iterator_class_initialize_method_status status;
bt_self_component_port_input_message_iterator_create_from_message_iterator_status
msg_iter_status;
struct trimmer_iterator *trimmer_it;
trimmer_it = g_new0(struct trimmer_iterator, 1);
if (!trimmer_it) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
- trimmer_it->trimmer_comp = bt_self_component_get_data(
- bt_self_component_filter_as_self_component(self_comp));
+ trimmer_it->trimmer_comp = bt_self_component_get_data(self_comp);
BT_ASSERT(trimmer_it->trimmer_comp);
if (trimmer_it->trimmer_comp->begin.is_set &&
bt_self_component_port_input_message_iterator_create_from_message_iterator(
self_msg_iter,
bt_self_component_filter_borrow_input_port_by_name(
- self_comp, in_port_name), &trimmer_it->upstream_iter);
+ trimmer_it->trimmer_comp->self_comp_filter, in_port_name),
+ &trimmer_it->upstream_iter);
if (msg_iter_status != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_OK) {
status = (int) msg_iter_status;
goto error;
trimmer_it->output_messages = g_queue_new();
if (!trimmer_it->output_messages) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
g_direct_equal, NULL,
(GDestroyNotify) destroy_trimmer_iterator_stream_state);
if (!trimmer_it->stream_states) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
trimmer_it->self_msg_iter = self_msg_iter;
bt_self_message_iterator_set_data(self_msg_iter, trimmer_it);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
goto end;
error:
}
static
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
state_set_trimmer_iterator_bounds(
struct trimmer_iterator *trimmer_it)
{
}
static
-bt_component_class_message_iterator_next_method_status state_seek_initially(
+bt_message_iterator_class_next_method_status state_seek_initially(
struct trimmer_iterator *trimmer_it)
{
struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp;
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
BT_ASSERT(trimmer_it->begin.is_set);
status = (int) bt_self_component_port_input_message_iterator_can_seek_beginning(
trimmer_it->upstream_iter, &can_seek);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
if (status < 0) {
BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
"Cannot make upstream message iterator initially seek its beginning.");
if (!can_seek) {
BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
"Cannot make upstream message iterator initially seek its beginning.");
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
trimmer_it->upstream_iter, trimmer_it->begin.ns_from_origin,
&can_seek);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
if (status < 0) {
BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
"Cannot make upstream message iterator initially seek: seek-ns-from-origin=%" PRId64,
BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
"Cannot make upstream message iterator initially seek: seek-ns-from-origin=%" PRId64,
trimmer_it->begin.ns_from_origin);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
trimmer_it->upstream_iter, trimmer_it->begin.ns_from_origin);
}
- if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
trimmer_it->state = TRIMMER_ITERATOR_STATE_TRIM;
}
}
static inline
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
end_stream(struct trimmer_iterator *trimmer_it,
struct trimmer_iterator_stream_state *sstate)
{
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
/* Initialize to silence maybe-uninitialized warning. */
uint64_t raw_value = 0;
bt_message *msg = NULL;
ret = clock_raw_value_from_ns_from_origin(clock_class,
trimmer_it->end.ns_from_origin, &raw_value);
if (ret) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
}
trimmer_it->self_msg_iter, sstate->cur_packet,
raw_value);
if (!msg) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
goto end;
}
msg = bt_message_stream_end_create(trimmer_it->self_msg_iter,
sstate->stream);
if (!msg) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
goto end;
}
}
static inline
-bt_component_class_message_iterator_next_method_status end_iterator_streams(
+bt_message_iterator_class_next_method_status end_iterator_streams(
struct trimmer_iterator *trimmer_it)
{
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
GHashTableIter iter;
gpointer key, sstate;
}
static
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
create_stream_state_entry(
struct trimmer_iterator *trimmer_it,
const struct bt_stream *stream,
struct trimmer_iterator_stream_state **stream_state)
{
struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp;
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
struct trimmer_iterator_stream_state *sstate;
const bt_stream_class *sc;
"stream-name=\"%s\"",
stream, bt_stream_get_id(stream),
bt_stream_get_name(stream));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
"stream-name=\"%s\"",
stream, bt_stream_get_id(stream),
bt_stream_get_name(stream));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
"stream-name=\"%s\"",
stream, bt_stream_get_id(stream),
bt_stream_get_name(stream));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
"stream-name=\"%s\"",
stream, bt_stream_get_id(stream),
bt_stream_get_name(stream));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
"stream-name=\"%s\"",
stream, bt_stream_get_id(stream),
bt_stream_get_name(stream));
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
sstate = g_new0(struct trimmer_iterator_stream_state, 1);
if (!sstate) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
goto end;
}
*stream_state = sstate;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
end:
return status;
* `reached_end`.
*/
static
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
handle_message_with_stream(
struct trimmer_iterator *trimmer_it, const bt_message *msg,
const struct bt_stream *stream, const int64_t *ns_from_origin,
bool *reached_end)
{
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
bt_message_type msg_type = bt_message_get_type(msg);
int ret;
struct trimmer_iterator_stream_state *sstate = NULL;
if (bt_clock_snapshot_get_ns_from_origin(end_cs,
&end_ns_from_origin)) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
ret = clock_raw_value_from_ns_from_origin(clock_class,
trimmer_it->end.ns_from_origin, &end_raw_value);
if (ret) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
}
if (!new_msg) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
goto end;
}
/* Learn about this stream. */
status = create_stream_state_entry(trimmer_it, stream, &sstate);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
* `reached_end`.
*/
static inline
-bt_component_class_message_iterator_next_method_status handle_message(
+bt_message_iterator_class_next_method_status handle_message(
struct trimmer_iterator *trimmer_it, const bt_message *msg,
bool *reached_end)
{
- bt_component_class_message_iterator_next_method_status status;
+ bt_message_iterator_class_next_method_status status;
const bt_stream *stream = NULL;
int64_t ns_from_origin = INT64_MIN;
bool has_ns_from_origin = false;
/* Retrieve the message's time */
ret = get_msg_ns_from_origin(msg, &ns_from_origin, &has_ns_from_origin);
if (G_UNLIKELY(ret)) {
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
goto end;
}
*reached_end = true;
} else {
push_message(trimmer_it, msg);
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
msg = NULL;
}
}
}
static inline
-bt_component_class_message_iterator_next_method_status state_ending(
+bt_message_iterator_class_next_method_status state_ending(
struct trimmer_iterator *trimmer_it,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
if (g_queue_is_empty(trimmer_it->output_messages)) {
trimmer_it->state = TRIMMER_ITERATOR_STATE_ENDED;
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
goto end;
}
}
static inline
-bt_component_class_message_iterator_next_method_status
+bt_message_iterator_class_next_method_status
state_trim(struct trimmer_iterator *trimmer_it,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
bt_message_array_const my_msgs;
uint64_t my_count;
uint64_t i;
while (g_queue_is_empty(trimmer_it->output_messages)) {
status = (int) bt_self_component_port_input_message_iterator_next(
trimmer_it->upstream_iter, &my_msgs, &my_count);
- if (G_UNLIKELY(status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK)) {
- if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END) {
+ if (G_UNLIKELY(status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK)) {
+ if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END) {
status = end_iterator_streams(trimmer_it);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
my_msgs[i] = NULL;
if (G_UNLIKELY(status !=
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK)) {
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK)) {
put_messages(my_msgs, my_count);
goto end;
}
}
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status trimmer_msg_iter_next(
+bt_message_iterator_class_next_method_status trimmer_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
struct trimmer_iterator *trimmer_it =
bt_self_message_iterator_get_data(self_msg_iter);
- bt_component_class_message_iterator_next_method_status status =
- BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
BT_ASSERT_DBG(trimmer_it);
if (G_LIKELY(trimmer_it->state == TRIMMER_ITERATOR_STATE_TRIM)) {
status = state_trim(trimmer_it, msgs, capacity, count);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
} else {
switch (trimmer_it->state) {
case TRIMMER_ITERATOR_STATE_SET_BOUNDS_NS_FROM_ORIGIN:
status = state_set_trimmer_iterator_bounds(trimmer_it);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
status = state_seek_initially(trimmer_it);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
status = state_trim(trimmer_it, msgs, capacity, count);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
break;
case TRIMMER_ITERATOR_STATE_SEEK_INITIALLY:
status = state_seek_initially(trimmer_it);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
status = state_trim(trimmer_it, msgs, capacity, count);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
case TRIMMER_ITERATOR_STATE_ENDING:
status = state_ending(trimmer_it, msgs, capacity,
count);
- if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
+ if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
goto end;
}
break;
case TRIMMER_ITERATOR_STATE_ENDED:
- status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
break;
default:
bt_common_abort();
const bt_value *params, void *init_data);
BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_init(
+bt_message_iterator_class_initialize_method_status trimmer_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *port);
BT_HIDDEN
-bt_component_class_message_iterator_next_method_status trimmer_msg_iter_next(
+bt_message_iterator_class_next_method_status trimmer_msg_iter_next(
bt_self_message_iterator *self_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count);
return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
}
-static bt_component_class_message_iterator_initialize_method_status
+static bt_message_iterator_class_initialize_method_status
src_dummy_iterator_init_method(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_source *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port)
{
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
}
-static bt_component_class_message_iterator_initialize_method_status
+static bt_message_iterator_class_initialize_method_status
flt_dummy_iterator_init_method(
bt_self_message_iterator *self_msg_iter,
bt_self_message_iterator_configuration *config,
- bt_self_component_filter *self_comp,
+ bt_self_component *self_comp,
bt_self_component_port_output *self_port)
{
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+ return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
}
static void dummy_iterator_finalize_method(
{
}
-static bt_component_class_message_iterator_next_method_status
+static bt_message_iterator_class_next_method_status
dummy_iterator_next_method(
bt_self_message_iterator *self_msg_iter,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
}
static bt_component_class_query_method_status flt_query_method(
};
static GArray *events;
+static bt_message_iterator_class *msg_iter_class;
static bt_component_class_source *src_comp_class;
static bt_component_class_sink *sink_comp_class;
static enum test current_test;
}
static
-bt_component_class_message_iterator_next_method_status src_iter_next(
+bt_message_iterator_class_next_method_status src_iter_next(
bt_self_message_iterator *self_iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
}
static
{
int ret;
+ msg_iter_class = bt_message_iterator_class_create(src_iter_next);
+ BT_ASSERT(msg_iter_class);
+
src_comp_class = bt_component_class_source_create(
- "src", src_iter_next);
+ "src", msg_iter_class);
BT_ASSERT(src_comp_class);
ret = bt_component_class_source_set_initialize_method(
src_comp_class, src_init);
}
static
-bt_component_class_message_iterator_next_method_status hello_iter_next(
+bt_message_iterator_class_next_method_status hello_iter_next(
bt_self_message_iterator *message_iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
BT_ASSERT(false);
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+ return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
}
int main(int argc, char **argv)
{
bt_graph *graph;
+ bt_message_iterator_class *msg_iter_cls;
bt_component_class_source *source_cc;
bt_component_class_set_method_status set_method_status;
bt_graph_add_component_status add_component_status;
plan_tests(NR_TESTS);
- source_cc = bt_component_class_source_create("Hello", hello_iter_next);
+ msg_iter_cls = bt_message_iterator_class_create(hello_iter_next);
+ BT_ASSERT(msg_iter_cls);
+
+ source_cc = bt_component_class_source_create("Hello", msg_iter_cls);
BT_ASSERT(source_cc);
set_method_status = bt_component_class_source_set_initialize_method(
bt_component_source_put_ref(source);
bt_component_class_source_put_ref(source_cc);
+ bt_message_iterator_class_put_ref(msg_iter_cls);
bt_graph_put_ref(graph);
return exit_status();
}
static
-bt_component_class_message_iterator_next_method_status src_iter_next(
+bt_message_iterator_class_next_method_status src_iter_next(
bt_self_message_iterator *message_iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END;
+ return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
}
static
bt_graph *create_graph_with_source(const bt_port_output **out_port)
{
+ bt_message_iterator_class *msg_iter_cls;
bt_component_class_source *src_comp_cls;
bt_graph *graph;
const bt_component_source *src_comp = NULL;
bt_component_class_set_method_status set_method_status;
BT_ASSERT(out_port);
- src_comp_cls = bt_component_class_source_create("src", src_iter_next);
+
+ msg_iter_cls = bt_message_iterator_class_create(src_iter_next);
+ BT_ASSERT(msg_iter_cls);
+
+ src_comp_cls = bt_component_class_source_create("src", msg_iter_cls);
BT_ASSERT(src_comp_cls);
set_method_status = bt_component_class_source_set_initialize_method(
src_comp_cls, src_init);
BT_ASSERT(*out_port);
bt_component_source_put_ref(src_comp);
bt_component_class_source_put_ref(src_comp_cls);
+ bt_message_iterator_class_put_ref(msg_iter_cls);
return graph;
}
}
static
-bt_component_class_message_iterator_next_method_status src_iter_next(
+bt_message_iterator_class_next_method_status src_iter_next(
bt_self_message_iterator *self_iterator,
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+ return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
}
static void test_example_scenario_in_graph(void)
{
+ bt_message_iterator_class *msg_iter_cls;
bt_component_class_source *comp_cls;
bt_graph *graph;
int ret;
- comp_cls = bt_component_class_source_create("src", src_iter_next);
+ msg_iter_cls = bt_message_iterator_class_create(src_iter_next);
+ BT_ASSERT(msg_iter_cls);
+
+ comp_cls = bt_component_class_source_create("src", msg_iter_cls);
BT_ASSERT(comp_cls);
ret = bt_component_class_source_set_initialize_method(comp_cls, src_init);
BT_ASSERT(ret == 0);
BT_ASSERT(ret == 0);
bt_graph_put_ref(graph);
bt_component_class_source_put_ref(comp_cls);
+ bt_message_iterator_class_put_ref(msg_iter_cls);
}
static void create_writer_user_full(struct writer_user *user)