- return bt2.message._create_from_ptr(msg_ptr)
-
-
-# This is created when a component wants to iterate on one of its input ports.
-class _UserComponentInputPortMessageIterator(_GenericMessageIterator):
- _get_msg_range = staticmethod(native_bt.py3_self_component_port_input_get_msg_range)
- _get_ref = staticmethod(native_bt.self_component_port_input_message_iterator_get_ref)
- _put_ref = staticmethod(native_bt.self_component_port_input_message_iterator_put_ref)
-
-
-# This is created when the user wants to iterate on a component's output port,
-# from outside the graph.
-class _OutputPortMessageIterator(_GenericMessageIterator):
- _get_msg_range = staticmethod(native_bt.py3_port_output_get_msg_range)
- _get_ref = staticmethod(native_bt.port_output_message_iterator_get_ref)
- _put_ref = staticmethod(native_bt.port_output_message_iterator_put_ref)
+ return bt2_message._create_from_ptr(msg_ptr)
+
+ def can_seek_beginning(self):
+ status, res = native_bt.self_component_port_input_message_iterator_can_seek_beginning(
+ self._ptr
+ )
+ utils._handle_func_status(
+ status,
+ 'cannot check whether or not message iterator can seek its beginning',
+ )
+ return res != 0
+
+ def seek_beginning(self):
+ # Forget about buffered messages, they won't be valid after seeking.
+ self._current_msgs.clear()
+ self._at = 0
+
+ status = native_bt.self_component_port_input_message_iterator_seek_beginning(
+ self._ptr
+ )
+ utils._handle_func_status(status, 'cannot seek message iterator beginning')
+
+ def can_seek_ns_from_origin(self, ns_from_origin):
+ utils._check_int64(ns_from_origin)
+ status, res = native_bt.self_component_port_input_message_iterator_can_seek_ns_from_origin(
+ self._ptr, ns_from_origin
+ )
+ utils._handle_func_status(
+ status,
+ 'cannot check whether or not message iterator can seek given ns from origin',
+ )
+ return res != 0
+
+ def seek_ns_from_origin(self, ns_from_origin):
+ utils._check_int64(ns_from_origin)
+
+ # Forget about buffered messages, they won't be valid after seeking.
+ self._current_msgs.clear()
+ self._at = 0
+
+ status = native_bt.self_component_port_input_message_iterator_seek_ns_from_origin(
+ self._ptr, ns_from_origin
+ )
+ utils._handle_func_status(
+ status, 'message iterator cannot seek given ns from origin'
+ )