static
struct bt_component_class *find_component_class(const char *plugin_name,
const char *comp_class_name,
- enum bt_component_type comp_class_type)
+ enum bt_component_class_type comp_class_type)
{
struct bt_component_class *comp_class = NULL;
struct bt_plugin *plugin = find_plugin(plugin_name);
}
static
-const char *component_type_str(enum bt_component_type type)
+const char *component_type_str(enum bt_component_class_type type)
{
switch (type) {
- case BT_COMPONENT_TYPE_SOURCE:
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
return "source";
- case BT_COMPONENT_TYPE_SINK:
+ case BT_COMPONENT_CLASS_TYPE_SINK:
return "sink";
- case BT_COMPONENT_TYPE_FILTER:
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
return "filter";
- case BT_COMPONENT_TYPE_UNKNOWN:
+ case BT_COMPONENT_CLASS_TYPE_UNKNOWN:
default:
return "unknown";
}
bt_plugin_get_description(plugin);
const char *comp_class_description =
bt_component_class_get_description(comp_class);
- enum bt_component_type type =
+ enum bt_component_class_type type =
bt_component_class_get_type(comp_class);
printf_verbose("[%s - %s (%s)]\n", plugin_name,
}
trimmer_class = find_component_class("utils", "trimmer",
- BT_COMPONENT_TYPE_FILTER);
+ BT_COMPONENT_CLASS_TYPE_FILTER);
if (!trimmer_class) {
fprintf(stderr, "Could not find trimmer component class. Aborting...\n");
goto end;
source_params = bt_get(source_cfg->params);
source_class = find_component_class(source_cfg->plugin_name->str,
source_cfg->component_name->str,
- BT_COMPONENT_TYPE_SOURCE);
+ BT_COMPONENT_CLASS_TYPE_SOURCE);
if (!source_class) {
fprintf(stderr, "Could not find %s.%s source component class. Aborting...\n",
source_cfg->plugin_name->str,
sink_params = bt_get(sink_cfg->params);
sink_class = find_component_class(sink_cfg->plugin_name->str,
sink_cfg->component_name->str,
- BT_COMPONENT_TYPE_SINK);
+ BT_COMPONENT_CLASS_TYPE_SINK);
if (!sink_class) {
fprintf(stderr, "Could not find %s.%s output component class. Aborting...\n",
sink_cfg->plugin_name->str,
babeltracecomponentinclude_HEADERS = \
babeltrace/component/component.h \
babeltrace/component/component-class.h \
+ babeltrace/component/component-class-source.h \
+ babeltrace/component/component-class-filter.h \
+ babeltrace/component/component-class-sink.h \
babeltrace/component/component-connection.h \
babeltrace/component/component-graph.h \
babeltrace/component/source.h \
--- /dev/null
+#ifndef BABELTRACE_COMPONENT_COMPONENT_CLASS_FILTER_H
+#define BABELTRACE_COMPONENT_COMPONENT_CLASS_FILTER_H
+
+/*
+ * Babeltrace - Component Class Interface.
+ *
+ * Copyright 2016 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/component/component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class;
+
+typedef enum bt_component_status (*bt_component_class_filter_init_iterator_method)(
+ struct bt_component *, struct bt_notification_iterator *);
+
+typedef enum bt_component_status (*bt_component_class_filter_add_iterator_method)(
+ struct bt_component *, struct bt_notification_iterator *);
+
+extern
+struct bt_component_class *bt_component_class_filter_create(const char *name,
+ bt_component_class_filter_init_iterator_method init_iterator_method);
+
+extern int bt_component_class_filter_set_add_iterator_method(
+ struct bt_component_class *component_class,
+ bt_component_class_filter_add_iterator_method add_iterator_method);
+
+#endif /* BABELTRACE_COMPONENT_COMPONENT_CLASS_FILTER_H */
#include <babeltrace/component/component.h>
#include <babeltrace/component/component-class.h>
+#include <babeltrace/component/component-class-source.h>
+#include <babeltrace/component/component-class-filter.h>
+#include <babeltrace/component/component-class-sink.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
#include <glib.h>
typedef void (*bt_component_class_destroy_listener_func)(
struct bt_component_class *class, void *data);
-struct bt_component_class_destroyer_listener {
+struct bt_component_class_destroy_listener {
bt_component_class_destroy_listener_func func;
void *data;
};
struct bt_component_class {
struct bt_object base;
- enum bt_component_type type;
+ enum bt_component_class_type type;
GString *name;
GString *description;
- bt_component_init_cb init;
-
- /* Array of struct bt_component_class_destroyer_listener */
+ struct {
+ bt_component_class_init_method init;
+ bt_component_class_destroy_method destroy;
+ } methods;
+ /* Array of struct bt_component_class_destroy_listener */
GArray *destroy_listeners;
};
+struct bt_component_class_source {
+ struct bt_component_class parent;
+ struct {
+ bt_component_class_source_init_iterator_method init_iterator;
+ } methods;
+};
+
+struct bt_component_class_sink {
+ struct bt_component_class parent;
+ struct {
+ bt_component_class_sink_consume_method consume;
+ bt_component_class_sink_add_iterator_method add_iterator;
+ } methods;
+};
+
+struct bt_component_class_filter {
+ struct bt_component_class parent;
+ struct {
+ bt_component_class_filter_init_iterator_method init_iterator;
+ bt_component_class_filter_add_iterator_method add_iterator;
+ } methods;
+};
+
BT_HIDDEN
int bt_component_class_add_destroy_listener(struct bt_component_class *class,
bt_component_class_destroy_listener_func func, void *data);
--- /dev/null
+#ifndef BABELTRACE_COMPONENT_COMPONENT_CLASS_SINK_H
+#define BABELTRACE_COMPONENT_COMPONENT_CLASS_SINK_H
+
+/*
+ * Babeltrace - Component Class Interface.
+ *
+ * Copyright 2016 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/component/component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class;
+
+typedef enum bt_component_status (*bt_component_class_sink_consume_method)(
+ struct bt_component *);
+
+typedef enum bt_component_status (*bt_component_class_sink_add_iterator_method)(
+ struct bt_component *, struct bt_notification_iterator *);
+
+extern
+struct bt_component_class *bt_component_class_sink_create(const char *name,
+ bt_component_class_sink_consume_method consume_method);
+
+extern int bt_component_class_sink_set_add_iterator_method(
+ struct bt_component_class *component_class,
+ bt_component_class_sink_add_iterator_method add_iterator_method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_COMPONENT_CLASS_SINK_H */
--- /dev/null
+#ifndef BABELTRACE_COMPONENT_COMPONENT_CLASS_SOURCE_H
+#define BABELTRACE_COMPONENT_COMPONENT_CLASS_SOURCE_H
+
+/*
+ * Babeltrace - Component Class Interface.
+ *
+ * Copyright 2016 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/component/component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class;
+
+typedef enum bt_component_status (*bt_component_class_source_init_iterator_method)(
+ struct bt_component *, struct bt_notification_iterator *);
+
+extern
+struct bt_component_class *bt_component_class_source_create(const char *name,
+ bt_component_class_source_init_iterator_method init_iterator_method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_COMPONENT_CLASS_SOURCE_H */
extern "C" {
#endif
-struct bt_plugin;
struct bt_component_class;
-extern struct bt_component_class *bt_component_class_create(
- enum bt_component_type type, const char *name,
- const char *description, bt_component_init_cb init);
+/**
+ * Component class type.
+ */
+enum bt_component_class_type {
+ BT_COMPONENT_CLASS_TYPE_UNKNOWN = -1,
+
+ /** A source component is a notification generator. */
+ BT_COMPONENT_CLASS_TYPE_SOURCE = 0,
+
+ /** A sink component handles incoming notifications. */
+ BT_COMPONENT_CLASS_TYPE_SINK = 1,
+
+ /** A filter component implements both Source and Sink interfaces. */
+ BT_COMPONENT_CLASS_TYPE_FILTER = 2,
+};
+
+typedef enum bt_component_status (*bt_component_class_init_method)(
+ struct bt_component *component, struct bt_value *params);
+
+typedef void (*bt_component_class_destroy_method)(struct bt_component *component);
+
+extern int bt_component_class_set_init_method(
+ struct bt_component_class *component_class,
+ bt_component_class_init_method init_method);
+
+extern int bt_component_class_set_destroy_method(
+ struct bt_component_class *component_class,
+ bt_component_class_destroy_method destroy_method);
+
+extern int bt_component_class_set_description(
+ struct bt_component_class *component_class,
+ const char *description);
/**
* Get a component class' name.
* @param component_class Component class of which to get the type
* @returns One of #bt_component_type
*/
-extern enum bt_component_type bt_component_class_get_type(
+extern enum bt_component_class_type bt_component_class_get_type(
struct bt_component_class *component_class);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* BABELTRACE_COMPONENT_COMPONENT_CLASS_H */
struct bt_object base;
struct bt_component_class *class;
GString *name;
- /** Source, Sink or Filter destroy */
- bt_component_destroy_cb destroy;
- /** User-defined data and its destruction callback */
+ /**
+ * Internal destroy function specific to a source, filter, or
+ * sink component object.
+ */
+ bt_component_class_destroy_method destroy;
+
+ /** User-defined data */
void *user_data;
- bt_component_destroy_cb user_destroy;
/**
* Used to protect operations which may only be used during
BT_HIDDEN
enum bt_component_status bt_component_init(struct bt_component *component,
- bt_component_destroy_cb destroy);
-
-BT_HIDDEN
-enum bt_component_type bt_component_get_type(struct bt_component *component);
+ bt_component_class_destroy_method destroy);
BT_HIDDEN
struct bt_notification_iterator *bt_component_create_iterator(
extern "C" {
#endif
-/**
- * Component type.
- */
-enum bt_component_type {
- BT_COMPONENT_TYPE_UNKNOWN = -1,
-
- /** A source component is a notification generator. */
- BT_COMPONENT_TYPE_SOURCE = 0,
-
- /** A sink component handles incoming notifications. */
- BT_COMPONENT_TYPE_SINK = 1,
-
- /** A filter component implements both Source and Sink interfaces. */
- BT_COMPONENT_TYPE_FILTER = 2,
-};
-
/**
* Status code. Errors are always negative.
*/
struct bt_value;
/**
- * Component private data deallocation function type.
- *
- * @param component Component instance
- */
-typedef void (*bt_component_destroy_cb)(struct bt_component *component);
-
-/**
- * Component initialization function type.
- *
- * A component's private data and required callbacks must be set by this
- * function.
+ * Create an instance of a component from a component class.
*
- * @param component Component instance
- * @param params A dictionary of component parameters
- * @returns One of #bt_component_status values
+ * @param component_class Component class of which to create an instance
+ * @param name Name of the new component instance, optional
+ * @param params A dictionary of component parameters
+ * @returns Returns a pointer to a new component instance
*/
-typedef enum bt_component_status (*bt_component_init_cb)(
- struct bt_component *component, struct bt_value *params);
-
+extern struct bt_component *bt_component_create(
+ struct bt_component_class *component_class, const char *name,
+ struct bt_value *params);
/**
* Get a component's private data.
extern enum bt_component_status bt_component_set_private_data(
struct bt_component *component, void *data);
-/**
- * Set a component's private data cleanup function.
- *
- * @param component Component of which to set the private data destruction
- * function
- * @param data Component private data clean-up function
- * @returns One of #bt_component_status values
- */
-extern enum bt_component_status bt_component_set_destroy_cb(
- struct bt_component *component,
- bt_component_destroy_cb destroy);
-
-/** bt_component_souce */
-/**
- * Iterator initialization function type.
- *
- * A notification iterator's private data, deinitialization, next, and get
- * callbacks must be set by this function.
- *
- * @param source Source component instance
- * @param iterator Notification iterator instance
- */
-typedef enum bt_component_status (*bt_component_source_init_iterator_cb)(
- struct bt_component *, struct bt_notification_iterator *);
-
-/**
- * Set a source component's iterator initialization function.
- *
- * @param source Source component instance
- * @param init_iterator Notification iterator initialization callback
- */
-extern enum bt_component_status
-bt_component_source_set_iterator_init_cb(struct bt_component *source,
- bt_component_source_init_iterator_cb init_iterator);
-
-/** bt_component_sink */
-/**
- * Notification consumption function type.
- *
- * @param sink Sink component instance
- * @returns One of #bt_component_status values
- */
-typedef enum bt_component_status (*bt_component_sink_consume_cb)(
- struct bt_component *);
-
-/**
- * Iterator addition function type.
- *
- * A sink component may choose to refuse the addition of an iterator
- * by not returning BT_COMPONENT_STATUS_OK.
- *
- * @param sink Sink component instance
- * @returns One of #bt_component_status values
- */
-typedef enum bt_component_status (*bt_component_sink_add_iterator_cb)(
- struct bt_component *, struct bt_notification_iterator *);
-
-/**
- * Set a sink component's consumption callback.
- *
- * @param sink Sink component instance
- * @param consume Consumption callback
- * @returns One of #bt_component_status values
- */
-extern enum bt_component_status
-bt_component_sink_set_consume_cb(struct bt_component *sink,
- bt_component_sink_consume_cb consume);
-
-/**
- * Set a sink component's iterator addition callback.
- *
- * @param sink Sink component instance
- * @param add_iterator Iterator addition callback
- * @returns One of #bt_component_status values
- */
-extern enum bt_component_status
-bt_component_sink_set_add_iterator_cb(struct bt_component *sink,
- bt_component_sink_add_iterator_cb add_iterator);
-
-/* Defaults to 1. */
-extern enum bt_component_status
-bt_component_sink_set_minimum_input_count(struct bt_component *sink,
- unsigned int minimum);
-
-/* Defaults to 1. */
-extern enum bt_component_status
-bt_component_sink_set_maximum_input_count(struct bt_component *sink,
- unsigned int maximum);
-
-extern enum bt_component_status
-bt_component_sink_get_input_count(struct bt_component *sink,
- unsigned int *count);
-
-/* May return NULL after an interator has reached its end. */
-extern enum bt_component_status
-bt_component_sink_get_input_iterator(struct bt_component *sink,
- unsigned int input, struct bt_notification_iterator **iterator);
-
-/** bt_component_filter */
-/**
- * Iterator initialization function type.
- *
- * A notification iterator's private data, deinitialization, next, and get
- * callbacks must be set by this function.
- *
- * @param filter Filter component instance
- * @param iterator Notification iterator instance
- */
-typedef enum bt_component_status (*bt_component_filter_init_iterator_cb)(
- struct bt_component *, struct bt_notification_iterator *);
-
-/**
- * Iterator addition function type.
- *
- * A filter component may choose to refuse the addition of an iterator
- * by not returning BT_COMPONENT_STATUS_OK.
- *
- * @param filter Filter component instance
- * @returns One of #bt_component_status values
- */
-typedef enum bt_component_status (*bt_component_filter_add_iterator_cb)(
- struct bt_component *, struct bt_notification_iterator *);
-
-/**
- * Set a filter component's iterator initialization function.
- *
- * @param filter Filter component instance
- * @param init_iterator Notification iterator initialization callback
- */
-extern enum bt_component_status
-bt_component_filter_set_iterator_init_cb(struct bt_component *filter,
- bt_component_filter_init_iterator_cb init_iterator);
-
-/**
- * Set a filter component's iterator addition callback.
- *
- * @param filter Filter component instance
- * @param add_iterator Iterator addition callback
- * @returns One of #bt_component_status values
- */
-extern enum bt_component_status
-bt_component_filter_set_add_iterator_cb(struct bt_component *filter,
- bt_component_filter_add_iterator_cb add_iterator);
-
-/* Defaults to 1. */
-extern enum bt_component_status
-bt_component_filter_set_minimum_input_count(struct bt_component *filter,
- unsigned int minimum);
-
-/* Defaults to 1. */
-extern enum bt_component_status
-bt_component_filter_set_maximum_input_count(struct bt_component *filter,
- unsigned int maximum);
-
-extern enum bt_component_status
-bt_component_filter_get_input_count(struct bt_component *filter,
- unsigned int *count);
-
-/* May return NULL after an interator has reached its end. */
-extern enum bt_component_status
-bt_component_filter_get_input_iterator(struct bt_component *filter,
- unsigned int input, struct bt_notification_iterator **iterator);
-
-/**
- * Create an instance of a component from a component class.
- *
- * @param component_class Component class of which to create an instance
- * @param name Name of the new component instance, optional
- * @param params A dictionary of component parameters
- * @returns Returns a pointer to a new component instance
- */
-extern struct bt_component *bt_component_create(
- struct bt_component_class *component_class, const char *name,
- struct bt_value *params);
-
/**
* Get component's name.
*
*/
extern const char *bt_component_get_name(struct bt_component *component);
-/**
- * Set component's name.
- *
- * @param component Component instance of which to set the name
- * @param name New component name (will be copied)
- * @returns One of #bt_component_status values
- */
-extern enum bt_component_status bt_component_set_name(
- struct bt_component *component, const char *name);
-
/**
* Get component's class.
*
extern struct bt_component_class *bt_component_get_class(
struct bt_component *component);
+extern enum bt_component_class_type bt_component_get_class_type(
+ struct bt_component *component);
+
#ifdef __cplusplus
}
#endif
struct bt_value;
-struct bt_component_filter_class {
- struct bt_component_class parent;
-};
-
struct bt_component_filter {
struct bt_component parent;
- bt_component_filter_init_iterator_cb init_iterator;
- bt_component_sink_add_iterator_cb add_iterator;
struct component_input input;
};
struct bt_notification_iterator *bt_component_filter_create_iterator(
struct bt_component *component);
+/* Defaults to 1. */
+extern enum bt_component_status
+bt_component_filter_set_minimum_input_count(struct bt_component *filter,
+ unsigned int minimum);
+
+/* Defaults to 1. */
+extern enum bt_component_status
+bt_component_filter_set_maximum_input_count(struct bt_component *filter,
+ unsigned int maximum);
+
+extern enum bt_component_status
+bt_component_filter_get_input_count(struct bt_component *filter,
+ unsigned int *count);
+
+/* May return NULL after an interator has reached its end. */
+extern enum bt_component_status
+bt_component_filter_get_input_iterator(struct bt_component *filter,
+ unsigned int input, struct bt_notification_iterator **iterator);
+
#ifdef __cplusplus
}
#endif
struct bt_value;
-struct bt_component_sink_class {
- struct bt_component_class parent;
-};
-
//typedef uint32_t notification_mask_t;
struct bt_component_sink {
struct bt_component parent;
- bt_component_sink_consume_cb consume;
- bt_component_sink_add_iterator_cb add_iterator;
struct component_input input;
/* notification_mask_t registered_notifications_mask;*/
};
enum bt_component_status bt_component_sink_consume(
struct bt_component *component);
+/* Defaults to 1. */
+extern enum bt_component_status
+bt_component_sink_set_minimum_input_count(struct bt_component *sink,
+ unsigned int minimum);
+
+/* Defaults to 1. */
+extern enum bt_component_status
+bt_component_sink_set_maximum_input_count(struct bt_component *sink,
+ unsigned int maximum);
+
+extern enum bt_component_status
+bt_component_sink_get_input_count(struct bt_component *sink,
+ unsigned int *count);
+
+/* May return NULL after an interator has reached its end. */
+extern enum bt_component_status
+bt_component_sink_get_input_iterator(struct bt_component *sink,
+ unsigned int input, struct bt_notification_iterator **iterator);
+
#ifdef __cplusplus
}
#endif
struct bt_value;
-struct bt_component_source_class {
- struct bt_component_class parent;
-};
-
struct bt_component_source {
struct bt_component parent;
- bt_component_source_init_iterator_cb init_iterator;
};
/**
#include <stdint.h>
#include <babeltrace/plugin/plugin.h>
#include <babeltrace/component/component-class.h>
+#include <babeltrace/component/component-class-source.h>
+#include <babeltrace/component/component-class-filter.h>
+#include <babeltrace/component/component-class-sink.h>
#ifdef __cplusplus
extern "C" {
/* Name of the attribute's type for debug purposes */
const char *type_name;
- /* Attribute's value */
+ /* Attribute's value (depends on attribute's type) */
union {
/* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT */
bt_plugin_init_func init;
*/
const struct __bt_plugin_descriptor *plugin_descriptor;
- /* Component type */
- enum bt_component_type type;
+ /* Component class type */
+ enum bt_component_class_type type;
/* Component class name */
const char *name;
- /* Component initialization function */
- bt_component_init_cb init_cb;
+ /* Mandatory methods (depends on component class type) */
+ union {
+ /* BT_COMPONENT_CLASS_TYPE_SOURCE */
+ struct {
+ bt_component_class_source_init_iterator_method init_iterator;
+ } source;
+
+ /* BT_COMPONENT_CLASS_TYPE_FILTER */
+ struct {
+ bt_component_class_filter_init_iterator_method init_iterator;
+ } filter;
+
+ /* BT_COMPONENT_CLASS_TYPE_SINK */
+ struct {
+ bt_component_class_sink_consume_method consume;
+ } sink;
+ } methods;
} __attribute__((packed));
/* Type of a component class attribute (internal use) */
enum __bt_plugin_component_class_descriptor_attribute_type {
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 0,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 0,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD = 1,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD = 2,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD = 3,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD = 4,
};
/* Component class attribute (internal use) */
/* Name of the attribute's type for debug purposes */
const char *type_name;
- /* Attribute's value */
+ /* Attribute's value (depends on attribute's type) */
union {
- /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
const char *description;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD */
+ bt_component_class_init_method init_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD */
+ bt_component_class_destroy_method destroy_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD */
+ bt_component_class_filter_add_iterator_method filter_add_iterator_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD */
+ bt_component_class_sink_add_iterator_method sink_add_iterator_method;
} value;
} __attribute__((packed));
__BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _x)
/*
- * Defines a component class descriptor with a custom ID.
+ * Declaration of start and stop symbols of component class descriptors
+ * section.
+ */
+#define __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP \
+ extern struct __bt_plugin_component_class_descriptor const *__start___bt_plugin_component_class_descriptors; \
+ extern struct __bt_plugin_component_class_descriptor const *__stop___bt_plugin_component_class_descriptors
+
+/*
+ * Defines a source component class descriptor with a custom ID.
*
- * _id: ID (any valid C identifier except `auto`).
- * _comp_class_id: Component class ID (C identifier).
- * _type: Component class type (enum bt_component_type).
- * _name: Component class name (C string).
- * _init_func: Component class's initialization function
- * (bt_component_init_cb).
+ * _id: ID (any valid C identifier except `auto`).
+ * _comp_class_id: Component class ID (C identifier).
+ * _name: Component class name (C string).
+ * _init_iterator_method: Component class's iterator initialization method
+ * (bt_component_class_source_init_iterator_method).
*/
-#define BT_PLUGIN_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _type, _name, _init_cb) \
- static struct __bt_plugin_component_class_descriptor __bt_plugin_component_class_descriptor_##_id##_##_comp_class_id##_##_type = { \
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _init_iterator_method) \
+ static struct __bt_plugin_component_class_descriptor __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id = { \
.plugin_descriptor = &__bt_plugin_descriptor_##_id, \
- .type = _type, \
+ .type = BT_COMPONENT_CLASS_TYPE_SOURCE, \
.name = _name, \
- .init_cb = _init_cb, \
+ .methods.source = { \
+ .init_iterator = _init_iterator_method, \
+ }, \
}; \
- static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_component_class_descriptor_##_id##_##_comp_class_id##_##_type##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_component_class_descriptor_##_id##_##_comp_class_id##_##_type; \
- extern struct __bt_plugin_component_class_descriptor const *__start___bt_plugin_component_class_descriptors; \
- extern struct __bt_plugin_component_class_descriptor const *__stop___bt_plugin_component_class_descriptors
+ static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id; \
+ __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP
+
+/*
+ * Defines a filter component class descriptor with a custom ID.
+ *
+ * _id: ID (any valid C identifier except `auto`).
+ * _comp_class_id: Component class ID (C identifier).
+ * _name: Component class name (C string).
+ * _init_iterator_method: Component class's iterator initialization method
+ * (bt_component_class_filter_init_iterator_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _init_iterator_method) \
+ static struct __bt_plugin_component_class_descriptor __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id = { \
+ .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
+ .type = BT_COMPONENT_CLASS_TYPE_FILTER, \
+ .name = _name, \
+ .methods.filter = { \
+ .init_iterator = _init_iterator_method, \
+ }, \
+ }; \
+ static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id; \
+ __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP
+
+/*
+ * Defines a sink component class descriptor with a custom ID.
+ *
+ * _id: ID (any valid C identifier except `auto`).
+ * _comp_class_id: Component class ID (C identifier).
+ * _name: Component class name (C string).
+ * _consume_method: Component class's iterator consume method
+ * (bt_component_class_sink_consume_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _consume_method) \
+ static struct __bt_plugin_component_class_descriptor __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id = { \
+ .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
+ .type = BT_COMPONENT_CLASS_TYPE_SINK, \
+ .name = _name, \
+ .methods.sink = { \
+ .consume = _consume_method, \
+ }, \
+ }; \
+ static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id; \
+ __BT_PLUGIN_DECL_COMPONENT_CLASS_DESCRIPTORS_SECTION_START_STOP
/*
* Defines a component class descriptor attribute (generic, internal
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class ID (C identifier).
- * _type: Component class type (enum bt_component_type).
+ * _type: Component class type (`source`, `filter`, or `sink`).
* _attr_name: Name of the attribute (C identifier).
* _attr_type: Type of the attribute
* (enum __bt_plugin_descriptor_attribute_type).
* _x: Value.
*/
#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(_attr_name, _attr_type, _id, _comp_class_id, _type, _x) \
- static struct __bt_plugin_component_class_descriptor_attribute __bt_plugin_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_type##_##_attr_name = { \
- .comp_class_descriptor = &__bt_plugin_component_class_descriptor_##_id##_##_comp_class_id##_##_type, \
+ static struct __bt_plugin_component_class_descriptor_attribute __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name = { \
+ .comp_class_descriptor = &__bt_plugin_##_type##_component_class_descriptor_##_id##_##_comp_class_id, \
.type = _attr_type, \
.type_name = #_attr_name, \
- .value.description = _x, \
+ .value._attr_name = _x, \
}; \
- static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_type##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_type##_##_attr_name; \
+ static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name; \
extern struct __bt_plugin_component_class_descriptor_attribute const *__start___bt_plugin_component_class_descriptor_attributes; \
extern struct __bt_plugin_component_class_descriptor_attribute const *__stop___bt_plugin_component_class_descriptor_attributes
/*
- * Defines a description attribute attached to a specific component
- * class descriptor.
+ * Defines a description attribute attached to a specific source
+ * component class descriptor.
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _type: Component class type (enum bt_component_type).
* _x: Description (C string).
*/
-#define BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _type, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, _type, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines a description attribute attached to a specific filter
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a description attribute attached to a specific sink
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines an initialization method attribute attached to a specific
+ * source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Initialization method (bt_component_class_init_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an initialization method attribute attached to a specific
+ * filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Initialization method (bt_component_class_init_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an initialization method attribute attached to a specific
+ * sink component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Initialization method (bt_component_class_init_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines a destroy method attribute attached to a specific source
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Destroy method (bt_component_class_destroy_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines a destroy method attribute attached to a specific filter
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Destroy method (bt_component_class_destroy_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a destroy method attribute attached to a specific sink
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Destroy method (bt_component_class_destroy_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines an add iterator method attribute attached to a specific
+ * filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Add iterator method
+ * (bt_component_class_filter_add_iterator_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_add_iterator_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an add iterator method attribute attached to a specific
+ * sink component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Add iterator method
+ * (bt_component_class_sink_add_iterator_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_add_iterator_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD, _id, _comp_class_id, sink, _x)
/*
* Defines a plugin descriptor with an automatic ID.
#define BT_PLUGIN_DESCRIPTION(_x) BT_PLUGIN_DESCRIPTION_WITH_ID(auto, _x)
/*
- * Defines a component class attached to the automatic plugin
+ * Defines a source component class attached to the automatic plugin
+ * descriptor. Its ID is the same as its name, hence its name must be a
+ * C identifier in this version.
+ *
+ * _name: Component class name (C identifier).
+ * _init_iterator_method: Component class's iterator initialization method
+ * (bt_component_class_source_init_iterator_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _init_iterator_method) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _init_iterator_method)
+
+/*
+ * Defines a filter component class attached to the automatic plugin
* descriptor. Its ID is the same as its name, hence its name must be a
* C identifier in this version.
*
- * _type: Component class type (enum bt_component_type).
- * _name: Component class name (C identifier).
- * _init_cb: Component class's initialization function
- * (bt_component_init_cb).
+ * _name: Component class name (C identifier).
+ * _init_iterator_method: Component class's iterator initialization method
+ * (bt_component_class_filter_init_iterator_method).
*/
-#define BT_PLUGIN_COMPONENT_CLASS(_type, _name, _init_cb) \
- BT_PLUGIN_COMPONENT_CLASS_WITH_ID(auto, _name, _type, #_name, _init_cb)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _init_iterator_method) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _init_iterator_method)
/*
- * Defines a description attribute attached to a component class
+ * Defines a sink component class attached to the automatic plugin
+ * descriptor. Its ID is the same as its name, hence its name must be a
+ * C identifier in this version.
+ *
+ * _name: Component class name (C identifier).
+ * _consume_method: Component class's consume method
+ * (bt_component_class_sink_consume_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS(_name, _consume_method) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _consume_method)
+
+/*
+ * Defines a description attribute attached to a source component class
* descriptor which is attached to the automatic plugin descriptor.
*
- * _type: Component class type (enum bt_component_type).
- * _name: Component class name (C identifier).
- * _x: Description (C string).
+ * _name: Component class name (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a description attribute attached to a filter component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a description attribute attached to a sink component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an initialization method attribute attached to a source
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_init_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an initialization method attribute attached to a filter
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_init_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an initialization method attribute attached to a sink
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_init_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a destroy method attribute attached to a source component
+ * class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_destroy_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a destroy method attribute attached to a filter component
+ * class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_destroy_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a destroy method attribute attached to a sink component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_destroy_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an add iterator method attribute attached to a filter
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Add iterator method (bt_component_class_filter_add_iterator_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ADD_ITERATOR_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an add iterator method attribute attached to a sink
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Add iterator method (bt_component_class_sink_add_iterator_method).
*/
-#define BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(_type, _name, _x) \
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _type, _x)
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_ADD_ITERATOR_METHOD_WITH_ID(auto, _name, _x)
#ifdef __cplusplus
}
extern
struct bt_component_class *bt_plugin_get_component_class_by_name_and_type(
struct bt_plugin *plugin, const char *name,
- enum bt_component_type type);
+ enum bt_component_class_type type);
#ifdef __cplusplus
}
/* Call destroy listeners in reverse registration order */
for (i = class->destroy_listeners->len - 1; i >= 0; i--) {
- struct bt_component_class_destroyer_listener *listener =
+ struct bt_component_class_destroy_listener *listener =
&g_array_index(class->destroy_listeners,
- struct bt_component_class_destroyer_listener,
+ struct bt_component_class_destroy_listener,
i);
listener->func(class, listener->data);
g_free(class);
}
-struct bt_component_class *bt_component_class_create(
- enum bt_component_type type, const char *name,
- const char *description, bt_component_init_cb init)
+static
+int bt_component_class_init(struct bt_component_class *class,
+ enum bt_component_class_type type, const char *name)
{
- struct bt_component_class *class = NULL;
+ int ret = 0;
+
+ bt_object_init(class, bt_component_class_destroy);
+ class->type = type;
+ class->name = g_string_new(name);
+ if (!class->name) {
+ goto error;
+ }
+
+ class->description = g_string_new(NULL);
+ if (!class->description) {
+ goto error;
+ }
+
+ class->destroy_listeners = g_array_new(FALSE, TRUE,
+ sizeof(struct bt_component_class_destroy_listener));
+ if (!class->destroy_listeners) {
+ goto error;
+ }
+
+ goto end;
- if (!name) {
+error:
+ BT_PUT(class);
+ ret = -1;
+
+end:
+ return ret;
+}
+
+struct bt_component_class *bt_component_class_source_create(const char *name,
+ bt_component_class_source_init_iterator_method init_iterator_method)
+{
+ struct bt_component_class_source *source_class = NULL;
+ int ret;
+
+ if (!name || !init_iterator_method) {
goto end;
}
- class = g_new0(struct bt_component_class, 1);
- if (!class) {
+ source_class = g_new0(struct bt_component_class_source, 1);
+ if (!source_class) {
goto end;
}
- bt_object_init(class, bt_component_class_destroy);
- class->type = type;
- class->init = init;
- class->name = g_string_new(name);
- if (!class->name) {
- BT_PUT(class);
+ ret = bt_component_class_init(&source_class->parent,
+ BT_COMPONENT_CLASS_TYPE_SOURCE, name);
+ if (ret) {
+ /*
+ * If bt_component_class_init() fails, the component
+ * class is put, therefore its memory is already
+ * freed.
+ */
+ source_class = NULL;
+ goto end;
+ }
+
+ source_class->methods.init_iterator = init_iterator_method;
+
+end:
+ return &source_class->parent;
+}
+
+struct bt_component_class *bt_component_class_filter_create(const char *name,
+ bt_component_class_filter_init_iterator_method init_iterator_method)
+{
+ struct bt_component_class_filter *filter_class = NULL;
+ int ret;
+
+ if (!name || !init_iterator_method) {
goto end;
}
- if (description) {
- class->description = g_string_new(description);
- if (!class->description) {
- BT_PUT(class);
- goto end;
- }
+ filter_class = g_new0(struct bt_component_class_filter, 1);
+ if (!filter_class) {
+ goto end;
}
- class->destroy_listeners = g_array_new(FALSE, TRUE,
- sizeof(struct bt_component_class_destroyer_listener));
- if (!class->destroy_listeners) {
- BT_PUT(class);
+ ret = bt_component_class_init(&filter_class->parent,
+ BT_COMPONENT_CLASS_TYPE_FILTER, name);
+ if (ret) {
+ /*
+ * If bt_component_class_init() fails, the component
+ * class is put, therefore its memory is already
+ * freed.
+ */
+ filter_class = NULL;
goto end;
}
+
+ filter_class->methods.init_iterator = init_iterator_method;
+
end:
- return class;
+ return &filter_class->parent;
+}
+
+struct bt_component_class *bt_component_class_sink_create(const char *name,
+ bt_component_class_sink_consume_method consume_method)
+{
+ struct bt_component_class_sink *sink_class = NULL;
+ int ret;
+
+ if (!name || !consume_method) {
+ goto end;
+ }
+
+ sink_class = g_new0(struct bt_component_class_sink, 1);
+ if (!sink_class) {
+ goto end;
+ }
+
+ ret = bt_component_class_init(&sink_class->parent,
+ BT_COMPONENT_CLASS_TYPE_SINK, name);
+ if (ret) {
+ /*
+ * If bt_component_class_init() fails, the component
+ * class is put, therefore its memory is already
+ * freed.
+ */
+ sink_class = NULL;
+ goto end;
+ }
+
+ sink_class->methods.consume = consume_method;
+
+end:
+ return &sink_class->parent;
+}
+
+int bt_component_class_set_init_method(
+ struct bt_component_class *component_class,
+ bt_component_class_init_method init_method)
+{
+ int ret = 0;
+
+ if (!component_class || !init_method) {
+ ret = -1;
+ goto end;
+ }
+
+ component_class->methods.init = init_method;
+
+end:
+ return ret;
+}
+
+int bt_component_class_set_destroy_method(
+ struct bt_component_class *component_class,
+ bt_component_class_destroy_method destroy_method)
+{
+ int ret = 0;
+
+ if (!component_class || !destroy_method) {
+ ret = -1;
+ goto end;
+ }
+
+ component_class->methods.destroy = destroy_method;
+
+end:
+ return ret;
+}
+
+extern int bt_component_class_set_description(
+ struct bt_component_class *component_class,
+ const char *description)
+{
+ int ret = 0;
+
+ if (!component_class || !description) {
+ ret = -1;
+ goto end;
+ }
+
+ g_string_assign(component_class->description, description);
+
+end:
+ return ret;
}
const char *bt_component_class_get_name(
return component_class ? component_class->name->str : NULL;
}
-enum bt_component_type bt_component_class_get_type(
+enum bt_component_class_type bt_component_class_get_type(
struct bt_component_class *component_class)
{
return component_class ? component_class->type :
- BT_COMPONENT_TYPE_UNKNOWN;
+ BT_COMPONENT_CLASS_TYPE_UNKNOWN;
}
const char *bt_component_class_get_description(
bt_component_class_destroy_listener_func func, void *data)
{
int ret = 0;
- struct bt_component_class_destroyer_listener listener;
+ struct bt_component_class_destroy_listener listener;
if (!class || !func) {
ret = -1;
end:
return ret;
}
+
+extern int bt_component_class_sink_set_add_iterator_method(
+ struct bt_component_class *component_class,
+ bt_component_class_sink_add_iterator_method add_iterator_method)
+{
+ struct bt_component_class_sink *sink_class;
+ int ret = 0;
+
+ if (!component_class || !add_iterator_method ||
+ component_class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
+ ret = -1;
+ goto end;
+ }
+
+ sink_class = container_of(component_class,
+ struct bt_component_class_sink, parent);
+ sink_class->methods.add_iterator = add_iterator_method;
+
+end:
+ return ret;
+}
+
+extern int bt_component_class_filter_set_add_iterator_method(
+ struct bt_component_class *component_class,
+ bt_component_class_filter_add_iterator_method add_iterator_method)
+{
+ struct bt_component_class_filter *filter_class;
+ int ret = 0;
+
+ if (!component_class || !add_iterator_method ||
+ component_class->type !=
+ BT_COMPONENT_CLASS_TYPE_FILTER) {
+ ret = -1;
+ goto end;
+ }
+
+ filter_class = container_of(component_class,
+ struct bt_component_class_filter, parent);
+ filter_class->methods.add_iterator = add_iterator_method;
+
+end:
+ return ret;
+}
#include <babeltrace/component/component.h>
#include <babeltrace/component/component-internal.h>
+#include <babeltrace/component/component-class-internal.h>
#include <babeltrace/component/source-internal.h>
#include <babeltrace/component/filter-internal.h>
#include <babeltrace/component/notification/iterator-internal.h>
static
struct bt_component * (* const component_create_funcs[])(
struct bt_component_class *, struct bt_value *) = {
- [BT_COMPONENT_TYPE_SOURCE] = bt_component_source_create,
- [BT_COMPONENT_TYPE_SINK] = bt_component_sink_create,
- [BT_COMPONENT_TYPE_FILTER] = bt_component_filter_create,
+ [BT_COMPONENT_CLASS_TYPE_SOURCE] = bt_component_source_create,
+ [BT_COMPONENT_CLASS_TYPE_SINK] = bt_component_sink_create,
+ [BT_COMPONENT_CLASS_TYPE_FILTER] = bt_component_filter_create,
};
static
enum bt_component_status (* const component_validation_funcs[])(
struct bt_component *) = {
- [BT_COMPONENT_TYPE_SOURCE] = bt_component_source_validate,
- [BT_COMPONENT_TYPE_SINK] = bt_component_sink_validate,
- [BT_COMPONENT_TYPE_FILTER] = bt_component_filter_validate,
+ [BT_COMPONENT_CLASS_TYPE_SOURCE] = bt_component_source_validate,
+ [BT_COMPONENT_CLASS_TYPE_SINK] = bt_component_sink_validate,
+ [BT_COMPONENT_CLASS_TYPE_FILTER] = bt_component_filter_validate,
};
static
* User data is destroyed first, followed by the concrete component
* instance.
*/
- if (component->user_destroy) {
- component->user_destroy(component);
+ if (component->class->methods.destroy) {
+ component->class->methods.destroy(component);
}
if (component->destroy) {
BT_HIDDEN
enum bt_component_status bt_component_init(struct bt_component *component,
- bt_component_destroy_cb destroy)
+ bt_component_class_destroy_method destroy)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
return ret;
}
-BT_HIDDEN
-enum bt_component_type bt_component_get_type(struct bt_component *component)
+enum bt_component_class_type bt_component_get_class_type(
+ struct bt_component *component)
{
- return component ? component->class->type : BT_COMPONENT_TYPE_UNKNOWN;
+ return component ? component->class->type : BT_COMPONENT_CLASS_TYPE_UNKNOWN;
}
BT_HIDDEN
struct bt_component *component)
{
enum bt_notification_iterator_status ret_iterator;
- enum bt_component_type component_type;
+ enum bt_component_class_type type;
struct bt_notification_iterator *iterator = NULL;
+ struct bt_component_class *class = component->class;
if (!component) {
goto error;
}
- component_type = bt_component_get_type(component);
- if (component_type != BT_COMPONENT_TYPE_SOURCE &&
- component_type != BT_COMPONENT_TYPE_FILTER) {
+ type = bt_component_get_class_type(component);
+ if (type != BT_COMPONENT_CLASS_TYPE_SOURCE &&
+ type != BT_COMPONENT_CLASS_TYPE_FILTER) {
/* Unsupported operation. */
goto error;
}
goto error;
}
- switch (component_type) {
- case BT_COMPONENT_TYPE_SOURCE:
+ switch (type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
{
- struct bt_component_source *source;
+ struct bt_component_class_source *source_class;
enum bt_component_status ret_component;
- source = container_of(component, struct bt_component_source, parent);
- assert(source->init_iterator);
- ret_component = source->init_iterator(component, iterator);
+ source_class = container_of(class, struct bt_component_class_source, parent);
+ assert(source_class->methods.init_iterator);
+ ret_component =
+ source_class->methods.init_iterator(component, iterator);
if (ret_component != BT_COMPONENT_STATUS_OK) {
goto error;
}
break;
}
- case BT_COMPONENT_TYPE_FILTER:
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
{
- struct bt_component_filter *filter;
+ struct bt_component_class_filter *filter_class;
enum bt_component_status ret_component;
- filter = container_of(component, struct bt_component_filter, parent);
- assert(filter->init_iterator);
- ret_component = filter->init_iterator(component, iterator);
+ filter_class = container_of(class, struct bt_component_class_filter, parent);
+ assert(filter_class->methods.init_iterator);
+ ret_component =
+ filter_class->methods.init_iterator(component, iterator);
if (ret_component != BT_COMPONENT_STATUS_OK) {
goto error;
}
{
int ret;
struct bt_component *component = NULL;
- enum bt_component_type type;
+ enum bt_component_class_type type;
if (!component_class) {
goto end;
}
+
type = bt_component_class_get_type(component_class);
- if (type <= BT_COMPONENT_TYPE_UNKNOWN ||
- type > BT_COMPONENT_TYPE_FILTER) {
+ if (type <= BT_COMPONENT_CLASS_TYPE_UNKNOWN ||
+ type > BT_COMPONENT_CLASS_TYPE_FILTER) {
goto end;
}
}
component->initializing = true;
- ret = component_class->init(component, params);
- component->initializing = false;
- if (ret != BT_COMPONENT_STATUS_OK) {
- BT_PUT(component);
- goto end;
+
+ if (component_class->methods.init) {
+ ret = component_class->methods.init(component, params);
+ component->initializing = false;
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ BT_PUT(component);
+ goto end;
+ }
}
+
+ component->initializing = false;
ret = component_validation_funcs[type](component);
if (ret != BT_COMPONENT_STATUS_OK) {
BT_PUT(component);
end:
return ret;
}
-
-enum bt_component_status bt_component_set_destroy_cb(
- struct bt_component *component, bt_component_destroy_cb destroy)
-{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
- if (!component || !component->initializing) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- component->user_destroy = destroy;
-end:
- return ret;
-}
#include <babeltrace/component/input.h>
#include <babeltrace/component/filter-internal.h>
#include <babeltrace/component/component-internal.h>
+#include <babeltrace/component/component-class-internal.h>
#include <babeltrace/component/notification/notification.h>
#include <babeltrace/component/notification/iterator-internal.h>
-enum bt_component_status bt_component_filter_set_iterator_init_cb(
- struct bt_component *component,
- bt_component_filter_init_iterator_cb init_iterator)
-{
- struct bt_component_filter *filter;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
- if (component->class->type != BT_COMPONENT_TYPE_FILTER ||
- !component->initializing) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- filter = container_of(component, struct bt_component_filter, parent);
- filter->init_iterator = init_iterator;
-end:
- return ret;
-}
-
-enum bt_component_status bt_component_filter_set_add_iterator_cb(
- struct bt_component *component,
- bt_component_filter_add_iterator_cb add_iterator)
-{
- struct bt_component_filter *filter;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
- if (!component) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) {
- ret = BT_COMPONENT_STATUS_UNSUPPORTED;
- goto end;
- }
-
- if (!component->initializing) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- filter = container_of(component, struct bt_component_filter, parent);
- filter->add_iterator = add_iterator;
-end:
- return ret;
-}
-
enum bt_component_status bt_component_filter_set_minimum_input_count(
struct bt_component *component,
unsigned int minimum)
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
{
struct bt_component_filter *filter;
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ struct bt_component_class_filter *filter_class;
if (!component || !iterator) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_FILTER) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_FILTER) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (filter->add_iterator) {
- ret = filter->add_iterator(component, iterator);
+ filter_class = container_of(component->class, struct bt_component_class_filter, parent);
+
+ if (filter_class->methods.add_iterator) {
+ ret = filter_class->methods.add_iterator(component, iterator);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
goto end;
}
- if (component->class->type != BT_COMPONENT_TYPE_FILTER) {
+ if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
filter = container_of(component, struct bt_component_filter, parent);
- if (!filter->init_iterator) {
- printf_error("Invalid filter component; no iterator initialization callback defined.");
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
ret = component_input_validate(&filter->input);
if (ret) {
goto end;
struct bt_notification_iterator *bt_notification_iterator_create(
struct bt_component *component)
{
- enum bt_component_type type;
+ enum bt_component_class_type type;
struct bt_notification_iterator *iterator = NULL;
if (!component) {
goto end;
}
- type = bt_component_get_type(component);
+ type = bt_component_get_class_type(component);
switch (type) {
- case BT_COMPONENT_TYPE_SOURCE:
- case BT_COMPONENT_TYPE_FILTER:
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
break;
default:
goto end;
goto end;
}
- if (component->class->type != BT_COMPONENT_TYPE_SINK) {
+ if (component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
sink = container_of(component, struct bt_component_sink, parent);
- if (!sink->consume) {
- printf_error("Invalid sink component; no notification consumption callback defined.");
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
ret = component_input_validate(&sink->input);
if (ret) {
goto end;
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_component_sink *sink = NULL;
+ struct bt_component_class_sink *sink_class = NULL;
if (!component) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
sink->input.validated = true;
}
- assert(sink->consume);
- ret = sink->consume(component);
+ sink_class = container_of(component->class, struct bt_component_class_sink, parent);
+ assert(sink_class->methods.consume);
+ ret = sink_class->methods.consume(component);
end:
return ret;
}
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
return ret;
}
*/
-enum bt_component_status bt_component_sink_set_consume_cb(
- struct bt_component *component,
- bt_component_sink_consume_cb consume)
-{
- struct bt_component_sink *sink;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
- if (!component) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
- ret = BT_COMPONENT_STATUS_UNSUPPORTED;
- goto end;
- }
-
- if (!component->initializing) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- sink = container_of(component, struct bt_component_sink, parent);
- sink->consume = consume;
-end:
- return ret;
-}
-
-enum bt_component_status bt_component_sink_set_add_iterator_cb(
- struct bt_component *component,
- bt_component_sink_add_iterator_cb add_iterator)
-{
- struct bt_component_sink *sink;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
- if (!component) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
- ret = BT_COMPONENT_STATUS_UNSUPPORTED;
- goto end;
- }
-
- if (!component->initializing) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- sink = container_of(component, struct bt_component_sink, parent);
- sink->add_iterator = add_iterator;
-end:
- return ret;
-}
enum bt_component_status bt_component_sink_set_minimum_input_count(
struct bt_component *component,
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
{
struct bt_component_sink *sink;
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ struct bt_component_class_sink *sink_class;
if (!component || !iterator) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
- if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ if (bt_component_get_class_type(component) != BT_COMPONENT_CLASS_TYPE_SINK) {
ret = BT_COMPONENT_STATUS_UNSUPPORTED;
goto end;
}
goto end;
}
- if (sink->add_iterator) {
- ret = sink->add_iterator(component, iterator);
+ sink_class = container_of(component->class, struct bt_component_class_sink, parent);
+
+ if (sink_class->methods.add_iterator) {
+ ret = sink_class->methods.add_iterator(component, iterator);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
struct bt_component *component)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- struct bt_component_source *source;
if (!component) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
- if (component->class->type != BT_COMPONENT_TYPE_SOURCE) {
+ if (component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
- source = container_of(component, struct bt_component_source, parent);
- if (!source->init_iterator) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
end:
return ret;
}
return source ? &source->parent : NULL;
}
-enum bt_component_status
-bt_component_source_set_iterator_init_cb(struct bt_component *component,
- bt_component_source_init_iterator_cb init_iterator)
-{
- struct bt_component_source *source;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
- if (component->class->type != BT_COMPONENT_TYPE_SOURCE ||
- !component->initializing) {
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- source = container_of(component, struct bt_component_source, parent);
- source->init_iterator = init_iterator;
-end:
- return ret;
-}
-
struct bt_notification_iterator *bt_component_source_create_iterator(
struct bt_component *component)
{
return plugin;
}
+/*
+ * This function does the following:
+ *
+ * 1. Iterate on the plugin descriptor attributes section and set the
+ * plugin's attributes depending on the attribute types. This
+ * includes the name of the plugin, its description, and its
+ * initialization function, for example.
+ *
+ * 2. Iterate on the component class descriptors section and create one
+ * "full descriptor" (temporary structure) for each one that is found
+ * and attached to our plugin descriptor.
+ *
+ * 3. Iterate on the component class descriptor attributes section and
+ * set the corresponding full descriptor's attributes depending on
+ * the attribute types. This includes the description of the
+ * component class, as well as its initialization and destroy
+ * methods.
+ *
+ * 4. Call the user's plugin initialization function, if any is
+ * defined.
+ *
+ * 5. For each full component class descriptor, create a component class
+ * object, set its optional attributes, and add it to the plugin
+ * object.
+ *
+ * 6. Freeze the plugin object.
+ */
static
enum bt_plugin_status bt_plugin_init(
struct bt_plugin *plugin,
struct comp_class_full_descriptor {
const struct __bt_plugin_component_class_descriptor *descriptor;
const char *description;
+ bt_component_class_init_method init_method;
+ bt_component_class_destroy_method destroy_method;
+ bt_component_class_filter_add_iterator_method filter_add_iterator_method;
+ bt_component_class_sink_add_iterator_method sink_add_iterator_method;
};
enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
struct __bt_plugin_component_class_descriptor_attribute const * const *cur_cc_descr_attr_ptr;
GArray *comp_class_full_descriptors;
size_t i;
+ int ret;
comp_class_full_descriptors = g_array_new(FALSE, TRUE,
sizeof(struct comp_class_full_descriptor));
for (cur_cc_descr_ptr = cc_descriptors_begin; cur_cc_descr_ptr != cc_descriptors_end; cur_cc_descr_ptr++) {
const struct __bt_plugin_component_class_descriptor *cur_cc_descr =
*cur_cc_descr_ptr;
- struct comp_class_full_descriptor full_descriptor;
+ struct comp_class_full_descriptor full_descriptor = {0};
if (cur_cc_descr->plugin_descriptor != descriptor) {
continue;
}
full_descriptor.descriptor = cur_cc_descr;
- full_descriptor.description = NULL;
g_array_append_val(comp_class_full_descriptors,
full_descriptor);
}
cc_full_descr->description =
cur_cc_descr_attr->value.description;
break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD:
+ cc_full_descr->init_method =
+ cur_cc_descr_attr->value.init_method;
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD:
+ cc_full_descr->destroy_method =
+ cur_cc_descr_attr->value.destroy_method;
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD:
+ cc_full_descr->filter_add_iterator_method =
+ cur_cc_descr_attr->value.filter_add_iterator_method;
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD:
+ cc_full_descr->sink_add_iterator_method =
+ cur_cc_descr_attr->value.sink_add_iterator_method;
+ break;
default:
printf_verbose("WARNING: Unknown attribute \"%s\" (type %d) for component class %s (type %d) in plugin %s\n",
cur_cc_descr_attr->type_name,
plugin->shared_lib_handle->init_called = true;
+ /* Add described component classes to plugin */
for (i = 0; i < comp_class_full_descriptors->len; i++) {
struct comp_class_full_descriptor *cc_full_descr =
&g_array_index(comp_class_full_descriptors,
struct comp_class_full_descriptor, i);
struct bt_component_class *comp_class;
- comp_class = bt_component_class_create(
- cc_full_descr->descriptor->type,
- cc_full_descr->descriptor->name,
- cc_full_descr->description,
- cc_full_descr->descriptor->init_cb);
+ switch (cc_full_descr->descriptor->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ comp_class = bt_component_class_source_create(
+ cc_full_descr->descriptor->name,
+ cc_full_descr->descriptor->methods.source.init_iterator);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ comp_class = bt_component_class_filter_create(
+ cc_full_descr->descriptor->name,
+ cc_full_descr->descriptor->methods.filter.init_iterator);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ comp_class = bt_component_class_sink_create(
+ cc_full_descr->descriptor->name,
+ cc_full_descr->descriptor->methods.sink.consume);
+ break;
+ default:
+ printf_verbose("WARNING: Unknown component class type %d for component class %s in plugin %s\n",
+ cc_full_descr->descriptor->type,
+ cc_full_descr->descriptor->name,
+ descriptor->name);
+ continue;
+ }
+
if (!comp_class) {
status = BT_PLUGIN_STATUS_ERROR;
goto end;
}
+ if (cc_full_descr->description) {
+ ret = bt_component_class_set_description(comp_class,
+ cc_full_descr->description);
+ if (ret) {
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_PUT(comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->init_method) {
+ ret = bt_component_class_set_init_method(comp_class,
+ cc_full_descr->init_method);
+ if (ret) {
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_PUT(comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->destroy_method) {
+ ret = bt_component_class_set_destroy_method(comp_class,
+ cc_full_descr->destroy_method);
+ if (ret) {
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_PUT(comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->descriptor->type ==
+ BT_COMPONENT_CLASS_TYPE_FILTER &&
+ cc_full_descr->filter_add_iterator_method) {
+ ret = bt_component_class_filter_set_add_iterator_method(comp_class,
+ cc_full_descr->filter_add_iterator_method);
+ if (ret) {
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_PUT(comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->descriptor->type ==
+ BT_COMPONENT_CLASS_TYPE_SINK &&
+ cc_full_descr->sink_add_iterator_method) {
+ ret = bt_component_class_sink_set_add_iterator_method(comp_class,
+ cc_full_descr->sink_add_iterator_method);
+ if (ret) {
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_PUT(comp_class);
+ goto end;
+ }
+ }
+
+ /* Add component class to the plugin object */
status = bt_plugin_add_component_class(plugin,
comp_class);
BT_PUT(comp_class);
printf_verbose("Section: Plugin component class descriptors: [%p - %p], (%zu elements)\n",
cc_descriptors_begin, cc_descriptors_end, cc_descriptors_count);
printf_verbose("Section: Plugin component class descriptor attributes: [%p - %p], (%zu elements)\n",
- cc_descr_attrs_begin, cc_descr_attrs_end, attrs_count);
+ cc_descr_attrs_begin, cc_descr_attrs_end, cc_descr_attrs_count);
plugins = calloc(descriptor_count + 1, sizeof(*plugins));
if (!plugins) {
goto error;
struct bt_component_class *bt_plugin_get_component_class_by_name_and_type(
struct bt_plugin *plugin, const char *name,
- enum bt_component_type type)
+ enum bt_component_class_type type)
{
struct bt_component_class *comp_class = NULL;
size_t i;
g_ptr_array_index(plugin->comp_classes, i);
const char *comp_class_cand_name =
bt_component_class_get_name(comp_class_candidate);
- enum bt_component_type comp_class_cand_type =
+ enum bt_component_class_type comp_class_cand_type =
bt_component_class_get_type(comp_class_candidate);
assert(comp_class_cand_name);
return ret;
}
-static
enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
struct bt_notification_iterator *it)
{
g_free(ctf_fs);
}
-static
void ctf_fs_destroy(struct bt_component *component)
{
void *data = bt_component_get_private_data(component);
goto end;
}
- ret = bt_component_set_destroy_cb(source, ctf_fs_destroy);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
ret = bt_component_set_private_data(source, ctf_fs);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
-
- ret = bt_component_source_set_iterator_init_cb(source,
- ctf_fs_iterator_init);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
end:
return ret;
error:
enum bt_component_status ctf_fs_init(struct bt_component *source,
struct bt_value *params);
+BT_HIDDEN
+void ctf_fs_destroy(struct bt_component *component);
+
+BT_HIDDEN
+enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
+ struct bt_notification_iterator *it);
+
#endif /* BABELTRACE_PLUGIN_CTF_FS_H */
#define LTTNG_LIVE_COMPONENT_DESCRIPTION "Component implementing an LTTng-live client."
+BT_HIDDEN
+enum bt_component_status lttng_live_iterator_init(struct bt_component *source,
+ struct bt_notification_iterator *it);
+
BT_HIDDEN
enum bt_component_status lttng_live_init(struct bt_component *source,
struct bt_value *params);
#include "lttng-live-internal.h"
#include <babeltrace/component/source.h>
+BT_HIDDEN
+enum bt_component_status lttng_live_iterator_init(struct bt_component *source,
+ struct bt_notification_iterator *it)
+{
+}
+
BT_HIDDEN
enum bt_component_status lttng_live_init(struct bt_component *component,
struct bt_value *params)
BT_PLUGIN_LICENSE("MIT");
/* Declare component classes implemented by this plug-in. */
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SOURCE, fs, ctf_fs_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SOURCE, fs,
- CTF_FS_COMPONENT_DESCRIPTION);
-BT_PLUGIN_COMPONENT_CLASS_WITH_ID(auto, lttng_live,
- BT_COMPONENT_TYPE_SOURCE, "lttng-live", lttng_live_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, lttng_live,
- BT_COMPONENT_TYPE_SOURCE, LTTNG_LIVE_COMPONENT_DESCRIPTION);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS(fs, ctf_fs_iterator_init);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(fs, ctf_fs_init);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD(fs, ctf_fs_destroy);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(fs, CTF_FS_COMPONENT_DESCRIPTION);
+
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, lttng_live, "lttng-live",
+ lttng_live_iterator_init);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, lttng_live,
+ lttng_live_init);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, lttng_live,
+ LTTNG_LIVE_COMPONENT_DESCRIPTION);
goto end;
}
- ret = bt_component_set_destroy_cb(component,
- destroy_muxer);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
ret = bt_component_set_private_data(component, muxer);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
return ret;
}
+enum bt_component_status muxer_init_iterator(
+ struct bt_component *component,
+ struct bt_notification_iterator *iter)
+{
+ return BT_COMPONENT_STATUS_OK;
+}
+
/* Initialize plug-in entry points. */
BT_PLUGIN(muxer);
BT_PLUGIN_DESCRIPTION("Babeltrace Trace Muxer Plug-In.");
BT_PLUGIN_AUTHOR("Jérémie Galarneau");
BT_PLUGIN_LICENSE("MIT");
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_FILTER, muxer,
- muxer_component_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_FILTER, muxer,
+BT_PLUGIN_FILTER_COMPONENT_CLASS(muxer, muxer_init_iterator);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(muxer,
"Time-correlate multiple traces.");
+BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(muxer, muxer_component_init);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD(muxer, destroy_muxer);
goto error;
}
- ret = bt_component_set_destroy_cb(component,
- destroy_text);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
ret = bt_component_set_private_data(component, text);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
-
- ret = bt_component_sink_set_consume_cb(component,
- run);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
end:
return ret;
error:
BT_PLUGIN_DESCRIPTION("Babeltrace text output plug-in.");
BT_PLUGIN_AUTHOR("Jérémie Galarneau");
BT_PLUGIN_LICENSE("MIT");
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SINK, text,
- text_component_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SINK, text,
+BT_PLUGIN_SINK_COMPONENT_CLASS(text, run);
+BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(text, text_component_init);
+BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD(text, destroy_text);
+BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(text,
"Formats CTF-IR to text. Formerly known as ctf-text.");
+
goto end;
}
- ret = bt_component_set_destroy_cb(component,
- destroy_trimmer);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
ret = bt_component_set_private_data(component, trimmer);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
- ret = bt_component_filter_set_iterator_init_cb(component,
- trimmer_iterator_init);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
ret = init_from_params(trimmer, params);
end:
return ret;
BT_PLUGIN_DESCRIPTION("Babeltrace Trace Trimmer Plug-In.");
BT_PLUGIN_AUTHOR("Jérémie Galarneau");
BT_PLUGIN_LICENSE("MIT");
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_FILTER, trimmer,
- trimmer_component_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_FILTER, trimmer,
+BT_PLUGIN_FILTER_COMPONENT_CLASS(trimmer, trimmer_iterator_init);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(trimmer,
"Ensure that trace notifications outside of a given range are filtered-out.");
+BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(trimmer, trimmer_component_init);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_DESTROY_METHOD(trimmer, destroy_trimmer);
goto error;
}
- ret = bt_component_set_destroy_cb(component,
- destroy_writer_component);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
ret = bt_component_set_private_data(component, writer_component);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
- ret = bt_component_sink_set_consume_cb(component,
- run);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
end:
return ret;
error:
BT_PLUGIN_DESCRIPTION("Babeltrace CTF-Writer output plug-in.");
BT_PLUGIN_AUTHOR("Jérémie Galarneau");
BT_PLUGIN_LICENSE("MIT");
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SINK, writer,
- writer_component_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SINK, writer,
- "Formats CTF-IR to CTF.");
+BT_PLUGIN_SINK_COMPONENT_CLASS(writer, run);
+BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(writer, writer_component_init);
+BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD(writer, destroy_writer_component);
+BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(writer, "Formats CTF-IR to CTF.");
#include <babeltrace/plugin/plugin-dev.h>
#include <babeltrace/component/component.h>
-static int sink_value = 42;
-
-static enum bt_component_status sink_run(struct bt_component *component)
-{
- return BT_COMPONENT_STATUS_OK;
-}
-
-static enum bt_component_status comp_class_sink_init(
- struct bt_component *component, struct bt_value *params)
+static enum bt_component_status sink_consume(struct bt_component *component)
{
- enum bt_component_status ret;
-
- ret = bt_component_set_private_data(component, &sink_value);
- if (ret != BT_COMPONENT_STATUS_OK) {
- return BT_COMPONENT_STATUS_ERROR;
- }
-
- ret = bt_component_sink_set_consume_cb(component, sink_run);
- if (ret != BT_COMPONENT_STATUS_OK) {
- return BT_COMPONENT_STATUS_ERROR;
- }
-
return BT_COMPONENT_STATUS_OK;
}
-static enum bt_component_status comp_class_dummy_init(
- struct bt_component *component, struct bt_value *params)
+enum bt_component_status dummy_init_iterator_method(
+ struct bt_component *component, struct bt_notification_iterator *iter)
{
return BT_COMPONENT_STATUS_OK;
}
BT_PLUGIN_AUTHOR("Janine Sutto");
BT_PLUGIN_LICENSE("Beerware");
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SOURCE, source, comp_class_dummy_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SOURCE, source, "A source.");
+BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_init_iterator_method);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SINK, sink, comp_class_sink_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SINK, sink, "A sink.");
+BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
+BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
-BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_FILTER, filter, comp_class_dummy_init);
-BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_FILTER, filter, "A filter.");
+BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_init_iterator_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
"bt_plugin_get_component_class_count() returns the expected value");
source_comp_class = bt_plugin_get_component_class_by_name_and_type(
- plugin, "source", BT_COMPONENT_TYPE_SOURCE);
+ plugin, "source", BT_COMPONENT_CLASS_TYPE_SOURCE);
ok(source_comp_class,
"bt_plugin_get_component_class_by_name_and_type() finds a source component class");
sink_comp_class = bt_plugin_get_component_class_by_name_and_type(
- plugin, "sink", BT_COMPONENT_TYPE_SINK);
+ plugin, "sink", BT_COMPONENT_CLASS_TYPE_SINK);
ok(sink_comp_class,
"bt_plugin_get_component_class_by_name_and_type() finds a sink component class");
filter_comp_class = bt_plugin_get_component_class_by_name_and_type(
- plugin, "filter", BT_COMPONENT_TYPE_FILTER);
+ plugin, "filter", BT_COMPONENT_CLASS_TYPE_FILTER);
ok(filter_comp_class,
"bt_plugin_get_component_class_by_name_and_type() finds a filter component class");
ok(!bt_plugin_get_component_class_by_name_and_type(plugin, "filter",
- BT_COMPONENT_TYPE_SOURCE),
+ BT_COMPONENT_CLASS_TYPE_SOURCE),
"bt_plugin_get_component_class_by_name_and_type() does not find a component class given the wrong type");
diag("> putting the plugin object here");