-#ifndef BABELTRACE_PLUGIN_COMPONENT_CLASS_H
-#define BABELTRACE_PLUGIN_COMPONENT_CLASS_H
+#ifndef BABELTRACE_PLUGIN_COMPONENT_FACTORY_H
+#define BABELTRACE_PLUGIN_COMPONENT_FACTORY_H
/*
- * Babeltrace - Plugin Component Class Interface.
+ * Babeltrace - Component Factory Class Interface.
*
- * Copyright 2015 EfficiOS Inc.
- * Copyright 2015 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 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
* SOFTWARE.
*/
-#include <stdint.h>
-#include <babeltrace/plugin/factory.h>
+#include <babeltrace/plugin/component.h>
+#include <babeltrace/plugin/source.h>
+#include <babeltrace/plugin/sink.h>
+#include <babeltrace/plugin/filter.h>
+#include <babeltrace/plugin/plugin-system.h>
+#include <babeltrace/values.h>
#ifdef __cplusplus
extern "C" {
- #endif
-
-#define BT_PLUGIN_NAME(_x) const char *__bt_plugin_name = (_x)
-#define BT_PLUGIN_AUTHOR(_x) const char *__bt_plugin_author = (_x)
-#define BT_PLUGIN_LICENSE(_x) const char *__bt_plugin_license = (_x)
-#define BT_PLUGIN_INIT(_x) void *__bt_plugin_init = (_x)
-#define BT_PLUGIN_EXIT(_x) void *__bt_plugin_exit = (_x)
-
-#define BT_PLUGIN_COMPONENT_CLASSES_BEGIN\
- enum bt_status __bt_plugin_register_component_classes(\
- struct bt_component_factory *factory)\
- {
-
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _it_cr) \
- bt_component_factory_register_source_component_class(factory, \
- _name, _init, _fini, _it_cr);
-
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(_name, _init, _fini, _hd_notif) \
- bt_component_factory_register_sink_component_class(factory, \
- _name, _init, _fini, _hd_notif);
-
-#define BT_PLUGIN_COMPONENT_CLASSES_END\
- \
- return BT_STATUS_OK;\
-}\
- \
- BT_PLUGIN_INIT(__bt_plugin_register_component_classes);\
- BT_PLUGIN_EXIT(NULL);
-
- #ifdef __cplusplus
+#endif
+
+/**
+ * Status code. Errors are always negative.
+ */
+enum bt_component_factory_status {
+ /** General error. */
+ BT_COMPONENT_FACTORY_STATUS_ERROR = -128,
+
+ /** Invalid plugin. */
+ BT_COMPONENT_FACTORY_STATUS_INVAL_PLUGIN = -6,
+
+ /** Invalid arguments. */
+ BT_COMPONENT_FACTORY_STATUS_INVAL = -5,
+
+ /** Memory allocation failure. */
+ BT_COMPONENT_FACTORY_STATUS_NOMEM = -4,
+
+ /** I/O error. */
+ BT_COMPONENT_FACTORY_STATUS_IO = -3,
+
+ /** No such file or directory. */
+ BT_COMPONENT_FACTORY_STATUS_NOENT = -2,
+
+ /** Operation not permitted. */
+ BT_COMPONENT_FACTORY_STATUS_PERM = -1,
+
+ /** No error, okay. */
+ BT_COMPONENT_FACTORY_STATUS_OK = 0,
+};
+
+struct bt_component_factory;
+
+/**
+ * Create a component factory.
+ *
+ * @returns An instance of component factory
+ */
+extern struct bt_component_factory *bt_component_factory_create(void);
+
+/**
+ * Get the list of components registered to this factory.
+ *
+ * @param factory Component factory
+ */
+extern struct bt_value *bt_component_factory_get_components(
+ struct bt_component_factory *factory);
+
+/**
+ * .
+ */
+extern struct bt_value *bt_component_factory_create_component(
+ struct bt_component_factory *factory);
+
+/**
+ * Recursively load and register Babeltrace plugins under a given path.
+ *
+ * Path will be traversed recursively if it is a directory, otherwise only the
+ * provided file will be loaded.
+ *
+ * @param factory A component factory instance
+ * @param path A path to a file or directory
+ * @returns One of #bt_component_factory_status values
+ */
+extern enum bt_component_factory_status bt_component_factory_load(
+ struct bt_component_factory *factory, const char *path);
+
+extern 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);
+
+extern 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);
+
+#ifdef __cplusplus
}
#endif
-#endif /* BABELTRACE_PLUGIN_H */
+#endif /* BABELTRACE_PLUGIN_COMPONENT_FACTORY_H */