From 90354d3a48e8659a3550bf6edf8d714323855a7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 3 Feb 2015 09:56:45 -0500 Subject: [PATCH] Initial plug-in interface draft MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- .../babeltrace/plugin/notification/event.h | 46 ++++++++++++ .../babeltrace/plugin/notification/iterator.h | 51 +++++++++++++ .../plugin/notification/notification.h | 53 ++++++++++++++ include/babeltrace/plugin/plugin-internal.h | 47 ++++++++++++ include/babeltrace/plugin/plugin.h | 73 +++++++++++++++++++ include/babeltrace/plugin/source.h | 52 +++++++++++++ 6 files changed, 322 insertions(+) create mode 100644 include/babeltrace/plugin/notification/event.h create mode 100644 include/babeltrace/plugin/notification/iterator.h create mode 100644 include/babeltrace/plugin/notification/notification.h create mode 100644 include/babeltrace/plugin/plugin-internal.h create mode 100644 include/babeltrace/plugin/plugin.h create mode 100644 include/babeltrace/plugin/source.h diff --git a/include/babeltrace/plugin/notification/event.h b/include/babeltrace/plugin/notification/event.h new file mode 100644 index 00000000..93d1d68a --- /dev/null +++ b/include/babeltrace/plugin/notification/event.h @@ -0,0 +1,46 @@ +#ifndef BABELTRACE_PLUGIN_NOTIFICATION_EVENT_H +#define BABELTRACE_PLUGIN_NOTIFICATION_EVENT_H + +/* + * BabelTrace - Plug-in Notification + * + * 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 + +struct bt_notification; +struct bt_ctf_event; + +struct bt_ctf_event *bt_plugin_notification_event_get_event( + struct bt_plugin_notification *notification); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_NOTIFICATION_EVENT_H */ diff --git a/include/babeltrace/plugin/notification/iterator.h b/include/babeltrace/plugin/notification/iterator.h new file mode 100644 index 00000000..baf62f04 --- /dev/null +++ b/include/babeltrace/plugin/notification/iterator.h @@ -0,0 +1,51 @@ +#ifndef BABELTRACE_PLUGIN_NOTIFICATION_ITERATOR_H +#define BABELTRACE_PLUGIN_NOTIFICATION_ITERATOR_H + +/* + * BabelTrace - Plug-in Notification Iterator + * + * 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 + +struct bt_notification; +struct bt_notification_iterator; + +int bt_notification_iterator_next(struct bt_notification_iterator *iterator); + +struct bt_notification *bt_notification_iterator_get_notification( + struct bt_notification_iterator *iterator); + +void bt_notification_iterator_get(struct bt_notification_iterator *iterator); +void bt_notification_iterator_put(struct bt_notification_iterator *iterator); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_NOTIFICATION_H */ diff --git a/include/babeltrace/plugin/notification/notification.h b/include/babeltrace/plugin/notification/notification.h new file mode 100644 index 00000000..2d73dcc1 --- /dev/null +++ b/include/babeltrace/plugin/notification/notification.h @@ -0,0 +1,53 @@ +#ifndef BABELTRACE_PLUGIN_NOTIFICATION_H +#define BABELTRACE_PLUGIN_NOTIFICATION_H + +/* + * BabelTrace - Plug-in Notification + * + * 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 + +struct bt_notification; + +enum bt_plugin_notification_type { + BT_PLUGIN_NOTIFICATION_TYPE_UNKNOWN = -1, + BT_PLUGIN_NOTIFICATION_TYPE_EVENT = 0, /* see notification/event.h */ +}; + +enum bt_plugin_notification_type bt_plugin_notification_get_type( + struct bt_plugin_notification *notification); + +void bt_plugin_notification_get(struct bt_plugin_notification *notification); +void bt_plugin_notification_put(struct bt_plugin_notification *notification); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_NOTIFICATION_H */ diff --git a/include/babeltrace/plugin/plugin-internal.h b/include/babeltrace/plugin/plugin-internal.h new file mode 100644 index 00000000..d6bbbd3f --- /dev/null +++ b/include/babeltrace/plugin/plugin-internal.h @@ -0,0 +1,47 @@ +#ifndef BABELTRACE_PLUGIN_INTERNAL_H +#define BABELTRACE_PLUGIN_INTERNAL_H + +/* + * BabelTrace - Plug-in 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 + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_notification; + +struct bt_plugin { + const char * name; + enum bt_plugin_type type; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_INTERNAL_H */ diff --git a/include/babeltrace/plugin/plugin.h b/include/babeltrace/plugin/plugin.h new file mode 100644 index 00000000..9c2c5f00 --- /dev/null +++ b/include/babeltrace/plugin/plugin.h @@ -0,0 +1,73 @@ +#ifndef BABELTRACE_PLUGIN_H +#define BABELTRACE_PLUGIN_H + +/* + * BabelTrace - Plug-in + * + * 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 + +struct bt_plugin; +struct bt_notification; + +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, +}; + +/** + * 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 about + * shared object about its attributes. + * + * The functions marked as mandatory MUST be exported by the shared object + * to be considered a valid plug-in. + */ +enum bt_plugin_type bt_plugin_get_type(void); +const char *bt_plugin_get_name(void); + +/* TODO: document mandatory fields and their expected types */ +int bt_plugin_set_parameters(struct bt_plugin *plugin, + struct bt_ctf_field *field); + +void bt_plugin_get(struct bt_plugin *plugin); +void bt_plugin_put(struct bt_plugin *plugin); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_H */ diff --git a/include/babeltrace/plugin/source.h b/include/babeltrace/plugin/source.h new file mode 100644 index 00000000..581b7893 --- /dev/null +++ b/include/babeltrace/plugin/source.h @@ -0,0 +1,52 @@ +#ifndef BABELTRACE_PLUGIN_SOURCE_H +#define BABELTRACE_PLUGIN_SOURCE_H + +/* + * BabelTrace - Source Plug-in + * + * 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 + +struct bt_plugin; +struct bt_notification_iterator; +typedef struct bt_iterator *(*bt_plugin_source_iterator_create_func)(struct bt_plugin *); + +struct bt_notification_iterator *bt_plugin_source_get_iterator( + struct bt_plugin *plugin); + +/* Plug-in initialization functions */ +struct bt_plugin *bt_plugin_source_create(void *data); +int bt_plugin_source_set_iterator_create_function(struct bt_plugin *plugin, + bt_plugin_source_iterator_create_func func); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_PLUGIN_SOURCE_H */ -- 2.34.1