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 JG |
33 | #include <babeltrace/plugin/notification/notification.h> |
34 | ||
43de0e13 JG |
35 | #ifdef __cplusplus |
36 | extern "C" { | |
37 | #endif | |
38 | ||
2bd8a567 | 39 | struct bt_notification; |
47e5a032 JG |
40 | struct bt_notification_iterator; |
41 | struct bt_component; | |
38b48196 | 42 | struct bt_component_factory; |
7c7c0433 | 43 | struct bt_value; |
38b48196 JG |
44 | |
45 | typedef enum bt_component_status (*bt_plugin_init_func)( | |
46 | struct bt_component_factory *factory); | |
47 | typedef void (*bt_plugin_exit_func)(void); | |
2bd8a567 | 48 | |
43de0e13 | 49 | /** |
633edee0 | 50 | * Component private data deallocation function type. |
43de0e13 | 51 | * |
633edee0 | 52 | * @param component Component instance |
43de0e13 | 53 | */ |
633edee0 | 54 | typedef void (*bt_component_destroy_cb)(struct bt_component *component); |
43de0e13 | 55 | |
2bd8a567 | 56 | /** |
38b48196 | 57 | * Component initialization function type. |
8738a040 | 58 | * |
38b48196 JG |
59 | * A component's private data and required callbacks must be set by this |
60 | * function. | |
2bd8a567 | 61 | * |
633edee0 | 62 | * @param component Component instance |
7c7c0433 | 63 | * @param params A dictionary of component parameters |
480dc8ed | 64 | * @returns One of #bt_component_status values |
2bd8a567 | 65 | */ |
38b48196 | 66 | typedef enum bt_component_status (*bt_component_init_cb)( |
7c7c0433 | 67 | struct bt_component *component, struct bt_value *params); |
8738a040 | 68 | |
8738a040 JG |
69 | /** |
70 | * Get a component's private data. | |
71 | * | |
72 | * @param component Component of which to get the private data | |
73 | * @returns Component's private data | |
74 | */ | |
75 | extern void *bt_component_get_private_data(struct bt_component *component); | |
47e5a032 | 76 | |
8738a040 JG |
77 | /** |
78 | * Set a component's private data. | |
79 | * | |
80 | * @param component Component of which to set the private data | |
81 | * @param data Component private data | |
82 | * @returns One of #bt_component_status values | |
83 | */ | |
84 | extern enum bt_component_status bt_component_set_private_data( | |
85 | struct bt_component *component, void *data); | |
86 | ||
87 | /** | |
88 | * Set a component's private data cleanup function. | |
89 | * | |
90 | * @param component Component of which to set the private data destruction | |
91 | * function | |
92 | * @param data Component private data clean-up function | |
93 | * @returns One of #bt_component_status values | |
94 | */ | |
95 | extern enum bt_component_status bt_component_set_destroy_cb( | |
96 | struct bt_component *component, | |
97 | bt_component_destroy_cb destroy); | |
98 | ||
99 | /** bt_component_souce */ | |
100 | /** | |
101 | * Iterator initialization function type. | |
102 | * | |
103 | * A notification iterator's private data, deinitialization, next, and get | |
104 | * callbacks must be set by this function. | |
105 | * | |
30d619df | 106 | * @param source Source component instance |
8738a040 JG |
107 | * @param iterator Notification iterator instance |
108 | */ | |
109 | typedef enum bt_component_status (*bt_component_source_init_iterator_cb)( | |
30d619df | 110 | struct bt_component *, struct bt_notification_iterator *); |
2bd8a567 | 111 | |
8738a040 JG |
112 | /** |
113 | * Set a source component's iterator initialization function. | |
114 | * | |
30d619df | 115 | * @param source Source component instance |
8738a040 JG |
116 | * @param init_iterator Notification iterator initialization callback |
117 | */ | |
118 | extern enum bt_component_status | |
30d619df | 119 | bt_component_source_set_iterator_init_cb(struct bt_component *source, |
8738a040 JG |
120 | bt_component_source_init_iterator_cb init_iterator); |
121 | ||
122 | /** bt_component_sink */ | |
2bd8a567 JG |
123 | /** |
124 | * Notification handling function type. | |
125 | * | |
30d619df | 126 | * @param sink Sink component instance |
2bd8a567 | 127 | * @param notificattion Notification to handle |
633edee0 | 128 | * @returns One of #bt_component_status values |
2bd8a567 | 129 | */ |
633edee0 JG |
130 | typedef enum bt_component_status (*bt_component_sink_handle_notification_cb)( |
131 | struct bt_component *, struct bt_notification *); | |
2bd8a567 | 132 | |
8738a040 JG |
133 | /** |
134 | * Set a sink component's notification handling callback. | |
135 | * | |
30d619df | 136 | * @param sink Sink component instance |
8738a040 JG |
137 | * @param handle_notification Notification handling callback |
138 | * @returns One of #bt_component_status values | |
139 | */ | |
140 | extern enum bt_component_status | |
30d619df | 141 | bt_component_sink_set_handle_notification_cb(struct bt_component *sink, |
8738a040 JG |
142 | bt_component_sink_handle_notification_cb handle_notification); |
143 | ||
30d619df JG |
144 | /** |
145 | * Register a sink to a given notification type. | |
146 | * | |
147 | * A sink is always registered to notifications of type | |
148 | * BT_NOTIFICATION_TYPE_EVENT. However, it may opt to receive any (or all) | |
149 | * other notification type(s). | |
150 | * | |
151 | * @param sink Sink component instance. | |
152 | * @param type One of #bt_notification_type | |
153 | * @returns One of #bt_component_status | |
154 | */ | |
155 | extern enum bt_component_status | |
156 | bt_component_sink_register_notification_type(struct bt_component *sink, | |
157 | enum bt_notification_type type); | |
158 | ||
8738a040 JG |
159 | /** bt_component_notification_iterator */ |
160 | /** | |
161 | * Function returning an iterator's current notification. | |
162 | * | |
163 | * @param iterator Notification iterator instance | |
164 | * @returns A notification instance | |
165 | */ | |
47e5a032 | 166 | typedef struct bt_notification *(*bt_notification_iterator_get_cb)( |
8738a040 | 167 | struct bt_notification_iterator *iterator); |
2bd8a567 | 168 | |
8738a040 | 169 | /** |
d97bac96 | 170 | * Function advancing an iterator's position of one element. |
8738a040 JG |
171 | * |
172 | * @param iterator Notification iterator instance | |
173 | * @returns One of #bt_notification_iterator_status values | |
174 | */ | |
47e5a032 | 175 | typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb)( |
8738a040 | 176 | struct bt_notification_iterator *iterator); |
2bd8a567 | 177 | |
43de0e13 | 178 | /** |
8738a040 | 179 | * Function cleaning-up an iterator's private data on destruction. |
43de0e13 | 180 | * |
8738a040 | 181 | * @param iterator Notification iterator instance |
43de0e13 | 182 | */ |
8738a040 JG |
183 | typedef void (*bt_notification_iterator_destroy_cb)( |
184 | struct bt_notification_iterator *iterator); | |
43de0e13 | 185 | |
d97bac96 JG |
186 | /** |
187 | * Set an iterator's "get" callback which return the current notification. | |
188 | * | |
189 | * @param iterator Notification iterator instance | |
190 | * @param get Notification return callback | |
191 | * @returns One of #bt_notification_iterator_status values | |
192 | */ | |
47e5a032 JG |
193 | extern enum bt_notification_iterator_status |
194 | bt_notification_iterator_set_get_cb(struct bt_notification_iterator *iterator, | |
195 | bt_notification_iterator_get_cb get); | |
196 | ||
d97bac96 JG |
197 | /** |
198 | * Set an iterator's "next" callback which advances the iterator's position. | |
199 | * | |
200 | * @param iterator Notification iterator instance | |
201 | * @param next Iterator "next" callback | |
202 | * @returns One of #bt_notification_iterator_status values | |
203 | */ | |
47e5a032 JG |
204 | extern enum bt_notification_iterator_status |
205 | bt_notification_iterator_set_next_cb(struct bt_notification_iterator *iterator, | |
206 | bt_notification_iterator_next_cb next); | |
207 | ||
d97bac96 JG |
208 | /** |
209 | * Set an iterator's "destroy" callback. | |
210 | * | |
211 | * @param iterator Notification iterator instance | |
212 | * @param next Iterator destruction callback | |
213 | * @returns One of #bt_notification_iterator_status values | |
214 | */ | |
8738a040 JG |
215 | extern enum bt_notification_iterator_status |
216 | bt_notification_iterator_set_destroy_cb( | |
217 | struct bt_notification_iterator *iterator, | |
218 | bt_notification_iterator_destroy_cb destroy); | |
219 | ||
d97bac96 JG |
220 | /** |
221 | * Set an iterator's private data. | |
222 | * | |
223 | * @param iterator Notification iterator instance | |
224 | * @param data Iterator private data | |
225 | * @returns One of #bt_notification_iterator_status values | |
226 | */ | |
47e5a032 JG |
227 | extern enum bt_notification_iterator_status |
228 | bt_notification_iterator_set_private_data( | |
229 | struct bt_notification_iterator *iterator, void *data); | |
230 | ||
d97bac96 | 231 | /** |
448143d9 | 232 | * Get an iterator's private data. |
d97bac96 JG |
233 | * |
234 | * @param iterator Notification iterator instance | |
235 | * @returns Iterator instance private data | |
236 | */ | |
47e5a032 JG |
237 | extern void *bt_notification_iterator_get_private_data( |
238 | struct bt_notification_iterator *iterator); | |
239 | ||
43de0e13 JG |
240 | #ifdef __cplusplus |
241 | } | |
242 | #endif | |
243 | ||
244 | #endif /* BABELTRACE_PLUGIN_SYSTEM_H */ |