bt2: let Python message iterators implement seek beginning
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 27 Jun 2019 03:33:58 +0000 (23:33 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 2 Jul 2019 15:57:01 +0000 (11:57 -0400)
commitf00b8d402364ed0b77c45a61467c1d27690222f7
tree28f5d433e3f47def6edb2d1e2551eb9f0e7fc39f
parentf137d351487bd035362dd50c8006af107db0e750
bt2: let Python message iterators implement seek beginning

This patch adds the possibility for message iterators implemented in
Python to implement the "can seek beginning" and "seek beginning"
operations.

A message iterator can support "seek beginning" by defining a
_seek_beginning method:

  class MyIter(bt2._UserMessageIterator):
    def _seek_beginning(self):
      # Do the needful.

It can support the "can seek beginning" operation by defining a
_can_seek_beginning property, which must evaluate to a bool:

  class MyIter(bt2._UserMessageIterator):
    @property
    def _can_seek_beginning(self):
      # Do the needful, including returning a bool.

The behavior of the "can seek beginning" operation is made to mimic
the C API:

- If the iterator has a _can_seek_beginning attribute, it is used to
  determine whether the iterator can seek beginning.
- Otherwise, the presence or absence of a _seek_beginning method
  indicates whether it can.

Change-Id: I68c48b5cd30090bff833529cda9fa918c7e72b0b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1555
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/native_bt_component_class.i
tests/bindings/python/bt2/test_message_iterator.py
This page took 0.024748 seconds and 4 git commands to generate.