#define BABELTRACE_PLUGIN_COMPONENT_H
/*
- * BabelTrace - Babeltrace Plug-in Component Interface
+ * BabelTrace - Babeltrace Component Interface
*
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* SOFTWARE.
*/
+#include <babeltrace/plugin/component-class.h>
#include <stdio.h>
#ifdef __cplusplus
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.
*/
enum bt_component_status {
/** Memory allocation failure. */
- /* -12 for compatibility with -ENOMEM */
- BT_COMPONENT_STATUS_NOMEM = -12,
+ BT_COMPONENT_STATUS_NOMEM = -4,
/** Invalid arguments. */
- /* -22 for compatibility with -EINVAL */
- BT_COMPONENT_STATUS_INVAL = -22,
+ BT_COMPONENT_STATUS_INVAL = -3,
/** Unsupported component feature. */
BT_COMPONENT_STATUS_UNSUPPORTED = -2,
BT_COMPONENT_STATUS_OK = 0,
};
+
struct bt_component;
+struct bt_value;
+
+/**
+ * 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.
*
* @param component Component instance of which to get the name
- * @returns Returns a pointer to the plug-in's name
+ * @returns Returns a pointer to the 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 plug-in name (will be copied)
+ * @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 instance type.
+ * Get component's class.
*
- * @param component Component instance of which to get the type
- * @returns One of #bt_component_type values
+ * @param component Component instance of which to get the class
+ * @returns The component's class
*/
-extern enum bt_component_type bt_component_get_type(
+extern struct bt_component_class *bt_component_get_class(
struct bt_component *component);
/**
- * Set a component instance's error stream.
+ * Set component instance's error stream.
*
* @param component Component instance
* @param error_stream Error stream
extern enum bt_component_status bt_component_set_error_stream(
struct bt_component *component, FILE *error_stream);
-/**
- * Increments the reference count of \p component.
- *
- * @param component Component of which to increment the reference count
- *
- * @see bt_component_put()
- */
-extern void bt_component_get(struct bt_component *component);
-
-/**
- * Decrements the reference count of \p component, destroying it when this
- * count reaches 0.
- *
- * @param component Component of which to decrement the reference count
- *
- * @see bt_component_get()
- */
-extern void bt_component_put(struct bt_component *component);
-
#ifdef __cplusplus
}
#endif