X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fplugin%2Fcomponent-factory.h;h=ded452f1430f487194a6c9ee89d5519f16a83cd5;hb=f3e4505ba1b7bacce5fc1cc942f4cfaa905b4e74;hp=8b8c81bfd408a72e8c17d565dbfee5d6ec746a1d;hpb=633edee06e8dea4a4a2ba34a175d974f8b90726d;p=babeltrace.git diff --git a/include/babeltrace/plugin/component-factory.h b/include/babeltrace/plugin/component-factory.h index 8b8c81bf..ded452f1 100644 --- a/include/babeltrace/plugin/component-factory.h +++ b/include/babeltrace/plugin/component-factory.h @@ -29,31 +29,79 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { #endif -struct bt_component_factory; +/** + * Status code. Errors are always negative. + */ +enum bt_component_factory_status { + /** General error. */ + BT_COMPONENT_FACTORY_STATUS_ERROR = -128, + + /** Invalid arguments. */ + /* -22 for compatibility with -EINVAL */ + BT_COMPONENT_FACTORY_STATUS_INVAL = -22, + + /** Memory allocation failure. */ + /* -12 for compatibility with -ENOMEM */ + BT_COMPONENT_FACTORY_STATUS_NOMEM = -12, + + /** I/O error. */ + /* -5 for compatibility with -EIO */ + BT_COMPONENT_FACTORY_STATUS_IO = -5, + + /** No such file or directory. */ + /* -2 for compatibility with -ENOENT */ + BT_COMPONENT_FACTORY_STATUS_NOENT = -2, + + /** Operation not permitted. */ + /* -1 for compatibility with -EPERM */ + BT_COMPONENT_FACTORY_STATUS_PERM = -1, -typedef struct bt_component *(*bt_component_init)( - struct bt_component *component); + /** No error, okay. */ + BT_COMPONENT_FACTORY_STATUS_OK = 0, +}; -typedef struct bt_component *(*bt_component_fini)( - struct bt_component *component); +struct bt_component_factory; + +/** + * Create a component factory. + * + * @returns An instance of component factory + */ +extern +struct bt_component_factory *bt_component_factory_create(void); -enum bt_component_status bt_component_factory_create(const char *path); +/** + * Recursively load and register Babeltrace plugins under a given path. + * + * Path will be traversed recursively if it is a directory, otherwise only the + * provided file will be loaded. + * + * @param factory A component factory instance + * @param path A path to a file or directory + * @returns One of #bt_component_factory_status values + */ +extern +enum bt_component_factory_status bt_component_factory_load( + struct bt_component_factory *factory, const char *path); -enum bt_component_status bt_component_factory_register_source_component_class( +extern +enum bt_component_factory_status +bt_component_factory_register_source_component_class( struct bt_component_factory *factory, const char *name, - bt_component_init init, bt_component_fini fini, - bt_component_source_iterator_create_cb iterator_create_cb); + bt_component_source_init_cb init); -enum bt_component_status bt_component_factory_register_sink_component_class( +extern +enum bt_component_factory_status bt_component_factory_register_sink_component_class( struct bt_component_factory *factory, const char *name, - bt_component_init init, bt_component_fini fini, - bt_component_sink_handle_notification_cb handle_notification_cb); + bt_component_sink_init_cb init); +extern void bt_component_factory_destroy(struct bt_component_factory *factory); #ifdef __cplusplus