1 #ifndef BABELTRACE_PLUGIN_SYSTEM_H
2 #define BABELTRACE_PLUGIN_SYSTEM_H
5 * BabelTrace - Babeltrace Plug-in System Interface
7 * This interface is provided for plug-ins to use the Babeltrace
8 * plug-in system facilities.
10 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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:
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
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
37 struct bt_notification
;
38 struct bt_notification_iterator
;
40 struct bt_component_factory
;
42 typedef enum bt_component_status (*bt_plugin_init_func
)(
43 struct bt_component_factory
*factory
);
44 typedef void (*bt_plugin_exit_func
)(void);
47 * Component private data deallocation function type.
49 * @param component Component instance
51 typedef void (*bt_component_destroy_cb
)(struct bt_component
*component
);
54 * Component initialization function type.
56 * A component's private data and required callbacks must be set by this
59 * @param component Component instance
60 * @returns One of #bt_component_status values
62 typedef enum bt_component_status (*bt_component_init_cb
)(
63 struct bt_component
*component
);
66 * Get a component's private data.
68 * @param component Component of which to get the private data
69 * @returns Component's private data
71 extern void *bt_component_get_private_data(struct bt_component
*component
);
74 * Set a component's private data.
76 * @param component Component of which to set the private data
77 * @param data Component private data
78 * @returns One of #bt_component_status values
80 extern enum bt_component_status
bt_component_set_private_data(
81 struct bt_component
*component
, void *data
);
84 * Set a component's private data cleanup function.
86 * @param component Component of which to set the private data destruction
88 * @param data Component private data clean-up function
89 * @returns One of #bt_component_status values
91 extern enum bt_component_status
bt_component_set_destroy_cb(
92 struct bt_component
*component
,
93 bt_component_destroy_cb destroy
);
95 /** bt_component_souce */
97 * Iterator initialization function type.
99 * A notification iterator's private data, deinitialization, next, and get
100 * callbacks must be set by this function.
102 * @param component Component instance
103 * @param iterator Notification iterator instance
105 typedef enum bt_component_status (*bt_component_source_init_iterator_cb
)(
106 struct bt_component
*component
,
107 struct bt_notification_iterator
*iterator
);
110 * Set a source component's iterator initialization function.
112 * @param component Component instance
113 * @param init_iterator Notification iterator initialization callback
115 extern enum bt_component_status
116 bt_component_source_set_iterator_init_cb(struct bt_component
*component
,
117 bt_component_source_init_iterator_cb init_iterator
);
119 /** bt_component_sink */
121 * Notification handling function type.
123 * @param component Component instance
124 * @param notificattion Notification to handle
125 * @returns One of #bt_component_status values
127 typedef enum bt_component_status (*bt_component_sink_handle_notification_cb
)(
128 struct bt_component
*, struct bt_notification
*);
131 * Set a sink component's notification handling callback.
133 * @param component Component instance
134 * @param handle_notification Notification handling callback
135 * @returns One of #bt_component_status values
137 extern enum bt_component_status
138 bt_component_sink_set_handle_notification_cb(struct bt_component
*component
,
139 bt_component_sink_handle_notification_cb handle_notification
);
141 /** bt_component_notification_iterator */
143 * Function returning an iterator's current notification.
145 * @param iterator Notification iterator instance
146 * @returns A notification instance
148 typedef struct bt_notification
*(*bt_notification_iterator_get_cb
)(
149 struct bt_notification_iterator
*iterator
);
152 * Function advancing an iterator's position of one element.
154 * @param iterator Notification iterator instance
155 * @returns One of #bt_notification_iterator_status values
157 typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb
)(
158 struct bt_notification_iterator
*iterator
);
161 * Function cleaning-up an iterator's private data on destruction.
163 * @param iterator Notification iterator instance
165 typedef void (*bt_notification_iterator_destroy_cb
)(
166 struct bt_notification_iterator
*iterator
);
169 * Set an iterator's "get" callback which return the current notification.
171 * @param iterator Notification iterator instance
172 * @param get Notification return callback
173 * @returns One of #bt_notification_iterator_status values
175 extern enum bt_notification_iterator_status
176 bt_notification_iterator_set_get_cb(struct bt_notification_iterator
*iterator
,
177 bt_notification_iterator_get_cb get
);
180 * Set an iterator's "next" callback which advances the iterator's position.
182 * @param iterator Notification iterator instance
183 * @param next Iterator "next" callback
184 * @returns One of #bt_notification_iterator_status values
186 extern enum bt_notification_iterator_status
187 bt_notification_iterator_set_next_cb(struct bt_notification_iterator
*iterator
,
188 bt_notification_iterator_next_cb next
);
191 * Set an iterator's "destroy" callback.
193 * @param iterator Notification iterator instance
194 * @param next Iterator destruction callback
195 * @returns One of #bt_notification_iterator_status values
197 extern enum bt_notification_iterator_status
198 bt_notification_iterator_set_destroy_cb(
199 struct bt_notification_iterator
*iterator
,
200 bt_notification_iterator_destroy_cb destroy
);
203 * Set an iterator's private data.
205 * @param iterator Notification iterator instance
206 * @param data Iterator private data
207 * @returns One of #bt_notification_iterator_status values
209 extern enum bt_notification_iterator_status
210 bt_notification_iterator_set_private_data(
211 struct bt_notification_iterator
*iterator
, void *data
);
214 * Get an iterator's private data.
216 * @param iterator Notification iterator instance
217 * @returns Iterator instance private data
219 extern void *bt_notification_iterator_get_private_data(
220 struct bt_notification_iterator
*iterator
);
226 #endif /* BABELTRACE_PLUGIN_SYSTEM_H */