Babeltrace 2 C API  2.0.6
Open-source trace manipulation framework
Simple shared object plugin definition C file

This example shows a basic Babeltrace 2 shared object plugin definition C file.

The shared object plugin's name is vestige. Therefore the input and output component classes would be identified in the babeltrace2 command-line tool as source.vestige.input and sink.vestige.output.

Assume that vestige.c contains the actual source and sink component classes's code, and that vestige.h contains its declarations.

vestige-plugin.c:

/* Component class method declarations */
#include "vestige.h"
/* Always start with this line */
/* Declare the `vestige` plugin */
BT_PLUGIN(vestige);
/* Set some optional plugin properties */
BT_PLUGIN_DESCRIPTION("Input and output for the Vestige format.");
BT_PLUGIN_AUTHOR("Denis Rondeau");
/* Add the `input` source component class */
BT_PLUGIN_SOURCE_COMPONENT_CLASS(input, vestige_in_iter_next);
/* Set the source component class's optional description */
"Read a Vestige trace file.");
/* Set some optional methods of the source component class */
vestige_in_init);
vestige_in_finalize);
input, vestige_in_iter_init);
input, vestige_in_iter_fini);
/* Add the `output` sink component class */
BT_PLUGIN_SINK_COMPONENT_CLASS(output, vestige_out_consume);
/* Set the sink component class's optional description */
"Write a Vestige trace file.");
/* Set some optional methods of the sink component class */
vestige_out_init);
vestige_out_finalize);
vestige_out_graph_is_configured);

See Compile and link a Babeltrace 2 shared object plugin to learn how you could compile and link those files as a Babeltrace 2 shared object plugin.