const char *object, const bt_value *params,
bt_logging_level logging_level, const bt_value **result);
-typedef bt_self_component_status
-(*bt_component_class_filter_accept_input_port_connection_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_filter_accept_output_port_connection_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
typedef bt_self_component_status
(*bt_component_class_filter_input_port_connected_method)(
bt_self_component_filter *self_component,
bt_component_class_filter *comp_class,
bt_component_class_filter_finalize_method method);
-extern bt_component_class_status
-bt_component_class_filter_set_accept_input_port_connection_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_accept_input_port_connection_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_accept_output_port_connection_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_accept_output_port_connection_method method);
-
extern bt_component_class_status
bt_component_class_filter_set_input_port_connected_method(
bt_component_class_filter *comp_class,
bt_logging_level logging_level,
const bt_value **result);
-typedef bt_self_component_status
-(*bt_component_class_sink_accept_input_port_connection_method)(
- bt_self_component_sink *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
typedef bt_self_component_status
(*bt_component_class_sink_input_port_connected_method)(
bt_self_component_sink *self_component,
bt_component_class_sink *comp_class,
bt_component_class_sink_finalize_method method);
-extern bt_component_class_status
-bt_component_class_sink_set_accept_input_port_connection_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_accept_input_port_connection_method method);
-
extern bt_component_class_status
bt_component_class_sink_set_input_port_connected_method(
bt_component_class_sink *comp_class,
bt_logging_level logging_level,
const bt_value **result);
-typedef bt_self_component_status
-(*bt_component_class_source_accept_output_port_connection_method)(
- bt_self_component_source *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
typedef bt_self_component_status
(*bt_component_class_source_output_port_connected_method)(
bt_self_component_source *self_component,
bt_component_class_source *comp_class,
bt_component_class_source_finalize_method method);
-extern bt_component_class_status
-bt_component_class_source_set_accept_output_port_connection_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_accept_output_port_connection_method method);
-
extern bt_component_class_status
bt_component_class_source_set_output_port_connected_method(
bt_component_class_source *comp_class,
BT_GRAPH_STATUS_OK = 0,
BT_GRAPH_STATUS_END = 1,
BT_GRAPH_STATUS_AGAIN = 11,
- BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111,
BT_GRAPH_STATUS_CANCELED = 125,
BT_GRAPH_STATUS_ERROR = -1,
BT_GRAPH_STATUS_NOMEM = -12,
BT_SELF_COMPONENT_STATUS_OK = 0,
BT_SELF_COMPONENT_STATUS_END = 1,
BT_SELF_COMPONENT_STATUS_AGAIN = 11,
- BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111,
BT_SELF_COMPONENT_STATUS_ERROR = -1,
BT_SELF_COMPONENT_STATUS_NOMEM = -12,
} bt_self_component_status;
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD = 2,
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD = 3,
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD = 4,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD = 5,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD = 6,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD = 7,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD = 8,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD = 9,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD = 10,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD = 11,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD = 12,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD = 13,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD = 14,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD = 15,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD = 5,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD = 6,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD = 7,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD = 8,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD = 9,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD = 10,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD = 11,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD = 12,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD = 13,
};
/* Component class attribute (internal use) */
bt_component_class_filter_query_method filter_query_method;
bt_component_class_sink_query_method sink_query_method;
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD */
- bt_component_class_filter_accept_input_port_connection_method filter_accept_input_port_connection_method;
- bt_component_class_sink_accept_input_port_connection_method sink_accept_input_port_connection_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD */
- bt_component_class_source_accept_output_port_connection_method source_accept_output_port_connection_method;
- bt_component_class_filter_accept_output_port_connection_method filter_accept_output_port_connection_method;
-
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD */
bt_component_class_filter_input_port_connected_method filter_input_port_connected_method;
bt_component_class_sink_input_port_connected_method sink_input_port_connected_method;
#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, sink, _x)
-/*
- * Defines an accept input port connection method attribute attached to
- * a specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an accept input port connection method attribute attached to
- * a specific sink component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_sink_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_source_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x)
-
/*
* Defines an input port connected method attribute attached to a
* specific filter component class descriptor.
#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
-/*
- * Defines an accept input port connection method attribute attached to
- * a filter component class descriptor which is attached to the
- * automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an accept input port connection method attribute attached to
- * a sink component class descriptor which is attached to the automatic
- * plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_sink_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a source component class descriptor which is attached to the
- * automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_source_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a filter component class descriptor which is attached to the
- * automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
/*
* Defines an input port connected method attribute attached to a filter
* component class descriptor which is attached to the automatic plugin
pass
-class PortConnectionRefused(Exception):
- pass
-
-
class IncompleteUserClass(Error):
pass
raise bt2.Stop
elif status == native_bt.SELF_COMPONENT_STATUS_AGAIN:
raise bt2.TryAgain
- elif status == native_bt.SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION:
- raise bt2.PortConnectionRefused
elif status < 0:
raise bt2.Error(gen_error_msg)
def _finalize(self):
pass
- def _accept_port_connection(self, port, other_port):
- return True
-
- def _accept_port_connection_from_native(self, self_port_ptr, self_port_type, other_port_ptr):
- port = bt2.port._create_self_from_ptr_and_get_ref(
- self_port_ptr, self_port_type)
-
- if self_port_type == native_bt.PORT_TYPE_OUTPUT:
- other_port_type = native_bt.PORT_TYPE_INPUT
- else:
- other_port_type = native_bt.PORT_TYPE_OUTPUT
-
- other_port = bt2.port._create_from_ptr_and_get_ref(
- other_port_ptr, other_port_type)
- res = self._accept_port_connection(port, other_port_ptr)
-
- if type(res) is not bool:
- raise TypeError("'{}' is not a 'bool' object")
-
- return res
-
def _port_connected(self, port, other_port):
pass
super().__init__(ptr)
def _handle_status(self, status, gen_error_msg):
- if status == native_bt.GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION:
- raise bt2.PortConnectionRefused
- elif status == native_bt.GRAPH_STATUS_CANCELED:
+ if status == native_bt.GRAPH_STATUS_CANCELED:
raise bt2.GraphCanceled
elif status == native_bt.GRAPH_STATUS_END:
raise bt2.Stop
BT_SELF_COMPONENT_STATUS_OK = 0,
BT_SELF_COMPONENT_STATUS_END = 1,
BT_SELF_COMPONENT_STATUS_AGAIN = 11,
- BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111,
BT_SELF_COMPONENT_STATUS_ERROR = -1,
BT_SELF_COMPONENT_STATUS_NOMEM = -12,
} bt_self_component_status;
bt_logging_level log_level,
const bt_value **result);
-typedef bt_self_component_status
-(*bt_component_class_source_accept_output_port_connection_method)(
- bt_self_component_source *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
typedef bt_self_component_status
(*bt_component_class_source_output_port_connected_method)(
bt_self_component_source *self_component,
bt_component_class_source *comp_class,
bt_component_class_source_finalize_method method);
-extern bt_component_class_status
-bt_component_class_source_set_accept_output_port_connection_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_accept_output_port_connection_method method);
-
extern bt_component_class_status
bt_component_class_source_set_output_port_connected_method(
bt_component_class_source *comp_class,
bt_logging_level log_level,
const bt_value **result);
-typedef bt_self_component_status
-(*bt_component_class_filter_accept_input_port_connection_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_filter_accept_output_port_connection_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
typedef bt_self_component_status
(*bt_component_class_filter_input_port_connected_method)(
bt_self_component_filter *self_component,
bt_component_class_filter *comp_class,
bt_component_class_filter_finalize_method method);
-extern bt_component_class_status
-bt_component_class_filter_set_accept_input_port_connection_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_accept_input_port_connection_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_accept_output_port_connection_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_accept_output_port_connection_method method);
-
extern bt_component_class_status
bt_component_class_filter_set_input_port_connected_method(
bt_component_class_filter *comp_class,
bt_logging_level log_level,
const bt_value **result);
-typedef bt_self_component_status
-(*bt_component_class_sink_accept_input_port_connection_method)(
- bt_self_component_sink *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
typedef bt_self_component_status
(*bt_component_class_sink_input_port_connected_method)(
bt_self_component_sink *self_component,
bt_component_class_sink *comp_class,
bt_component_class_sink_finalize_method method);
-extern bt_component_class_status
-bt_component_class_sink_set_accept_input_port_connection_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_accept_input_port_connection_method method);
-
extern bt_component_class_status
bt_component_class_sink_set_input_port_connected_method(
bt_component_class_sink *comp_class,
static PyObject *py_mod_bt2_exc_error_type = NULL;
static PyObject *py_mod_bt2_exc_try_again_type = NULL;
static PyObject *py_mod_bt2_exc_stop_type = NULL;
-static PyObject *py_mod_bt2_exc_port_connection_refused_type = NULL;
static PyObject *py_mod_bt2_exc_msg_iter_canceled_type = NULL;
static PyObject *py_mod_bt2_exc_invalid_query_object_type = NULL;
static PyObject *py_mod_bt2_exc_invalid_query_params_type = NULL;
py_mod_bt2_exc_stop_type =
PyObject_GetAttrString(py_mod_bt2, "Stop");
BT_ASSERT(py_mod_bt2_exc_stop_type);
- py_mod_bt2_exc_port_connection_refused_type =
- PyObject_GetAttrString(py_mod_bt2, "PortConnectionRefused");
- BT_ASSERT(py_mod_bt2_exc_port_connection_refused_type);
py_mod_bt2_exc_invalid_query_object_type =
PyObject_GetAttrString(py_mod_bt2, "InvalidQueryObject");
BT_ASSERT(py_mod_bt2_exc_invalid_query_object_type);
Py_XDECREF(py_mod_bt2_exc_error_type);
Py_XDECREF(py_mod_bt2_exc_try_again_type);
Py_XDECREF(py_mod_bt2_exc_stop_type);
- Py_XDECREF(py_mod_bt2_exc_port_connection_refused_type);
Py_XDECREF(py_mod_bt2_exc_msg_iter_canceled_type);
Py_XDECREF(py_mod_bt2_exc_invalid_query_object_type);
Py_XDECREF(py_mod_bt2_exc_invalid_query_params_type);
/*
* traceback can be NULL, when we fail to call a Python function from the
- * native code (there is not Python stack at that point). E.g.:
+ * native code (there is no Python stack at that point). E.g.:
*
- * TypeError: _accept_port_connection_from_native() takes 3 positional arguments but 4 were given
+ * TypeError: _query_from_native() takes 5 positional arguments but 8 were given
*/
} else if (PyErr_GivenExceptionMatches(exc,
py_mod_bt2_exc_stop_type)) {
status = BT_SELF_COMPONENT_STATUS_END;
- } else if (PyErr_GivenExceptionMatches(exc,
- py_mod_bt2_exc_port_connection_refused_type)) {
- status = BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION;
} else {
bt2_py_loge_exception();
status = BT_SELF_COMPONENT_STATUS_ERROR;
bt_py3_component_class_finalize(self_component);
}
-static bt_self_component_status
-bt_py3_component_class_accept_port_connection(
- bt_self_component *self_component,
- bt_self_component_port *self_component_port,
- bt_port_type self_component_port_type,
- const bt_port *other_port)
-{
- enum bt_self_component_status status;
- PyObject *py_comp = NULL;
- PyObject *py_self_port_ptr = NULL;
- PyObject *py_other_port_ptr = NULL;
- PyObject *py_method_result = NULL;
-
- py_comp = bt_self_component_get_data(self_component);
- BT_ASSERT(py_comp);
-
- swig_type_info *self_component_port_swig_type = NULL;
- swig_type_info *other_port_swig_type = NULL;
- switch (self_component_port_type) {
- case BT_PORT_TYPE_INPUT:
- self_component_port_swig_type = SWIGTYPE_p_bt_self_component_port_input;
- other_port_swig_type = SWIGTYPE_p_bt_port_output;
- break;
- case BT_PORT_TYPE_OUTPUT:
- self_component_port_swig_type = SWIGTYPE_p_bt_self_component_port_output;
- other_port_swig_type = SWIGTYPE_p_bt_port_input;
- break;
- }
- BT_ASSERT(self_component_port_swig_type != NULL);
- BT_ASSERT(other_port_swig_type != NULL);
-
- py_self_port_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(self_component_port),
- self_component_port_swig_type, 0);
- if (!py_self_port_ptr) {
- BT_LOGE_STR("Failed to create a SWIG pointer object.");
- goto error;
- }
-
- py_other_port_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(other_port),
- other_port_swig_type, 0);
- if (!py_other_port_ptr) {
- BT_LOGE_STR("Failed to create a SWIG pointer object.");
- goto error;
- }
-
- py_method_result = PyObject_CallMethod(py_comp,
- "_accept_port_connection_from_native", "(OiO)", py_self_port_ptr,
- self_component_port_type, py_other_port_ptr);
-
- status = bt_py3_exc_to_self_component_status();
- if (!py_method_result && status == BT_SELF_COMPONENT_STATUS_OK) {
- /* Pretty sure this should never happen, but just in case */
- BT_LOGE("User's _accept_port_connection() method failed without raising an exception: "
- "status=%d", status);
- goto error;
- }
-
- if (status == BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION) {
- /*
- * Looks like the user method raised
- * PortConnectionRefused: accept this like if it
- * returned False.
- */
- goto end;
- } else if (status != BT_SELF_COMPONENT_STATUS_OK) {
- BT_LOGE("User's _accept_port_connection() raised an unexpected exception: "
- "status=%d", status);
- goto error;
- }
-
- BT_ASSERT(PyBool_Check(py_method_result));
-
- if (py_method_result == Py_True) {
- status = BT_SELF_COMPONENT_STATUS_OK;
- } else {
- status = BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION;
- }
-
- goto end;
-
-error:
- status = BT_SELF_COMPONENT_STATUS_ERROR;
-
- /*
- * Clear any exception: we're returning a bad status anyway. If
- * this call originated from Python, then the user gets an
- * appropriate error.
- */
- PyErr_Clear();
-
-end:
- Py_XDECREF(py_self_port_ptr);
- Py_XDECREF(py_other_port_ptr);
- Py_XDECREF(py_method_result);
- return status;
-}
-
-static bt_self_component_status
-bt_py3_component_class_source_accept_output_port_connection(bt_self_component_source *self_component_source,
- bt_self_component_port_output *self_component_port_output,
- const bt_port_input *other_port_input)
-{
- bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source);
- bt_self_component_port *self_component_port = bt_self_component_port_output_as_self_component_port(self_component_port_output);
- const bt_port *other_port = bt_port_input_as_port_const(other_port_input);
- return bt_py3_component_class_accept_port_connection(self_component, self_component_port, BT_PORT_TYPE_OUTPUT, other_port);
-}
-
-static bt_self_component_status
-bt_py3_component_class_filter_accept_input_port_connection(bt_self_component_filter *self_component_filter,
- bt_self_component_port_input *self_component_port_input,
- const bt_port_output *other_port_output)
-{
- bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
- bt_self_component_port *self_component_port = bt_self_component_port_input_as_self_component_port(self_component_port_input);
- const bt_port *other_port = bt_port_output_as_port_const(other_port_output);
- return bt_py3_component_class_accept_port_connection(self_component, self_component_port, BT_PORT_TYPE_INPUT, other_port);
-}
-
-static bt_self_component_status
-bt_py3_component_class_filter_accept_output_port_connection(bt_self_component_filter *self_component_filter,
- bt_self_component_port_output *self_component_port_output,
- const bt_port_input *other_port_input)
-{
- bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
- bt_self_component_port *self_component_port = bt_self_component_port_output_as_self_component_port(self_component_port_output);
- const bt_port *other_port = bt_port_input_as_port_const(other_port_input);
- return bt_py3_component_class_accept_port_connection(self_component, self_component_port, BT_PORT_TYPE_OUTPUT, other_port);
-}
-
-static bt_self_component_status
-bt_py3_component_class_sink_accept_input_port_connection(bt_self_component_sink *self_component_sink,
- bt_self_component_port_input *self_component_port_input,
- const bt_port_output *other_port_output)
-{
- bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink);
- bt_self_component_port *self_component_port = bt_self_component_port_input_as_self_component_port(self_component_port_input);
- const bt_port *other_port = bt_port_output_as_port_const(other_port_output);
- return bt_py3_component_class_accept_port_connection(self_component, self_component_port, BT_PORT_TYPE_INPUT, other_port);
-}
-
static bt_self_component_status
bt_py3_component_class_port_connected(
bt_self_component *self_component,
BT_ASSERT(ret == 0);
ret = bt_component_class_source_set_finalize_method (component_class_source, bt_py3_component_class_source_finalize);
BT_ASSERT(ret == 0);
- ret = bt_component_class_source_set_accept_output_port_connection_method(component_class_source,
- bt_py3_component_class_source_accept_output_port_connection);
- BT_ASSERT(ret == 0);
ret = bt_component_class_source_set_output_port_connected_method(component_class_source,
bt_py3_component_class_source_output_port_connected);
BT_ASSERT(ret == 0);
BT_ASSERT(ret == 0);
ret = bt_component_class_filter_set_finalize_method (component_class_filter, bt_py3_component_class_filter_finalize);
BT_ASSERT(ret == 0);
- ret = bt_component_class_filter_set_accept_input_port_connection_method(component_class_filter,
- bt_py3_component_class_filter_accept_input_port_connection);
- BT_ASSERT(ret == 0);
- ret = bt_component_class_filter_set_accept_output_port_connection_method(component_class_filter,
- bt_py3_component_class_filter_accept_output_port_connection);
- BT_ASSERT(ret == 0);
ret = bt_component_class_filter_set_input_port_connected_method(component_class_filter,
bt_py3_component_class_filter_input_port_connected);
BT_ASSERT(ret == 0);
BT_ASSERT(ret == 0);
ret = bt_component_class_sink_set_finalize_method(component_class_sink, bt_py3_component_class_sink_finalize);
BT_ASSERT(ret == 0);
- ret = bt_component_class_sink_set_accept_input_port_connection_method(component_class_sink,
- bt_py3_component_class_sink_accept_input_port_connection);
- BT_ASSERT(ret == 0);
ret = bt_component_class_sink_set_input_port_connected_method(component_class_sink,
bt_py3_component_class_sink_input_port_connected);
BT_ASSERT(ret == 0);
BT_GRAPH_STATUS_OK = 0,
BT_GRAPH_STATUS_END = 1,
BT_GRAPH_STATUS_AGAIN = 11,
- BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111,
BT_GRAPH_STATUS_CANCELED = 125,
BT_GRAPH_STATUS_ERROR = -1,
BT_GRAPH_STATUS_NOMEM = -12,
BT_LOGI_STR("Graph was canceled by user.");
status = BT_GRAPH_STATUS_OK;
break;
- case BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION:
- BT_LOGE("A component refused a connection to one of its ports: "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-comp-addr=%p, downstream-comp-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\", "
- "conn-arg=\"%s\"",
- upstream_comp, bt_component_get_name(upstream_comp),
- upstream_port, bt_port_get_name(upstream_port),
- downstream_comp, cfg_conn->downstream_comp_name->str,
- downstream_port, downstream_port_name,
- cfg_conn->arg->str);
- fprintf(stderr,
- "A component refused a connection to one of its ports (`%s` to `%s`): %s\n",
- bt_port_get_name(upstream_port),
- downstream_port_name,
- cfg_conn->arg->str);
- break;
default:
BT_LOGE("Cannot create connection: graph refuses to connect ports: "
"upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
return "BT_GRAPH_STATUS_END";
case BT_GRAPH_STATUS_AGAIN:
return "BT_GRAPH_STATUS_AGAIN";
- case BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION:
- return "BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION";
case BT_GRAPH_STATUS_CANCELED:
return "BT_GRAPH_STATUS_CANCELED";
case BT_GRAPH_STATUS_ERROR:
return "BT_SELF_COMPONENT_STATUS_END";
case BT_SELF_COMPONENT_STATUS_AGAIN:
return "BT_SELF_COMPONENT_STATUS_AGAIN";
- case BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION:
- return "BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION";
case BT_SELF_COMPONENT_STATUS_ERROR:
return "BT_SELF_COMPONENT_STATUS_ERROR";
case BT_SELF_COMPONENT_STATUS_NOMEM:
return BT_COMPONENT_CLASS_STATUS_OK;
}
-enum bt_component_class_status
-bt_component_class_filter_set_accept_input_port_connection_method(
- struct bt_component_class_filter *comp_cls,
- bt_component_class_filter_accept_input_port_connection_method method)
-{
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- BT_ASSERT_PRE_NON_NULL(method, "Method");
- BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls);
- comp_cls->methods.accept_input_port_connection = method;
- BT_LIB_LOGD("Set filter component class's \"accept input port connection\" method"
- ": %!+C", comp_cls);
- return BT_COMPONENT_CLASS_STATUS_OK;
-}
-
-enum bt_component_class_status
-bt_component_class_sink_set_accept_input_port_connection_method(
- struct bt_component_class_sink *comp_cls,
- bt_component_class_sink_accept_input_port_connection_method method)
-{
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- BT_ASSERT_PRE_NON_NULL(method, "Method");
- BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls);
- comp_cls->methods.accept_input_port_connection = method;
- BT_LIB_LOGD("Set sink component class's \"accept input port connection\" method"
- ": %!+C", comp_cls);
- return BT_COMPONENT_CLASS_STATUS_OK;
-}
-
-enum bt_component_class_status
-bt_component_class_source_set_accept_output_port_connection_method(
- struct bt_component_class_source *comp_cls,
- bt_component_class_source_accept_output_port_connection_method method)
-{
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- BT_ASSERT_PRE_NON_NULL(method, "Method");
- BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls);
- comp_cls->methods.accept_output_port_connection = method;
- BT_LIB_LOGD("Set source component class's \"accept output port connection\" method"
- ": %!+C", comp_cls);
- return BT_COMPONENT_CLASS_STATUS_OK;
-}
-
-enum bt_component_class_status
-bt_component_class_filter_set_accept_output_port_connection_method(
- struct bt_component_class_filter *comp_cls,
- bt_component_class_filter_accept_output_port_connection_method method)
-{
- BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
- BT_ASSERT_PRE_NON_NULL(method, "Method");
- BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls);
- comp_cls->methods.accept_output_port_connection = method;
- BT_LIB_LOGD("Set filter component class's \"accept output port connection\" method"
- ": %!+C", comp_cls);
- return BT_COMPONENT_CLASS_STATUS_OK;
-}
-
enum bt_component_class_status
bt_component_class_filter_set_input_port_connected_method(
struct bt_component_class_filter *comp_cls,
bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
bt_component_class_source_query_method query;
- bt_component_class_source_accept_output_port_connection_method accept_output_port_connection;
bt_component_class_source_output_port_connected_method output_port_connected;
} methods;
};
bt_component_class_sink_init_method init;
bt_component_class_sink_finalize_method finalize;
bt_component_class_sink_query_method query;
- bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
bt_component_class_sink_input_port_connected_method input_port_connected;
bt_component_class_sink_graph_is_configured_method graph_is_configured;
bt_component_class_sink_consume_method consume;
bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
bt_component_class_filter_query_method query;
- bt_component_class_filter_accept_input_port_connection_method accept_input_port_connection;
- bt_component_class_filter_accept_output_port_connection_method accept_output_port_connection;
bt_component_class_filter_input_port_connected_method input_port_connected;
bt_component_class_filter_output_port_connected_method output_port_connected;
} methods;
BT_PORT_TYPE_OUTPUT, name, user_data, port);
}
-BT_HIDDEN
-enum bt_self_component_status bt_component_accept_port_connection(
- struct bt_component *comp, struct bt_port *self_port,
- struct bt_port *other_port)
-{
- typedef enum bt_self_component_status (*method_t)(
- void *, void *, const void *);
-
- enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
- method_t method = NULL;
-
- BT_ASSERT(comp);
- BT_ASSERT(self_port);
- BT_ASSERT(other_port);
-
- switch (comp->class->type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- {
- struct bt_component_class_source *src_cc = (void *) comp->class;
-
- switch (self_port->type) {
- case BT_PORT_TYPE_OUTPUT:
- method = (method_t) src_cc->methods.accept_output_port_connection;
- break;
- default:
- abort();
- }
-
- break;
- }
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- {
- struct bt_component_class_filter *flt_cc = (void *) comp->class;
-
- switch (self_port->type) {
- case BT_PORT_TYPE_INPUT:
- method = (method_t) flt_cc->methods.accept_input_port_connection;
- break;
- case BT_PORT_TYPE_OUTPUT:
- method = (method_t) flt_cc->methods.accept_output_port_connection;
- break;
- default:
- abort();
- }
-
- break;
- }
- case BT_COMPONENT_CLASS_TYPE_SINK:
- {
- struct bt_component_class_sink *sink_cc = (void *) comp->class;
-
- switch (self_port->type) {
- case BT_PORT_TYPE_INPUT:
- method = (method_t) sink_cc->methods.accept_input_port_connection;
- break;
- default:
- abort();
- }
-
- break;
- }
- default:
- abort();
- }
-
- if (method) {
- BT_LIB_LOGD("Calling user's \"accept port connection\" method: "
- "%![comp-]+c, %![self-port-]+p, %![other-port-]+p",
- comp, self_port, other_port);
- status = method(comp, self_port, (void *) other_port);
- BT_LOGD("User method returned: status=%s",
- bt_self_component_status_string(status));
- }
-
- return status;
-}
-
BT_HIDDEN
enum bt_self_component_status bt_component_port_connected(
struct bt_component *comp, struct bt_port *self_port,
const char *name, bt_logging_level log_level,
struct bt_component **component);
-BT_HIDDEN
-enum bt_self_component_status bt_component_accept_port_connection(
- struct bt_component *component, struct bt_port *self_port,
- struct bt_port *other_port);
-
BT_HIDDEN
enum bt_self_component_status bt_component_port_connected(
struct bt_component *comp,
downstream_component = bt_port_borrow_component_inline(
(void *) downstream_port);
- /*
- * At this point the ports are not connected yet. Both
- * components need to accept an eventual connection to their
- * port by the other port before we continue.
- */
- BT_LIB_LOGD("Asking upstream component to accept the connection: "
- "%![comp-]+c", upstream_component);
- component_status = bt_component_accept_port_connection(
- upstream_component, (void *) upstream_port,
- (void *) downstream_port);
- if (component_status != BT_SELF_COMPONENT_STATUS_OK) {
- if (component_status == BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION) {
- BT_LOGD_STR("Upstream component refused the connection.");
- } else {
- BT_LOGW("Cannot ask upstream component to accept the connection: "
- "status=%s", bt_self_component_status_string(component_status));
- }
-
- status = (int) component_status;
- goto end;
- }
-
- BT_LIB_LOGD("Asking downstream component to accept the connection: "
- "%![comp-]+c", downstream_component);
- component_status = bt_component_accept_port_connection(
- downstream_component, (void *) downstream_port,
- (void *) upstream_port);
- if (component_status != BT_SELF_COMPONENT_STATUS_OK) {
- if (component_status == BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION) {
- BT_LOGD_STR("Downstream component refused the connection.");
- } else {
- BT_LOGW("Cannot ask downstream component to accept the connection: "
- "status=%s", bt_self_component_status_string(component_status));
- }
-
- status = (int) component_status;
- goto end;
- }
-
BT_LOGD_STR("Creating connection.");
connection = bt_connection_create(graph, (void *) upstream_port,
(void *) downstream_port);
return "BT_GRAPH_STATUS_OK";
case BT_GRAPH_STATUS_ERROR:
return "BT_GRAPH_STATUS_ERROR";
- case BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION:
- return "BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION";
case BT_GRAPH_STATUS_NOMEM:
return "BT_GRAPH_STATUS_NOMEM";
default:
bt_component_class_source_init_method init;
bt_component_class_source_finalize_method finalize;
bt_component_class_source_query_method query;
- bt_component_class_source_accept_output_port_connection_method accept_output_port_connection;
bt_component_class_source_output_port_connected_method output_port_connected;
bt_component_class_source_message_iterator_init_method msg_iter_init;
bt_component_class_source_message_iterator_finalize_method msg_iter_finalize;
bt_component_class_filter_init_method init;
bt_component_class_filter_finalize_method finalize;
bt_component_class_filter_query_method query;
- bt_component_class_filter_accept_input_port_connection_method accept_input_port_connection;
- bt_component_class_filter_accept_output_port_connection_method accept_output_port_connection;
bt_component_class_filter_input_port_connected_method input_port_connected;
bt_component_class_filter_output_port_connected_method output_port_connected;
bt_component_class_filter_message_iterator_init_method msg_iter_init;
bt_component_class_sink_init_method init;
bt_component_class_sink_finalize_method finalize;
bt_component_class_sink_query_method query;
- bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
bt_component_class_sink_input_port_connected_method input_port_connected;
bt_component_class_sink_graph_is_configured_method graph_is_configured;
} sink;
abort();
}
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD:
- switch (cc_type) {
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- cc_full_descr->methods.filter.accept_input_port_connection =
- cur_cc_descr_attr->value.filter_accept_input_port_connection_method;
- break;
- case BT_COMPONENT_CLASS_TYPE_SINK:
- cc_full_descr->methods.sink.accept_input_port_connection =
- cur_cc_descr_attr->value.sink_accept_input_port_connection_method;
- break;
- default:
- abort();
- }
- break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD:
- switch (cc_type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- cc_full_descr->methods.source.accept_output_port_connection =
- cur_cc_descr_attr->value.source_accept_output_port_connection_method;
- break;
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- cc_full_descr->methods.filter.accept_output_port_connection =
- cur_cc_descr_attr->value.filter_accept_output_port_connection_method;
- break;
- default:
- abort();
- }
- break;
case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD:
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_FILTER:
}
}
- if (cc_full_descr->methods.source.accept_output_port_connection) {
- ret = bt_component_class_source_set_accept_output_port_connection_method(
- src_comp_class,
- cc_full_descr->methods.source.accept_output_port_connection);
- if (ret) {
- BT_LOGE_STR("Cannot set source component class's \"accept input output connection\" method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
- goto end;
- }
- }
-
if (cc_full_descr->methods.source.output_port_connected) {
ret = bt_component_class_source_set_output_port_connected_method(
src_comp_class,
}
}
- if (cc_full_descr->methods.filter.accept_input_port_connection) {
- ret = bt_component_class_filter_set_accept_input_port_connection_method(
- flt_comp_class,
- cc_full_descr->methods.filter.accept_input_port_connection);
- if (ret) {
- BT_LOGE_STR("Cannot set filter component class's \"accept input port connection\" method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
- goto end;
- }
- }
-
- if (cc_full_descr->methods.filter.accept_output_port_connection) {
- ret = bt_component_class_filter_set_accept_output_port_connection_method(
- flt_comp_class,
- cc_full_descr->methods.filter.accept_output_port_connection);
- if (ret) {
- BT_LOGE_STR("Cannot set filter component class's \"accept input output connection\" method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
- goto end;
- }
- }
-
if (cc_full_descr->methods.filter.input_port_connected) {
ret = bt_component_class_filter_set_input_port_connected_method(
flt_comp_class,
}
}
- if (cc_full_descr->methods.sink.accept_input_port_connection) {
- ret = bt_component_class_sink_set_accept_input_port_connection_method(
- sink_comp_class,
- cc_full_descr->methods.sink.accept_input_port_connection);
- if (ret) {
- BT_LOGE_STR("Cannot set sink component class's \"accept input port connection\" method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
- goto end;
- }
- }
-
if (cc_full_descr->methods.sink.input_port_connected) {
ret = bt_component_class_sink_set_input_port_connected_method(
sink_comp_class,
conn = self._graph.connect_ports(sink.input_ports['in'],
src.output_ports['out'])
- def test_connect_ports_refused(self):
- class MyIter(bt2._UserMessageIterator):
- def __next__(self):
- raise bt2.Stop
-
- class MySource(bt2._UserSourceComponent,
- message_iterator_class=MyIter):
- def __init__(self, params):
- self._add_output_port('out')
-
- class MySink(bt2._UserSinkComponent):
- def __init__(self, params):
- self._add_input_port('in')
-
- def _consume(self):
- raise bt2.Stop
-
- def _accept_port_connection(self, port, other_port):
- return False
-
- src = self._graph.add_component(MySource, 'src')
- sink = self._graph.add_component(MySink, 'sink')
-
- with self.assertRaises(bt2.PortConnectionRefused):
- conn = self._graph.connect_ports(src.output_ports['out'],
- sink.input_ports['in'])
-
def test_cancel(self):
self.assertFalse(self._graph.is_canceled)
self._graph.cancel()
#include "tap/tap.h"
-#define NR_TESTS 48
+#define NR_TESTS 33
enum event_type {
- SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION,
- SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION,
SRC_COMP_OUTPUT_PORT_CONNECTED,
SINK_COMP_INPUT_PORT_CONNECTED,
GRAPH_SRC_OUTPUT_PORT_ADDED,
enum event_type type;
union {
- struct {
- const bt_component *comp;
- const bt_port *self_port;
- const bt_port *other_port;
- } src_comp_accept_output_port_connection;
-
- struct {
- const bt_component *comp;
- const bt_port *self_port;
- const bt_port *other_port;
- } sink_comp_accept_input_port_connection;
-
struct {
const bt_component *comp;
const bt_port *self_port;
}
switch (ev_a->type) {
- case SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION:
- if (ev_a->data.src_comp_accept_output_port_connection.comp !=
- ev_b->data.src_comp_accept_output_port_connection.comp) {
- return false;
- }
-
- if (ev_a->data.src_comp_accept_output_port_connection.self_port !=
- ev_b->data.src_comp_accept_output_port_connection.self_port) {
- return false;
- }
-
- if (ev_a->data.src_comp_accept_output_port_connection.other_port !=
- ev_b->data.src_comp_accept_output_port_connection.other_port) {
- return false;
- }
- break;
- case SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION:
- if (ev_a->data.sink_comp_accept_input_port_connection.comp !=
- ev_b->data.sink_comp_accept_input_port_connection.comp) {
- return false;
- }
-
- if (ev_a->data.sink_comp_accept_input_port_connection.self_port !=
- ev_b->data.sink_comp_accept_input_port_connection.self_port) {
- return false;
- }
-
- if (ev_a->data.sink_comp_accept_input_port_connection.other_port !=
- ev_b->data.sink_comp_accept_input_port_connection.other_port) {
- return false;
- }
- break;
case SRC_COMP_OUTPUT_PORT_CONNECTED:
if (ev_a->data.src_comp_output_port_connected.comp !=
ev_b->data.src_comp_output_port_connected.comp) {
return BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
}
-static
-bt_self_component_status src_accept_output_port_connection(
- bt_self_component_source *self_comp,
- bt_self_component_port_output *self_comp_port,
- const bt_port_input *other_port)
-{
- struct event event = {
- .type = SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION,
- .data.src_comp_accept_output_port_connection = {
- .comp = bt_self_component_as_component(
- bt_self_component_source_as_self_component(
- self_comp)),
- .self_port = bt_self_component_port_as_port(
- bt_self_component_port_output_as_self_component_port(
- self_comp_port)),
- .other_port = bt_port_input_as_port_const(other_port),
- },
- };
-
- append_event(&event);
- return BT_SELF_COMPONENT_STATUS_OK;
-}
-
-static
-bt_self_component_status sink_accept_input_port_connection(
- bt_self_component_sink *self_comp,
- bt_self_component_port_input *self_comp_port,
- const bt_port_output *other_port)
-{
- struct event event = {
- .type = SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION,
- .data.sink_comp_accept_input_port_connection = {
- .comp = bt_self_component_as_component(
- bt_self_component_sink_as_self_component(
- self_comp)),
- .self_port = bt_self_component_port_as_port(
- bt_self_component_port_input_as_self_component_port(
- self_comp_port)),
- .other_port = bt_port_output_as_port_const(other_port),
- },
- };
-
- append_event(&event);
- return BT_SELF_COMPONENT_STATUS_OK;
-}
-
static
bt_self_component_status src_output_port_connected(
bt_self_component_source *self_comp,
ret = bt_component_class_source_set_init_method(
src_comp_class, src_init);
BT_ASSERT(ret == 0);
- ret = bt_component_class_source_set_accept_output_port_connection_method(
- src_comp_class, src_accept_output_port_connection);
- BT_ASSERT(ret == 0);
ret = bt_component_class_source_set_output_port_connected_method(
src_comp_class, src_output_port_connected);
BT_ASSERT(ret == 0);
ret = bt_component_class_sink_set_init_method(sink_comp_class,
sink_init);
BT_ASSERT(ret == 0);
- ret = bt_component_class_sink_set_accept_input_port_connection_method(
- sink_comp_class, sink_accept_input_port_connection);
- BT_ASSERT(ret == 0);
ret = bt_component_class_sink_set_input_port_connected_method(
sink_comp_class, sink_input_port_connected);
BT_ASSERT(ret == 0);
const bt_port *gsink_def_port;
struct event event;
bt_graph_status status;
- size_t src_accept_port_connection_pos;
- size_t sink_accept_port_connection_pos;
size_t src_port_connected_pos;
size_t sink_port_connected_pos;
size_t graph_ports_connected_pos;
gsrc_hello_port = bt_port_output_as_port_const(src_hello_port);
gsink_def_port = bt_port_input_as_port_const(sink_def_port);
- /* We're supposed to have 8 events */
- ok(events->len == 8, "we have the expected number of events");
+ /* We're supposed to have 6 events */
+ ok(events->len == 6, "we have the expected number of events");
/* Source's port added */
event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
event.data.graph_sink_input_port_added.port = gsink_def_port;
ok(has_event(&event), "got the expected graph's port added event (for sink, initial)");
- /* Source's accept port connection */
- event.type = SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION;
- event.data.src_comp_accept_output_port_connection.comp = gsrc;
- event.data.src_comp_accept_output_port_connection.self_port = gsrc_def_port;
- event.data.src_comp_accept_output_port_connection.other_port = gsink_def_port;
- ok(has_event(&event), "got the expected source's accept port connection event");
- src_accept_port_connection_pos = event_pos(&event);
-
- /* Sink's accept port connection */
- event.type = SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION;
- event.data.sink_comp_accept_input_port_connection.comp = gsink;
- event.data.sink_comp_accept_input_port_connection.self_port = gsink_def_port;
- event.data.sink_comp_accept_input_port_connection.other_port = gsrc_def_port;
- ok(has_event(&event), "got the expected sink's accept port connection event");
- sink_accept_port_connection_pos = event_pos(&event);
-
/* Source's port connected */
event.type = SRC_COMP_OUTPUT_PORT_CONNECTED;
event.data.src_comp_output_port_connected.comp = gsrc;
"event order is good (1)");
ok(sink_port_connected_pos < graph_ports_connected_pos,
"event order is good (2)");
- ok(src_accept_port_connection_pos < src_port_connected_pos,
- "event order is good (3)");
- ok(sink_accept_port_connection_pos < sink_port_connected_pos,
- "event order is good (4)");
ok(src_port_connected_pos < graph_port_added_src_pos,
- "event order is good (5)");
+ "event order is good (3)");
ok(graph_port_added_src_pos < graph_ports_connected_pos,
- "event order is good (6)");
+ "event order is good (4)");
bt_component_source_put_ref(src);
bt_component_sink_put_ref(sink);
const bt_port *gsink_def_port;
struct event event;
bt_graph_status status;
- size_t src_accept_port_connection_pos;
- size_t sink_accept_port_connection_pos;
size_t src_port_connected_pos;
size_t sink_port_connected_pos;
size_t graph_ports_connected_pos;
gsrc_def_port = bt_port_output_as_port_const(src_def_port);
gsink_def_port = bt_port_input_as_port_const(sink_def_port);
- /* We're supposed to have 7 events */
- ok(events->len == 7, "we have the expected number of events");
+ /* We're supposed to have 5 events */
+ ok(events->len == 5, "we have the expected number of events");
/* Source's port added */
event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
event.data.graph_sink_input_port_added.port = gsink_def_port;
ok(has_event(&event), "got the expected graph's port added event (for sink, initial)");
- /* Source's accept port connection */
- event.type = SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION;
- event.data.src_comp_accept_output_port_connection.comp = gsrc;
- event.data.src_comp_accept_output_port_connection.self_port = gsrc_def_port;
- event.data.src_comp_accept_output_port_connection.other_port = gsink_def_port;
- ok(has_event(&event), "got the expected source's accept port connection event");
- src_accept_port_connection_pos = event_pos(&event);
-
- /* Sink's accept port connection */
- event.type = SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION;
- event.data.sink_comp_accept_input_port_connection.comp = gsink;
- event.data.sink_comp_accept_input_port_connection.self_port = gsink_def_port;
- event.data.sink_comp_accept_input_port_connection.other_port = gsrc_def_port;
- ok(has_event(&event), "got the expected sink's accept port connection event");
- sink_accept_port_connection_pos = event_pos(&event);
-
/* Source's port connected */
event.type = SRC_COMP_OUTPUT_PORT_CONNECTED;
event.data.src_comp_output_port_connected.comp = gsrc;
"event order is good (1)");
ok(sink_port_connected_pos < graph_ports_connected_pos,
"event order is good (2)");
- ok(src_accept_port_connection_pos < src_port_connected_pos,
- "event order is good (3)");
- ok(sink_accept_port_connection_pos < sink_port_connected_pos,
- "event order is good (4)");
bt_component_sink_put_ref(sink);
bt_graph_put_ref(graph);
const bt_connection *conn = NULL;
struct event event;
bt_graph_status status;
- size_t src_accept_port_connection_pos;
- size_t src_port_connected_pos;
prepare_test(TEST_SRC_PORT_CONNECTED_ERROR, "port connected error: source");
graph = create_graph();
gsrc_def_port = bt_port_output_as_port_const(src_def_port);
gsink_def_port = bt_port_input_as_port_const(sink_def_port);
- /* We're supposed to have 5 events */
- ok(events->len == 5, "we have the expected number of events");
+ /* We're supposed to have 3 events */
+ ok(events->len == 3, "we have the expected number of events");
/* Source's port added */
event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
event.data.graph_sink_input_port_added.port = gsink_def_port;
ok(has_event(&event), "got the expected graph's port added event (for sink, initial)");
- /* Source's accept port connection */
- event.type = SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION;
- event.data.src_comp_accept_output_port_connection.comp = gsrc;
- event.data.src_comp_accept_output_port_connection.self_port = gsrc_def_port;
- event.data.src_comp_accept_output_port_connection.other_port = gsink_def_port;
- ok(has_event(&event), "got the expected source's accept port connection event");
- src_accept_port_connection_pos = event_pos(&event);
-
- /* Sink's accept port connection */
- event.type = SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION;
- event.data.sink_comp_accept_input_port_connection.comp = gsink;
- event.data.sink_comp_accept_input_port_connection.self_port = gsink_def_port;
- event.data.sink_comp_accept_input_port_connection.other_port = gsrc_def_port;
- ok(has_event(&event), "got the expected sink's accept port connection event");
-
/* Source's port connected */
event.type = SRC_COMP_OUTPUT_PORT_CONNECTED;
event.data.src_comp_output_port_connected.comp = gsrc;
event.data.src_comp_output_port_connected.self_port = gsrc_def_port;
event.data.src_comp_output_port_connected.other_port = gsink_def_port;
ok(has_event(&event), "got the expected source's port connected event");
- src_port_connected_pos = event_pos(&event);
-
- /* Order of events */
- ok(src_accept_port_connection_pos < src_port_connected_pos,
- "event order is good (1)");
bt_graph_put_ref(graph);
bt_component_sink_put_ref(sink);
const bt_connection *conn = NULL;
struct event event;
bt_graph_status status;
- size_t src_accept_port_connection_pos;
- size_t sink_accept_port_connection_pos;
- size_t src_port_connected_pos;
- size_t sink_port_connected_pos;
prepare_test(TEST_SINK_PORT_CONNECTED_ERROR, "port connected error: sink");
graph = create_graph();
gsrc_def_port = bt_port_output_as_port_const(src_def_port);
gsink_def_port = bt_port_input_as_port_const(sink_def_port);
- /* We're supposed to have 6 events */
- ok(events->len == 6, "we have the expected number of events");
+ /* We're supposed to have 4 events */
+ ok(events->len == 4, "we have the expected number of events");
/* Source's port added */
event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
event.data.graph_sink_input_port_added.port = gsink_def_port;
ok(has_event(&event), "got the expected graph's port added event (for sink, initial)");
- /* Source's accept port connection */
- event.type = SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION;
- event.data.src_comp_accept_output_port_connection.comp = gsrc;
- event.data.src_comp_accept_output_port_connection.self_port = gsrc_def_port;
- event.data.src_comp_accept_output_port_connection.other_port = gsink_def_port;
- ok(has_event(&event), "got the expected source's accept port connection event");
- src_accept_port_connection_pos = event_pos(&event);
-
- /* Sink's accept port connection */
- event.type = SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION;
- event.data.sink_comp_accept_input_port_connection.comp = gsink;
- event.data.sink_comp_accept_input_port_connection.self_port = gsink_def_port;
- event.data.sink_comp_accept_input_port_connection.other_port = gsrc_def_port;
- ok(has_event(&event), "got the expected sink's accept port connection event");
- sink_accept_port_connection_pos = event_pos(&event);
-
/* Source's port connected */
event.type = SRC_COMP_OUTPUT_PORT_CONNECTED;
event.data.src_comp_output_port_connected.comp = gsrc;
event.data.src_comp_output_port_connected.self_port = gsrc_def_port;
event.data.src_comp_output_port_connected.other_port = gsink_def_port;
ok(has_event(&event), "got the expected source's port connected event");
- src_port_connected_pos = event_pos(&event);
/* Sink's port connected */
event.type = SINK_COMP_INPUT_PORT_CONNECTED;
event.data.sink_comp_input_port_connected.self_port = gsink_def_port;
event.data.sink_comp_input_port_connected.other_port = gsrc_def_port;
ok(has_event(&event), "got the expected sink's port connected event");
- sink_port_connected_pos = event_pos(&event);
-
- /* Order of events */
- ok(src_accept_port_connection_pos < src_port_connected_pos,
- "event order is good (1)");
- ok(sink_accept_port_connection_pos < sink_port_connected_pos,
- "event order is good (2)");
bt_connection_put_ref(conn);
bt_graph_put_ref(graph);