babeltrace/plugin/source.h \
babeltrace/plugin/sink.h \
babeltrace/plugin/filter.h \
- babeltrace/plugin/plugin-lib.h \
babeltrace/plugin/plugin-system.h \
babeltrace/plugin/notification/eot.h \
babeltrace/plugin/notification/notification.h \
+#ifndef BABELTRACE_PLUGIN_COMPONENT_FACTORY_INTERNAL_H
+#define BABELTRACE_PLUGIN_COMPONENT_FACTORY_INTERNAL_H
+
+/*
+ * BabelTrace - Component Factory Internal
+ *
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/plugin/component-internal.h>
+#include <babeltrace/plugin/plugin-system.h>
/** Component initialization functions */
/**
* @param iterator_create_cb Iterator creation callback
* @returns A source component instance
*/
+BT_HIDDEN
extern struct bt_component *bt_component_source_create(const char *name,
void *private_data, bt_component_destroy_cb destroy_func,
bt_component_source_iterator_create_cb iterator_create_cb);
* @param notification_cb Notification handling callback
* @returns A sink component instance
*/
+BT_HIDDEN
extern struct bt_component *bt_component_sink_create(const char *name,
void *private_data, bt_component_destroy_cb destroy_func,
bt_component_sink_handle_notification_cb notification_cb);
+
+#endif /* BABELTRACE_PLUGIN_COMPONENT_FACTORY_INTERNAL_H */
#include <babeltrace/plugin/source.h>
#include <babeltrace/plugin/sink.h>
#include <babeltrace/plugin/filter.h>
+#include <babeltrace/plugin/plugin-system.h>
#ifdef __cplusplus
extern "C" {
struct bt_component_factory;
-typedef struct bt_component *(*bt_component_init)(
+typedef struct bt_component *(*bt_component_init_cb)(
struct bt_component *component);
-typedef struct bt_component *(*bt_component_fini)(
+typedef struct bt_component *(*bt_component_fini_cb)(
struct bt_component *component);
enum bt_component_status bt_component_factory_create(const char *path);
enum bt_component_status bt_component_factory_register_source_component_class(
struct bt_component_factory *factory, const char *name,
- bt_component_init init, bt_component_fini fini,
+ bt_component_init_cb init, bt_component_fini_cb fini,
bt_component_source_iterator_create_cb iterator_create_cb);
enum bt_component_status bt_component_factory_register_sink_component_class(
struct bt_component_factory *factory, const char *name,
- bt_component_init init, bt_component_fini fini,
+ bt_component_init_cb init, bt_component_fini_cb fini,
bt_component_sink_handle_notification_cb handle_notification_cb);
void bt_component_factory_destroy(struct bt_component_factory *factory);
struct bt_component {
struct bt_ctf_ref ref_count;
GString *name;
- enum bt_plugin_type type;
+ enum bt_component_type type;
/** No ownership taken */
FILE *error_stream;
void *user_data;
- bt_plugin_destroy_cb user_data_destroy;
- bt_plugin_destroy_cb destroy;
+ bt_component_destroy_cb user_data_destroy;
+ bt_component_destroy_cb destroy;
};
BT_HIDDEN
* Get a component's private (implementation) data.
*
* @param component Component of which to get the private data
+ * @returns Component's private data
*/
extern void *bt_component_get_private_data(struct bt_component *component);
* Set a component's private (implementation) data.
*
* @param component Component of which to set the private data
- * @param data Component private data
+ * @param data Component private data
+ * @returns One of #bt_component_status values
*/
-extern enum bt_component_status bt_component_set_private_data(struct bt_component *component,
- void *data);
+extern enum bt_component_status bt_component_set_private_data(
+ struct bt_component *component, void *data);
/** Notification iterator functions */
+#ifndef BABELTRACE_PLUGIN_SINK_INTERNAL_H
+#define BABELTRACE_PLUGIN_SINK_INTERNAL_H
+
+/*
+ * BabelTrace - Sink Component internal
+ *
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/plugin/component-internal.h>
+#include <babeltrace/plugin/plugin-system.h>
+
+struct bt_component_sink {
+ struct bt_component parent;
+
+ /* Component implementation callbacks */
+ bt_component_sink_handle_notification_cb handle_notification;
+};
+
+#endif /* BABELTRACE_PLUGIN_SINK_INTERNAL_H */
#define BABELTRACE_PLUGIN_SOURCE_INTERNAL_H
/*
- * BabelTrace - Source Plug-in internal
+ * BabelTrace - Source Component internal
*
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
*/
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/plugin/plugin-internal.h>
+#include <babeltrace/plugin/component-internal.h>
#include <babeltrace/plugin/plugin-system.h>
#ifdef __cplusplus
extern "C" {
#endif
-struct bt_plugin_source {
- struct bt_plugin parent;
+struct bt_component_source {
+ struct bt_component parent;
- /* Plug-in implementation callbacks */
- bt_plugin_source_iterator_create_cb create_iterator;
+ /* Component implementation callbacks */
+ bt_component_source_iterator_create_cb create_iterator;
};
#ifdef __cplusplus
AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include
-SUBDIRS = . ctf
+SUBDIRS = .
lib_LTLIBRARIES = libbabeltrace-plugin.la
}
BT_HIDDEN
-enum bt_component_status bt_component_init(struct bt_component *component, const char *name,
- void *user_data, bt_component_destroy_cb user_destroy_func,
+enum bt_component_status bt_component_init(struct bt_component *component,
+ const char *name, void *user_data,
+ bt_component_destroy_cb user_destroy_func,
enum bt_component_type component_type,
bt_component_destroy_cb component_destroy)
{
void *bt_component_get_private_data(struct bt_component *component)
{
- void *ret = NULL;
+ void *ret = NULL;
if (!component) {
goto end;
+/*
+ * sink.c
+ *
+ * Babeltrace Source Component
+ *
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/compiler.h>
+#include <babeltrace/plugin/sink-internal.h>
+#include <babeltrace/plugin/component-internal.h>
+
+static
+void bt_component_sink_destroy(struct bt_component *component)
+{
+ struct bt_component_sink *sink;
+
+ if (!component) {
+ return;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ g_free(sink);
+}
+
+struct bt_component *bt_component_sink_create(const char *name,
+ void *private_data, bt_component_destroy_cb destroy_func,
+ bt_component_sink_handle_notification_cb notification_cb)
+{
+ struct bt_component_sink *sink = NULL;
+ enum bt_component_status ret;
+
+ if (!notification_cb) {
+ goto end;
+ }
+
+ sink = g_new0(struct bt_component_sink, 1);
+ if (!sink) {
+ goto end;
+ }
+
+ ret = bt_component_init(&sink->parent, name, private_data,
+ destroy_func, BT_COMPONENT_TYPE_SINK,
+ bt_component_sink_destroy);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ g_free(sink);
+ sink = NULL;
+ goto end;
+ }
+
+ sink->handle_notification = notification_cb;
+end:
+ return sink ? &sink->parent : NULL;
+}
/*
* source.c
*
- * Babeltrace Source Plugin
+ * Babeltrace Source Component
*
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
#include <babeltrace/compiler.h>
#include <babeltrace/plugin/source-internal.h>
-#include <babeltrace/plugin/plugin-internal.h>
+#include <babeltrace/plugin/component-internal.h>
static
-void bt_plugin_source_destroy(struct bt_plugin *plugin)
+void bt_component_source_destroy(struct bt_component *component)
{
- struct bt_plugin_source *source;
+ struct bt_component_source *source;
- if (!plugin) {
+ if (!component) {
return;
}
- source = container_of(plugin, struct bt_plugin_source, parent);
+ source = container_of(component, struct bt_component_source, parent);
g_free(source);
}
-struct bt_plugin *bt_plugin_source_create(const char *name,
- void *private_data, bt_plugin_destroy_cb destroy_func,
- bt_plugin_source_iterator_create_cb iterator_create_cb)
+struct bt_component *bt_component_source_create(const char *name,
+ void *private_data, bt_component_destroy_cb destroy_func,
+ bt_component_source_iterator_create_cb iterator_create_cb)
{
- struct bt_plugin_source *source = NULL;
- enum bt_plugin_status ret;
+ struct bt_component_source *source = NULL;
+ enum bt_component_status ret;
if (!iterator_create_cb) {
goto end;
}
- source = g_new0(struct bt_plugin_source, 1);
+ source = g_new0(struct bt_component_source, 1);
if (!source) {
goto end;
}
- ret = bt_plugin_init(&source->parent, name, private_data,
- destroy_func, BT_PLUGIN_TYPE_SOURCE, bt_plugin_source_destroy);
- if (ret != BT_PLUGIN_STATUS_OK) {
+ ret = bt_component_init(&source->parent, name, private_data,
+ destroy_func, BT_COMPONENT_TYPE_SOURCE,
+ bt_component_source_destroy);
+ if (ret != BT_COMPONENT_STATUS_OK) {
g_free(source);
source = NULL;
goto end;