lib: simplify the public notification iterator interfaces
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 6 Jun 2018 20:52:03 +0000 (16:52 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:05:45 +0000 (00:05 -0400)
commit07245ac23157616e3f4ff611341f18193de8e37d
tree1bed16dc4866a26c08f6cfc8a5c86f315d89c6e6
parent26a157567b3ede2fa9e26a7f8d410aef32222be9
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.026659 seconds and 4 git commands to generate.