-#ifndef BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H
-#define BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H
-
/*
+ * SPDX-License-Identifier: MIT
+ *
* Copyright 2017-2018 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
- * 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 "common/macros.h"
+#ifndef BABELTRACE_LIB_PLUGIN_PLUGIN_H
+#define BABELTRACE_LIB_PLUGIN_PLUGIN_H
+
+#include "common/common.h"
#include "lib/graph/component-class.h"
-#include <babeltrace2/plugin/plugin-const.h>
+#include <babeltrace2/plugin/plugin-loading.h>
#include <babeltrace2/plugin/plugin-dev.h>
#include "lib/object.h"
#include <babeltrace2/types.h>
#include "common/assert.h"
#include <glib.h>
+#include <stdbool.h>
#include "plugin-so.h"
#include "lib/func-status.h"
{
switch (type) {
case BT_PLUGIN_TYPE_SO:
- return "BT_PLUGIN_TYPE_SO";
+ return "SO";
case BT_PLUGIN_TYPE_PYTHON:
- return "BT_PLUGIN_TYPE_PYTHON";
+ return "PYTHON";
default:
return "(unknown)";
}
comp_classes = plugin->sink_comp_classes;
break;
default:
- abort();
+ bt_common_abort();
}
/* Set component class's original plugin name */
return plugin_set;
}
+static inline
+bool bt_plugin_set_contains_plugin(struct bt_plugin_set *plugin_set,
+ const char *name)
+{
+ uint64_t i;
+ bool contains = false;
+
+ BT_ASSERT(plugin_set);
+ BT_ASSERT(name);
+
+ for (i = 0; i < plugin_set->plugins->len; i++) {
+ const struct bt_plugin *plugin = plugin_set->plugins->pdata[i];
+
+ if (strcmp(plugin->info.name->str, name) == 0) {
+ contains = true;
+ goto end;
+ }
+ }
+
+end:
+ return contains;
+}
+
static inline
void bt_plugin_set_add_plugin(struct bt_plugin_set *plugin_set,
struct bt_plugin *plugin)
{
BT_ASSERT(plugin_set);
BT_ASSERT(plugin);
+
+ if (bt_plugin_set_contains_plugin(plugin_set,
+ plugin->info.name->str)) {
+ goto end;
+ }
+
bt_object_get_ref(plugin);
g_ptr_array_add(plugin_set->plugins, plugin);
BT_LIB_LOGD("Added plugin to plugin set: "
"plugin-set-addr=%p, %![plugin-]+l",
plugin_set, plugin);
+
+end:
+ return;
}
-#endif /* BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H */
+#endif /* BABELTRACE_LIB_PLUGIN_PLUGIN_H */