cpp-common/bt2: add `bt2::MessageIterator`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 1 Nov 2023 20:33:19 +0000 (16:33 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 14 Dec 2023 15:57:04 +0000 (10:57 -0500)
commitd9a27df87dad3d1d7727709b7515904b8860514b
treee6c9f6432992fe11007557ba9c50ea2600aa0802
parent7bdf11a1a672ad4e1416c9e9c075c7f4aa7e6421
cpp-common/bt2: add `bt2::MessageIterator`

This patch adds `bt2::MessageIterator` to wrap `bt_message_iterator`
objects.

`bt2::MessageIterator` offers:

component():
    Borrows the parent component of the message iterator.

next():
    Returns the next batch of messages.

    This method returns an optional message array: set if there are
    messages (`BT_MESSAGE_ITERATOR_NEXT_STATUS_OK`), or not set on end
    of iteration (`BT_MESSAGE_ITERATOR_NEXT_STATUS_END`).

    Throws otherwise.

    Example:

        if (const auto msgs = myMsgIter.next()) {
            for (const auto msg : *msgs) {
                if (msg.isEvent()) {
                    // ...
                }
            }
        } else {
            // This is the end, my only friend, the end
        }

canSeekBeginning():
    Wraps bt_message_iterator_can_seek_beginning().

seekBeginning():
    Wraps bt_message_iterator_seek_beginning().

canSeekNsFromOrigin():
    Wraps bt_message_iterator_can_seek_ns_from_origin().

seekNsFromOrigin():
    Wraps bt_message_iterator_seek_ns_from_origin().

canSeekForward():
    Wraps bt_message_iterator_can_seek_forward().

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifd16546ad56b237d62491fd17dd6cb180ca3edba
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11194
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
src/Makefile.am
src/cpp-common/bt2/exc.hpp
src/cpp-common/bt2/message-iterator.hpp [new file with mode: 0644]
This page took 0.025981 seconds and 4 git commands to generate.