ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = include types compat lib formats converter bindings tests doc extras
+SUBDIRS = include types compat lib formats converter bindings tests doc extras plugins
dist_doc_DATA = ChangeLog LICENSE mit-license.txt gpl-2.0.txt \
std-ext-lib.txt README
*/
#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/plugin/plugin.h>
+#include <babeltrace/plugin/plugin-system.h>
#include <babeltrace/ctf-writer/ref-internal.h>
#include <glib.h>
BT_HIDDEN
enum bt_plugin_status bt_plugin_init(struct bt_plugin *plugin, const char *name,
- void *user_data,bt_plugin_destroy_func destroy_func,
+ void *user_data,bt_plugin_destroy_cb destroy_func,
enum bt_plugin_type plugin_type,
- bt_plugin_destroy_func plugin_destroy);
+ bt_plugin_destroy_cb plugin_destroy);
#ifdef __cplusplus
}
*/
#include <babeltrace/objects.h>
+#include <babeltrace/plugin/notification/iterator.h>
#ifdef __cplusplus
extern "C" {
#endif
+struct bt_notification;
+
/**
* Plug-in private data deallocation function type.
*
*/
typedef void (*bt_plugin_destroy_cb)(struct bt_plugin *plugin);
+/**
+ * Iterator creation function type.
+ *
+ * @param plugin Plug-in instance
+ */
+typedef struct bt_notification_iterator *(
+ *bt_plugin_source_iterator_create_cb)(
+ struct bt_plugin *plugin);
+
+/**
+ * Notification handling function type.
+ *
+ * @param plugin Plug-in instance
+ * @param notificattion Notification to handle
+ */
+typedef int (*bt_plugin_sink_handle_notification_cb)(struct bt_plugin *,
+ struct bt_notification *);
+
+typedef struct bt_notification *(bt_notification_iterator_get_notification_cb)(
+ struct bt_notification_iterator *);
+
+typedef struct bt_notification *(bt_notification_iterator_get_notification_cb)(
+ struct bt_notification_iterator *);
+
+typedef enum bt_notification_iterator_status (bt_notification_iterator_next_cb)(
+ struct bt_notification_iterator *);
+
/**
* Get a plug-in's private (implementation) data.
*
*/
extern void *bt_plugin_get_private_data(struct bt_plugin *plugin);
-
+
/** Plug-in initialization functions */
/**
* Allocate a source plug-in.
* @returns A source plug-in instance
*/
extern struct bt_plugin *bt_plugin_source_create(const char *name,
- void *private_data, bt_plugin_destroy_func destroy_func,
+ void *private_data, bt_plugin_destroy_cb destroy_func,
bt_plugin_source_iterator_create_cb iterator_create_cb);
/**
* @returns A sink plug-in instance
*/
extern struct bt_plugin *bt_plugin_sink_create(const char *name,
- void *private_data, bt_plugin_destroy_func destroy_func,
+ void *private_data, bt_plugin_destroy_cb destroy_func,
bt_plugin_sink_handle_notification_cb notification_cb);
bt_notification_iterator_next_cb next_cb,
bt_notification_iterator_get_notification_cb notification_cb);
-/**
- * Set an iterator's private data.
- *
- * @param plugin Plug-in instance on which to iterate
- * @param data Iterator private data
- * @returns One of #bt_notification_iterator_status values
- */
-extern enum bt_notification_iterator_status *bt_notification_iterator_create(
- struct bt_plugin *plugin, void *data);
-
#ifdef __cplusplus
}
#endif
/** No error, okay. */
BT_PLUGIN_STATUS_OK = 0,
-}
+};
+
+struct bt_plugin;
/**
* Get plug-in instance name.
struct bt_plugin;
struct bt_notification_iterator;
-/**
- * Iterator creation function type.
- *
- * @param plugin Plug-in instance
- */
-typedef struct bt_notification_iterator *(
- *bt_plugin_source_iterator_create_func)(
- struct bt_plugin *plugin);
-
/**
* Create an iterator on a plug-in instance.
*
lib_LTLIBRARIES = libbabeltrace-plugin.la
+# Plug-in system library
libbabeltrace_plugin_la_SOURCES = \
plugin.c \
+ filter.c \
source.c \
sink.c \
iterator.c
-# Request that the linker keeps all static libraries objects.
+# Request that the linker keeps all static librarie objects.
libbabeltrace_plugin_la_LDFLAGS = \
-Wl,--no-as-needed -version-info $(BABELTRACE_LIBRARY_VERSION)
* SOFTWARE.
*/
+#include <babeltrace/plugin/plugin-internal.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/compiler.h>
+
+static void bt_plugin_destroy(struct bt_ctf_ref *ref);
+
const char *bt_plugin_get_name(struct bt_plugin *plugin)
{
const char *ret = NULL;
BT_HIDDEN
enum bt_plugin_status bt_plugin_init(struct bt_plugin *plugin, const char *name,
- void *user_data, bt_plugin_destroy_func user_destroy_func,
+ void *user_data, bt_plugin_destroy_cb user_destroy_func,
enum bt_plugin_type plugin_type,
- bt_plugin_destroy_func plugin_destroy)
+ bt_plugin_destroy_cb plugin_destroy)
{
enum bt_plugin_status ret = BT_PLUGIN_STATUS_OK;
if (!plugin || !name || name[0] == '\0' ||
- !destroy_func || !private_data) {
+ !user_destroy_func || !user_data || !plugin_destroy) {
ret = BT_PLUGIN_STATUS_INVAL;
goto end;
}
static
void bt_plugin_destroy(struct bt_ctf_ref *ref)
{
- struct bt_ctf_plugin *plugin = NULL;
+ struct bt_plugin *plugin = NULL;
if (!ref) {
return;
}
- plugin = container_of(ref, struct bt_plugin, parent);
+ plugin = container_of(ref, struct bt_plugin, ref_count);
/**
* Destroy user data, base and source/filter/sink last since
* it will deallocate the plugin.
*/
- assert(plugin->user_destroy_func);
- plugin->user_destroy_func(plugin->user_data);
+ assert(plugin->user_data_destroy);
+ plugin->user_data_destroy(plugin->user_data);
g_string_free(plugin->name, TRUE);