X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fmessage%2Fiterator.h;h=894a914cb68613cde5eeba2792c46225374af0f9;hb=a3f0c7db90f4cfc81090a83a7442b7bc624d5789;hp=36795bd083baa4e7902ada7a788d87604e37a3c7;hpb=54b135a0370e1ff40ff39515058b2f941955cd40;p=babeltrace.git diff --git a/src/lib/graph/message/iterator.h b/src/lib/graph/message/iterator.h index 36795bd0..894a914c 100644 --- a/src/lib/graph/message/iterator.h +++ b/src/lib/graph/message/iterator.h @@ -28,20 +28,14 @@ #include "lib/object.h" #include #include -#include #include #include "common/assert.h" #include -#include +#include "common/uuid.h" struct bt_port; struct bt_graph; -enum bt_message_iterator_type { - BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT, - BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT, -}; - enum bt_self_component_port_input_message_iterator_state { /* Iterator is not initialized */ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED, @@ -71,44 +65,70 @@ enum bt_self_component_port_input_message_iterator_state { BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, }; -struct bt_message_iterator { - struct bt_object base; - enum bt_message_iterator_type type; - GPtrArray *msgs; -}; - -typedef enum bt_self_message_iterator_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_self_message_iterator_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_self_message_iterator_status +typedef enum bt_message_iterator_class_seek_beginning_method_status (*bt_self_component_port_input_message_iterator_seek_beginning_method)( void *); -typedef bt_bool +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); + void *, int64_t, bt_bool *); -typedef bt_bool +typedef enum bt_message_iterator_class_can_seek_beginning_method_status (*bt_self_component_port_input_message_iterator_can_seek_beginning_method)( - void *); + void *, bt_bool *); + +struct bt_self_message_iterator_configuration { + bool frozen; + bool can_seek_forward; +}; struct bt_self_component_port_input_message_iterator { - struct bt_message_iterator base; + struct bt_object base; + GPtrArray *msgs; struct bt_component *upstream_component; /* Weak */ struct bt_port *upstream_port; /* Weak */ struct bt_connection *connection; /* Weak */ struct bt_graph *graph; /* Weak */ + struct bt_self_message_iterator_configuration config; + + /* + * Array of + * `struct bt_self_component_port_input_message_iterator *` + * (weak). + * + * This is an array of upstream message iterators on which this + * iterator depends. The references are weak: an upstream + * message iterator is responsible for removing its entry within + * this array on finalization/destruction. + */ + GPtrArray *upstream_msg_iters; + + /* + * Downstream message iterator which depends on this message + * iterator (weak). + * + * This can be `NULL` if this message iterator's owner is a sink + * component. + */ + struct bt_self_component_port_input_message_iterator *downstream_msg_iter; struct { bt_self_component_port_input_message_iterator_next_method next; + + /* These two are always both set or both unset. */ bt_self_component_port_input_message_iterator_seek_ns_from_origin_method seek_ns_from_origin; - bt_self_component_port_input_message_iterator_seek_beginning_method seek_beginning; bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method can_seek_ns_from_origin; + + /* These two are always both set or both unset. */ + bt_self_component_port_input_message_iterator_seek_beginning_method seek_beginning; bt_self_component_port_input_message_iterator_can_seek_beginning_method can_seek_beginning; } methods; @@ -145,7 +165,7 @@ struct bt_self_component_port_input_message_iterator { * irrelevant (as the clock will be correlatable with other * clocks having the same origin). */ - uint8_t uuid[BABELTRACE_UUID_LEN]; + bt_uuid_t uuid; } clock_expectation; /* @@ -179,18 +199,6 @@ struct bt_self_component_port_input_message_iterator { void *user_data; }; -struct bt_port_output_message_iterator { - struct bt_message_iterator base; - struct bt_graph *graph; /* Owned by this */ - struct bt_component_sink *colander; /* Owned by this */ - - /* - * Only used temporarily as a bridge between a colander sink and - * the user. - */ - uint64_t count; -}; - BT_HIDDEN void bt_self_component_port_input_message_iterator_try_finalize( struct bt_self_component_port_input_message_iterator *iterator); @@ -206,19 +214,19 @@ const char *bt_self_component_port_input_message_iterator_state_string( { switch (state) { case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE"; + return "ACTIVE"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED"; + return "ENDED"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING"; + return "FINALIZING"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED"; + return "FINALIZED"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING"; + return "SEEKING"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN"; + return "LAST_SEEKING_RETURNED_AGAIN"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR"; + return "LAST_SEEKING_RETURNED_ERROR"; default: return "(unknown)"; }