| 1 | #ifndef BABELTRACE_PLUGIN_SYSTEM_H |
| 2 | #define BABELTRACE_PLUGIN_SYSTEM_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace - Babeltrace Plug-in System Interface |
| 6 | * |
| 7 | * This interface is provided for plug-ins to use the Babeltrace |
| 8 | * plug-in system facilities. |
| 9 | * |
| 10 | * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 11 | * |
| 12 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 13 | * |
| 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 15 | * of this software and associated documentation files (the "Software"), to deal |
| 16 | * in the Software without restriction, including without limitation the rights |
| 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 18 | * copies of the Software, and to permit persons to whom the Software is |
| 19 | * furnished to do so, subject to the following conditions: |
| 20 | * |
| 21 | * The above copyright notice and this permission notice shall be included in |
| 22 | * all copies or substantial portions of the Software. |
| 23 | * |
| 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 30 | * SOFTWARE. |
| 31 | */ |
| 32 | |
| 33 | #ifdef __cplusplus |
| 34 | extern "C" { |
| 35 | #endif |
| 36 | |
| 37 | struct bt_notification; |
| 38 | struct bt_notification_iterator; |
| 39 | struct bt_component; |
| 40 | |
| 41 | /** |
| 42 | * Component private data deallocation function type. |
| 43 | * |
| 44 | * @param component Component instance |
| 45 | */ |
| 46 | typedef void (*bt_component_destroy_cb)(struct bt_component *component); |
| 47 | |
| 48 | /** |
| 49 | * Source component initialization function type. |
| 50 | * |
| 51 | * A source component's iterator initialization callback, private data and |
| 52 | * deinitialization callback must be set by this function. |
| 53 | * |
| 54 | * @param component Component instance |
| 55 | * @returns One of #bt_component_status values |
| 56 | */ |
| 57 | typedef enum bt_component_status (*bt_component_source_init_cb)( |
| 58 | struct bt_component *component); |
| 59 | |
| 60 | /** |
| 61 | * Sink component initialization function type. |
| 62 | * |
| 63 | * A sink component's notification handling callback, private data and |
| 64 | * deinitialization callback must be set by this function. |
| 65 | * |
| 66 | * @param component Component instance |
| 67 | * @returns One of #bt_component_status values |
| 68 | */ |
| 69 | typedef enum bt_component_status (*bt_component_sink_init_cb)( |
| 70 | struct bt_component *component); |
| 71 | |
| 72 | /** |
| 73 | * Iterator initialization function type. |
| 74 | * |
| 75 | * @param component Component instance |
| 76 | * @param iterator Iterator instance |
| 77 | */ |
| 78 | typedef enum bt_component_status (*bt_component_source_iterator_init_cb)( |
| 79 | struct bt_component *component, |
| 80 | struct bt_notification_iterator *iterator); |
| 81 | |
| 82 | /** |
| 83 | * Get a component's private data. |
| 84 | * |
| 85 | * @param component Component of which to get the private data |
| 86 | * @returns Component's private data |
| 87 | */ |
| 88 | extern void *bt_component_get_private_data(struct bt_component *component); |
| 89 | |
| 90 | /** |
| 91 | * Set a component's private data. |
| 92 | * |
| 93 | * @param component Component of which to set the private data |
| 94 | * @param data Component private data |
| 95 | * @returns One of #bt_component_status values |
| 96 | */ |
| 97 | extern enum bt_component_status bt_component_set_private_data( |
| 98 | struct bt_component *component, void *data); |
| 99 | |
| 100 | /** |
| 101 | * Set a component's private data cleanup function. |
| 102 | * |
| 103 | * @param component Component of which to set the private data destruction |
| 104 | * function |
| 105 | * @param data Component private data clean-up function |
| 106 | * @returns One of #bt_component_status values |
| 107 | */ |
| 108 | extern enum bt_component_status bt_component_set_destroy_cb( |
| 109 | struct bt_component *component, |
| 110 | bt_component_destroy_cb destroy); |
| 111 | |
| 112 | /** bt_component_souce */ |
| 113 | /** |
| 114 | * Iterator initialization function type. |
| 115 | * |
| 116 | * A notification iterator's private data, deinitialization, next, and get |
| 117 | * callbacks must be set by this function. |
| 118 | * |
| 119 | * @param component Component instance |
| 120 | * @param iterator Notification iterator instance |
| 121 | */ |
| 122 | typedef enum bt_component_status (*bt_component_source_init_iterator_cb)( |
| 123 | struct bt_component *component, |
| 124 | struct bt_notification_iterator *iterator); |
| 125 | |
| 126 | /** |
| 127 | * Set a source component's iterator initialization function. |
| 128 | * |
| 129 | * @param component Component instance |
| 130 | * @param init_iterator Notification iterator initialization callback |
| 131 | */ |
| 132 | extern enum bt_component_status |
| 133 | bt_component_source_set_iterator_init_cb(struct bt_component *component, |
| 134 | bt_component_source_init_iterator_cb init_iterator); |
| 135 | |
| 136 | /** bt_component_sink */ |
| 137 | /** |
| 138 | * Notification handling function type. |
| 139 | * |
| 140 | * @param component Component instance |
| 141 | * @param notificattion Notification to handle |
| 142 | * @returns One of #bt_component_status values |
| 143 | */ |
| 144 | typedef enum bt_component_status (*bt_component_sink_handle_notification_cb)( |
| 145 | struct bt_component *, struct bt_notification *); |
| 146 | |
| 147 | /** |
| 148 | * Set a sink component's notification handling callback. |
| 149 | * |
| 150 | * @param component Component instance |
| 151 | * @param handle_notification Notification handling callback |
| 152 | * @returns One of #bt_component_status values |
| 153 | */ |
| 154 | extern enum bt_component_status |
| 155 | bt_component_sink_set_handle_notification_cb(struct bt_component *component, |
| 156 | bt_component_sink_handle_notification_cb handle_notification); |
| 157 | |
| 158 | /** bt_component_notification_iterator */ |
| 159 | /** |
| 160 | * Function returning an iterator's current notification. |
| 161 | * |
| 162 | * @param iterator Notification iterator instance |
| 163 | * @returns A notification instance |
| 164 | */ |
| 165 | typedef struct bt_notification *(*bt_notification_iterator_get_cb)( |
| 166 | struct bt_notification_iterator *iterator); |
| 167 | |
| 168 | /** |
| 169 | * Function advancing an iterator's position of one element. |
| 170 | * |
| 171 | * @param iterator Notification iterator instance |
| 172 | * @returns One of #bt_notification_iterator_status values |
| 173 | */ |
| 174 | typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb)( |
| 175 | struct bt_notification_iterator *iterator); |
| 176 | |
| 177 | /** |
| 178 | * Function cleaning-up an iterator's private data on destruction. |
| 179 | * |
| 180 | * @param iterator Notification iterator instance |
| 181 | */ |
| 182 | typedef void (*bt_notification_iterator_destroy_cb)( |
| 183 | struct bt_notification_iterator *iterator); |
| 184 | |
| 185 | /** |
| 186 | * Set an iterator's "get" callback which return the current notification. |
| 187 | * |
| 188 | * @param iterator Notification iterator instance |
| 189 | * @param get Notification return callback |
| 190 | * @returns One of #bt_notification_iterator_status values |
| 191 | */ |
| 192 | extern enum bt_notification_iterator_status |
| 193 | bt_notification_iterator_set_get_cb(struct bt_notification_iterator *iterator, |
| 194 | bt_notification_iterator_get_cb get); |
| 195 | |
| 196 | /** |
| 197 | * Set an iterator's "next" callback which advances the iterator's position. |
| 198 | * |
| 199 | * @param iterator Notification iterator instance |
| 200 | * @param next Iterator "next" callback |
| 201 | * @returns One of #bt_notification_iterator_status values |
| 202 | */ |
| 203 | extern enum bt_notification_iterator_status |
| 204 | bt_notification_iterator_set_next_cb(struct bt_notification_iterator *iterator, |
| 205 | bt_notification_iterator_next_cb next); |
| 206 | |
| 207 | /** |
| 208 | * Set an iterator's "destroy" callback. |
| 209 | * |
| 210 | * @param iterator Notification iterator instance |
| 211 | * @param next Iterator destruction callback |
| 212 | * @returns One of #bt_notification_iterator_status values |
| 213 | */ |
| 214 | extern enum bt_notification_iterator_status |
| 215 | bt_notification_iterator_set_destroy_cb( |
| 216 | struct bt_notification_iterator *iterator, |
| 217 | bt_notification_iterator_destroy_cb destroy); |
| 218 | |
| 219 | /** |
| 220 | * Set an iterator's private data. |
| 221 | * |
| 222 | * @param iterator Notification iterator instance |
| 223 | * @param data Iterator private data |
| 224 | * @returns One of #bt_notification_iterator_status values |
| 225 | */ |
| 226 | extern enum bt_notification_iterator_status |
| 227 | bt_notification_iterator_set_private_data( |
| 228 | struct bt_notification_iterator *iterator, void *data); |
| 229 | |
| 230 | /** |
| 231 | * Gett an iterator's private data. |
| 232 | * |
| 233 | * @param iterator Notification iterator instance |
| 234 | * @returns Iterator instance private data |
| 235 | */ |
| 236 | extern void *bt_notification_iterator_get_private_data( |
| 237 | struct bt_notification_iterator *iterator); |
| 238 | |
| 239 | #ifdef __cplusplus |
| 240 | } |
| 241 | #endif |
| 242 | |
| 243 | #endif /* BABELTRACE_PLUGIN_SYSTEM_H */ |