lib: strictly type function return status enumerations
[babeltrace.git] / src / lib / plugin / plugin.h
index d7f2d68fcbbc0d79685152f878a8e0bd8d915029..202c69bede6cee35272eec13c569059d909abaf1 100644 (file)
 #include "lib/object.h"
 #include <babeltrace2/types.h>
 #include "common/assert.h"
-#include "lib/lib-logging.h"
 #include <glib.h>
 
 #include "plugin-so.h"
+#include "lib/func-status.h"
+
+/* Protection: this file uses BT_LIB_LOG*() macros directly */
+#ifndef BT_LIB_LOG_SUPPORTED
+# error Please include "lib/logging.h" before including this file.
+#endif
 
 enum bt_plugin_type {
        BT_PLUGIN_TYPE_SO = 0,
        BT_PLUGIN_TYPE_PYTHON = 1,
 };
 
-enum bt_plugin_status {
-       BT_PLUGIN_STATUS_OK = 0,
-       BT_PLUGIN_STATUS_ERROR = -1,
-       BT_PLUGIN_STATUS_NOMEM = -12,
-};
-
 struct bt_plugin {
        struct bt_object base;
        enum bt_plugin_type type;
@@ -89,21 +88,6 @@ struct bt_plugin_set {
        GPtrArray *plugins;
 };
 
-static inline
-const char *bt_plugin_status_string(enum bt_plugin_status status)
-{
-       switch (status) {
-       case BT_PLUGIN_STATUS_OK:
-               return "BT_PLUGIN_STATUS_OK";
-       case BT_PLUGIN_STATUS_ERROR:
-               return "BT_PLUGIN_STATUS_ERROR";
-       case BT_PLUGIN_STATUS_NOMEM:
-               return "BT_PLUGIN_STATUS_NOMEM";
-       default:
-               return "(unknown)";
-       }
-}
-
 static inline
 const char *bt_plugin_type_string(enum bt_plugin_type type)
 {
@@ -124,7 +108,7 @@ void bt_plugin_destroy(struct bt_object *obj)
 
        BT_ASSERT(obj);
        plugin = container_of(obj, struct bt_plugin, base);
-       BT_LIB_LOGD("Destroying plugin object: %!+l", plugin);
+       BT_LIB_LOGI("Destroying plugin object: %!+l", plugin);
 
        if (plugin->destroy_spec_data) {
                plugin->destroy_spec_data(plugin);
@@ -277,7 +261,7 @@ void bt_plugin_set_path(struct bt_plugin *plugin, const char *path)
        BT_ASSERT(path);
        g_string_assign(plugin->info.path, path);
        plugin->info.path_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, path=\"%s\"",
+       BT_LIB_LOGD("Set plugin's path: %![plugin-]+l, path=\"%s\"",
                plugin, path);
 }
 
@@ -288,7 +272,7 @@ void bt_plugin_set_name(struct bt_plugin *plugin, const char *name)
        BT_ASSERT(name);
        g_string_assign(plugin->info.name, name);
        plugin->info.name_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's name: %![plugin-]+l, name=\"%s\"",
+       BT_LIB_LOGD("Set plugin's name: %![plugin-]+l, name=\"%s\"",
                plugin, name);
 }
 
@@ -300,7 +284,7 @@ void bt_plugin_set_description(struct bt_plugin *plugin,
        BT_ASSERT(description);
        g_string_assign(plugin->info.description, description);
        plugin->info.description_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's description: %![plugin-]+l", plugin);
+       BT_LIB_LOGD("Set plugin's description: %![plugin-]+l", plugin);
 }
 
 static inline
@@ -310,7 +294,7 @@ void bt_plugin_set_author(struct bt_plugin *plugin, const char *author)
        BT_ASSERT(author);
        g_string_assign(plugin->info.author, author);
        plugin->info.author_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's author: %![plugin-]+l, author=\"%s\"",
+       BT_LIB_LOGD("Set plugin's author: %![plugin-]+l, author=\"%s\"",
                plugin, author);
 }
 
@@ -321,7 +305,7 @@ void bt_plugin_set_license(struct bt_plugin *plugin, const char *license)
        BT_ASSERT(license);
        g_string_assign(plugin->info.license, license);
        plugin->info.license_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, license=\"%s\"",
+       BT_LIB_LOGD("Set plugin's path: %![plugin-]+l, license=\"%s\"",
                plugin, license);
 }
 
@@ -339,13 +323,13 @@ void bt_plugin_set_version(struct bt_plugin *plugin, unsigned int major,
        }
 
        plugin->info.version_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's version: %![plugin-]+l, "
+       BT_LIB_LOGD("Set plugin's version: %![plugin-]+l, "
                "major=%u, minor=%u, patch=%u, extra=\"%s\"",
                plugin, major, minor, patch, extra);
 }
 
 static inline
-enum bt_plugin_status bt_plugin_add_component_class(
+int bt_plugin_add_component_class(
        struct bt_plugin *plugin, struct bt_component_class *comp_class)
 {
        GPtrArray *comp_classes;
@@ -378,7 +362,7 @@ enum bt_plugin_status bt_plugin_add_component_class(
 
        BT_LIB_LOGD("Added component class to plugin: "
                "%![plugin-]+l, %![cc-]+C", plugin, comp_class);
-       return BT_PLUGIN_STATUS_OK;
+       return BT_FUNC_STATUS_OK;
 }
 
 static
@@ -435,7 +419,7 @@ void bt_plugin_set_add_plugin(struct bt_plugin_set *plugin_set,
        BT_ASSERT(plugin);
        bt_object_get_ref(plugin);
        g_ptr_array_add(plugin_set->plugins, plugin);
-       BT_LIB_LOGV("Added plugin to plugin set: "
+       BT_LIB_LOGD("Added plugin to plugin set: "
                "plugin-set-addr=%p, %![plugin-]+l",
                plugin_set, plugin);
 }
This page took 0.026402 seconds and 4 git commands to generate.