From 633edee06e8dea4a4a2ba34a175d974f8b90726d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 6 Jul 2015 20:48:17 -0400 Subject: [PATCH] More modifications MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- include/babeltrace/plugin/component-class.h | 67 ------------------- .../plugin/component-factory-internal.h | 27 ++++++++ include/babeltrace/plugin/component-factory.h | 60 ++++++++--------- include/babeltrace/plugin/component.h | 6 +- include/babeltrace/plugin/plugin-internal.h | 20 +++--- include/babeltrace/plugin/plugin-system.h | 60 ++++++----------- include/babeltrace/plugin/plugin.h | 34 ++++++++-- .../plugin/{plugin-lib.h => sink.h} | 50 +++----------- 8 files changed, 128 insertions(+), 196 deletions(-) delete mode 100644 include/babeltrace/plugin/component-class.h create mode 100644 include/babeltrace/plugin/component-factory-internal.h rename include/babeltrace/plugin/{plugin-lib.h => sink.h} (50%) diff --git a/include/babeltrace/plugin/component-class.h b/include/babeltrace/plugin/component-class.h deleted file mode 100644 index 8988abc2..00000000 --- a/include/babeltrace/plugin/component-class.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef BABELTRACE_PLUGIN_COMPONENT_CLASS_H -#define BABELTRACE_PLUGIN_COMPONENT_CLASS_H - -/* - * Babeltrace - Plugin Component Class Interface. - * - * Copyright 2015 EfficiOS Inc. - * Copyright 2015 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { - #endif - -#define BT_PLUGIN_NAME(_x) const char *__bt_plugin_name = (_x) -#define BT_PLUGIN_AUTHOR(_x) const char *__bt_plugin_author = (_x) -#define BT_PLUGIN_LICENSE(_x) const char *__bt_plugin_license = (_x) -#define BT_PLUGIN_INIT(_x) void *__bt_plugin_init = (_x) -#define BT_PLUGIN_EXIT(_x) void *__bt_plugin_exit = (_x) - -#define BT_PLUGIN_COMPONENT_CLASSES_BEGIN\ - enum bt_status __bt_plugin_register_component_classes(\ - struct bt_component_factory *factory)\ - { - -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _it_cr) \ - bt_component_factory_register_source_component_class(factory, \ - _name, _init, _fini, _it_cr); - -#define BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _hd_notif) \ - bt_component_factory_register_sink_component_class(factory, \ - _name, _init, _fini, _hd_notif); - -#define BT_PLUGIN_COMPONENT_CLASSES_END\ - \ - return BT_STATUS_OK;\ -}\ - \ - BT_PLUGIN_INIT(__bt_plugin_register_component_classes);\ - BT_PLUGIN_EXIT(NULL); - - #ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_PLUGIN_COMPONENT_CLASS_H */ diff --git a/include/babeltrace/plugin/component-factory-internal.h b/include/babeltrace/plugin/component-factory-internal.h new file mode 100644 index 00000000..e6d368da --- /dev/null +++ b/include/babeltrace/plugin/component-factory-internal.h @@ -0,0 +1,27 @@ + +/** Component initialization functions */ +/** + * Allocate a source component. + * + * @param name Component instance name (will be copied) + * @param private_data Private component implementation data + * @param destroy_cb Component private data clean-up callback + * @param iterator_create_cb Iterator creation callback + * @returns A source component instance + */ +extern struct bt_component *bt_component_source_create(const char *name, + void *private_data, bt_component_destroy_cb destroy_func, + bt_component_source_iterator_create_cb iterator_create_cb); + +/** + * Allocate a sink component. + * + * @param name Component instance name (will be copied) + * @param private_data Private component implementation data + * @param destroy_cb Component private data clean-up callback + * @param notification_cb Notification handling callback + * @returns A sink component instance + */ +extern struct bt_component *bt_component_sink_create(const char *name, + void *private_data, bt_component_destroy_cb destroy_func, + bt_component_sink_handle_notification_cb notification_cb); diff --git a/include/babeltrace/plugin/component-factory.h b/include/babeltrace/plugin/component-factory.h index 379e6c0a..8b8c81bf 100644 --- a/include/babeltrace/plugin/component-factory.h +++ b/include/babeltrace/plugin/component-factory.h @@ -1,11 +1,10 @@ -#ifndef BABELTRACE_PLUGIN_COMPONENT_CLASS_H -#define BABELTRACE_PLUGIN_COMPONENT_CLASS_H +#ifndef BABELTRACE_PLUGIN_COMPONENT_FACTORY_H +#define BABELTRACE_PLUGIN_COMPONENT_FACTORY_H /* - * Babeltrace - Plugin Component Class Interface. + * Babeltrace - Component Factory Class Interface. * - * Copyright 2015 EfficiOS Inc. - * Copyright 2015 Philippe Proulx + * Copyright 2015 Jérémie Galarneau * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,42 +25,39 @@ * SOFTWARE. */ -#include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { - #endif +#endif + +struct bt_component_factory; -#define BT_PLUGIN_NAME(_x) const char *__bt_plugin_name = (_x) -#define BT_PLUGIN_AUTHOR(_x) const char *__bt_plugin_author = (_x) -#define BT_PLUGIN_LICENSE(_x) const char *__bt_plugin_license = (_x) -#define BT_PLUGIN_INIT(_x) void *__bt_plugin_init = (_x) -#define BT_PLUGIN_EXIT(_x) void *__bt_plugin_exit = (_x) +typedef struct bt_component *(*bt_component_init)( + struct bt_component *component); -#define BT_PLUGIN_COMPONENT_CLASSES_BEGIN\ - enum bt_status __bt_plugin_register_component_classes(\ - struct bt_component_factory *factory)\ - { +typedef struct bt_component *(*bt_component_fini)( + struct bt_component *component); -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _it_cr) \ - bt_component_factory_register_source_component_class(factory, \ - _name, _init, _fini, _it_cr); +enum bt_component_status bt_component_factory_create(const char *path); -#define BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _hd_notif) \ - bt_component_factory_register_sink_component_class(factory, \ - _name, _init, _fini, _hd_notif); +enum bt_component_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); -#define BT_PLUGIN_COMPONENT_CLASSES_END\ - \ - return BT_STATUS_OK;\ -}\ - \ - BT_PLUGIN_INIT(__bt_plugin_register_component_classes);\ - BT_PLUGIN_EXIT(NULL); +enum bt_component_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); - #ifdef __cplusplus +void bt_component_factory_destroy(struct bt_component_factory *factory); + +#ifdef __cplusplus } #endif -#endif /* BABELTRACE_PLUGIN_H */ +#endif /* BABELTRACE_PLUGIN_COMPONENT_FACTORY_H */ diff --git a/include/babeltrace/plugin/component.h b/include/babeltrace/plugin/component.h index 1a17ed7e..87dac51f 100644 --- a/include/babeltrace/plugin/component.h +++ b/include/babeltrace/plugin/component.h @@ -2,7 +2,7 @@ #define BABELTRACE_PLUGIN_COMPONENT_H /* - * BabelTrace - Babeltrace Plug-in Component Interface + * BabelTrace - Babeltrace Component Interface * * Copyright 2015 Jérémie Galarneau * @@ -77,7 +77,7 @@ struct bt_component; * Get component's name. * * @param component Component instance of which to get the name - * @returns Returns a pointer to the plug-in's name + * @returns Returns a pointer to the component's name */ extern const char *bt_component_get_name(struct bt_component *component); @@ -85,7 +85,7 @@ 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 plug-in name (will be copied) + * @param name New component name (will be copied) * @returns One of #bt_component_status values */ extern enum bt_component_status bt_component_set_name( diff --git a/include/babeltrace/plugin/plugin-internal.h b/include/babeltrace/plugin/plugin-internal.h index 22d50abe..3fc85c85 100644 --- a/include/babeltrace/plugin/plugin-internal.h +++ b/include/babeltrace/plugin/plugin-internal.h @@ -1,8 +1,8 @@ -#ifndef BABELTRACE_PLUGIN_INTERNAL_H -#define BABELTRACE_PLUGIN_INTERNAL_H +#ifndef BABELTRACE_PLUGIN_COMPONENT_INTERNAL_H +#define BABELTRACE_PLUGIN_COMPONENT_INTERNAL_H /* - * BabelTrace - Plug-in internal + * BabelTrace - Component internal * * Copyright 2015 Jérémie Galarneau * @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,7 @@ extern "C" { struct bt_notification; -struct bt_plugin { +struct bt_component { struct bt_ctf_ref ref_count; GString *name; enum bt_plugin_type type; @@ -53,13 +54,14 @@ struct bt_plugin { }; BT_HIDDEN -enum bt_plugin_status bt_plugin_init(struct bt_plugin *plugin, const char *name, - void *user_data,bt_plugin_destroy_cb destroy_func, - enum bt_plugin_type plugin_type, - bt_plugin_destroy_cb plugin_destroy); +enum bt_component_status bt_component_init(struct bt_component *plugin, + const char *name, void *user_data, + bt_component_destroy_cb destroy_func, + enum bt_component_type component_type, + bt_component_destroy_cb component_destroy); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_PLUGIN_INTERNAL_H */ +#endif /* BABELTRACE_PLUGIN_COMPONENT_INTERNAL_H */ diff --git a/include/babeltrace/plugin/plugin-system.h b/include/babeltrace/plugin/plugin-system.h index e66e1aba..6d6614da 100644 --- a/include/babeltrace/plugin/plugin-system.h +++ b/include/babeltrace/plugin/plugin-system.h @@ -40,30 +40,30 @@ extern "C" { struct bt_notification; /** - * Plug-in private data deallocation function type. + * Component private data deallocation function type. * - * @param plugin Plug-in instance + * @param component Component instance */ -typedef void (*bt_plugin_destroy_cb)(struct bt_plugin *plugin); +typedef void (*bt_component_destroy_cb)(struct bt_component *component); /** * Iterator creation function type. * - * @param plugin Plug-in instance + * @param component Component instance */ typedef struct bt_notification_iterator *( - *bt_plugin_source_iterator_create_cb)( - struct bt_plugin *plugin); + *bt_component_source_iterator_create_cb)( + struct bt_component *component); /** * Notification handling function type. * - * @param plugin Plug-in instance + * @param component Component instance * @param notificattion Notification to handle - * @returns One of #bt_plugin_status values + * @returns One of #bt_component_status values */ -typedef enum bt_plugin_status (*bt_plugin_sink_handle_notification_cb)( - struct bt_plugin *, struct bt_notification *); +typedef enum bt_component_status (*bt_component_sink_handle_notification_cb)( + struct bt_component *, struct bt_notification *); typedef struct bt_notification *(bt_notification_iterator_get_notification_cb)( struct bt_notification_iterator *); @@ -72,53 +72,33 @@ typedef enum bt_notification_iterator_status (bt_notification_iterator_next_cb)( struct bt_notification_iterator *); /** - * Get a plug-in's private (implementation) data. + * Get a component's private (implementation) data. * - * @param plugin Plug-in of which to get the private data - * @returns Plug-in private data + * @param component Component of which to get the private data */ -extern void *bt_plugin_get_private_data(struct bt_plugin *plugin); - - -/** Plug-in initialization functions */ -/** - * Allocate a source plug-in. - * - * @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 - */ -extern struct bt_plugin *bt_plugin_source_create(const char *name, - void *private_data, bt_plugin_destroy_cb destroy_func, - bt_plugin_source_iterator_create_cb iterator_create_cb); +extern void *bt_component_get_private_data(struct bt_component *component); /** - * Allocate a sink plug-in. + * Set a component's private (implementation) data. * - * @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 component Component of which to set the private data + * @param data Component private data */ -extern struct bt_plugin *bt_plugin_sink_create(const char *name, - void *private_data, bt_plugin_destroy_cb destroy_func, - bt_plugin_sink_handle_notification_cb notification_cb); +extern enum bt_component_status bt_component_set_private_data(struct bt_component *component, + void *data); /** Notification iterator functions */ /** * Allocate a notification iterator. * - * @param plugin Plug-in instance + * @param component Component instance * @param next_cb Callback advancing to the next notification * @param notification_cb Callback providing the current notification * @returns A notification iterator instance */ extern struct bt_notification_iterator *bt_notification_iterator_create( - struct bt_plugin *plugin, + struct bt_component *component, bt_notification_iterator_next_cb next_cb, bt_notification_iterator_get_notification_cb notification_cb); diff --git a/include/babeltrace/plugin/plugin.h b/include/babeltrace/plugin/plugin.h index 60a1a21a..ae6dae86 100644 --- a/include/babeltrace/plugin/plugin.h +++ b/include/babeltrace/plugin/plugin.h @@ -5,6 +5,7 @@ * BabelTrace - Babeltrace Plug-in Interface * * Copyright 2015 Jérémie Galarneau + * Copyright 2015 Philippe Proulx * * Author: Jérémie Galarneau * @@ -27,10 +28,33 @@ * SOFTWARE. */ -#include -#include -#include -#include -#include +#include + +#define BT_PLUGIN_NAME(_x) const char *__bt_plugin_name = (_x) +#define BT_PLUGIN_AUTHOR(_x) const char *__bt_plugin_author = (_x) +#define BT_PLUGIN_LICENSE(_x) const char *__bt_plugin_license = (_x) +#define BT_PLUGIN_INIT(_x) void *__bt_plugin_init = (_x) +#define BT_PLUGIN_EXIT(_x) void *__bt_plugin_exit = (_x) + +#define BT_PLUGIN_COMPONENT_CLASSES_BEGIN \ + enum bt_status __bt_plugin_register_component_classes(\ + struct bt_component_factory *factory)\ + { + +#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _it_cr) \ + bt_component_factory_register_source_component_class(factory, \ + _name, _init, _fini, _it_cr); + +#define BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _hd_notif) \ + bt_component_factory_register_sink_component_class(factory, \ + _name, _init, _fini, _hd_notif); + +#define BT_PLUGIN_COMPONENT_CLASSES_END\ + \ + return BT_STATUS_OK;\ +}\ + \ + BT_PLUGIN_INIT(__bt_plugin_register_component_classes);\ + BT_PLUGIN_EXIT(NULL); #endif /* BABELTRACE_PLUGIN_H */ diff --git a/include/babeltrace/plugin/plugin-lib.h b/include/babeltrace/plugin/sink.h similarity index 50% rename from include/babeltrace/plugin/plugin-lib.h rename to include/babeltrace/plugin/sink.h index bea8665a..8284b348 100644 --- a/include/babeltrace/plugin/plugin-lib.h +++ b/include/babeltrace/plugin/sink.h @@ -1,8 +1,8 @@ -#ifndef BABELTRACE_PLUGIN_LIB_H -#define BABELTRACE_PLUGIN_LIB_H +#ifndef BABELTRACE_PLUGIN_COMPONENT_SINK_H +#define BABELTRACE_PLUGIN_COMPONENT_SINK_H /* - * BabelTrace - Base interface of a Babeltrace Plug-in Library + * BabelTrace - Sink Component Interface * * Copyright 2015 Jérémie Galarneau * @@ -27,53 +27,23 @@ * SOFTWARE. */ -#include -#include -#include +#include #ifdef __cplusplus extern "C" { #endif -struct bt_plugin; -struct bt_notification; - -/** - * Plug-in discovery functions. - * - * The Babeltrace plug-in architecture mandates that a given plug-in shared - * object only define one plug-in. These functions are used to query a plug-in - * shared object about its attributes. - * - * The functions marked as mandatory MUST be exported by the shared object - * to be considered a valid plug-in. - */ - -/** - * Get the plug-in type implemented by the library. - * - * @returns One of #bt_plugin_type values - */ -extern enum bt_plugin_type bt_plugin_lib_get_type(void); - -/** - * Get the name of the format implemented by the library. - * - * @returns A string (ownership is not transfered) - */ -extern const char *bt_plugin_lib_get_format_name(void); - /** - * Create a plug-in instance configured with the provided parameters. + * Hand-off a notification to a sink component. * - * @param params Map object of configuration parameters - * (see bt_object_map_create()) - * @returns An instance of the plug-in + * @param component Component instance + * @returns One of #bt_component_status values */ -extern struct bt_plugin *bt_plugin_lib_create(struct bt_object *params); +enum bt_component_status bt_component_sink_handle_notification( + struct bt_component *component); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_PLUGIN_H */ +#endif /* BABELTRACE_PLUGIN_COMPONENT_SINK_H */ -- 2.34.1