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