Create sink plugins
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 4 Sep 2015 19:24:38 +0000 (15:24 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 16:57:26 +0000 (12:57 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/plugin/component-class-internal.h
include/babeltrace/plugin/component-factory-internal.h
include/babeltrace/plugin/sink-internal.h
plugins/component-factory.c
plugins/ctf/text/text.c

index 500d7cf3f503f34c51bf2edcbf354d57d1fd920d..48cb3d9d34d942bc1876b4bf800f123cac2dd2ab 100644 (file)
@@ -40,8 +40,12 @@ struct bt_component_class {
 };
 
 BT_HIDDEN
-struct bt_component_class *bt_component_class_create(
-               enum bt_component_type type, const char *name,
+int bt_component_class_init(
+               struct bt_component_class *class, enum bt_component_type type,
+               const char *name);
+
+BT_HIDDEN
+int bt_component_class_set_plugin(struct bt_component_class *class,
                struct bt_plugin *plugin);
 
 #endif /* BABELTRACE_PLUGIN_COMPONENT_CLASS_INTERNAL_H */
index 3ee24f8510d80f1f81b164b59d524ba1e61e6f9f..d2f14478d9672d5907342f9938205549dcf8df04 100644 (file)
@@ -41,7 +41,7 @@ struct bt_component_factory {
        /** Array of pointers to struct bt_plugin */
        GPtrArray *plugins;
        /** Array of pointers to struct bt_component_class */
-       GPtrArray *components;
+       GPtrArray *component_classes;
 };
 
 #endif /* BABELTRACE_PLUGIN_COMPONENT_FACTORY_INTERNAL_H */
index f7b7bc4cbdfc0be76b4ae852e7f7a38d1fa85595..1bcd4ba599adf35e670709811ce6ff126c2364f0 100644 (file)
@@ -55,4 +55,15 @@ BT_HIDDEN
 extern struct bt_component *bt_component_sink_create(
                struct bt_component_class *class, const char *name);
 
+/**
+ * Allocate a sink component class.
+ *
+ * @param name                 Component instance name (will be copied)
+ * @returns                    A sink component class instance
+ */
+/* FIXME */
+BT_HIDDEN
+extern struct bt_component *bt_component_class_sink_create(
+               struct bt_component_class *class, const char *name);
+
 #endif /* BABELTRACE_PLUGIN_SINK_INTERNAL_H */
index 28b1e10618a4bfd90372d7a1dde44210ec558f50..8dc6103d9f530ebfa3b90ca0019ad94756b90de2 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <babeltrace/plugin/component-factory.h>
 #include <babeltrace/plugin/component-factory-internal.h>
+#include <babeltrace/plugin/source-internal.h>
+#include <babeltrace/plugin/sink-internal.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler.h>
 #include <babeltrace/ref.h>
@@ -70,6 +72,7 @@ bt_component_factory_load_file(struct bt_component_factory *factory,
        size_t path_len;
        GModule *module;
        struct bt_plugin *plugin;
+       bool is_libtool_wrapper = false, is_shared_object = false;
 
        if (!factory || !path) {
                ret = BT_COMPONENT_FACTORY_STATUS_INVAL;
@@ -87,12 +90,13 @@ bt_component_factory_load_file(struct bt_component_factory *factory,
         * Check if the file ends with a known plugin file type suffix (i.e. .so
         * or .la on Linux).
         */
-       if (strncmp(NATIVE_PLUGIN_SUFFIX,
-                       path + path_len - NATIVE_PLUGIN_SUFFIX_LEN,
-                       NATIVE_PLUGIN_SUFFIX_LEN) &&
-                       strncmp(LIBTOOL_PLUGIN_SUFFIX,
+       is_libtool_wrapper = !strncmp(LIBTOOL_PLUGIN_SUFFIX,
                        path + path_len - LIBTOOL_PLUGIN_SUFFIX_LEN,
-                       LIBTOOL_PLUGIN_SUFFIX_LEN)) {
+                       LIBTOOL_PLUGIN_SUFFIX_LEN);
+       is_shared_object = !strncmp(NATIVE_PLUGIN_SUFFIX,
+                       path + path_len - NATIVE_PLUGIN_SUFFIX_LEN,
+                       NATIVE_PLUGIN_SUFFIX_LEN);
+       if (!is_shared_object && !is_libtool_wrapper) {
                /* Name indicates that this is not a plugin file. */
                ret = BT_COMPONENT_FACTORY_STATUS_INVAL;
                goto end;
@@ -240,8 +244,8 @@ void bt_component_factory_destroy(struct bt_object *obj)
        if (factory->plugins) {
                g_ptr_array_free(factory->plugins, TRUE);
        }
-       if (factory->components) {
-               g_ptr_array_free(factory->components, TRUE);
+       if (factory->component_classes) {
+               g_ptr_array_free(factory->component_classes, TRUE);
        }
        g_free(factory);
 }
@@ -261,9 +265,9 @@ struct bt_component_factory *bt_component_factory_create(void)
        if (!factory->plugins) {
                goto error;
        }
-       factory->components = g_ptr_array_new_with_free_func(
+       factory->component_classes = g_ptr_array_new_with_free_func(
                (GDestroyNotify) bt_put);
-       if (!factory->components) {
+       if (!factory->component_classes) {
                goto error;
        }
 end:
@@ -273,6 +277,13 @@ error:
        return factory;
 }
 
+struct bt_object *bt_component_factory_get_components(
+               struct bt_component_factory *factory)
+{
+       assert(0);
+       return NULL;
+}
+
 enum bt_component_factory_status bt_component_factory_load(
                struct bt_component_factory *factory, const char *path)
 {
@@ -300,3 +311,30 @@ enum bt_component_factory_status bt_component_factory_load(
 end:
        return ret;
 }
+
+enum bt_component_factory_status
+bt_component_factory_register_source_component_class(
+               struct bt_component_factory *factory, const char *name,
+               bt_component_source_init_cb init)
+{
+       assert(0);
+       return BT_COMPONENT_FACTORY_STATUS_ERROR;
+}
+
+enum bt_component_factory_status
+bt_component_factory_register_sink_component_class(
+               struct bt_component_factory *factory, const char *name,
+               bt_component_sink_init_cb init)
+{
+       struct bt_component_class *class;
+       enum bt_component_factory_status ret = BT_COMPONENT_FACTORY_STATUS_OK;
+
+       if (!factory || !name || !init) {
+               ret = BT_COMPONENT_FACTORY_STATUS_INVAL;
+               goto end;
+       }
+
+       
+end:
+       return ret;
+}
index b77c9fcd8659bc3e73a1096f48ece628c60d434a..49a6335be44a1dba2eb4b4b206d145983465aaf3 100644 (file)
@@ -99,7 +99,6 @@ struct ctf_text_component {
        bool opt_print_trace_default_fields : 1;
        bool opt_print_loglevel_field : 1;
        bool opt_print_emf_field : 1;
-       bool opt_print_callsite_field : 1;
        bool opt_print_delta_field : 1;
 };
 
This page took 0.028702 seconds and 4 git commands to generate.