Build fix and sink implementation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Jul 2015 19:48:42 +0000 (15:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 16:57:25 +0000 (12:57 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/Makefile.am
include/babeltrace/plugin/component-factory-internal.h
include/babeltrace/plugin/component-factory.h
include/babeltrace/plugin/component-internal.h
include/babeltrace/plugin/plugin-system.h
include/babeltrace/plugin/sink-internal.h
include/babeltrace/plugin/source-internal.h
plugins/Makefile.am
plugins/component.c
plugins/sink.c
plugins/source.c

index f6b11bfc1f174320755e7c8ead57fc5a34d70eb3..d26647b24263ac825f9cb8deb1a98ac5e24d823c 100644 (file)
@@ -43,7 +43,6 @@ babeltraceplugininclude_HEADERS = \
        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 \
index e6d368da3b499d9f300da4d2c32f370986642fef..4810e9cad450bc567ec90f58eb18edf71933f922 100644 (file)
@@ -1,3 +1,35 @@
+#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 */
 /**
@@ -9,6 +41,7 @@
  * @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);
@@ -22,6 +55,9 @@ extern struct bt_component *bt_component_source_create(const char *name,
  * @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 */
index 8b8c81bfd408a72e8c17d565dbfee5d6ec746a1d..06c613799a99f69c494e5c3b76757b8d4f477b40 100644 (file)
@@ -29,6 +29,7 @@
 #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" {
@@ -36,22 +37,22 @@ 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);
index 3fc85c858c90b905e5a40531960cfb4308f729b1..6c8689aaabd5cd2dfd781bd2bdac35b3f31bd439 100644 (file)
@@ -44,13 +44,13 @@ struct bt_notification;
 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
index 6d6614da2f7c87fd35c78695dba9306d6f198e38..e7ca01a58dca2bbc58f8c83b0c797fd850885120 100644 (file)
@@ -75,6 +75,7 @@ typedef enum bt_notification_iterator_status (bt_notification_iterator_next_cb)(
  * 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);
 
@@ -82,10 +83,11 @@ 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 */
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..30617789559a8d7a376f84c9143cda85c17809c3 100644 (file)
@@ -0,0 +1,41 @@
+#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 */
index 38bf7f8901ba4d911bcd5668c38d154291558548..54af8b703abe3148dc074e68388d47fc2b17c8e9 100644 (file)
@@ -2,7 +2,7 @@
 #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
index ffb0295b963c518659d12d405aab0582f9ff07f9..ec8248ffbdbe29a49f9c680c5d69d69bac421a3b 100644 (file)
@@ -1,6 +1,6 @@
 AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include
 
-SUBDIRS = . ctf
+SUBDIRS = .
 
 lib_LTLIBRARIES = libbabeltrace-plugin.la
 
index 6036fd501ec39020ff67d63d64b1f178dee5f6cb..5b7a23b3666472484f9a6e389030be920ea5c83a 100644 (file)
@@ -107,8 +107,9 @@ void bt_component_put(struct bt_component *component)
 }
 
 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)
 {
@@ -137,7 +138,7 @@ end:
 
 void *bt_component_get_private_data(struct bt_component *component)
 {
-        void *ret = NULL;
+       void *ret = NULL;
 
        if (!component) {
                goto end;
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..911b5e84060088eadd45ddcc89df00b2ff0d0282 100644 (file)
@@ -0,0 +1,74 @@
+/*
+ * 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;
+}
index 6b115abeede46b34b3c9974a06e6666353367174..d32fa2a7071df83e2a24990c71ae32a1f8678c8b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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;
This page took 0.033003 seconds and 4 git commands to generate.