Allow a component to remove a port and any user to disconnect one
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 23 Mar 2017 21:12:40 +0000 (17:12 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:38 +0000 (12:57 -0400)
commit72b913fbad1753b5b122bfb54c1e7936eaf9d0ef
tree8aa27604f9956edf8c048055efab4b20f593818f
parent6fbd4105b92d0da8b3c5818a5b7c5b07850f4a01
Allow a component to remove a port and any user to disconnect one

This patch allows a component to remove one of its own ports at anytime.
Removing a connected port has the side effect of also disconnecting it.
This patch also allows any user (graph's creator or component, for
example) to disconnect a component's port.

A component can remove one of its port with
bt_port_remove_from_component(). This function only needs the port
object because the removing component is its parent. Note that this
function does not check in any way that the removing component is the
parent of the port to remove from its parent, so any component or even
the graph's user could remove any component's port. This is prohibited
by the API's contract, but it's not enforced. It should be documented
accordingly.

You can disconnect a port with bt_port_disconnect(). When you call this
function, both upstream and downstream ports of the port's current
connection are disconnected, that is, they become available again for
bt_graph_connect().

When a port is disconnected with bt_port_remove_from_component(), the
parent component's of the connection's other port is called back ("port
disconnected" method) to notify it that one of its ports lost a
connection. Then the component is free to keep this port as an available
port, or to remove it too.

When a port is disconnected with bt_port_disconnect(), both
components are called back ("port disconnected method").

The existing iterators on a connection which is dropped (ports are
disconnected) are left as is: they still work.

The "new connection" optional method is renamed to "accept port
connection": this method can return
BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION to explicitly refuse the
new connection.

With this patch, only one connection per port is allowed. This
simplifies the model. One-to-many connections can be replaced with
a "tee" filter. Thus this patch removes the concept of a maximum number
of connections per port (it's always one).

With this patch, a component can add a new port at anytime, not just
during its initialization.

Also in this patch: the input and output ports are part of the
bt_component object. The public API is not changed. This avoids some
code duplication.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
31 files changed:
converter/babeltrace.c
include/babeltrace/component/component-class-internal.h
include/babeltrace/component/component-class.h
include/babeltrace/component/component-filter-internal.h
include/babeltrace/component/component-internal.h
include/babeltrace/component/component-sink-internal.h
include/babeltrace/component/component-sink.h
include/babeltrace/component/component-source-internal.h
include/babeltrace/component/component-source.h
include/babeltrace/component/component.h
include/babeltrace/component/connection-internal.h
include/babeltrace/component/connection.h
include/babeltrace/component/graph.h
include/babeltrace/component/port-internal.h
include/babeltrace/component/port.h
include/babeltrace/plugin/plugin-dev.h
lib/component/component-class.c
lib/component/component.c
lib/component/connection.c
lib/component/filter.c
lib/component/graph.c
lib/component/port.c
lib/component/sink.c
lib/component/source.c
lib/plugin/plugin-so.c
plugins/text/text.c
plugins/utils/dummy/dummy.c
plugins/utils/dummy/dummy.h
plugins/utils/plugin.c
plugins/utils/trimmer/iterator.c
plugins/writer/writer.c
This page took 0.027373 seconds and 4 git commands to generate.