src/plugins/ctf/common/src: add item sequence iterator API
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 17 Apr 2024 17:52:29 +0000 (13:52 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
commitb4a4f72504872d570f012f0fd0fb32919c883881
tree04f17bd70b4a735b25fdcca9f4dd85337455d567
parent619481cbc383fd7c2e0fb5cf795150e467d98302
src/plugins/ctf/common/src: add item sequence iterator API

This patch adds the item sequence iterator API, internal to the `ctf`
plugin, to be used by the source components (`src.ctf.fs`
and `src.ctf.lttng-live`).

An item sequence iterator can decode a sequence of packets using:

• A medium, which provides binary stream data to the iterator.
• A CTF IR trace class, which describes how to decode said data.

This makes it possible to completely decode CTF data streams without
ever needing to create trace IR objects. In other words, it's a
standalone CTF decoding library which, minus a few utilities borrowed
from the Babeltrace project, could even be reused in other projects.

The value of an item sequence iterator is an item. The item sequence
iterator doesn't actually create items as it advances: it has one
instance of each concrete item class and sets a pointer to one of those
as it advances (it's a single-pass input iterator).

Seek a specific packet beginning with the seekPkt() method.

Methods which make the iterator decode may append a cause to the error
of the current thread and throw `bt2c::Error`.

┌──────────────────────────────────────────────────────────────────────┐
│ NOTE: Currently, this isn't an STL-compliant iterator class: you     │
│ can't copy an instance and you can't get an end iterator, because    │
│ there's no item sequence (container) class (you need to check        │
│ whether or not the next() method returns `nullptr`). Also, the       │
│ typical STL type aliases such as `value` and `reference` aren't part │
│ of the class.                                                        │
└──────────────────────────────────────────────────────────────────────┘

This API and its implementation are inspired by the yactfr
(<https://github.com/eepp/yactfr>) element sequence iterator API,
conveniently written by the same author 😉.

Please read the class comments of `ctf::src::ItemSeqIter` and
`ctf::src::Medium` to learn how to use this API and how it
works internally.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I423cc934d2425331a09f16ba40fbeb6b5496ff3a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7966
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12256
src/Makefile.am
src/plugins/ctf/common/src/item-seq/item-seq-iter.cpp [new file with mode: 0644]
src/plugins/ctf/common/src/item-seq/item-seq-iter.hpp [new file with mode: 0644]
src/plugins/ctf/common/src/item-seq/item-visitor.cpp [new file with mode: 0644]
src/plugins/ctf/common/src/item-seq/item-visitor.hpp [new file with mode: 0644]
src/plugins/ctf/common/src/item-seq/item.cpp [new file with mode: 0644]
src/plugins/ctf/common/src/item-seq/item.hpp [new file with mode: 0644]
src/plugins/ctf/common/src/item-seq/medium.cpp [new file with mode: 0644]
src/plugins/ctf/common/src/item-seq/medium.hpp [new file with mode: 0644]
This page took 0.025912 seconds and 4 git commands to generate.