lib: simplify the public notification iterator interfaces
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 6 Jun 2018 20:52:03 +0000 (16:52 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:34 +0000 (18:19 -0400)
commit94a96686f6ecb39b08e1afd636995f7e1c5ed13c
tree09c189b5c0cac11033a553b7497bfb7b2abb6371
parentf8cd6131bdbdcd86779a15226163a849f9e92370
lib: simplify the public notification iterator interfaces

Simplify the public notification iterator interfaces so as to remove:

* bt_notification_iterator_borrow_notification()
* bt_notification_iterator_get_notification()
* bt_notification_iterator_next()

in favor of:

    enum bt_notification_iterator_status
    bt_output_port_notification_iterator_next(struct
        bt_notification_iterator *iterator,
        struct bt_notification **notification);

    enum bt_notification_iterator_status
    bt_private_connection_notification_iterator_next(
        struct bt_notification_iterator *iterator,
        struct bt_notification **notification);

Those two new functions:

* Move the notification received from the user method to the
  `notification` output variable directly without modifying the
  reference count.

* Do not need to check the notification iterator type of notification to
  perform the appropriate specific operation and have precondition
  checks to ensure `iterator` has the right type.

This API is also in line with some popular iterator interfaces where the
"next" function returns the iteration status and the element at the same
time, for example:

* g_hash_table_iter_next()
* Python's next()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
13 files changed:
include/babeltrace/graph/notification-iterator-internal.h
include/babeltrace/graph/notification-iterator.h
include/babeltrace/graph/output-port-notification-iterator.h
include/babeltrace/graph/private-connection-notification-iterator.h
lib/graph/component-class-sink-colander.c
lib/graph/iterator.c
lib/lib-logging.c
plugins/text/pretty/pretty.c
plugins/utils/counter/counter.c
plugins/utils/dummy/dummy.c
plugins/utils/muxer/muxer.c
tests/lib/test_bt_notification_iterator.c
tests/plugins/test-utils-muxer.c
This page took 0.026264 seconds and 4 git commands to generate.