Document libbabeltrace2's C API
[babeltrace.git] / src / lib / graph / port.c
index ff4e4430438998cd201288f13cb133cd20104419..46735e2226025a419819f4f37952e37f215744c9 100644 (file)
  * SOFTWARE.
  */
 
-#define BT_LOG_TAG "PORT"
-#include "lib/lib-logging.h"
+#define BT_LOG_TAG "LIB/PORT"
+#include "lib/logging.h"
 
 #include "common/assert.h"
 #include "lib/assert-pre.h"
-#include <babeltrace2/graph/port-const.h>
-#include <babeltrace2/graph/port-input-const.h>
-#include <babeltrace2/graph/port-output-const.h>
+#include <babeltrace2/graph/port.h>
 #include <babeltrace2/graph/self-component-port.h>
-#include <babeltrace2/graph/self-component-port-input.h>
-#include <babeltrace2/graph/self-component-port-output.h>
 #include "lib/object.h"
 #include "compat/compiler.h"
 
@@ -44,7 +40,7 @@ void destroy_port(struct bt_object *obj)
 {
        struct bt_port *port = (void *) obj;
 
-       BT_LIB_LOGD("Destroying port: %!+p", port);
+       BT_LIB_LOGI("Destroying port: %!+p", port);
 
        if (port->name) {
                g_string_free(port->name, TRUE);
@@ -66,17 +62,17 @@ struct bt_port *bt_port_create(struct bt_component *parent_component,
        BT_ASSERT(strlen(name) > 0);
        port = g_new0(struct bt_port, 1);
        if (!port) {
-               BT_LOGE_STR("Failed to allocate one port.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one port.");
                goto end;
        }
 
-       BT_LIB_LOGD("Creating port for component: %![comp-]+c, port-type=%s, "
+       BT_LIB_LOGI("Creating port for component: %![comp-]+c, port-type=%s, "
                "port-name=\"%s\"", parent_component, bt_port_type_string(type),
                name);
        bt_object_init_shared_with_parent(&port->base, destroy_port);
        port->name = g_string_new(name);
        if (!port->name) {
-               BT_LOGE_STR("Failed to allocate one GString.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GString.");
                BT_OBJECT_PUT_REF_AND_RESET(port);
                goto end;
        }
@@ -84,7 +80,7 @@ struct bt_port *bt_port_create(struct bt_component *parent_component,
        port->type = type;
        port->user_data = user_data;
        bt_object_set_parent(&port->base, &parent_component->base);
-       BT_LIB_LOGD("Created port for component: "
+       BT_LIB_LOGI("Created port for component: "
                "%![comp-]+c, %![port-]+p", parent_component, port);
 
 end:
@@ -93,34 +89,34 @@ end:
 
 const char *bt_port_get_name(const struct bt_port *port)
 {
-       BT_ASSERT_PRE_NON_NULL(port, "Port");
+       BT_ASSERT_PRE_DEV_NON_NULL(port, "Port");
        return port->name->str;
 }
 
 enum bt_port_type bt_port_get_type(const struct bt_port *port)
 {
-       BT_ASSERT_PRE_NON_NULL(port, "Port");
+       BT_ASSERT_PRE_DEV_NON_NULL(port, "Port");
        return port->type;
 }
 
 const struct bt_connection *bt_port_borrow_connection_const(
                const struct bt_port *port)
 {
-       BT_ASSERT_PRE_NON_NULL(port, "Port");
+       BT_ASSERT_PRE_DEV_NON_NULL(port, "Port");
        return port->connection;
 }
 
 const struct bt_component *bt_port_borrow_component_const(
                const struct bt_port *port)
 {
-       BT_ASSERT_PRE_NON_NULL(port, "Port");
+       BT_ASSERT_PRE_DEV_NON_NULL(port, "Port");
        return bt_port_borrow_component_inline(port);
 }
 
 struct bt_self_component *bt_self_component_port_borrow_component(
                struct bt_self_component_port *port)
 {
-       BT_ASSERT_PRE_NON_NULL(port, "Port");
+       BT_ASSERT_PRE_DEV_NON_NULL(port, "Port");
        return (void *) bt_object_borrow_parent((void *) port);
 }
 
@@ -134,19 +130,19 @@ void bt_port_set_connection(struct bt_port *port,
         * connection exists.
         */
        port->connection = connection;
-       BT_LIB_LOGV("Set port's connection: %![port-]+p, %![conn-]+x", port,
+       BT_LIB_LOGI("Set port's connection: %![port-]+p, %![conn-]+x", port,
                connection);
 }
 
 bt_bool bt_port_is_connected(const struct bt_port *port)
 {
-       BT_ASSERT_PRE_NON_NULL(port, "Port");
+       BT_ASSERT_PRE_DEV_NON_NULL(port, "Port");
        return port->connection ? BT_TRUE : BT_FALSE;
 }
 
 void *bt_self_component_port_get_data(const struct bt_self_component_port *port)
 {
-       BT_ASSERT_PRE_NON_NULL(port, "Port");
+       BT_ASSERT_PRE_DEV_NON_NULL(port, "Port");
        return ((struct bt_port *) port)->user_data;
 }
 
This page took 0.026117 seconds and 4 git commands to generate.