Component creation
[babeltrace.git] / include / babeltrace / plugin / plugin-system.h
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 struct bt_component_factory;
41
42 typedef enum bt_component_status (*bt_plugin_init_func)(
43 struct bt_component_factory *factory);
44 typedef void (*bt_plugin_exit_func)(void);
45
46 /**
47 * Component private data deallocation function type.
48 *
49 * @param component Component instance
50 */
51 typedef void (*bt_component_destroy_cb)(struct bt_component *component);
52
53 /**
54 * Component initialization function type.
55 *
56 * A component's private data and required callbacks must be set by this
57 * function.
58 *
59 * @param component Component instance
60 * @returns One of #bt_component_status values
61 */
62 typedef enum bt_component_status (*bt_component_init_cb)(
63 struct bt_component *component);
64
65 /**
66 * Get a component's private data.
67 *
68 * @param component Component of which to get the private data
69 * @returns Component's private data
70 */
71 extern void *bt_component_get_private_data(struct bt_component *component);
72
73 /**
74 * Set a component's private data.
75 *
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
79 */
80 extern enum bt_component_status bt_component_set_private_data(
81 struct bt_component *component, void *data);
82
83 /**
84 * Set a component's private data cleanup function.
85 *
86 * @param component Component of which to set the private data destruction
87 * function
88 * @param data Component private data clean-up function
89 * @returns One of #bt_component_status values
90 */
91 extern enum bt_component_status bt_component_set_destroy_cb(
92 struct bt_component *component,
93 bt_component_destroy_cb destroy);
94
95 /** bt_component_souce */
96 /**
97 * Iterator initialization function type.
98 *
99 * A notification iterator's private data, deinitialization, next, and get
100 * callbacks must be set by this function.
101 *
102 * @param component Component instance
103 * @param iterator Notification iterator instance
104 */
105 typedef enum bt_component_status (*bt_component_source_init_iterator_cb)(
106 struct bt_component *component,
107 struct bt_notification_iterator *iterator);
108
109 /**
110 * Set a source component's iterator initialization function.
111 *
112 * @param component Component instance
113 * @param init_iterator Notification iterator initialization callback
114 */
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);
118
119 /** bt_component_sink */
120 /**
121 * Notification handling function type.
122 *
123 * @param component Component instance
124 * @param notificattion Notification to handle
125 * @returns One of #bt_component_status values
126 */
127 typedef enum bt_component_status (*bt_component_sink_handle_notification_cb)(
128 struct bt_component *, struct bt_notification *);
129
130 /**
131 * Set a sink component's notification handling callback.
132 *
133 * @param component Component instance
134 * @param handle_notification Notification handling callback
135 * @returns One of #bt_component_status values
136 */
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);
140
141 /** bt_component_notification_iterator */
142 /**
143 * Function returning an iterator's current notification.
144 *
145 * @param iterator Notification iterator instance
146 * @returns A notification instance
147 */
148 typedef struct bt_notification *(*bt_notification_iterator_get_cb)(
149 struct bt_notification_iterator *iterator);
150
151 /**
152 * Function advancing an iterator's position of one element.
153 *
154 * @param iterator Notification iterator instance
155 * @returns One of #bt_notification_iterator_status values
156 */
157 typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb)(
158 struct bt_notification_iterator *iterator);
159
160 /**
161 * Function cleaning-up an iterator's private data on destruction.
162 *
163 * @param iterator Notification iterator instance
164 */
165 typedef void (*bt_notification_iterator_destroy_cb)(
166 struct bt_notification_iterator *iterator);
167
168 /**
169 * Set an iterator's "get" callback which return the current notification.
170 *
171 * @param iterator Notification iterator instance
172 * @param get Notification return callback
173 * @returns One of #bt_notification_iterator_status values
174 */
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);
178
179 /**
180 * Set an iterator's "next" callback which advances the iterator's position.
181 *
182 * @param iterator Notification iterator instance
183 * @param next Iterator "next" callback
184 * @returns One of #bt_notification_iterator_status values
185 */
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);
189
190 /**
191 * Set an iterator's "destroy" callback.
192 *
193 * @param iterator Notification iterator instance
194 * @param next Iterator destruction callback
195 * @returns One of #bt_notification_iterator_status values
196 */
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);
201
202 /**
203 * Set an iterator's private data.
204 *
205 * @param iterator Notification iterator instance
206 * @param data Iterator private data
207 * @returns One of #bt_notification_iterator_status values
208 */
209 extern enum bt_notification_iterator_status
210 bt_notification_iterator_set_private_data(
211 struct bt_notification_iterator *iterator, void *data);
212
213 /**
214 * Get an iterator's private data.
215 *
216 * @param iterator Notification iterator instance
217 * @returns Iterator instance private data
218 */
219 extern void *bt_notification_iterator_get_private_data(
220 struct bt_notification_iterator *iterator);
221
222 #ifdef __cplusplus
223 }
224 #endif
225
226 #endif /* BABELTRACE_PLUGIN_SYSTEM_H */
This page took 0.033736 seconds and 4 git commands to generate.