Commit | Line | Data |
---|---|---|
633edee0 JG |
1 | #ifndef BABELTRACE_PLUGIN_COMPONENT_FACTORY_H |
2 | #define BABELTRACE_PLUGIN_COMPONENT_FACTORY_H | |
62ed7c30 JG |
3 | |
4 | /* | |
633edee0 | 5 | * Babeltrace - Component Factory Class Interface. |
62ed7c30 | 6 | * |
633edee0 | 7 | * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
62ed7c30 JG |
8 | * |
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
10 | * of this software and associated documentation files (the "Software"), to deal | |
11 | * in the Software without restriction, including without limitation the rights | |
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
13 | * copies of the Software, and to permit persons to whom the Software is | |
14 | * furnished to do so, subject to the following conditions: | |
15 | * | |
16 | * The above copyright notice and this permission notice shall be included in | |
17 | * all copies or substantial portions of the Software. | |
18 | * | |
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
25 | * SOFTWARE. | |
26 | */ | |
27 | ||
633edee0 JG |
28 | #include <babeltrace/plugin/component.h> |
29 | #include <babeltrace/plugin/source.h> | |
30 | #include <babeltrace/plugin/sink.h> | |
31 | #include <babeltrace/plugin/filter.h> | |
0d884c50 | 32 | #include <babeltrace/plugin/plugin-system.h> |
2e339de1 | 33 | #include <babeltrace/values.h> |
62ed7c30 JG |
34 | |
35 | #ifdef __cplusplus | |
36 | extern "C" { | |
633edee0 JG |
37 | #endif |
38 | ||
f3e4505b JG |
39 | /** |
40 | * Status code. Errors are always negative. | |
41 | */ | |
42 | enum bt_component_factory_status { | |
43 | /** General error. */ | |
fb2dcc52 JG |
44 | BT_COMPONENT_FACTORY_STATUS_ERROR = -128, |
45 | ||
0859fe1f JG |
46 | /** Duplicate component class being registered. */ |
47 | BT_COMPONENT_FACTORY_STATUS_DUPLICATE = -7, | |
48 | ||
fb2dcc52 JG |
49 | /** Invalid plugin. */ |
50 | BT_COMPONENT_FACTORY_STATUS_INVAL_PLUGIN = -6, | |
f3e4505b JG |
51 | |
52 | /** Invalid arguments. */ | |
fb2dcc52 | 53 | BT_COMPONENT_FACTORY_STATUS_INVAL = -5, |
f3e4505b JG |
54 | |
55 | /** Memory allocation failure. */ | |
fb2dcc52 | 56 | BT_COMPONENT_FACTORY_STATUS_NOMEM = -4, |
f3e4505b JG |
57 | |
58 | /** I/O error. */ | |
fb2dcc52 | 59 | BT_COMPONENT_FACTORY_STATUS_IO = -3, |
f3e4505b JG |
60 | |
61 | /** No such file or directory. */ | |
fb2dcc52 | 62 | BT_COMPONENT_FACTORY_STATUS_NOENT = -2, |
f3e4505b JG |
63 | |
64 | /** Operation not permitted. */ | |
fb2dcc52 | 65 | BT_COMPONENT_FACTORY_STATUS_PERM = -1, |
f3e4505b JG |
66 | |
67 | /** No error, okay. */ | |
fb2dcc52 | 68 | BT_COMPONENT_FACTORY_STATUS_OK = 0, |
f3e4505b JG |
69 | }; |
70 | ||
633edee0 | 71 | struct bt_component_factory; |
62ed7c30 | 72 | |
f3e4505b JG |
73 | /** |
74 | * Create a component factory. | |
75 | * | |
76 | * @returns An instance of component factory | |
77 | */ | |
b8a06801 | 78 | extern struct bt_component_factory *bt_component_factory_create(void); |
f3e4505b | 79 | |
fb2dcc52 | 80 | /** |
38b48196 | 81 | * Get the number of component classes registered to the component factory. |
fc11e32c | 82 | * |
38b48196 JG |
83 | * @param factory A component factory instance |
84 | * @returns The number of component classes registered to the | |
85 | * component factory, or a negative value on error. | |
fb2dcc52 | 86 | */ |
38b48196 | 87 | extern int bt_component_factory_get_component_class_count( |
fb2dcc52 JG |
88 | struct bt_component_factory *factory); |
89 | ||
fc11e32c | 90 | /** |
38b48196 JG |
91 | * Get component class at index. |
92 | * | |
93 | * @param factory A component factory instance | |
94 | * @param index Index of the component class to return | |
95 | * @returns A component class instance, NULL on error. | |
fc11e32c | 96 | */ |
38b48196 JG |
97 | extern struct bt_component_class *bt_component_factory_get_component_class_index( |
98 | struct bt_component_factory *factory, int index); | |
99 | ||
100 | /** | |
101 | * Look-up component class. | |
102 | * | |
103 | * @param factory A component factory instance | |
104 | * @param plugin_name Name of the plug-in which registered the | |
105 | * component class | |
106 | * @param type Component type (@see #bt_component_type) | |
107 | * @param component_name Component name | |
108 | * @returns A component class instance, NULL on error. | |
109 | */ | |
110 | extern struct bt_component_class *bt_component_factory_get_component_class( | |
111 | struct bt_component_factory *factory, | |
112 | const char *plugin_name, enum bt_component_type type, | |
113 | const char *component_name); | |
fc11e32c | 114 | |
5d4cba3d JG |
115 | /** |
116 | * Load and register Babeltrace plugins under a given path. | |
117 | * | |
118 | * Path will be traversed if it is a directory, otherwise only the provided file | |
119 | * will be loaded. | |
120 | * | |
121 | * @param factory A component factory instance | |
122 | * @param path A path to a file or directory | |
123 | * @returns One of #bt_component_factory_status values | |
124 | */ | |
125 | extern enum bt_component_factory_status bt_component_factory_load( | |
126 | struct bt_component_factory *factory, const char *path); | |
127 | ||
f3e4505b JG |
128 | /** |
129 | * Recursively load and register Babeltrace plugins under a given path. | |
130 | * | |
131 | * Path will be traversed recursively if it is a directory, otherwise only the | |
132 | * provided file will be loaded. | |
133 | * | |
134 | * @param factory A component factory instance | |
135 | * @param path A path to a file or directory | |
136 | * @returns One of #bt_component_factory_status values | |
137 | */ | |
5d4cba3d | 138 | extern enum bt_component_factory_status bt_component_factory_load_recursive( |
f3e4505b | 139 | struct bt_component_factory *factory, const char *path); |
62ed7c30 | 140 | |
cba174d5 JG |
141 | /** |
142 | * Load and register Babeltrace plugins statically-linked to the executable. | |
143 | * | |
144 | * @param factory A component factory instance | |
145 | * @returns One of #bt_component_factory_status values | |
146 | */ | |
147 | extern enum bt_component_factory_status bt_component_factory_load_static( | |
148 | struct bt_component_factory *factory); | |
149 | ||
b8a06801 | 150 | extern enum bt_component_factory_status |
f3e4505b | 151 | bt_component_factory_register_source_component_class( |
fb2dcc52 | 152 | struct bt_component_factory *factory, const char *name, |
7c7c0433 | 153 | const char *description, bt_component_init_cb init); |
62ed7c30 | 154 | |
b8a06801 JG |
155 | extern enum bt_component_factory_status |
156 | bt_component_factory_register_sink_component_class( | |
fb2dcc52 | 157 | struct bt_component_factory *factory, const char *name, |
7c7c0433 | 158 | const char *description, bt_component_init_cb init); |
62ed7c30 | 159 | |
34ac9eaf JG |
160 | extern enum bt_component_factory_status |
161 | bt_component_factory_register_filter_component_class( | |
162 | struct bt_component_factory *factory, const char *name, | |
163 | const char *description, bt_component_init_cb init); | |
164 | ||
633edee0 | 165 | #ifdef __cplusplus |
62ed7c30 JG |
166 | } |
167 | #endif | |
168 | ||
633edee0 | 169 | #endif /* BABELTRACE_PLUGIN_COMPONENT_FACTORY_H */ |