X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bindings%2Fpython%2Freader.py;h=3b5374f505add9a27c60c25ed5c16cf329b8dc01;hb=9b93351a50fa730a8e0676521b0d036f981960da;hp=ab0b2c3e967a024961aa96adac9003ec11182b4a;hpb=8200883463ae0329f8f5053d898614fd5051abc3;p=babeltrace.git diff --git a/bindings/python/reader.py b/bindings/python/reader.py index ab0b2c3e..3b5374f5 100644 --- a/bindings/python/reader.py +++ b/bindings/python/reader.py @@ -45,12 +45,13 @@ class TraceCollection: trace from a trace collection. """ - def __init__(self): + def __init__(self, intersect_mode=False): """ Creates an empty trace collection. """ self._tc = nbt._bt_context_create() + self.intersect_mode = intersect_mode def __del__(self): nbt._bt_context_put(self._tc) @@ -147,8 +148,10 @@ class TraceCollection: begin_pos_ptr = nbt._bt_python_create_iter_pos() end_pos_ptr = nbt._bt_python_create_iter_pos() - begin_pos_ptr.type = nbt.SEEK_BEGIN - end_pos_ptr.type = nbt.SEEK_LAST + + if not self.intersect_mode: + begin_pos_ptr.type = nbt.SEEK_BEGIN + end_pos_ptr.type = nbt.SEEK_LAST for event in self._events(begin_pos_ptr, end_pos_ptr): yield event @@ -219,7 +222,19 @@ class TraceCollection: return ev.timestamp def _events(self, begin_pos_ptr, end_pos_ptr): - ctf_it_ptr = nbt._bt_ctf_iter_create(self._tc, begin_pos_ptr, end_pos_ptr) + if self.intersect_mode: + has_intersection = nbt._bt_python_has_intersection(self._tc) + if not has_intersection: + # There are no events to provide. + return + + ctf_it_ptr = nbt._bt_python_ctf_iter_create_intersect( + self._tc, begin_pos_ptr, end_pos_ptr + ) + else: + ctf_it_ptr = nbt._bt_ctf_iter_create( + self._tc, begin_pos_ptr, end_pos_ptr + ) if ctf_it_ptr is None: raise NotImplementedError("Creation of multiple iterators is unsupported.")