Component creation
[babeltrace.git] / include / babeltrace / plugin / plugin-system.h
CommitLineData
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
34extern "C" {
35#endif
36
2bd8a567 37struct bt_notification;
47e5a032
JG
38struct bt_notification_iterator;
39struct bt_component;
38b48196
JG
40struct bt_component_factory;
41
42typedef enum bt_component_status (*bt_plugin_init_func)(
43 struct bt_component_factory *factory);
44typedef void (*bt_plugin_exit_func)(void);
2bd8a567 45
43de0e13 46/**
633edee0 47 * Component private data deallocation function type.
43de0e13 48 *
633edee0 49 * @param component Component instance
43de0e13 50 */
633edee0 51typedef void (*bt_component_destroy_cb)(struct bt_component *component);
43de0e13 52
2bd8a567 53/**
38b48196 54 * Component initialization function type.
8738a040 55 *
38b48196
JG
56 * A component's private data and required callbacks must be set by this
57 * function.
2bd8a567 58 *
633edee0 59 * @param component Component instance
480dc8ed 60 * @returns One of #bt_component_status values
2bd8a567 61 */
38b48196 62typedef enum bt_component_status (*bt_component_init_cb)(
8738a040
JG
63 struct bt_component *component);
64
8738a040
JG
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 */
71extern void *bt_component_get_private_data(struct bt_component *component);
47e5a032 72
8738a040
JG
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 */
80extern 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 */
91extern 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 */
105typedef enum bt_component_status (*bt_component_source_init_iterator_cb)(
106 struct bt_component *component,
107 struct bt_notification_iterator *iterator);
2bd8a567 108
8738a040
JG
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 */
115extern enum bt_component_status
116bt_component_source_set_iterator_init_cb(struct bt_component *component,
117 bt_component_source_init_iterator_cb init_iterator);
118
119/** bt_component_sink */
2bd8a567
JG
120/**
121 * Notification handling function type.
122 *
633edee0 123 * @param component Component instance
2bd8a567 124 * @param notificattion Notification to handle
633edee0 125 * @returns One of #bt_component_status values
2bd8a567 126 */
633edee0
JG
127typedef enum bt_component_status (*bt_component_sink_handle_notification_cb)(
128 struct bt_component *, struct bt_notification *);
2bd8a567 129
8738a040
JG
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 */
137extern enum bt_component_status
138bt_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 */
47e5a032 148typedef struct bt_notification *(*bt_notification_iterator_get_cb)(
8738a040 149 struct bt_notification_iterator *iterator);
2bd8a567 150
8738a040 151/**
d97bac96 152 * Function advancing an iterator's position of one element.
8738a040
JG
153 *
154 * @param iterator Notification iterator instance
155 * @returns One of #bt_notification_iterator_status values
156 */
47e5a032 157typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb)(
8738a040 158 struct bt_notification_iterator *iterator);
2bd8a567 159
43de0e13 160/**
8738a040 161 * Function cleaning-up an iterator's private data on destruction.
43de0e13 162 *
8738a040 163 * @param iterator Notification iterator instance
43de0e13 164 */
8738a040
JG
165typedef void (*bt_notification_iterator_destroy_cb)(
166 struct bt_notification_iterator *iterator);
43de0e13 167
d97bac96
JG
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 */
47e5a032
JG
175extern enum bt_notification_iterator_status
176bt_notification_iterator_set_get_cb(struct bt_notification_iterator *iterator,
177 bt_notification_iterator_get_cb get);
178
d97bac96
JG
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 */
47e5a032
JG
186extern enum bt_notification_iterator_status
187bt_notification_iterator_set_next_cb(struct bt_notification_iterator *iterator,
188 bt_notification_iterator_next_cb next);
189
d97bac96
JG
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 */
8738a040
JG
197extern enum bt_notification_iterator_status
198bt_notification_iterator_set_destroy_cb(
199 struct bt_notification_iterator *iterator,
200 bt_notification_iterator_destroy_cb destroy);
201
d97bac96
JG
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 */
47e5a032
JG
209extern enum bt_notification_iterator_status
210bt_notification_iterator_set_private_data(
211 struct bt_notification_iterator *iterator, void *data);
212
d97bac96 213/**
448143d9 214 * Get an iterator's private data.
d97bac96
JG
215 *
216 * @param iterator Notification iterator instance
217 * @returns Iterator instance private data
218 */
47e5a032
JG
219extern void *bt_notification_iterator_get_private_data(
220 struct bt_notification_iterator *iterator);
221
43de0e13
JG
222#ifdef __cplusplus
223}
224#endif
225
226#endif /* BABELTRACE_PLUGIN_SYSTEM_H */
This page took 0.03392 seconds and 4 git commands to generate.