| 1 | #ifndef BABELTRACE_PLUGIN_PLUGIN_H |
| 2 | #define BABELTRACE_PLUGIN_PLUGIN_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace - Babeltrace Plug-in Interface |
| 6 | * |
| 7 | * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 8 | * Copyright 2017 Philippe Proulx <pproulx@efficios.com> |
| 9 | * |
| 10 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 11 | * |
| 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 13 | * of this software and associated documentation files (the "Software"), to deal |
| 14 | * in the Software without restriction, including without limitation the rights |
| 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 16 | * copies of the Software, and to permit persons to whom the Software is |
| 17 | * furnished to do so, subject to the following conditions: |
| 18 | * |
| 19 | * The above copyright notice and this permission notice shall be included in |
| 20 | * all copies or substantial portions of the Software. |
| 21 | * |
| 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 28 | * SOFTWARE. |
| 29 | */ |
| 30 | |
| 31 | #include <stddef.h> |
| 32 | #include <stdbool.h> |
| 33 | #include <babeltrace/graph/component-class.h> |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
| 39 | struct bt_plugin; |
| 40 | struct bt_plugin_set; |
| 41 | struct bt_component_class; |
| 42 | |
| 43 | /** |
| 44 | * Status code. Errors are always negative. |
| 45 | */ |
| 46 | enum bt_plugin_status { |
| 47 | /** No error, okay. */ |
| 48 | BT_PLUGIN_STATUS_OK = 0, |
| 49 | /** General error. */ |
| 50 | BT_PLUGIN_STATUS_ERROR = -1, |
| 51 | /** Memory allocation failure. */ |
| 52 | BT_PLUGIN_STATUS_NOMEM = -4, |
| 53 | }; |
| 54 | |
| 55 | extern struct bt_plugin *bt_plugin_find(const char *plugin_name); |
| 56 | |
| 57 | extern struct bt_component_class *bt_plugin_find_component_class( |
| 58 | const char *plugin_name, const char *component_class_name, |
| 59 | enum bt_component_class_type component_class_type); |
| 60 | |
| 61 | extern struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path); |
| 62 | |
| 63 | extern struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path, |
| 64 | bool recurse); |
| 65 | |
| 66 | extern struct bt_plugin_set *bt_plugin_create_all_from_static(void); |
| 67 | |
| 68 | /** |
| 69 | * Get the name of a plug-in. |
| 70 | * |
| 71 | * @param plugin An instance of a plug-in |
| 72 | * @returns Plug-in name or NULL on error |
| 73 | */ |
| 74 | extern const char *bt_plugin_get_name(struct bt_plugin *plugin); |
| 75 | |
| 76 | /** |
| 77 | * Get the name of a plug-in's author. |
| 78 | * |
| 79 | * @param plugin An instance of a plug-in |
| 80 | * @returns Plug-in author or NULL on error |
| 81 | */ |
| 82 | extern const char *bt_plugin_get_author(struct bt_plugin *plugin); |
| 83 | |
| 84 | /** |
| 85 | * Get the license of a plug-in. |
| 86 | * |
| 87 | * @param plugin An instance of a plug-in |
| 88 | * @returns Plug-in license or NULL on error |
| 89 | */ |
| 90 | extern const char *bt_plugin_get_license(struct bt_plugin *plugin); |
| 91 | |
| 92 | /** |
| 93 | * Get the decription of a plug-in. |
| 94 | * |
| 95 | * @param plugin An instance of a plug-in |
| 96 | * @returns Plug-in description or NULL if none is available |
| 97 | */ |
| 98 | extern const char *bt_plugin_get_description(struct bt_plugin *plugin); |
| 99 | |
| 100 | /** |
| 101 | * Get the path of a plug-in. |
| 102 | * |
| 103 | * @param plugin An instance of a plug-in |
| 104 | * @returns Plug-in path or NULL on error |
| 105 | */ |
| 106 | extern const char *bt_plugin_get_path(struct bt_plugin *plugin); |
| 107 | |
| 108 | extern enum bt_plugin_status bt_plugin_get_version(struct bt_plugin *plugin, |
| 109 | unsigned int *major, unsigned int *minor, unsigned int *patch, |
| 110 | const char **extra); |
| 111 | |
| 112 | extern int bt_plugin_get_component_class_count(struct bt_plugin *plugin); |
| 113 | |
| 114 | extern struct bt_component_class *bt_plugin_get_component_class( |
| 115 | struct bt_plugin *plugin, size_t index); |
| 116 | |
| 117 | extern |
| 118 | struct bt_component_class *bt_plugin_get_component_class_by_name_and_type( |
| 119 | struct bt_plugin *plugin, const char *name, |
| 120 | enum bt_component_class_type type); |
| 121 | |
| 122 | extern |
| 123 | int bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set); |
| 124 | |
| 125 | extern |
| 126 | struct bt_plugin *bt_plugin_set_get_plugin(struct bt_plugin_set *plugin_set, |
| 127 | unsigned int index); |
| 128 | |
| 129 | #ifdef __cplusplus |
| 130 | } |
| 131 | #endif |
| 132 | |
| 133 | #endif /* BABELTRACE_PLUGIN_PLUGIN_H */ |