plugin-dev.h: put selector (type) close to union in structures
[babeltrace.git] / include / babeltrace / plugin / plugin-dev.h
CommitLineData
33b34c43
PP
1#ifndef BABELTRACE_PLUGIN_PLUGIN_DEV_H
2#define BABELTRACE_PLUGIN_PLUGIN_DEV_H
3
4/*
6ba0b073 5 * BabelTrace - Babeltrace Plug-in Development API
33b34c43
PP
6 *
7 * This is the header that you need to include for the development of
8 * a Babeltrace plug-in.
9 *
10 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
12 *
13 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 * of this software and associated documentation files (the "Software"), to deal
17 * in the Software without restriction, including without limitation the rights
18 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 * copies of the Software, and to permit persons to whom the Software is
20 * furnished to do so, subject to the following conditions:
21 *
22 * The above copyright notice and this permission notice shall be included in
23 * all copies or substantial portions of the Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 */
33
6ba0b073 34#include <stdint.h>
33b34c43
PP
35#include <babeltrace/plugin/plugin.h>
36#include <babeltrace/component/component-class.h>
d3e4dcd8
PP
37#include <babeltrace/component/component-class-source.h>
38#include <babeltrace/component/component-class-filter.h>
39#include <babeltrace/component/component-class-sink.h>
33b34c43
PP
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
6ba0b073
PP
45/*
46 * Plugin interface's version, not synced with Babeltrace's version
47 * (internal use).
48 */
49#define __BT_PLUGIN_VERSION_MAJOR 1
50#define __BT_PLUGIN_VERSION_MINOR 0
51
52/* Plugin initialization function type */
33b34c43
PP
53typedef enum bt_plugin_status (*bt_plugin_init_func)(
54 struct bt_plugin *plugin);
55
6ba0b073 56/* Plugin exit function type */
33b34c43
PP
57typedef enum bt_plugin_status (*bt_plugin_exit_func)(void);
58
6ba0b073
PP
59/*
60 * Function to call from a plugin's initialization function to add a
61 * component class to a plugin object.
62 */
33b34c43
PP
63extern enum bt_plugin_status bt_plugin_add_component_class(
64 struct bt_plugin *plugin,
65 struct bt_component_class *component_class);
66
6ba0b073
PP
67/* Plugin descriptor: describes a single plugin (internal use) */
68struct __bt_plugin_descriptor {
69 /* Plugin's interface major version number */
70 uint32_t major;
71
72 /* Plugin's interface minor version number */
73 uint32_t minor;
74
75 /* Plugin's name */
76 const char *name;
77} __attribute__((packed));
78
79/* Type of a plugin attribute (internal use) */
80enum __bt_plugin_descriptor_attribute_type {
81 BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT = 0,
82 BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT = 1,
83 BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR = 2,
84 BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE = 3,
85 BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 4,
b6de043b
PP
86 BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION = 5,
87};
88
89/* Plugin (user) version */
90struct __bt_plugin_descriptor_version {
91 uint32_t major;
92 uint32_t minor;
93 uint32_t patch;
94 const char *extra;
6ba0b073
PP
95};
96
97/* Plugin attribute (internal use) */
98struct __bt_plugin_descriptor_attribute {
99 /* Plugin descriptor to which to associate this attribute */
100 const struct __bt_plugin_descriptor *plugin_descriptor;
101
6ba0b073
PP
102 /* Name of the attribute's type for debug purposes */
103 const char *type_name;
104
857f4dce
PP
105 /* Attribute's type */
106 enum __bt_plugin_descriptor_attribute_type type;
107
d3e4dcd8 108 /* Attribute's value (depends on attribute's type) */
6ba0b073
PP
109 union {
110 /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT */
111 bt_plugin_init_func init;
112
113 /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT */
114 bt_plugin_exit_func exit;
115
116 /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR */
117 const char *author;
118
119 /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE */
120 const char *license;
121
122 /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
123 const char *description;
b6de043b
PP
124
125 /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION */
126 struct __bt_plugin_descriptor_version version;
6ba0b073
PP
127 } value;
128} __attribute__((packed));
129
130/* Component class descriptor (internal use) */
131struct __bt_plugin_component_class_descriptor {
132 /*
133 * Plugin descriptor to which to associate this component
134 * class descriptor.
135 */
136 const struct __bt_plugin_descriptor *plugin_descriptor;
137
6ba0b073
PP
138 /* Component class name */
139 const char *name;
140
857f4dce
PP
141 /* Component class type */
142 enum bt_component_class_type type;
143
d3e4dcd8
PP
144 /* Mandatory methods (depends on component class type) */
145 union {
146 /* BT_COMPONENT_CLASS_TYPE_SOURCE */
147 struct {
148 bt_component_class_source_init_iterator_method init_iterator;
149 } source;
150
151 /* BT_COMPONENT_CLASS_TYPE_FILTER */
152 struct {
153 bt_component_class_filter_init_iterator_method init_iterator;
154 } filter;
155
156 /* BT_COMPONENT_CLASS_TYPE_SINK */
157 struct {
158 bt_component_class_sink_consume_method consume;
159 } sink;
160 } methods;
6ba0b073
PP
161} __attribute__((packed));
162
163/* Type of a component class attribute (internal use) */
164enum __bt_plugin_component_class_descriptor_attribute_type {
d3e4dcd8
PP
165 BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 0,
166 BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD = 1,
167 BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD = 2,
168 BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD = 3,
169 BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD = 4,
6ba0b073
PP
170};
171
172/* Component class attribute (internal use) */
173struct __bt_plugin_component_class_descriptor_attribute {
174 /*
175 * Component class plugin attribute to which to associate this
176 * component class attribute.
177 */
178 const struct __bt_plugin_component_class_descriptor *comp_class_descriptor;
179
6ba0b073
PP
180 /* Name of the attribute's type for debug purposes */
181 const char *type_name;
182
857f4dce
PP
183 /* Attribute's type */
184 enum __bt_plugin_component_class_descriptor_attribute_type type;
185
d3e4dcd8 186 /* Attribute's value (depends on attribute's type) */
6ba0b073 187 union {
d3e4dcd8 188 /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
6ba0b073 189 const char *description;
d3e4dcd8
PP
190
191 /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD */
192 bt_component_class_init_method init_method;
193
194 /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD */
195 bt_component_class_destroy_method destroy_method;
196
197 /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD */
198 bt_component_class_filter_add_iterator_method filter_add_iterator_method;
199
200 /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD */
201 bt_component_class_sink_add_iterator_method sink_add_iterator_method;
6ba0b073
PP
202 } value;
203} __attribute__((packed));
204
205/*
206 * Variable attributes for a plugin descriptor pointer to be added to
207 * the plugin descriptor section (internal use).
208 */
209#define __BT_PLUGIN_DESCRIPTOR_ATTRS \
210 __attribute__((section("__bt_plugin_descriptors"), used))
211
212/*
213 * Variable attributes for a plugin attribute pointer to be added to
214 * the plugin attribute section (internal use).
215 */
216#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \
217 __attribute__((section("__bt_plugin_descriptor_attributes"), used))
218
219/*
220 * Variable attributes for a component class descriptor pointer to be
221 * added to the component class descriptor section (internal use).
222 */
223#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \
224 __attribute__((section("__bt_plugin_component_class_descriptors"), used))
225
226/*
227 * Variable attributes for a component class descriptor attribute
228 * pointer to be added to the component class descriptor attribute
229 * section (internal use).
230 */
231#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \
232 __attribute__((section("__bt_plugin_component_class_descriptor_attributes"), used))
233
234/*
235 * Declares a plugin descriptor pointer variable with a custom ID.
236 *
237 * _id: ID (any valid C identifier except `auto`).
238 */
239#define BT_PLUGIN_DECLARE(_id) extern struct __bt_plugin_descriptor __bt_plugin_descriptor_##_id
240
241/*
242 * Defines a plugin descriptor with a custom ID.
243 *
244 * _id: ID (any valid C identifier except `auto`).
245 * _name: Plugin's name (C string).
246 */
247#define BT_PLUGIN_WITH_ID(_id, _name) \
248 struct __bt_plugin_descriptor __bt_plugin_descriptor_##_id = { \
249 .major = __BT_PLUGIN_VERSION_MAJOR, \
250 .minor = __BT_PLUGIN_VERSION_MINOR, \
251 .name = _name, \
252 }; \
253 static struct __bt_plugin_descriptor const * const __bt_plugin_descriptor_##_id##_ptr __BT_PLUGIN_DESCRIPTOR_ATTRS = &__bt_plugin_descriptor_##_id; \
254 extern struct __bt_plugin_descriptor const *__start___bt_plugin_descriptors; \
255 extern struct __bt_plugin_descriptor const *__stop___bt_plugin_descriptors
256
257/*
258 * Defines a plugin attribute (generic, internal use).
259 *
260 * _attr_name: Name of the attribute (C identifier).
261 * _attr_type: Type of the attribute (enum __bt_plugin_descriptor_attribute_type).
262 * _id: Plugin descriptor ID (C identifier).
263 * _x: Value.
264 */
265#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(_attr_name, _attr_type, _id, _x) \
266 static struct __bt_plugin_descriptor_attribute __bt_plugin_descriptor_attribute_##_id##_##_attr_name = { \
267 .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
6ba0b073 268 .type_name = #_attr_name, \
857f4dce 269 .type = _attr_type, \
6ba0b073
PP
270 .value._attr_name = _x, \
271 }; \
272 static struct __bt_plugin_descriptor_attribute const * const __bt_plugin_descriptor_attribute_##_id##_##_attr_name##_ptr __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_descriptor_attribute_##_id##_##_attr_name; \
273 extern struct __bt_plugin_descriptor_attribute const *__start___bt_plugin_descriptor_attributes; \
274 extern struct __bt_plugin_descriptor_attribute const *__stop___bt_plugin_descriptor_attributes
275
276/*
277 * Defines a plugin initialization function attribute attached to a
278 * specific plugin descriptor.
279 *
280 * _id: Plugin descriptor ID (C identifier).
281 * _x: Initialization function (bt_plugin_init_func).
282 */
283#define BT_PLUGIN_INIT_WITH_ID(_id, _x) \
284 __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(init, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT, _id, _x)
285
286/*
287 * Defines a plugin exit function attribute attached to a specific
288 * plugin descriptor.
289 *
290 * _id: Plugin descriptor ID (C identifier).
291 * _x: Exit function (bt_plugin_exit_func).
292 */
293#define BT_PLUGIN_EXIT_WITH_ID(_id, _x) \
294 __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(exit, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT, _id, _x)
295
296/*
297 * Defines an author attribute attached to a specific plugin descriptor.
298 *
299 * _id: Plugin descriptor ID (C identifier).
300 * _x: Author (C string).
301 */
302#define BT_PLUGIN_AUTHOR_WITH_ID(_id, _x) \
303 __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(author, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR, _id, _x)
304
305/*
306 * Defines a license attribute attached to a specific plugin descriptor.
307 *
308 * _id: Plugin descriptor ID (C identifier).
309 * _x: License (C string).
310 */
311#define BT_PLUGIN_LICENSE_WITH_ID(_id, _x) \
312 __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(license, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE, _id, _x)
313
314/*
315 * Defines a description attribute attached to a specific plugin
316 * descriptor.
317 *
318 * _id: Plugin descriptor ID (C identifier).
319 * _x: Description (C string).
320 */
321#define BT_PLUGIN_DESCRIPTION_WITH_ID(_id, _x) \
322 __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _x)
323
b6de043b
PP
324#define __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra) \
325 {.major = _major, .minor = _minor, .patch = _patch, .extra = _extra,}
326
327/*
328 * Defines a version attribute attached to a specific plugin descriptor.
329 *
330 * _id: Plugin descriptor ID (C identifier).
331 * _major: Plugin's major version (uint32_t).
332 * _minor: Plugin's minor version (uint32_t).
333 * _patch: Plugin's patch version (uint32_t).
334 * _extra: Plugin's version extra information (C string).
335 */
336#define BT_PLUGIN_VERSION_WITH_ID(_id, _major, _minor, _patch, _extra) \
337 __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(version, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION, _id, __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra))
338
6ba0b073 339/*
d3e4dcd8
PP
340 * Declaration of start and stop symbols of component class descriptors
341 * section.
342 */
343#define __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP \
344 extern struct __bt_plugin_component_class_descriptor const *__start___bt_plugin_component_class_descriptors; \
345 extern struct __bt_plugin_component_class_descriptor const *__stop___bt_plugin_component_class_descriptors
346
347/*
348 * Defines a source component class descriptor with a custom ID.
6ba0b073 349 *
d3e4dcd8
PP
350 * _id: ID (any valid C identifier except `auto`).
351 * _comp_class_id: Component class ID (C identifier).
352 * _name: Component class name (C string).
353 * _init_iterator_method: Component class's iterator initialization method
354 * (bt_component_class_source_init_iterator_method).
6ba0b073 355 */
d3e4dcd8
PP
356#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _init_iterator_method) \
357 static struct __bt_plugin_component_class_descriptor __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id = { \
6ba0b073 358 .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
6ba0b073 359 .name = _name, \
857f4dce 360 .type = BT_COMPONENT_CLASS_TYPE_SOURCE, \
d3e4dcd8
PP
361 .methods.source = { \
362 .init_iterator = _init_iterator_method, \
363 }, \
6ba0b073 364 }; \
d3e4dcd8
PP
365 static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id; \
366 __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP
367
368/*
369 * Defines a filter component class descriptor with a custom ID.
370 *
371 * _id: ID (any valid C identifier except `auto`).
372 * _comp_class_id: Component class ID (C identifier).
373 * _name: Component class name (C string).
374 * _init_iterator_method: Component class's iterator initialization method
375 * (bt_component_class_filter_init_iterator_method).
376 */
377#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _init_iterator_method) \
378 static struct __bt_plugin_component_class_descriptor __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id = { \
379 .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
d3e4dcd8 380 .name = _name, \
857f4dce 381 .type = BT_COMPONENT_CLASS_TYPE_FILTER, \
d3e4dcd8
PP
382 .methods.filter = { \
383 .init_iterator = _init_iterator_method, \
384 }, \
385 }; \
386 static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id; \
387 __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP
388
389/*
390 * Defines a sink component class descriptor with a custom ID.
391 *
392 * _id: ID (any valid C identifier except `auto`).
393 * _comp_class_id: Component class ID (C identifier).
394 * _name: Component class name (C string).
395 * _consume_method: Component class's iterator consume method
396 * (bt_component_class_sink_consume_method).
397 */
398#define BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _consume_method) \
399 static struct __bt_plugin_component_class_descriptor __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id = { \
400 .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
d3e4dcd8 401 .name = _name, \
857f4dce 402 .type = BT_COMPONENT_CLASS_TYPE_SINK, \
d3e4dcd8
PP
403 .methods.sink = { \
404 .consume = _consume_method, \
405 }, \
406 }; \
407 static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id; \
408 __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP
6ba0b073
PP
409
410/*
411 * Defines a component class descriptor attribute (generic, internal
412 * use).
413 *
414 * _id: Plugin descriptor ID (C identifier).
415 * _comp_class_id: Component class ID (C identifier).
d3e4dcd8 416 * _type: Component class type (`source`, `filter`, or `sink`).
6ba0b073
PP
417 * _attr_name: Name of the attribute (C identifier).
418 * _attr_type: Type of the attribute
419 * (enum __bt_plugin_descriptor_attribute_type).
420 * _x: Value.
421 */
422#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(_attr_name, _attr_type, _id, _comp_class_id, _type, _x) \
d3e4dcd8
PP
423 static struct __bt_plugin_component_class_descriptor_attribute __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name = { \
424 .comp_class_descriptor = &__bt_plugin_##_type##_component_class_descriptor_##_id##_##_comp_class_id, \
6ba0b073 425 .type_name = #_attr_name, \
857f4dce 426 .type = _attr_type, \
d3e4dcd8 427 .value._attr_name = _x, \
6ba0b073 428 }; \
d3e4dcd8 429 static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name; \
6ba0b073
PP
430 extern struct __bt_plugin_component_class_descriptor_attribute const *__start___bt_plugin_component_class_descriptor_attributes; \
431 extern struct __bt_plugin_component_class_descriptor_attribute const *__stop___bt_plugin_component_class_descriptor_attributes
432
433/*
d3e4dcd8
PP
434 * Defines a description attribute attached to a specific source
435 * component class descriptor.
6ba0b073
PP
436 *
437 * _id: Plugin descriptor ID (C identifier).
438 * _comp_class_id: Component class descriptor ID (C identifier).
6ba0b073
PP
439 * _x: Description (C string).
440 */
d3e4dcd8
PP
441#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
442 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, source, _x)
443
444/*
445 * Defines a description attribute attached to a specific filter
446 * component class descriptor.
447 *
448 * _id: Plugin descriptor ID (C identifier).
449 * _comp_class_id: Component class descriptor ID (C identifier).
450 * _x: Description (C string).
451 */
452#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
453 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, filter, _x)
454
455/*
456 * Defines a description attribute attached to a specific sink
457 * component class descriptor.
458 *
459 * _id: Plugin descriptor ID (C identifier).
460 * _comp_class_id: Component class descriptor ID (C identifier).
461 * _x: Description (C string).
462 */
463#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
464 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, sink, _x)
465
466/*
467 * Defines an initialization method attribute attached to a specific
468 * source component class descriptor.
469 *
470 * _id: Plugin descriptor ID (C identifier).
471 * _comp_class_id: Component class descriptor ID (C identifier).
472 * _x: Initialization method (bt_component_class_init_method).
473 */
474#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
475 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, source, _x)
476
477/*
478 * Defines an initialization method attribute attached to a specific
479 * filter component class descriptor.
480 *
481 * _id: Plugin descriptor ID (C identifier).
482 * _comp_class_id: Component class descriptor ID (C identifier).
483 * _x: Initialization method (bt_component_class_init_method).
484 */
485#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
486 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, filter, _x)
487
488/*
489 * Defines an initialization method attribute attached to a specific
490 * sink component class descriptor.
491 *
492 * _id: Plugin descriptor ID (C identifier).
493 * _comp_class_id: Component class descriptor ID (C identifier).
494 * _x: Initialization method (bt_component_class_init_method).
495 */
496#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
497 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, sink, _x)
498
499/*
500 * Defines a destroy method attribute attached to a specific source
501 * component class descriptor.
502 *
503 * _id: Plugin descriptor ID (C identifier).
504 * _comp_class_id: Component class descriptor ID (C identifier).
505 * _x: Destroy method (bt_component_class_destroy_method).
506 */
507#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
508 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD, _id, _comp_class_id, source, _x)
509
510/*
511 * Defines a destroy method attribute attached to a specific filter
512 * component class descriptor.
513 *
514 * _id: Plugin descriptor ID (C identifier).
515 * _comp_class_id: Component class descriptor ID (C identifier).
516 * _x: Destroy method (bt_component_class_destroy_method).
517 */
518#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
519 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD, _id, _comp_class_id, filter, _x)
520
521/*
522 * Defines a destroy method attribute attached to a specific sink
523 * component class descriptor.
524 *
525 * _id: Plugin descriptor ID (C identifier).
526 * _comp_class_id: Component class descriptor ID (C identifier).
527 * _x: Destroy method (bt_component_class_destroy_method).
528 */
529#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
530 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD, _id, _comp_class_id, sink, _x)
531
532/*
533 * Defines an add iterator method attribute attached to a specific
534 * filter component class descriptor.
535 *
536 * _id: Plugin descriptor ID (C identifier).
537 * _comp_class_id: Component class descriptor ID (C identifier).
538 * _x: Add iterator method
539 * (bt_component_class_filter_add_iterator_method).
540 */
541#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(_id, _comp_class_id, _x) \
542 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_add_iterator_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD, _id, _comp_class_id, filter, _x)
543
544/*
545 * Defines an add iterator method attribute attached to a specific
546 * sink component class descriptor.
547 *
548 * _id: Plugin descriptor ID (C identifier).
549 * _comp_class_id: Component class descriptor ID (C identifier).
550 * _x: Add iterator method
551 * (bt_component_class_sink_add_iterator_method).
552 */
553#define BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(_id, _comp_class_id, _x) \
554 __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_add_iterator_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD, _id, _comp_class_id, sink, _x)
6ba0b073
PP
555
556/*
557 * Defines a plugin descriptor with an automatic ID.
558 *
559 * _name: Plugin's name (C string).
560 */
561#define BT_PLUGIN(_name) static BT_PLUGIN_WITH_ID(auto, #_name)
562
563/*
564 * Defines a plugin initialization function attribute attached to the
565 * automatic plugin descriptor.
566 *
567 * _x: Initialization function (bt_plugin_init_func).
568 */
569#define BT_PLUGIN_INIT(_x) BT_PLUGIN_INIT_WITH_ID(auto, _x)
570
571 /*
572 * Defines a plugin exit function attribute attached to the automatic
573 * plugin descriptor.
574 *
575 * _x: Exit function (bt_plugin_exit_func).
576 */
577#define BT_PLUGIN_EXIT(_x) BT_PLUGIN_EXIT_WITH_ID(auto, _x)
578
579/*
580 * Defines an author attribute attached to the automatic plugin
581 * descriptor.
582 *
583 * _x: Author (C string).
584 */
585#define BT_PLUGIN_AUTHOR(_x) BT_PLUGIN_AUTHOR_WITH_ID(auto, _x)
586
587/*
588 * Defines a license attribute attached to the automatic plugin
589 * descriptor.
590 *
591 * _x: License (C string).
592 */
593#define BT_PLUGIN_LICENSE(_x) BT_PLUGIN_LICENSE_WITH_ID(auto, _x)
594
595/*
596 * Defines a description attribute attached to the automatic plugin
597 * descriptor.
598 *
599 * _x: Description (C string).
600 */
601#define BT_PLUGIN_DESCRIPTION(_x) BT_PLUGIN_DESCRIPTION_WITH_ID(auto, _x)
b6de043b
PP
602
603/*
604 * Defines a version attribute attached to the automatic plugin
605 * descriptor.
606 *
607 * _major: Plugin's major version (uint32_t).
608 * _minor: Plugin's minor version (uint32_t).
609 * _patch: Plugin's patch version (uint32_t).
610 * _extra: Plugin's version extra information (C string).
611 */
612#define BT_PLUGIN_VERSION(_major, _minor, _patch, _extra) BT_PLUGIN_VERSION_WITH_ID(auto, _major, _minor, _patch, _extra)
6ba0b073
PP
613
614/*
d3e4dcd8
PP
615 * Defines a source component class attached to the automatic plugin
616 * descriptor. Its ID is the same as its name, hence its name must be a
617 * C identifier in this version.
618 *
619 * _name: Component class name (C identifier).
620 * _init_iterator_method: Component class's iterator initialization method
621 * (bt_component_class_source_init_iterator_method).
622 */
623#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _init_iterator_method) \
624 BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _init_iterator_method)
625
626/*
627 * Defines a filter component class attached to the automatic plugin
6ba0b073
PP
628 * descriptor. Its ID is the same as its name, hence its name must be a
629 * C identifier in this version.
630 *
d3e4dcd8
PP
631 * _name: Component class name (C identifier).
632 * _init_iterator_method: Component class's iterator initialization method
633 * (bt_component_class_filter_init_iterator_method).
6ba0b073 634 */
d3e4dcd8
PP
635#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _init_iterator_method) \
636 BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _init_iterator_method)
6ba0b073
PP
637
638/*
d3e4dcd8
PP
639 * Defines a sink component class attached to the automatic plugin
640 * descriptor. Its ID is the same as its name, hence its name must be a
641 * C identifier in this version.
642 *
643 * _name: Component class name (C identifier).
644 * _consume_method: Component class's consume method
645 * (bt_component_class_sink_consume_method).
646 */
647#define BT_PLUGIN_SINK_COMPONENT_CLASS(_name, _consume_method) \
648 BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _consume_method)
649
650/*
651 * Defines a description attribute attached to a source component class
6ba0b073
PP
652 * descriptor which is attached to the automatic plugin descriptor.
653 *
d3e4dcd8
PP
654 * _name: Component class name (C identifier).
655 * _x: Description (C string).
656 */
657#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
658 BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
659
660/*
661 * Defines a description attribute attached to a filter component class
662 * descriptor which is attached to the automatic plugin descriptor.
663 *
664 * _name: Component class name (C identifier).
665 * _x: Description (C string).
666 */
667#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
668 BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
669
670/*
671 * Defines a description attribute attached to a sink component class
672 * descriptor which is attached to the automatic plugin descriptor.
673 *
674 * _name: Component class name (C identifier).
675 * _x: Description (C string).
676 */
677#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
678 BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
679
680/*
681 * Defines an initialization method attribute attached to a source
682 * component class descriptor which is attached to the automatic plugin
683 * descriptor.
684 *
685 * _name: Component class name (C identifier).
686 * _x: Initialization method (bt_component_class_init_method).
687 */
688#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
689 BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
690
691/*
692 * Defines an initialization method attribute attached to a filter
693 * component class descriptor which is attached to the automatic plugin
694 * descriptor.
695 *
696 * _name: Component class name (C identifier).
697 * _x: Initialization method (bt_component_class_init_method).
698 */
699#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
700 BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
701
702/*
703 * Defines an initialization method attribute attached to a sink
704 * component class descriptor which is attached to the automatic plugin
705 * descriptor.
706 *
707 * _name: Component class name (C identifier).
708 * _x: Initialization method (bt_component_class_init_method).
709 */
710#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
711 BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
712
713/*
714 * Defines a destroy method attribute attached to a source component
715 * class descriptor which is attached to the automatic plugin
716 * descriptor.
717 *
718 * _name: Component class name (C identifier).
719 * _x: Initialization method (bt_component_class_destroy_method).
720 */
721#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD(_name, _x) \
722 BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(auto, _name, _x)
723
724/*
725 * Defines a destroy method attribute attached to a filter component
726 * class descriptor which is attached to the automatic plugin
727 * descriptor.
728 *
729 * _name: Component class name (C identifier).
730 * _x: Initialization method (bt_component_class_destroy_method).
731 */
732#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD(_name, _x) \
733 BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(auto, _name, _x)
734
735/*
736 * Defines a destroy method attribute attached to a sink component class
737 * descriptor which is attached to the automatic plugin descriptor.
738 *
739 * _name: Component class name (C identifier).
740 * _x: Initialization method (bt_component_class_destroy_method).
741 */
742#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD(_name, _x) \
743 BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(auto, _name, _x)
744
745/*
746 * Defines an add iterator method attribute attached to a filter
747 * component class descriptor which is attached to the automatic plugin
748 * descriptor.
749 *
750 * _name: Component class name (C identifier).
751 * _x: Add iterator method (bt_component_class_filter_add_iterator_method).
752 */
753#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ADD_ITERATOR_METHOD(_name, _x) \
754 BT_PLUGIN_FILTER_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(auto, _name, _x)
755
756/*
757 * Defines an add iterator method attribute attached to a sink
758 * component class descriptor which is attached to the automatic plugin
759 * descriptor.
760 *
761 * _name: Component class name (C identifier).
762 * _x: Add iterator method (bt_component_class_sink_add_iterator_method).
6ba0b073 763 */
d3e4dcd8
PP
764#define BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD(_name, _x) \
765 BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(auto, _name, _x)
33b34c43
PP
766
767#ifdef __cplusplus
768}
769#endif
770
771#endif /* BABELTRACE_PLUGIN_PLUGIN_DEV_H */
This page took 0.053993 seconds and 4 git commands to generate.