Commit | Line | Data |
---|---|---|
81447b5b PP |
1 | /* |
2 | * The MIT License (MIT) | |
3 | * | |
4 | * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com> | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | ||
25 | %{ | |
26 | #include <babeltrace/component/notification/iterator.h> | |
27 | %} | |
28 | ||
29 | /* Type */ | |
30 | struct bt_notification_iterator; | |
31 | ||
32 | /* Status */ | |
33 | enum bt_notification_iterator_status { | |
34 | BT_NOTIFICATION_ITERATOR_STATUS_END = 1, | |
35 | BT_NOTIFICATION_ITERATOR_STATUS_OK = 0, | |
36 | BT_NOTIFICATION_ITERATOR_STATUS_INVAL = -1, | |
37 | BT_NOTIFICATION_ITERATOR_STATUS_ERROR = -2, | |
38 | BT_NOTIFICATION_ITERATOR_STATUS_NOMEM = -3, | |
39 | BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED = -4, | |
40 | }; | |
41 | ||
42 | /* Seek reference */ | |
43 | enum bt_notification_iterator_seek_origin { | |
44 | BT_NOTIFICATION_ITERATOR_SEEK_ORIGIN_BEGIN = 0, | |
45 | BT_NOTIFICATION_ITERATOR_SEEK_ORIGIN_CURRENT = 1, | |
46 | BT_NOTIFICATION_ITERATOR_SEEK_ORIGIN_END = 2, | |
47 | BT_NOTIFICATION_ITERATOR_SEEK_ORIGIN_EPOCH = 3, | |
48 | }; | |
49 | ||
50 | /* Functions */ | |
51 | struct bt_notification *bt_notification_iterator_get_notification( | |
52 | struct bt_notification_iterator *iterator); | |
53 | enum bt_notification_iterator_status bt_notification_iterator_next( | |
54 | struct bt_notification_iterator *iterator); | |
55 | enum bt_notification_iterator_status bt_notification_iterator_seek_time( | |
56 | struct bt_notification_iterator *iterator, | |
57 | enum bt_notification_iterator_seek_origin seek_origin, | |
58 | int64_t time); | |
59 | struct bt_component *bt_notification_iterator_get_component( | |
60 | struct bt_notification_iterator *iterator); | |
61 | enum bt_notification_iterator_status bt_notification_iterator_set_private_data( | |
62 | struct bt_notification_iterator *iterator, void *data); | |
63 | void *bt_notification_iterator_get_private_data( | |
64 | struct bt_notification_iterator *iterator); | |
65 | ||
66 | /* Helper functions for Python */ | |
67 | %{ | |
68 | static PyObject *bt_py3_get_component_from_notif_iter( | |
69 | struct bt_notification_iterator *iter) | |
70 | { | |
71 | struct bt_component *component = bt_notification_iterator_get_component(iter); | |
72 | PyObject *py_comp; | |
73 | ||
74 | assert(component); | |
75 | py_comp = bt_component_get_private_data(component); | |
76 | BT_PUT(component); | |
77 | assert(py_comp); | |
78 | ||
79 | /* Return new reference */ | |
80 | Py_INCREF(py_comp); | |
81 | return py_comp; | |
82 | } | |
83 | %} | |
84 | ||
85 | PyObject *bt_py3_get_component_from_notif_iter( | |
86 | struct bt_notification_iterator *iter); |