X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fplugin%2Fplugin-system.h;h=ec84b872926bdc369c2d16ed43e504bf16774024;hb=fec2a9f220bdae0ce64716538c111348302f2696;hp=67406353b6133382ec8c1f4a75b6c959c9a658b2;hpb=c602a80978f213e96007e49c821d98c487322d8b;p=babeltrace.git diff --git a/include/babeltrace/plugin/plugin-system.h b/include/babeltrace/plugin/plugin-system.h index 67406353..ec84b872 100644 --- a/include/babeltrace/plugin/plugin-system.h +++ b/include/babeltrace/plugin/plugin-system.h @@ -30,96 +30,239 @@ * SOFTWARE. */ -#include +#include +#include #ifdef __cplusplus extern "C" { #endif +struct bt_notification; +struct bt_notification_iterator; +struct bt_component; +struct bt_component_factory; +struct bt_value; + +typedef enum bt_component_status (*bt_plugin_init_func)( + struct bt_component_factory *factory); +typedef void (*bt_plugin_exit_func)(void); + +/** + * Component private data deallocation function type. + * + * @param component Component instance + */ +typedef void (*bt_component_destroy_cb)(struct bt_component *component); + +/** + * Component initialization function type. + * + * A component's private data and required callbacks must be set by this + * function. + * + * @param component Component instance + * @param params A dictionary of component parameters + * @returns One of #bt_component_status values + */ +typedef enum bt_component_status (*bt_component_init_cb)( + struct bt_component *component, struct bt_value *params); + /** - * Plug-in private data deallocation function type. + * Get a component's private data. * - * @param plugin Plug-in instance + * @param component Component of which to get the private data + * @returns Component's private data */ -typedef void (*bt_plugin_destroy_cb)(struct bt_plugin *plugin); +extern void *bt_component_get_private_data(struct bt_component *component); /** - * Plug-in error stream registration function type. + * Set a component's private data. * - * @param plugin Plug-in instance - * @param error_stream Error stream, ownership is not transferred - * @returns One of #bt_plugin_status values + * @param component Component of which to set the private data + * @param data Component private data + * @returns One of #bt_component_status values */ -typedef enum bt_plugin_status (*bt_plugin_set_error_stream_cb)( - struct bt_plugin *plugin, FILE *error_stream); +extern enum bt_component_status bt_component_set_private_data( + struct bt_component *component, void *data); /** - * Get a plug-in's private (implementation) data. + * Set a component's private data cleanup function. * - * @param plugin Plug-in of which to get the private data - * @returns Plug-in private data + * @param component Component of which to set the private data destruction + * function + * @param data Component private data clean-up function + * @returns One of #bt_component_status values */ -extern void *bt_plugin_get_private_data(struct bt_plugin *plugin); +extern enum bt_component_status bt_component_set_destroy_cb( + struct bt_component *component, + bt_component_destroy_cb destroy); +/** bt_component_souce */ /** - * Set a callback permiting the registration of an error stream. + * Iterator initialization function type. * - * @param plugin Plug-in to which the callback should be registered - * @param cb Error stream registration callback + * A notification iterator's private data, deinitialization, next, and get + * callbacks must be set by this function. + * + * @param source Source component instance + * @param iterator Notification iterator instance */ -extern int bt_plugin_set_error_stream_cb(struct bt_plugin *plugin, - bt_plugin_set_error_stream_cb cb); +typedef enum bt_component_status (*bt_component_source_init_iterator_cb)( + struct bt_component *, struct bt_notification_iterator *); -/* Plug-in initialization functions */ /** - * Allocate a source plug-in. + * Set a source component's iterator initialization function. * - * @param name Plug-in instance name (will be copied) - * @param private_data Private plug-in implementation data - * @param destroy_cb Plug-in private data clean-up callback - * @param iterator_create_cb Iterator creation callback - * @returns A source plug-in instance + * @param source Source component instance + * @param init_iterator Notification iterator initialization callback */ -extern struct bt_plugin *bt_plugin_source_create(const char *name, - void *private_data, bt_plugin_destroy_func destroy_func, - bt_plugin_source_iterator_create_cb iterator_create_cb); +extern enum bt_component_status +bt_component_source_set_iterator_init_cb(struct bt_component *source, + bt_component_source_init_iterator_cb init_iterator); +/** bt_component_sink */ /** - * Allocate a sink plug-in. + * Notification consumption function type. * - * @param name Plug-in instance name (will be copied) - * @param private_data Private plug-in implementation data - * @param destroy_cb Plug-in private data clean-up callback - * @param notification_cb Notification handling callback - * @returns A sink plug-in instance + * @param sink Sink component instance + * @returns One of #bt_component_status values */ -extern struct bt_plugin *bt_plugin_sink_create(const char *name, - void *private_data, bt_plugin_destroy_func destroy_func, - bt_plugin_sink_handle_notification_cb notification_cb); +typedef enum bt_component_status (*bt_component_sink_consume_cb)( + struct bt_component *); -/* Notification iterator functions */ /** - * Allocate an notification iterator. + * Iterator addition function type. + * + * A sink component may choose to refuse the addition of an iterator + * by not returning BT_COMPONENT_STATUS_OK. * - * @param plugin Plug-in instance - * @param next_cb Callback advancing to the next notification - * @param notification_cb Callback providing the current notification - * @returns A notification iterator instance + * @param sink Sink component instance + * @returns One of #bt_component_status values */ -extern struct bt_notification_iterator *bt_notification_iterator_create( - struct bt_plugin *plugin, - bt_notification_iterator_next_cb next_cb, - bt_notification_iterator_get_notification_cb notification_cb); +typedef enum bt_component_status (*bt_component_sink_add_iterator_cb)( + struct bt_component *, struct bt_notification_iterator *); + +/** + * Set a sink component's consumption callback. + * + * @param sink Sink component instance + * @param consume Consumption callback + * @returns One of #bt_component_status values + */ +extern enum bt_component_status +bt_component_sink_set_consume_cb(struct bt_component *sink, + bt_component_sink_consume_cb consume); + +/** + * Set a sink component's iterator addition callback. + * + * @param sink Sink component instance + * @param add_iterator Iterator addition callback + * @returns One of #bt_component_status values + */ +extern enum bt_component_status +bt_component_sink_set_add_iterator_cb(struct bt_component *sink, + bt_component_sink_add_iterator_cb add_iterator); + +/* Defaults to 1. */ +extern enum bt_component_status +bt_component_sink_set_minimum_input_count(struct bt_component *sink, + unsigned int minimum); + +/* Defaults to 1. */ +extern enum bt_component_status +bt_component_sink_set_maximum_input_count(struct bt_component *sink, + unsigned int maximum); + +extern enum bt_component_status +bt_component_sink_get_input_count(struct bt_component *sink, + unsigned int *count); + +/* May return NULL after an interator has reached its end. */ +extern enum bt_component_status +bt_component_sink_get_input_iterator(struct bt_component *sink, + unsigned int input, struct bt_notification_iterator **iterator); + +/** bt_notification_iterator */ +/** + * Function returning an iterator's current notification. + * + * @param iterator Notification iterator instance + * @returns A notification instance + */ +typedef struct bt_notification *(*bt_notification_iterator_get_cb)( + struct bt_notification_iterator *iterator); + +/** + * Function advancing an iterator's position of one element. + * + * @param iterator Notification iterator instance + * @returns One of #bt_notification_iterator_status values + */ +typedef enum bt_notification_iterator_status (*bt_notification_iterator_next_cb)( + struct bt_notification_iterator *iterator); + +/** + * Function cleaning-up an iterator's private data on destruction. + * + * @param iterator Notification iterator instance + */ +typedef void (*bt_notification_iterator_destroy_cb)( + struct bt_notification_iterator *iterator); + +/** + * Set an iterator's "get" callback which return the current notification. + * + * @param iterator Notification iterator instance + * @param get Notification return callback + * @returns One of #bt_notification_iterator_status values + */ +extern enum bt_notification_iterator_status +bt_notification_iterator_set_get_cb(struct bt_notification_iterator *iterator, + bt_notification_iterator_get_cb get); + +/** + * Set an iterator's "next" callback which advances the iterator's position. + * + * @param iterator Notification iterator instance + * @param next Iterator "next" callback + * @returns One of #bt_notification_iterator_status values + */ +extern enum bt_notification_iterator_status +bt_notification_iterator_set_next_cb(struct bt_notification_iterator *iterator, + bt_notification_iterator_next_cb next); + +/** + * Set an iterator's "destroy" callback. + * + * @param iterator Notification iterator instance + * @param next Iterator destruction callback + * @returns One of #bt_notification_iterator_status values + */ +extern enum bt_notification_iterator_status +bt_notification_iterator_set_destroy_cb( + struct bt_notification_iterator *iterator, + bt_notification_iterator_destroy_cb destroy); /** * Set an iterator's private data. * - * @param plugin Plug-in instance on which to iterate - * @param data Iterator private data - * @returns One of #bt_notification_iterator_status values + * @param iterator Notification iterator instance + * @param data Iterator private data + * @returns One of #bt_notification_iterator_status values + */ +extern enum bt_notification_iterator_status +bt_notification_iterator_set_private_data( + struct bt_notification_iterator *iterator, void *data); + +/** + * Get an iterator's private data. + * + * @param iterator Notification iterator instance + * @returns Iterator instance private data */ -extern enum bt_notification_iterator_status *bt_notification_iterator_create( - struct bt_plugin *plugin, void *data); +extern void *bt_notification_iterator_get_private_data( + struct bt_notification_iterator *iterator); #ifdef __cplusplus }