From 62ed7c304672e2b6fd88b6d59fa3c9a7ad993a2d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 3 Jun 2015 10:39:55 +0200 Subject: [PATCH] Integrate modifications after plugin review MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- include/Makefile.am | 7 +- include/babeltrace/plugin/component-class.h | 67 +++++++++ include/babeltrace/plugin/component-factory.h | 67 +++++++++ include/babeltrace/plugin/component.h | 136 ++++++++++++++++++ .../plugin/notification/event-internal.h | 53 +++++++ .../notification/notification-internal.h | 48 +++++++ include/babeltrace/plugin/plugin.h | 109 +------------- 7 files changed, 382 insertions(+), 105 deletions(-) create mode 100644 include/babeltrace/plugin/component-class.h create mode 100644 include/babeltrace/plugin/component-factory.h create mode 100644 include/babeltrace/plugin/component.h create mode 100644 include/babeltrace/plugin/notification/event-internal.h create mode 100644 include/babeltrace/plugin/notification/notification-internal.h diff --git a/include/Makefile.am b/include/Makefile.am index d839f478..01273ae4 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -38,6 +38,9 @@ babeltracectfirinclude_HEADERS = \ babeltraceplugininclude_HEADERS = \ babeltrace/plugin/plugin.h \ + babeltrace/plugin/component.h \ + babeltrace/plugin/component-class.h \ + babeltrace/plugin/component-factory.h \ babeltrace/plugin/source.h \ babeltrace/plugin/sink.h \ babeltrace/plugin/filter.h \ @@ -106,8 +109,10 @@ noinst_HEADERS = \ babeltrace/compat/mman.h \ babeltrace/endian.h \ babeltrace/mmap-align.h \ - babeltrace/plugin/plugin-internal.h \ babeltrace/plugin/sink-internal.h \ + babeltrace/plugin/component-internal.h \ + babeltrace/plugin/component-class-internal.h \ + babeltrace/plugin/component-factory-internal.h \ babeltrace/plugin/source-internal.h \ babeltrace/plugin/filter-internal.h \ babeltrace/plugin/notification/event-internal.h \ diff --git a/include/babeltrace/plugin/component-class.h b/include/babeltrace/plugin/component-class.h new file mode 100644 index 00000000..8988abc2 --- /dev/null +++ b/include/babeltrace/plugin/component-class.h @@ -0,0 +1,67 @@ +#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.h b/include/babeltrace/plugin/component-factory.h new file mode 100644 index 00000000..379e6c0a --- /dev/null +++ b/include/babeltrace/plugin/component-factory.h @@ -0,0 +1,67 @@ +#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_H */ diff --git a/include/babeltrace/plugin/component.h b/include/babeltrace/plugin/component.h new file mode 100644 index 00000000..1a17ed7e --- /dev/null +++ b/include/babeltrace/plugin/component.h @@ -0,0 +1,136 @@ +#ifndef BABELTRACE_PLUGIN_COMPONENT_H +#define BABELTRACE_PLUGIN_COMPONENT_H + +/* + * BabelTrace - Babeltrace Plug-in Component Interface + * + * Copyright 2015 Jérémie Galarneau + * + * Author: 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 + * 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Component type. + */ +enum bt_component_type { + BT_COMPONENT_TYPE_UNKNOWN = -1, + + /** A source component is a notification generator. */ + BT_COMPONENT_TYPE_SOURCE = 0, + + /** A sink component handles incoming notifications. */ + BT_COMPONENT_TYPE_SINK = 1, + + /** A filter component implements both Source and Sink interfaces. */ + BT_COMPONENT_TYPE_FILTER = 2, +}; + +/** + * Status code. Errors are always negative. + */ +enum bt_component_status { + /** Memory allocation failure. */ + /* -12 for compatibility with -ENOMEM */ + BT_COMPONENT_STATUS_NOMEM = -12, + + /** Invalid arguments. */ + /* -22 for compatibility with -EINVAL */ + BT_COMPONENT_STATUS_INVAL = -22, + + /** Unsupported component feature. */ + BT_COMPONENT_STATUS_UNSUPPORTED = -2, + + /** General error. */ + BT_COMPONENT_STATUS_ERROR = -1, + + /** No error, okay. */ + BT_COMPONENT_STATUS_OK = 0, +}; + +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 + */ +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) + * @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 instance type. + * + * @param component Component instance of which to get the type + * @returns One of #bt_component_type values + */ +extern enum bt_component_type bt_component_get_type( + struct bt_component *component); + +/** + * Set a component instance's error stream. + * + * @param component Component instance + * @param error_stream Error stream + * @returns One of #bt_component_status values + */ +extern enum bt_component_status bt_component_set_error_stream( + struct bt_component *component, FILE *error_stream); + +/** + * Increments the reference count of \p component. + * + * @param component Component of which to increment the reference count + * + * @see bt_component_put() + */ +extern void bt_component_get(struct bt_component *component); + +/** + * Decrements the reference count of \p component, destroying it when this + * count reaches 0. + * + * @param component Component of which to decrement the reference count + * + * @see bt_component_get() + */ +extern void bt_component_put(struct bt_component *component); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_COMPONENT_H */ diff --git a/include/babeltrace/plugin/notification/event-internal.h b/include/babeltrace/plugin/notification/event-internal.h new file mode 100644 index 00000000..442f6040 --- /dev/null +++ b/include/babeltrace/plugin/notification/event-internal.h @@ -0,0 +1,53 @@ +#ifndef BABELTRACE_PLUGIN_NOTIFICATION_EVENT_INTERNAL_H +#define BABELTRACE_PLUGIN_NOTIFICATION_EVENT_INTERNAL_H + +/* + * BabelTrace - Plug-in Event Notification internal + * + * Copyright 2015 Jérémie Galarneau + * + * Author: 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 + * 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 +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_plugin_notification_event { + struct bt_plugin_notification parent; + struct bt_ctf_trace *trace; + struct bt_ctf_stream *stream; + struct bt_ctf_event *event; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_NOTIFICATION_EVENT_INTERNAL_H */ diff --git a/include/babeltrace/plugin/notification/notification-internal.h b/include/babeltrace/plugin/notification/notification-internal.h new file mode 100644 index 00000000..92cea158 --- /dev/null +++ b/include/babeltrace/plugin/notification/notification-internal.h @@ -0,0 +1,48 @@ +#ifndef BABELTRACE_PLUGIN_NOTIFICATION_INTERNAL_H +#define BABELTRACE_PLUGIN_NOTIFICATION_INTERNAL_H + +/* + * BabelTrace - Plug-in Notification internal + * + * Copyright 2015 Jérémie Galarneau + * + * Author: 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 + * 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 +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_plugin_notification { + struct bt_ctf_ref ref_count; + enum bt_plugin_notification_type type; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_NOTIFICATION_INTERNAL_H */ diff --git a/include/babeltrace/plugin/plugin.h b/include/babeltrace/plugin/plugin.h index d0816261..60a1a21a 100644 --- a/include/babeltrace/plugin/plugin.h +++ b/include/babeltrace/plugin/plugin.h @@ -27,109 +27,10 @@ * SOFTWARE. */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Plug-in type. - */ -enum bt_plugin_type { - BT_PLUGIN_TYPE_UNKNOWN = -1, - - /** A source plug-in is a notification generator. */ - BT_PLUGIN_TYPE_SOURCE = 0, - - /** A sink plug-in handles incoming notifications. */ - BT_PLUGIN_TYPE_SINK = 1, - - /** A filter plug-in implements both Source and Sink interfaces. */ - BT_PLUGIN_TYPE_FILTER = 2, -}; - -/** - * Status code. Errors are always negative. - */ -enum bt_plugin_status { - /** Memory allocation failure. */ - /* -12 for compatibility with -ENOMEM */ - BT_PLUGIN_STATUS_NOMEM = -12, - - /** Invalid arguments. */ - /* -22 for compatibility with -EINVAL */ - BT_PLUGIN_STATUS_INVAL = -22, - - /** Unsupported plug-in feature. */ - BT_PLUGIN_STATUS_UNSUPPORTED = -2, - - /** General error. */ - BT_PLUGIN_STATUS_ERROR = -1, - - /** No error, okay. */ - BT_PLUGIN_STATUS_OK = 0, -}; - -struct bt_plugin; - -/** - * Get plug-in instance name. - * - * @param plugin Plug-in instance of which to get the name - * @returns Returns a pointer to the plug-in's name - */ -extern const char *bt_plugin_get_name(struct bt_plugin *plugin); - -/** - * Set plug-in instance name. - * - * @param plugin Plug-in instance of which to set the name - * @param name New plug-in name (will be copied) - * @returns One of #bt_plugin_status values - */ -extern enum bt_plugin_status bt_plugin_set_name( - struct bt_plugin *plugin, const char *name); - -/** - * Get plug-in instance type. - * - * @param plugin Plug-in instance of which to get the type - * @returns One of #bt_plugin_type values - */ -extern enum bt_plugin_type bt_plugin_get_type(struct bt_plugin *plugin); - -/** - * Set a plug-in instance's error stream. - * - * @param plugin Plug-in instance - * @param error_stream Error stream - * @returns One of #bt_plugin_status values - */ -extern enum bt_plugin_status bt_plugin_set_error_stream( - struct bt_plugin *plugin, FILE *error_stream); - -/** - * Increments the reference count of \p plugin. - * - * @param plugin Plug-in of which to increment the reference count - * - * @see bt_plugin_put() - */ -extern void bt_plugin_get(struct bt_plugin *plugin); - -/** - * Decrements the reference count of \p plugin, destroying it when this - * count reaches 0. - * - * @param plugin Plug-in of which to decrement the reference count - * - * @see bt_plugin_get() - */ -extern void bt_plugin_put(struct bt_plugin *plugin); - -#ifdef __cplusplus -} -#endif +#include +#include +#include +#include +#include #endif /* BABELTRACE_PLUGIN_H */ -- 2.34.1