X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fcomponent%2Fcomponent.h;h=0a2f70d7579735d58be3de9e7fa642318900ba56;hb=72b913fbad1753b5b122bfb54c1e7936eaf9d0ef;hp=7a1464fd2206937e62cd86f2fa377dc50abcae6a;hpb=33b34c437c354e1c065e33151135bc2e57e2e29c;p=babeltrace.git diff --git a/include/babeltrace/component/component.h b/include/babeltrace/component/component.h index 7a1464fd..0a2f70d7 100644 --- a/include/babeltrace/component/component.h +++ b/include/babeltrace/component/component.h @@ -27,6 +27,7 @@ * SOFTWARE. */ +#include #include #include #include @@ -35,53 +36,54 @@ extern "C" { #endif +struct bt_component_class; +struct bt_component_graph; +struct bt_component; +struct bt_value; +struct bt_port; + /** * Status code. Errors are always negative. */ enum bt_component_status { /** No error, okay. */ - BT_COMPONENT_STATUS_OK = 0, + BT_COMPONENT_STATUS_OK = 0, /** No more work to be done by this component. **/ - BT_COMPONENT_STATUS_END = 1, + BT_COMPONENT_STATUS_END = 1, /** * Component can't process a notification at this time * (e.g. would block), try again later. */ - BT_COMPONENT_STATUS_AGAIN = 2, + BT_COMPONENT_STATUS_AGAIN = 2, + /** Refuse port connection. */ + BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 3, /** General error. */ - BT_COMPONENT_STATUS_ERROR = -1, + BT_COMPONENT_STATUS_ERROR = -1, /** Unsupported component feature. */ - BT_COMPONENT_STATUS_UNSUPPORTED = -2, + BT_COMPONENT_STATUS_UNSUPPORTED = -2, /** Invalid arguments. */ - BT_COMPONENT_STATUS_INVALID = -3, + BT_COMPONENT_STATUS_INVALID = -3, /** Memory allocation failure. */ - BT_COMPONENT_STATUS_NOMEM = -4, + BT_COMPONENT_STATUS_NOMEM = -4, + /** Element not found. */ + BT_COMPONENT_STATUS_NOT_FOUND = -5, }; -struct bt_component_class; -struct bt_component; -struct bt_value; - /** - * 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. + * Create an instance of a component from a component class. * - * @param component Component instance - * @param params A dictionary of component parameters - * @returns One of #bt_component_status values + * @param component_class Component class of which to create an instance + * @param name Name of the new component instance, optional + * @param params A dictionary of component parameters + * @returns Returns a pointer to a new component instance */ -typedef enum bt_component_status (*bt_component_init_cb)( - struct bt_component *component, struct bt_value *params); +extern struct bt_component *bt_component_create( + struct bt_component_class *component_class, const char *name, + struct bt_value *params); +extern struct bt_component *bt_component_create_with_init_method_data( + struct bt_component_class *component_class, const char *name, + struct bt_value *params, void *init_method_data); /** * Get a component's private data. @@ -101,181 +103,6 @@ extern void *bt_component_get_private_data(struct bt_component *component); extern enum bt_component_status bt_component_set_private_data( struct bt_component *component, void *data); -/** - * Set a component's private data cleanup function. - * - * @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 enum bt_component_status bt_component_set_destroy_cb( - struct bt_component *component, - bt_component_destroy_cb destroy); - -/** bt_component_souce */ -/** - * Iterator initialization function type. - * - * 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 - */ -typedef enum bt_component_status (*bt_component_source_init_iterator_cb)( - struct bt_component *, struct bt_notification_iterator *); - -/** - * Set a source component's iterator initialization function. - * - * @param source Source component instance - * @param init_iterator Notification iterator initialization callback - */ -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 */ -/** - * Notification consumption function type. - * - * @param sink Sink component instance - * @returns One of #bt_component_status values - */ -typedef enum bt_component_status (*bt_component_sink_consume_cb)( - struct bt_component *); - -/** - * Iterator addition function type. - * - * A sink component may choose to refuse the addition of an iterator - * by not returning BT_COMPONENT_STATUS_OK. - * - * @param sink Sink component instance - * @returns One of #bt_component_status values - */ -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_component_filter */ -/** - * Iterator initialization function type. - * - * A notification iterator's private data, deinitialization, next, and get - * callbacks must be set by this function. - * - * @param filter Filter component instance - * @param iterator Notification iterator instance - */ -typedef enum bt_component_status (*bt_component_filter_init_iterator_cb)( - struct bt_component *, struct bt_notification_iterator *); - -/** - * Iterator addition function type. - * - * A filter component may choose to refuse the addition of an iterator - * by not returning BT_COMPONENT_STATUS_OK. - * - * @param filter Filter component instance - * @returns One of #bt_component_status values - */ -typedef enum bt_component_status (*bt_component_filter_add_iterator_cb)( - struct bt_component *, struct bt_notification_iterator *); - -/** - * Set a filter component's iterator initialization function. - * - * @param filter Filter component instance - * @param init_iterator Notification iterator initialization callback - */ -extern enum bt_component_status -bt_component_filter_set_iterator_init_cb(struct bt_component *filter, - bt_component_filter_init_iterator_cb init_iterator); - -/** - * Set a filter component's iterator addition callback. - * - * @param filter Filter component instance - * @param add_iterator Iterator addition callback - * @returns One of #bt_component_status values - */ -extern enum bt_component_status -bt_component_filter_set_add_iterator_cb(struct bt_component *filter, - bt_component_filter_add_iterator_cb add_iterator); - -/* Defaults to 1. */ -extern enum bt_component_status -bt_component_filter_set_minimum_input_count(struct bt_component *filter, - unsigned int minimum); - -/* Defaults to 1. */ -extern enum bt_component_status -bt_component_filter_set_maximum_input_count(struct bt_component *filter, - unsigned int maximum); - -extern enum bt_component_status -bt_component_filter_get_input_count(struct bt_component *filter, - unsigned int *count); - -/* May return NULL after an interator has reached its end. */ -extern enum bt_component_status -bt_component_filter_get_input_iterator(struct bt_component *filter, - unsigned int input, struct bt_notification_iterator **iterator); - -/** - * Create an instance of a component from a component class. - * - * @param component_class Component class of which to create an instance - * @param name Name of the new component instance, optional - * @param params A dictionary of component parameters - * @returns Returns a pointer to a new component instance - */ -extern struct bt_component *bt_component_create( - struct bt_component_class *component_class, const char *name, - struct bt_value *params); - /** * Get component's name. * @@ -284,16 +111,6 @@ extern struct bt_component *bt_component_create( */ extern const char *bt_component_get_name(struct bt_component *component); -/** - * Set component's name. - * - * @param component Component instance of which to set the name - * @param name New component name (will be copied) - * @returns One of #bt_component_status values - */ -extern enum bt_component_status bt_component_set_name( - struct bt_component *component, const char *name); - /** * Get component's class. * @@ -303,6 +120,11 @@ extern enum bt_component_status bt_component_set_name( extern struct bt_component_class *bt_component_get_class( struct bt_component *component); +extern enum bt_component_class_type bt_component_get_class_type( + struct bt_component *component); + +extern struct bt_graph *bt_component_get_graph(struct bt_component *component); + #ifdef __cplusplus } #endif