Commit | Line | Data |
---|---|---|
43de0e13 JG |
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 | ||
30d619df | 33 | #include <babeltrace/plugin/notification/notification.h> |
fec2a9f2 | 34 | #include <stdint.h> |
30d619df | 35 | |
43de0e13 JG |
36 | #ifdef __cplusplus |
37 | extern "C" { | |
38 | #endif | |
39 | ||
2bd8a567 | 40 | struct bt_notification; |
47e5a032 JG |
41 | struct bt_notification_iterator; |
42 | struct bt_component; | |
38b48196 | 43 | struct bt_component_factory; |
7c7c0433 | 44 | struct bt_value; |
38b48196 JG |
45 | |
46 | typedef enum bt_component_status (*bt_plugin_init_func)( | |
47 | struct bt_component_factory *factory); | |
48 | typedef void (*bt_plugin_exit_func)(void); | |
2bd8a567 | 49 | |
43de0e13 | 50 | /** |
633edee0 | 51 | * Component private data deallocation function type. |
43de0e13 | 52 | * |
760051fa | 53 | * @param component Component instance |
43de0e13 | 54 | */ |
760051fa | 55 | typedef void (*bt_component_destroy_cb)(struct bt_component *component); |
43de0e13 | 56 | |
2bd8a567 | 57 | /** |
38b48196 | 58 | * Component initialization function type. |
8738a040 | 59 | * |
38b48196 JG |
60 | * A component's private data and required callbacks must be set by this |
61 | * function. | |
2bd8a567 | 62 | * |
633edee0 | 63 | * @param component Component instance |
7c7c0433 | 64 | * @param params A dictionary of component parameters |
480dc8ed | 65 | * @returns One of #bt_component_status values |
2bd8a567 | 66 | */ |
38b48196 | 67 | typedef enum bt_component_status (*bt_component_init_cb)( |
7c7c0433 | 68 | struct bt_component *component, struct bt_value *params); |
8738a040 | 69 | |
8738a040 JG |
70 | /** |
71 | * Get a component's private data. | |
72 | * | |
73 | * @param component Component of which to get the private data | |
74 | * @returns Component's private data | |
75 | */ | |
76 | extern void *bt_component_get_private_data(struct bt_component *component); | |
47e5a032 | 77 | |
8738a040 JG |
78 | /** |
79 | * Set a component's private data. | |
80 | * | |
81 | * @param component Component of which to set the private data | |
82 | * @param data Component private data | |
83 | * @returns One of #bt_component_status values | |
84 | */ | |
85 | extern enum bt_component_status bt_component_set_private_data( | |
86 | struct bt_component *component, void *data); | |
87 | ||
88 | /** | |
89 | * Set a component's private data cleanup function. | |
90 | * | |
91 | * @param component Component of which to set the private data destruction | |
92 | * function | |
93 | * @param data Component private data clean-up function | |
94 | * @returns One of #bt_component_status values | |
95 | */ | |
96 | extern enum bt_component_status bt_component_set_destroy_cb( | |
97 | struct bt_component *component, | |
98 | bt_component_destroy_cb destroy); | |
99 | ||
100 | /** bt_component_souce */ | |
101 | /** | |
102 | * Iterator initialization function type. | |
103 | * | |
104 | * A notification iterator's private data, deinitialization, next, and get | |
105 | * callbacks must be set by this function. | |
106 | * | |
30d619df | 107 | * @param source Source component instance |
8738a040 JG |
108 | * @param iterator Notification iterator instance |
109 | */ | |
110 | typedef enum bt_component_status (*bt_component_source_init_iterator_cb)( | |
30d619df | 111 | struct bt_component *, struct bt_notification_iterator *); |
2bd8a567 | 112 | |
8738a040 JG |
113 | /** |
114 | * Set a source component's iterator initialization function. | |
115 | * | |
30d619df | 116 | * @param source Source component instance |
8738a040 JG |
117 | * @param init_iterator Notification iterator initialization callback |
118 | */ | |
119 | extern enum bt_component_status | |
30d619df | 120 | bt_component_source_set_iterator_init_cb(struct bt_component *source, |
8738a040 JG |
121 | bt_component_source_init_iterator_cb init_iterator); |
122 | ||
123 | /** bt_component_sink */ | |
2bd8a567 | 124 | /** |
fec2a9f2 | 125 | * Notification consumption function type. |
2bd8a567 | 126 | * |
fec2a9f2 JG |
127 | * @param sink Sink component instance |
128 | * @returns One of #bt_component_status values | |
129 | */ | |
130 | typedef enum bt_component_status (*bt_component_sink_consume_cb)( | |
131 | struct bt_component *); | |
132 | ||
133 | /** | |
134 | * Iterator addition function type. | |
135 | * | |
136 | * A sink component may choose to refuse the addition of an iterator | |
137 | * by not returning BT_COMPONENT_STATUS_OK. | |
0dfd8ee4 | 138 | * |
30d619df | 139 | * @param sink Sink component instance |
633edee0 | 140 | * @returns One of #bt_component_status values |
2bd8a567 | 141 | */ |
fec2a9f2 JG |
142 | typedef enum bt_component_status (*bt_component_sink_add_iterator_cb)( |
143 | struct bt_component *, struct bt_notification_iterator *); | |
2bd8a567 | 144 | |
8738a040 | 145 | /** |
fec2a9f2 | 146 | * Set a sink component's consumption callback. |
8738a040 | 147 | * |
fec2a9f2 JG |
148 | * @param sink Sink component instance |
149 | * @param consume Consumption callback | |
150 | * @returns One of #bt_component_status values | |
8738a040 JG |
151 | */ |
152 | extern enum bt_component_status | |
fec2a9f2 JG |
153 | bt_component_sink_set_consume_cb(struct bt_component *sink, |
154 | bt_component_sink_consume_cb consume); | |
8738a040 | 155 | |
30d619df | 156 | /** |
fec2a9f2 | 157 | * Set a sink component's iterator addition callback. |
30d619df | 158 | * |
fec2a9f2 JG |
159 | * @param sink Sink component instance |
160 | * @param add_iterator Iterator addition callback | |
161 | * @returns One of #bt_component_status values | |
30d619df JG |
162 | */ |
163 | extern enum bt_component_status | |
fec2a9f2 JG |
164 | bt_component_sink_set_add_iterator_cb(struct bt_component *sink, |
165 | bt_component_sink_add_iterator_cb add_iterator); | |
166 | ||
167 | /* Defaults to 1. */ | |
168 | extern enum bt_component_status | |
169 | bt_component_sink_set_minimum_input_count(struct bt_component *sink, | |
170 | unsigned int minimum); | |
171 | ||
172 | /* Defaults to 1. */ | |
173 | extern enum bt_component_status | |
174 | bt_component_sink_set_maximum_input_count(struct bt_component *sink, | |
175 | unsigned int maximum); | |
176 | ||
177 | extern enum bt_component_status | |
178 | bt_component_sink_get_input_count(struct bt_component *sink, | |
179 | unsigned int *count); | |
180 | ||
181 | /* May return NULL after an interator has reached its end. */ | |
182 | extern enum bt_component_status | |
183 | bt_component_sink_get_input_iterator(struct bt_component *sink, | |
184 | unsigned int input, struct bt_notification_iterator **iterator); | |
30d619df | 185 | |
fec2a9f2 | 186 | /** bt_notification_iterator */ |
8738a040 JG |
187 | /** |
188 | * Function returning an iterator's current notification. | |
189 | * | |
190 | * @param iterator Notification iterator instance | |
191 | * @returns A notification instance | |
192 | */ | |
47e5a032 | 193 | typedef struct bt_notification *(*bt_notification_iterator_get_cb)( |
8738a040 | 194 | struct bt_notification_iterator *iterator); |
2bd8a567 | 195 | |
8738a040 | 196 | /** |
d97bac96 | 197 | * Function advancing an iterator's position of one element. |
8738a040 JG |
198 | * |
199 | * @param iterator Notification iterator instance | |
200 | * @returns One of #bt_notification_iterator_status values | |
201 | */ | |
47e5a032 | 202 | typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb)( |
8738a040 | 203 | struct bt_notification_iterator *iterator); |
2bd8a567 | 204 | |
43de0e13 | 205 | /** |
8738a040 | 206 | * Function cleaning-up an iterator's private data on destruction. |
43de0e13 | 207 | * |
8738a040 | 208 | * @param iterator Notification iterator instance |
43de0e13 | 209 | */ |
8738a040 JG |
210 | typedef void (*bt_notification_iterator_destroy_cb)( |
211 | struct bt_notification_iterator *iterator); | |
43de0e13 | 212 | |
d97bac96 JG |
213 | /** |
214 | * Set an iterator's "get" callback which return the current notification. | |
215 | * | |
216 | * @param iterator Notification iterator instance | |
217 | * @param get Notification return callback | |
218 | * @returns One of #bt_notification_iterator_status values | |
219 | */ | |
47e5a032 JG |
220 | extern enum bt_notification_iterator_status |
221 | bt_notification_iterator_set_get_cb(struct bt_notification_iterator *iterator, | |
222 | bt_notification_iterator_get_cb get); | |
223 | ||
d97bac96 JG |
224 | /** |
225 | * Set an iterator's "next" callback which advances the iterator's position. | |
226 | * | |
227 | * @param iterator Notification iterator instance | |
228 | * @param next Iterator "next" callback | |
229 | * @returns One of #bt_notification_iterator_status values | |
230 | */ | |
47e5a032 JG |
231 | extern enum bt_notification_iterator_status |
232 | bt_notification_iterator_set_next_cb(struct bt_notification_iterator *iterator, | |
233 | bt_notification_iterator_next_cb next); | |
234 | ||
d97bac96 JG |
235 | /** |
236 | * Set an iterator's "destroy" callback. | |
237 | * | |
238 | * @param iterator Notification iterator instance | |
239 | * @param next Iterator destruction callback | |
240 | * @returns One of #bt_notification_iterator_status values | |
241 | */ | |
8738a040 JG |
242 | extern enum bt_notification_iterator_status |
243 | bt_notification_iterator_set_destroy_cb( | |
244 | struct bt_notification_iterator *iterator, | |
245 | bt_notification_iterator_destroy_cb destroy); | |
246 | ||
d97bac96 JG |
247 | /** |
248 | * Set an iterator's private data. | |
249 | * | |
250 | * @param iterator Notification iterator instance | |
251 | * @param data Iterator private data | |
252 | * @returns One of #bt_notification_iterator_status values | |
253 | */ | |
47e5a032 JG |
254 | extern enum bt_notification_iterator_status |
255 | bt_notification_iterator_set_private_data( | |
256 | struct bt_notification_iterator *iterator, void *data); | |
257 | ||
d97bac96 | 258 | /** |
448143d9 | 259 | * Get an iterator's private data. |
d97bac96 JG |
260 | * |
261 | * @param iterator Notification iterator instance | |
262 | * @returns Iterator instance private data | |
263 | */ | |
47e5a032 JG |
264 | extern void *bt_notification_iterator_get_private_data( |
265 | struct bt_notification_iterator *iterator); | |
266 | ||
43de0e13 JG |
267 | #ifdef __cplusplus |
268 | } | |
269 | #endif | |
270 | ||
271 | #endif /* BABELTRACE_PLUGIN_SYSTEM_H */ |