X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fport.c;h=f119d60b6dfb5414ac805cc90b3b1550c4296f2b;hb=68b66a256a54d32992dfefeaad11eea88b7df234;hp=aa8ed98f26f03d865e670ded59fc9b8c459f2278;hpb=d94d92ac6656fd252a5d7bb4f6c76935ba18e62e;p=babeltrace.git diff --git a/lib/graph/port.c b/lib/graph/port.c index aa8ed98f..f119d60b 100644 --- a/lib/graph/port.c +++ b/lib/graph/port.c @@ -1,8 +1,7 @@ /* + * Copyright 2017-2018 Philippe Proulx * Copyright 2017 Jérémie Galarneau * - * Author: Jérémie Galarneau - * * 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 @@ -23,20 +22,21 @@ */ #define BT_LOG_TAG "PORT" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static void destroy_port(struct bt_object *obj) @@ -90,28 +90,30 @@ end: return port; } -const char *bt_port_get_name(struct bt_port *port) +const char *bt_port_get_name(const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return port->name->str; } -enum bt_port_type bt_port_get_type(struct bt_port *port) +enum bt_port_type bt_port_get_type(const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return port->type; } -struct bt_connection *bt_port_borrow_connection(struct bt_port *port) +const struct bt_connection *bt_port_borrow_connection_const( + const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return port->connection; } -struct bt_component *bt_port_borrow_component(struct bt_port *port) +const struct bt_component *bt_port_borrow_component_const( + const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); - return (struct bt_component *) bt_object_borrow_parent(&port->base); + return bt_port_borrow_component_inline(port); } struct bt_self_component *bt_self_component_port_borrow_component( @@ -135,36 +137,44 @@ void bt_port_set_connection(struct bt_port *port, connection); } -enum bt_self_component_port_status bt_self_component_port_remove_from_component( - struct bt_self_component_port *self_port) +bt_bool bt_port_is_connected(const struct bt_port *port) { - struct bt_port *port = (void *) self_port; - struct bt_component *comp = NULL; + BT_ASSERT_PRE_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"); + return ((struct bt_port *) port)->user_data; +} - comp = (void *) bt_object_borrow_parent(&port->base); - if (!comp) { - BT_LIB_LOGV("Port already removed from its component: %!+p", - port); - goto end; - } +void bt_port_get_ref(const struct bt_port *port) +{ + bt_object_get_ref(port); +} - /* bt_component_remove_port() logs details */ - bt_component_remove_port(comp, port); +void bt_port_put_ref(const struct bt_port *port) +{ + bt_object_put_ref(port); +} -end: - return BT_SELF_PORT_STATUS_OK; +void bt_port_input_get_ref(const struct bt_port_input *port_input) +{ + bt_object_get_ref(port_input); } -bt_bool bt_port_is_connected(struct bt_port *port) +void bt_port_input_put_ref(const struct bt_port_input *port_input) { - BT_ASSERT_PRE_NON_NULL(port, "Port"); - return port->connection ? BT_TRUE : BT_FALSE; + bt_object_put_ref(port_input); } -void *bt_self_component_port_get_data(struct bt_self_component_port *port) +void bt_port_output_get_ref(const struct bt_port_output *port_output) { - BT_ASSERT_PRE_NON_NULL(port, "Port"); - return ((struct bt_port *) port)->user_data; + bt_object_get_ref(port_output); +} + +void bt_port_output_put_ref(const struct bt_port_output *port_output) +{ + bt_object_put_ref(port_output); }