borrow_port_by_index(comp->output_ports, index, api_func);
}
+static
+bool port_name_is_unique(GPtrArray *ports, const char *name)
+{
+ guint i;
+ bool unique;
+
+ for (i = 0; i < ports->len; i++) {
+ struct bt_port *port = g_ptr_array_index(ports, i);
+
+ if (strcmp(port->name->str, name) == 0) {
+ unique = false;
+ goto end;
+ }
+ }
+
+ unique = true;
+
+end:
+ return unique;
+}
+
enum bt_self_component_add_port_status bt_component_add_input_port(
struct bt_component *component, const char *name,
void *user_data, struct bt_port **port, const char *api_func)
BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(api_func, component);
BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
BT_ASSERT_PRE_FROM_FUNC(api_func, "input-port-name-is-unique",
- bt_component_port_name_is_unique(component->input_ports, name),
+ port_name_is_unique(component->input_ports, name),
"Input port name is not unique: name=\"%s\", %![comp-]c",
name, component);
BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(api_func, component);
BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
BT_ASSERT_PRE_FROM_FUNC(api_func, "output-port-name-is-unique",
- bt_component_port_name_is_unique(component->output_ports, name),
+ port_name_is_unique(component->output_ports, name),
"Output port name is not unique: name=\"%s\", %![comp-]c",
name, component);
BT_PORT_TYPE_OUTPUT, name, user_data, port, api_func);
}
-bool bt_component_port_name_is_unique(GPtrArray *ports, const char *name)
-{
- guint i;
- bool unique;
-
- for (i = 0; i < ports->len; i++) {
- struct bt_port *port = g_ptr_array_index(ports, i);
-
- if (strcmp(port->name->str, name) == 0) {
- unique = false;
- goto end;
- }
- }
-
- unique = true;
-
-end:
- return unique;
-}
-
enum bt_component_class_port_connected_method_status
bt_component_port_connected(
struct bt_component *comp, struct bt_port *self_port,
#include "component-class.h"
#include "port.h"
-#define BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE(comp, name) \
- BT_ASSERT_PRE("output-port-is-unique", \
- bt_component_port_name_is_unique(comp->output_ports, name), \
- "Output port name is not unique: name=\"%s\", %![comp-]c", name, comp);
-
typedef void (*bt_component_destroy_listener_func)(
struct bt_component *class, void *data);
void *user_data, struct bt_port **port,
const char *api_func);
-bool bt_component_port_name_is_unique(GPtrArray *ports, const char *name);
-
void bt_component_remove_port(struct bt_component *component,
struct bt_port *port);