ret = validate_all_components_connected_in_array(
cfg->cmd_data.run.sources,
- bt_value_borrow_from_private(connected_components),
+ bt_private_value_borrow_value(connected_components),
error_buf, error_buf_size);
if (ret) {
goto end;
ret = validate_all_components_connected_in_array(
cfg->cmd_data.run.filters,
- bt_value_borrow_from_private(connected_components),
+ bt_private_value_borrow_value(connected_components),
error_buf, error_buf_size);
if (ret) {
goto end;
ret = validate_all_components_connected_in_array(
cfg->cmd_data.run.sinks,
- bt_value_borrow_from_private(connected_components),
+ bt_private_value_borrow_value(connected_components),
error_buf, error_buf_size);
if (ret) {
goto end;
connection->downstream_comp_name->str,
connection->downstream_port_glob->str);
- if (bt_value_map_has_entry(bt_value_borrow_from_private(
+ if (bt_value_map_has_entry(bt_private_value_borrow_value(
flat_connection_names),
flat_connection_name->str)) {
snprintf(error_buf, error_buf_size,
}
if (bt_value_map_has_entry(
- bt_value_borrow_from_private(state->params),
+ bt_private_value_borrow_value(state->params),
state->last_map_key)) {
g_string_append_printf(state->ini_error,
"Duplicate parameter key: `%s`\n",
goto error;
}
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_integer_create_init(
(int64_t) int_val));
break;
}
case G_TOKEN_FLOAT:
/* Positive floating point number */
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_real_create_init(
state->scanner->value.v_float));
break;
case G_TOKEN_STRING:
/* Quoted string */
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_string_create_init(
state->scanner->value.v_string));
break;
} else if (!strcmp(id, "true") || !strcmp(id, "TRUE") ||
!strcmp(id, "yes") ||
!strcmp(id, "YES")) {
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_bool_create_init(true));
} else if (!strcmp(id, "false") ||
!strcmp(id, "FALSE") ||
!strcmp(id, "no") ||
!strcmp(id, "NO")) {
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_bool_create_init(false));
} else {
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_string_create_init(id));
}
break;
goto error;
}
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_integer_create_init(
-((int64_t) int_val)));
break;
}
case G_TOKEN_FLOAT:
/* Negative floating point number */
- value = bt_value_borrow_from_private(
+ value = bt_private_value_borrow_value(
bt_private_value_real_create_init(
-state->scanner->value.v_float));
break;
goto end;
}
- if (bt_value_map_has_entry(bt_value_borrow_from_private(instance_names),
+ if (bt_value_map_has_entry(bt_private_value_borrow_value(instance_names),
cfg_comp->instance_name->str)) {
printf_err("Duplicate component instance name:\n %s\n",
cfg_comp->instance_name->str);
}
cfg->cmd_data.help.cfg_component =
- bt_config_component_create(BT_COMPONENT_CLASS_TYPE_UNKNOWN,
- NULL, NULL);
+ bt_config_component_create(-1, NULL, NULL);
if (!cfg->cmd_data.help.cfg_component) {
goto error;
}
comp_cls_name);
} else {
/* Fall back to plugin help */
- cfg->cmd_data.help.cfg_component->type =
- BT_COMPONENT_CLASS_TYPE_UNKNOWN;
g_string_assign(
cfg->cmd_data.help.cfg_component->plugin_name,
leftover);
bt_object_put_ref(cur_cfg_comp->params);
status = bt_value_copy(
&cur_cfg_comp->params,
- bt_value_borrow_from_private(cur_base_params));
+ bt_private_value_borrow_value(cur_base_params));
if (status != BT_VALUE_STATUS_OK) {
print_err_oom();
goto error;
}
status = bt_value_map_extend(¶ms_to_set,
- bt_value_borrow_from_private(cur_cfg_comp->params),
- bt_value_borrow_from_private(params));
+ bt_private_value_borrow_value(cur_cfg_comp->params),
+ bt_private_value_borrow_value(params));
BT_OBJECT_PUT_REF_AND_RESET(params);
if (status != BT_VALUE_STATUS_OK) {
printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n",
}
ret = bt_config_cli_args_create_connections(cfg,
- bt_value_borrow_from_private(connection_args),
+ bt_private_value_borrow_value(connection_args),
error_buf, 256);
if (ret) {
printf_err("Cannot creation connections:\n%s", error_buf);
}
name = get_component_auto_name(prefix,
- bt_value_borrow_from_private(existing_names));
+ bt_private_value_borrow_value(existing_names));
if (!name) {
ret = -1;
}
for (i = 0; i < bt_value_array_get_size(
- bt_value_borrow_from_private(impl_args->extra_params));
+ bt_private_value_borrow_value(impl_args->extra_params));
i++) {
struct bt_value *elem;
const char *arg;
elem = bt_value_array_borrow_element_by_index(
- bt_value_borrow_from_private(impl_args->extra_params),
+ bt_private_value_borrow_value(impl_args->extra_params),
i);
if (!elem) {
goto error;
* component.
*/
name = get_component_auto_name(cur_name_prefix->str,
- bt_value_borrow_from_private(all_names));
+ bt_private_value_borrow_value(all_names));
append_name_opt = true;
} else {
/*
* component.
*/
if (bt_value_map_has_entry(
- bt_value_borrow_from_private(all_names),
+ bt_private_value_borrow_value(all_names),
cur_name->str)) {
printf_err("Duplicate component instance name:\n %s\n",
cur_name->str);
*/
BT_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params);
status = bt_value_copy(&impl_args->extra_params,
- bt_value_borrow_from_private(
+ bt_private_value_borrow_value(
base_implicit_ctf_input_args->extra_params));
if (status != BT_VALUE_STATUS_OK) {
print_err_oom();
implicit_text_args.exists = true;
ret = insert_flat_params_from_array(
implicit_text_args.params_arg,
- bt_value_borrow_from_private(fields), "field");
+ bt_private_value_borrow_value(fields), "field");
bt_object_put_ref(fields);
if (ret) {
goto error;
implicit_text_args.exists = true;
ret = insert_flat_params_from_array(
implicit_text_args.params_arg,
- bt_value_borrow_from_private(names), "name");
+ bt_private_value_borrow_value(names), "name");
bt_object_put_ref(names);
if (ret) {
goto error;
}
for (i = 0; i < bt_value_array_get_size(
- bt_value_borrow_from_private(run_args)); i++) {
+ bt_private_value_borrow_value(run_args)); i++) {
struct bt_value *arg_value =
bt_value_array_borrow_element_by_index(
- bt_value_borrow_from_private(run_args),
+ bt_private_value_borrow_value(run_args),
i);
const char *arg;
GString *quoted = NULL;
}
if (i < bt_value_array_get_size(
- bt_value_borrow_from_private(run_args)) - 1) {
+ bt_private_value_borrow_value(run_args)) - 1) {
if (print_run_args) {
putchar(' ');
} else {
}
cfg = bt_config_run_from_args_array(
- bt_value_borrow_from_private(run_args), retcode,
+ bt_private_value_borrow_value(run_args), retcode,
force_omit_system_plugin_path, force_omit_home_plugin_path,
initial_plugin_paths);
if (!cfg) {
/* Application's processing graph (weak) */
static struct bt_private_graph *the_graph;
-static struct bt_query_executor *the_query_executor;
+static struct bt_private_query_executor *the_query_executor;
static bool canceled = false;
GPtrArray *loaded_plugins;
}
if (the_query_executor) {
- bt_query_executor_cancel(the_query_executor);
+ bt_private_query_executor_cancel(the_query_executor);
}
canceled = true;
{
int ret = 0;
- the_query_executor = bt_query_executor_create();
+ the_query_executor = bt_private_query_executor_create();
if (!the_query_executor) {
BT_LOGE_STR("Cannot create a query executor.");
ret = -1;
}
while (true) {
- status = bt_query_executor_query(the_query_executor, comp_cls,
- obj, params, &result);
+ status = bt_private_query_executor_query(the_query_executor,
+ comp_cls, obj, params, &result);
switch (status) {
case BT_QUERY_STATUS_OK:
goto ok;
"time-us=%" PRIu64, sleep_time_us);
if (usleep(sleep_time_us)) {
- if (bt_query_executor_is_canceled(the_query_executor)) {
+ if (bt_query_executor_is_canceled(
+ bt_private_query_executor_borrow_query_executor(the_query_executor))) {
BT_LOGI("Query was canceled by user: "
"comp-cls-addr=%p, comp-cls-name=\"%s\", "
"query-obj=\"%s\"", comp_cls,
*fail_reason = "canceled by user";
goto error;
case BT_QUERY_STATUS_ERROR:
- case BT_QUERY_STATUS_INVALID:
goto error;
case BT_QUERY_STATUS_INVALID_OBJECT:
*fail_reason = "invalid or unknown query object";
return bt_object_get_ref(plugin);
}
+typedef void *(*plugin_borrow_comp_cls_func_t)(struct bt_plugin *,
+ const char *);
+
static
-struct bt_component_class *find_component_class(const char *plugin_name,
+void *find_component_class_from_plugin(const char *plugin_name,
const char *comp_class_name,
- enum bt_component_class_type comp_class_type)
+ plugin_borrow_comp_cls_func_t plugin_borrow_comp_cls_func)
{
- struct bt_component_class *comp_class = NULL;
+ void *comp_class = NULL;
struct bt_plugin *plugin;
BT_LOGD("Finding component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
- plugin_name, comp_class_name, comp_class_type);
+ "comp-cls-name=\"%s\"", plugin_name, comp_class_name);
plugin = find_plugin(plugin_name);
-
if (!plugin) {
goto end;
}
- comp_class = bt_plugin_get_component_class_by_name_and_type(plugin,
- comp_class_name, comp_class_type);
+ comp_class = bt_object_get_ref(
+ plugin_borrow_comp_cls_func(plugin, comp_class_name));
BT_OBJECT_PUT_REF_AND_RESET(plugin);
end:
BT_LOGD("Found component class: comp-cls-addr=%p",
comp_class);
} else {
- BT_LOGD("Cannot find component class.");
+ BT_LOGD("Cannot find source component class.");
}
}
return comp_class;
}
+static
+struct bt_component_class_source *find_source_component_class(
+ const char *plugin_name, const char *comp_class_name)
+{
+ return (void *) find_component_class_from_plugin(plugin_name,
+ comp_class_name,
+ (plugin_borrow_comp_cls_func_t)
+ bt_plugin_borrow_source_component_class_by_name);
+}
+
+static
+struct bt_component_class_filter *find_filter_component_class(
+ const char *plugin_name, const char *comp_class_name)
+{
+ return (void *) find_component_class_from_plugin(plugin_name,
+ comp_class_name,
+ (plugin_borrow_comp_cls_func_t)
+ bt_plugin_borrow_filter_component_class_by_name);
+}
+
+static
+struct bt_component_class_sink *find_sink_component_class(
+ const char *plugin_name, const char *comp_class_name)
+{
+ return (void *) find_component_class_from_plugin(plugin_name,
+ comp_class_name,
+ (plugin_borrow_comp_cls_func_t)
+ bt_plugin_borrow_sink_component_class_by_name);
+}
+
+static
+struct bt_component_class *find_component_class(const char *plugin_name,
+ const char *comp_class_name,
+ enum bt_component_class_type comp_class_type)
+{
+ struct bt_component_class *comp_cls = NULL;
+
+ switch (comp_class_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ comp_cls = bt_component_class_source_borrow_component_class(
+ find_source_component_class(plugin_name,
+ comp_class_name));
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ comp_cls = bt_component_class_filter_borrow_component_class(
+ find_filter_component_class(plugin_name,
+ comp_class_name));
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ comp_cls = bt_component_class_sink_borrow_component_class(
+ find_sink_component_class(plugin_name,
+ comp_class_name));
+ break;
+ default:
+ abort();
+ }
+
+ return comp_cls;
+}
+
static
void print_indent(FILE *fp, size_t indent)
{
return "sink";
case BT_COMPONENT_CLASS_TYPE_FILTER:
return "filter";
- case BT_COMPONENT_CLASS_TYPE_UNKNOWN:
default:
return "(unknown)";
}
fprintf(stderr, " Parameters:\n");
print_value(stderr,
- bt_value_borrow_from_private(bt_config_component->params), 8);
+ bt_private_value_borrow_value(bt_config_component->params), 8);
}
static
{
size_t i;
- print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
+ print_plugin_paths(bt_private_value_borrow_value(cfg->plugin_paths));
fprintf(stderr, " Source component instances:\n");
print_bt_config_components(cfg->cmd_data.run.sources);
static
void print_cfg_list_plugins(struct bt_config *cfg)
{
- print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
+ print_plugin_paths(bt_private_value_borrow_value(cfg->plugin_paths));
}
static
void print_cfg_help(struct bt_config *cfg)
{
- print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
+ print_plugin_paths(bt_private_value_borrow_value(cfg->plugin_paths));
}
static
void print_cfg_print_ctf_metadata(struct bt_config *cfg)
{
- print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
+ print_plugin_paths(bt_private_value_borrow_value(cfg->plugin_paths));
fprintf(stderr, " Path: %s\n",
cfg->cmd_data.print_ctf_metadata.path->str);
}
static
void print_cfg_print_lttng_live_sessions(struct bt_config *cfg)
{
- print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
+ print_plugin_paths(bt_private_value_borrow_value(cfg->plugin_paths));
fprintf(stderr, " URL: %s\n",
cfg->cmd_data.print_lttng_live_sessions.url->str);
}
static
void print_cfg_query(struct bt_config *cfg)
{
- print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
+ print_plugin_paths(bt_private_value_borrow_value(cfg->plugin_paths));
fprintf(stderr, " Object: `%s`\n", cfg->cmd_data.query.object->str);
fprintf(stderr, " Component class:\n");
print_bt_config_component(cfg->cmd_data.query.cfg_component);
for (i = 0; i < count; i++) {
struct bt_plugin *plugin =
- bt_plugin_set_get_plugin(plugin_set, i);
+ bt_plugin_set_borrow_plugin_by_index(plugin_set, i);
struct bt_plugin *loaded_plugin =
- find_plugin(bt_plugin_get_name(plugin));
+ find_plugin(bt_plugin_get_name(plugin));
BT_ASSERT(plugin);
bt_plugin_get_name(plugin));
g_ptr_array_add(loaded_plugins, bt_object_get_ref(plugin));
}
-
- bt_object_put_ref(plugin);
}
}
struct bt_value *results = NULL;
const char *fail_reason = NULL;
- comp_cls = find_component_class(cfg->cmd_data.query.cfg_component->plugin_name->str,
+ comp_cls = find_component_class(
+ cfg->cmd_data.query.cfg_component->plugin_name->str,
cfg->cmd_data.query.cfg_component->comp_cls_name->str,
cfg->cmd_data.query.cfg_component->type);
if (!comp_cls) {
}
ret = query(comp_cls, cfg->cmd_data.query.object->str,
- bt_value_borrow_from_private(cfg->cmd_data.query.cfg_component->params),
+ bt_private_value_borrow_value(
+ cfg->cmd_data.query.cfg_component->params),
&results, &fail_reason);
if (ret) {
goto failed;
return ret;
}
+static
+void print_component_class_help(const char *plugin_name,
+ struct bt_component_class *comp_cls)
+{
+ const char *comp_class_name =
+ bt_component_class_get_name(comp_cls);
+ const char *comp_class_description =
+ bt_component_class_get_description(comp_cls);
+ const char *comp_class_help =
+ bt_component_class_get_help(comp_cls);
+ enum bt_component_class_type type =
+ bt_component_class_get_type(comp_cls);
+
+ print_plugin_comp_cls_opt(stdout, plugin_name, comp_class_name, type);
+ printf("\n");
+ printf(" %sDescription%s: %s\n", bt_common_color_bold(),
+ bt_common_color_reset(),
+ comp_class_description ? comp_class_description : "(None)");
+
+ if (comp_class_help) {
+ printf("\n%s\n", comp_class_help);
+ }
+}
+
static
int cmd_help(struct bt_config *cfg)
{
int ret = 0;
struct bt_plugin *plugin = NULL;
- size_t i;
+ struct bt_component_class *needed_comp_cls = NULL;
plugin = find_plugin(cfg->cmd_data.help.cfg_component->plugin_name->str);
if (!plugin) {
}
print_plugin_info(plugin);
- printf(" %sComponent classes%s: %d\n",
+ printf(" %sSource component classes%s: %d\n",
+ bt_common_color_bold(),
+ bt_common_color_reset(),
+ (int) bt_plugin_get_source_component_class_count(plugin));
+ printf(" %sFilter component classes%s: %d\n",
bt_common_color_bold(),
bt_common_color_reset(),
- (int) bt_plugin_get_component_class_count(plugin));
+ (int) bt_plugin_get_filter_component_class_count(plugin));
+ printf(" %sSink component classes%s: %d\n",
+ bt_common_color_bold(),
+ bt_common_color_reset(),
+ (int) bt_plugin_get_sink_component_class_count(plugin));
+ if (strlen(cfg->cmd_data.help.cfg_component->comp_cls_name->str) == 0) {
+ /* Plugin help only */
+ goto end;
+ }
- if (cfg->cmd_data.help.cfg_component->type !=
- BT_COMPONENT_CLASS_TYPE_UNKNOWN) {
- struct bt_component_class *needed_comp_cls =
- find_component_class(
- cfg->cmd_data.help.cfg_component->plugin_name->str,
- cfg->cmd_data.help.cfg_component->comp_cls_name->str,
- cfg->cmd_data.help.cfg_component->type);
+ needed_comp_cls = find_component_class(
+ cfg->cmd_data.help.cfg_component->plugin_name->str,
+ cfg->cmd_data.help.cfg_component->comp_cls_name->str,
+ cfg->cmd_data.help.cfg_component->type);
+ if (!needed_comp_cls) {
+ BT_LOGE("Cannot find component class: plugin-name=\"%s\", "
+ "comp-cls-name=\"%s\", comp-cls-type=%d",
+ cfg->cmd_data.help.cfg_component->plugin_name->str,
+ cfg->cmd_data.help.cfg_component->comp_cls_name->str,
+ cfg->cmd_data.help.cfg_component->type);
+ fprintf(stderr, "\n%s%sCannot find component class %s",
+ bt_common_color_bold(),
+ bt_common_color_fg_red(),
+ bt_common_color_reset());
+ print_plugin_comp_cls_opt(stderr,
+ cfg->cmd_data.help.cfg_component->plugin_name->str,
+ cfg->cmd_data.help.cfg_component->comp_cls_name->str,
+ cfg->cmd_data.help.cfg_component->type);
+ fprintf(stderr, "\n");
+ ret = -1;
+ goto end;
+ }
- if (!needed_comp_cls) {
- BT_LOGE("Cannot find component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
- cfg->cmd_data.help.cfg_component->plugin_name->str,
- cfg->cmd_data.help.cfg_component->comp_cls_name->str,
- cfg->cmd_data.help.cfg_component->type);
- fprintf(stderr, "\n%s%sCannot find component class %s",
- bt_common_color_bold(),
- bt_common_color_fg_red(),
- bt_common_color_reset());
- print_plugin_comp_cls_opt(stderr,
- cfg->cmd_data.help.cfg_component->plugin_name->str,
- cfg->cmd_data.help.cfg_component->comp_cls_name->str,
- cfg->cmd_data.help.cfg_component->type);
- fprintf(stderr, "\n");
- ret = -1;
- goto end;
- }
+ printf("\n");
+ print_component_class_help(
+ cfg->cmd_data.help.cfg_component->plugin_name->str,
+ needed_comp_cls);
+
+end:
+ bt_object_put_ref(needed_comp_cls);
+ bt_object_put_ref(plugin);
+ return ret;
+}
+
+typedef void *(* plugin_borrow_comp_cls_by_index_func_t)(struct bt_plugin *,
+ uint64_t);
+typedef struct bt_component_class *(* spec_comp_cls_borrow_comp_cls_func_t)(
+ void *);
+
+void cmd_list_plugins_print_component_classes(struct bt_plugin *plugin,
+ const char *cc_type_name, uint64_t count,
+ plugin_borrow_comp_cls_by_index_func_t borrow_comp_cls_by_index_func,
+ spec_comp_cls_borrow_comp_cls_func_t spec_comp_cls_borrow_comp_cls_func)
+{
+ uint64_t i;
- bt_object_put_ref(needed_comp_cls);
+ if (count == 0) {
+ printf(" %s%s component classes%s: (none)\n", cc_type_name,
+ bt_common_color_bold(),
+ bt_common_color_reset());
+ goto end;
+ } else {
+ printf(" %s%s component classes%s:\n", cc_type_name,
+ bt_common_color_bold(),
+ bt_common_color_reset());
}
- for (i = 0; i < bt_plugin_get_component_class_count(plugin); i++) {
- struct bt_component_class *comp_cls =
- bt_plugin_get_component_class_by_index(plugin, i);
+ for (i = 0; i < count; i++) {
+ struct bt_component_class *comp_class =
+ spec_comp_cls_borrow_comp_cls_func(
+ borrow_comp_cls_by_index_func(plugin, i));
const char *comp_class_name =
- bt_component_class_get_name(comp_cls);
+ bt_component_class_get_name(comp_class);
const char *comp_class_description =
- bt_component_class_get_description(comp_cls);
- const char *comp_class_help =
- bt_component_class_get_help(comp_cls);
+ bt_component_class_get_description(comp_class);
enum bt_component_class_type type =
- bt_component_class_get_type(comp_cls);
-
- BT_ASSERT(comp_cls);
+ bt_component_class_get_type(comp_class);
- if (cfg->cmd_data.help.cfg_component->type !=
- BT_COMPONENT_CLASS_TYPE_UNKNOWN) {
- if (strcmp(cfg->cmd_data.help.cfg_component->comp_cls_name->str,
- comp_class_name) != 0 ||
- type != cfg->cmd_data.help.cfg_component->type) {
- bt_object_put_ref(comp_cls);
- continue;
- }
- }
-
- printf("\n");
+ printf(" ");
print_plugin_comp_cls_opt(stdout,
- cfg->cmd_data.help.cfg_component->plugin_name->str,
- comp_class_name,
+ bt_plugin_get_name(plugin), comp_class_name,
type);
- printf("\n");
- printf(" %sDescription%s: %s\n", bt_common_color_bold(),
- bt_common_color_reset(),
- comp_class_description ? comp_class_description : "(None)");
- if (comp_class_help) {
- printf("\n%s\n", comp_class_help);
+ if (comp_class_description) {
+ printf(": %s", comp_class_description);
}
- bt_object_put_ref(comp_cls);
+ printf("\n");
}
end:
- bt_object_put_ref(plugin);
- return ret;
+ return;
}
static
int plugins_count, component_classes_count = 0, i;
printf("From the following plugin paths:\n\n");
- print_value(stdout, bt_value_borrow_from_private(cfg->plugin_paths), 2);
+ print_value(stdout, bt_private_value_borrow_value(cfg->plugin_paths), 2);
printf("\n");
plugins_count = loaded_plugins->len;
if (plugins_count == 0) {
for (i = 0; i < plugins_count; i++) {
struct bt_plugin *plugin = g_ptr_array_index(loaded_plugins, i);
- component_classes_count += bt_plugin_get_component_class_count(plugin);
+ component_classes_count +=
+ bt_plugin_get_source_component_class_count(plugin) +
+ bt_plugin_get_filter_component_class_count(plugin) +
+ bt_plugin_get_sink_component_class_count(plugin);
}
printf("Found %s%d%s component classes in %s%d%s plugins.\n",
bt_common_color_reset());
for (i = 0; i < plugins_count; i++) {
- int j;
struct bt_plugin *plugin = g_ptr_array_index(loaded_plugins, i);
- component_classes_count =
- bt_plugin_get_component_class_count(plugin);
printf("\n");
print_plugin_info(plugin);
-
- if (component_classes_count == 0) {
- printf(" %sComponent classes%s: (none)\n",
- bt_common_color_bold(),
- bt_common_color_reset());
- } else {
- printf(" %sComponent classes%s:\n",
- bt_common_color_bold(),
- bt_common_color_reset());
- }
-
- for (j = 0; j < component_classes_count; j++) {
- struct bt_component_class *comp_class =
- bt_plugin_get_component_class_by_index(
- plugin, j);
- const char *comp_class_name =
- bt_component_class_get_name(comp_class);
- const char *comp_class_description =
- bt_component_class_get_description(comp_class);
- enum bt_component_class_type type =
- bt_component_class_get_type(comp_class);
-
- printf(" ");
- print_plugin_comp_cls_opt(stdout,
- bt_plugin_get_name(plugin), comp_class_name,
- type);
-
- if (comp_class_description) {
- printf(": %s", comp_class_description);
- }
-
- printf("\n");
- bt_object_put_ref(comp_class);
- }
+ cmd_list_plugins_print_component_classes(plugin, "Source",
+ bt_plugin_get_source_component_class_count(plugin),
+ (plugin_borrow_comp_cls_by_index_func_t)
+ bt_plugin_borrow_source_component_class_by_name,
+ (spec_comp_cls_borrow_comp_cls_func_t)
+ bt_component_class_source_borrow_component_class);
+ cmd_list_plugins_print_component_classes(plugin, "Filter",
+ bt_plugin_get_filter_component_class_count(plugin),
+ (plugin_borrow_comp_cls_by_index_func_t)
+ bt_plugin_borrow_filter_component_class_by_name,
+ (spec_comp_cls_borrow_comp_cls_func_t)
+ bt_component_class_filter_borrow_component_class);
+ cmd_list_plugins_print_component_classes(plugin, "Sink",
+ bt_plugin_get_sink_component_class_count(plugin),
+ (plugin_borrow_comp_cls_by_index_func_t)
+ bt_plugin_borrow_sink_component_class_by_name,
+ (spec_comp_cls_borrow_comp_cls_func_t)
+ bt_component_class_sink_borrow_component_class);
}
end:
goto error;
}
- ret = query(comp_cls, "sessions", bt_value_borrow_from_private(params),
+ ret = query(comp_cls, "sessions", bt_private_value_borrow_value(params),
&results, &fail_reason);
if (ret) {
goto failed;
}
ret = query(comp_cls, "metadata-info",
- bt_value_borrow_from_private(params), &results, &fail_reason);
+ bt_private_value_borrow_value(params), &results, &fail_reason);
if (ret) {
goto failed;
}
bt_common_color_reset());
end:
- destroy_the_query_executor();
bt_object_put_ref(results);
bt_object_put_ref(params);
bt_object_put_ref(comp_cls);
struct cmd_run_ctx {
/* Owned by this */
- GHashTable *components;
+ GHashTable *src_components;
+
+ /* Owned by this */
+ GHashTable *flt_components;
+
+ /* Owned by this */
+ GHashTable *sink_components;
/* Owned by this */
struct bt_private_graph *graph;
static
int cmd_run_ctx_connect_upstream_port_to_downstream_component(
- struct cmd_run_ctx *ctx, struct bt_component *upstream_comp,
- struct bt_port *upstream_port,
+ struct cmd_run_ctx *ctx,
+ struct bt_component *upstream_comp,
+ struct bt_port_output *out_upstream_port,
struct bt_config_connection *cfg_conn)
{
+ typedef uint64_t (*input_port_count_func_t)(void *);
+ typedef struct bt_port_input *(*borrow_input_port_by_index_func_t)(
+ void *, uint64_t);
+ struct bt_port *upstream_port =
+ bt_port_output_borrow_port(out_upstream_port);
+
int ret = 0;
GQuark downstreamp_comp_name_quark;
- struct bt_component *downstream_comp;
- int64_t downstream_port_count;
+ void *downstream_comp;
+ uint64_t downstream_port_count;
uint64_t i;
- int64_t (*port_count_fn)(struct bt_component *);
- struct bt_port *(*port_by_index_fn)(struct bt_component *, uint64_t);
+ input_port_count_func_t port_count_fn;
+ borrow_input_port_by_index_func_t port_by_index_fn;
enum bt_graph_status status = BT_GRAPH_STATUS_ERROR;
bool insert_trimmer = false;
struct bt_private_value *trimmer_params = NULL;
char *intersection_begin = NULL;
char *intersection_end = NULL;
- struct bt_component *trimmer = NULL;
- struct bt_component_class *trimmer_class = NULL;
- struct bt_port *trimmer_input = NULL;
- struct bt_port *trimmer_output = NULL;
+ struct bt_component_filter *trimmer = NULL;
+ struct bt_component_class_filter *trimmer_class = NULL;
+ struct bt_port_input *trimmer_input = NULL;
+ struct bt_port_output *trimmer_output = NULL;
if (ctx->intersections &&
bt_component_get_class_type(upstream_comp) ==
}
}
- trimmer_class = find_component_class("utils", "trimmer",
- BT_COMPONENT_CLASS_TYPE_FILTER);
+ trimmer_class = find_filter_component_class("utils", "trimmer");
if (!trimmer_class) {
goto error;
}
downstreamp_comp_name_quark = g_quark_from_string(
cfg_conn->downstream_comp_name->str);
BT_ASSERT(downstreamp_comp_name_quark > 0);
- downstream_comp = g_hash_table_lookup(ctx->components,
+ downstream_comp = g_hash_table_lookup(ctx->flt_components,
GUINT_TO_POINTER(downstreamp_comp_name_quark));
+ port_count_fn = (input_port_count_func_t)
+ bt_component_filter_get_input_port_count;
+ port_by_index_fn = (borrow_input_port_by_index_func_t)
+ bt_component_filter_borrow_input_port_by_index;
+
+ if (!downstream_comp) {
+ downstream_comp = g_hash_table_lookup(ctx->sink_components,
+ GUINT_TO_POINTER(downstreamp_comp_name_quark));
+ port_count_fn = (input_port_count_func_t)
+ bt_component_sink_get_input_port_count;
+ port_by_index_fn = (borrow_input_port_by_index_func_t)
+ bt_component_sink_borrow_input_port_by_index;
+ }
+
if (!downstream_comp) {
BT_LOGE("Cannot find downstream component: comp-name=\"%s\", "
"conn-arg=\"%s\"", cfg_conn->downstream_comp_name->str,
goto error;
}
- if (bt_component_is_filter(downstream_comp)) {
- port_count_fn = bt_component_filter_get_input_port_count;
- port_by_index_fn = bt_component_filter_get_input_port_by_index;
- } else if (bt_component_is_sink(downstream_comp)) {
- port_count_fn = bt_component_sink_get_input_port_count;
- port_by_index_fn = bt_component_sink_get_input_port_by_index;
- } else {
- /*
- * Should never happen because the connections are
- * validated before we get here.
- */
- BT_LOGF("Invalid connection: downstream component is a source: "
- "conn-arg=\"%s\"", cfg_conn->arg->str);
- abort();
- }
-
downstream_port_count = port_count_fn(downstream_comp);
BT_ASSERT(downstream_port_count >= 0);
for (i = 0; i < downstream_port_count; i++) {
- struct bt_port *downstream_port =
+ struct bt_port_input *in_downstream_port =
port_by_index_fn(downstream_comp, i);
+ struct bt_port *downstream_port =
+ bt_port_input_borrow_port(in_downstream_port);
const char *upstream_port_name;
const char *downstream_port_name;
/* Skip port if it's already connected. */
if (bt_port_is_connected(downstream_port)) {
- bt_object_put_ref(downstream_port);
BT_LOGD("Skipping downstream port: already connected: "
"port-addr=%p, port-name=\"%s\"",
downstream_port,
if (!bt_common_star_glob_match(
cfg_conn->downstream_port_glob->str, SIZE_MAX,
downstream_port_name, SIZE_MAX)) {
- bt_object_put_ref(downstream_port);
continue;
}
if (insert_trimmer) {
/*
- * In order to insert the trimmer between the two
- * components that were being connected, we create
- * a connection configuration entry which describes
- * a connection from the trimmer's output to the
- * original input that was being connected.
+ * In order to insert the trimmer between the
+ * two components that were being connected, we
+ * create a connection configuration entry which
+ * describes a connection from the trimmer's
+ * output to the original input that was being
+ * connected.
*
- * Hence, the creation of the trimmer will cause the
- * graph "new port" listener to establish all downstream
- * connections as its output port is connected. We will
- * then establish the connection between the original
- * upstream source and the trimmer.
+ * Hence, the creation of the trimmer will cause
+ * the graph "new port" listener to establish
+ * all downstream connections as its output port
+ * is connected. We will then establish the
+ * connection between the original upstream
+ * source and the trimmer.
*/
char *trimmer_name = NULL;
enum bt_graph_status graph_status;
- ret = asprintf(&trimmer_name, "%s-%s",
- "stream-intersection-trimmer",
+ ret = asprintf(&trimmer_name,
+ "stream-intersection-trimmer-%s",
upstream_port_name);
if (ret < 0) {
goto error;
ret = 0;
ctx->connect_ports = false;
- graph_status = bt_private_graph_add_component(ctx->graph,
- trimmer_class, trimmer_name,
- bt_value_borrow_from_private(trimmer_params),
+ graph_status = bt_private_graph_add_filter_component(
+ ctx->graph, trimmer_class, trimmer_name,
+ bt_private_value_borrow_value(trimmer_params),
&trimmer);
free(trimmer_name);
if (graph_status != BT_GRAPH_STATUS_OK) {
BT_ASSERT(trimmer);
trimmer_input =
- bt_component_filter_get_input_port_by_index(
+ bt_component_filter_borrow_input_port_by_index(
trimmer, 0);
if (!trimmer_input) {
goto error;
}
trimmer_output =
- bt_component_filter_get_output_port_by_index(
+ bt_component_filter_borrow_output_port_by_index(
trimmer, 0);
if (!trimmer_output) {
goto error;
* Replace the current downstream port by the trimmer's
* upstream port.
*/
- BT_OBJECT_MOVE_REF(downstream_port, trimmer_input);
+ in_downstream_port = trimmer_input;
+ downstream_port =
+ bt_port_input_borrow_port(in_downstream_port);
downstream_port_name = bt_port_get_name(
downstream_port);
- if (!downstream_port_name) {
- goto error;
- }
+ BT_ASSERT(downstream_port_name);
}
/* We have a winner! */
status = bt_private_graph_connect_ports(ctx->graph,
- upstream_port, downstream_port, NULL);
- BT_OBJECT_PUT_REF_AND_RESET(downstream_port);
+ out_upstream_port, in_downstream_port, NULL);
+ downstream_port = NULL;
switch (status) {
case BT_GRAPH_STATUS_OK:
break;
* original downstream port.
*/
ret = cmd_run_ctx_connect_upstream_port_to_downstream_component(
- ctx, trimmer, trimmer_output, cfg_conn);
+ ctx,
+ bt_component_filter_borrow_component(trimmer),
+ trimmer_output, cfg_conn);
if (ret) {
goto error;
}
BT_OBJECT_PUT_REF_AND_RESET(trimmer_params);
BT_OBJECT_PUT_REF_AND_RESET(trimmer_class);
BT_OBJECT_PUT_REF_AND_RESET(trimmer);
- BT_OBJECT_PUT_REF_AND_RESET(trimmer_input);
- BT_OBJECT_PUT_REF_AND_RESET(trimmer_output);
return ret;
}
static
int cmd_run_ctx_connect_upstream_port(struct cmd_run_ctx *ctx,
- struct bt_port *upstream_port)
+ struct bt_port_output *upstream_port)
{
int ret = 0;
const char *upstream_port_name;
BT_ASSERT(ctx);
BT_ASSERT(upstream_port);
- upstream_port_name = bt_port_get_name(upstream_port);
+ upstream_port_name = bt_port_get_name(
+ bt_port_output_borrow_port(upstream_port));
BT_ASSERT(upstream_port_name);
- upstream_comp = bt_port_get_component(upstream_port);
+ upstream_comp = bt_port_borrow_component(
+ bt_port_output_borrow_port(upstream_port));
if (!upstream_comp) {
BT_LOGW("Upstream port to connect is not part of a component: "
"port-addr=%p, port-name=\"%s\"",
ret = -1;
end:
- bt_object_put_ref(upstream_comp);
return ret;
}
static
-void graph_port_added_listener(struct bt_port *port, void *data)
+void graph_output_port_added_listener(struct cmd_run_ctx *ctx,
+ struct bt_port_output *out_port)
{
- struct bt_component *comp = NULL;
- struct cmd_run_ctx *ctx = data;
+ struct bt_component *comp;
+ struct bt_port *port = bt_port_output_borrow_port(out_port);
- comp = bt_port_get_component(port);
+ comp = bt_port_borrow_component(port);
BT_LOGI("Port added to a graph's component: comp-addr=%p, "
"comp-name=\"%s\", port-addr=%p, port-name=\"%s\"",
comp, comp ? bt_component_get_name(comp) : "",
goto end;
}
- if (!bt_port_is_output(port)) {
- BT_LOGI_STR("Skipping input port.");
- goto end;
- }
-
- if (cmd_run_ctx_connect_upstream_port(ctx, port)) {
+ if (cmd_run_ctx_connect_upstream_port(ctx, out_port)) {
BT_LOGF_STR("Cannot connect upstream port.");
fprintf(stderr, "Added port could not be connected: aborting\n");
abort();
}
end:
- bt_object_put_ref(comp);
return;
}
static
-void graph_port_removed_listener(struct bt_component *component,
- struct bt_port *port, void *data)
+void graph_source_output_port_added_listener(
+ struct bt_component_source *component,
+ struct bt_port_output *port, void *data)
{
- BT_LOGI("Port removed from a graph's component: comp-addr=%p, "
- "comp-name=\"%s\", port-addr=%p, port-name=\"%s\"",
- component, bt_component_get_name(component),
- port, bt_port_get_name(port));
-}
-
-static
-void graph_ports_connected_listener(struct bt_port *upstream_port,
- struct bt_port *downstream_port, void *data)
-{
- struct bt_component *upstream_comp = bt_port_get_component(upstream_port);
- struct bt_component *downstream_comp = bt_port_get_component(downstream_port);
-
- BT_ASSERT(upstream_comp);
- BT_ASSERT(downstream_comp);
- BT_LOGI("Graph's component ports connected: "
- "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\"",
- upstream_comp, bt_component_get_name(upstream_comp),
- upstream_port, bt_port_get_name(upstream_port),
- downstream_comp, bt_component_get_name(downstream_comp),
- downstream_port, bt_port_get_name(downstream_port));
- bt_object_put_ref(upstream_comp);
- bt_object_put_ref(downstream_comp);
+ graph_output_port_added_listener(data, port);
}
static
-void graph_ports_disconnected_listener(
- struct bt_component *upstream_component,
- struct bt_component *downstream_component,
- struct bt_port *upstream_port, struct bt_port *downstream_port,
- void *data)
+void graph_filter_output_port_added_listener(
+ struct bt_component_filter *component,
+ struct bt_port_output *port, void *data)
{
- BT_LOGI("Graph's component ports disconnected: "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
+ graph_output_port_added_listener(data, port);
}
static
return;
}
- if (ctx->components) {
- g_hash_table_destroy(ctx->components);
- ctx->components = NULL;
+ if (ctx->src_components) {
+ g_hash_table_destroy(ctx->src_components);
+ ctx->src_components = NULL;
+ }
+
+ if (ctx->flt_components) {
+ g_hash_table_destroy(ctx->flt_components);
+ ctx->flt_components = NULL;
+ }
+
+ if (ctx->sink_components) {
+ g_hash_table_destroy(ctx->sink_components);
+ ctx->sink_components = NULL;
}
if (ctx->intersections) {
int cmd_run_ctx_init(struct cmd_run_ctx *ctx, struct bt_config *cfg)
{
int ret = 0;
+ enum bt_graph_status status;
ctx->cfg = cfg;
ctx->connect_ports = false;
- ctx->components = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, bt_object_put_ref);
- if (!ctx->components) {
+ ctx->src_components = g_hash_table_new_full(g_direct_hash,
+ g_direct_equal, NULL, bt_object_put_ref);
+ if (!ctx->src_components) {
+ goto error;
+ }
+
+ ctx->flt_components = g_hash_table_new_full(g_direct_hash,
+ g_direct_equal, NULL, bt_object_put_ref);
+ if (!ctx->flt_components) {
+ goto error;
+ }
+
+ ctx->sink_components = g_hash_table_new_full(g_direct_hash,
+ g_direct_equal, NULL, bt_object_put_ref);
+ if (!ctx->sink_components) {
goto error;
}
}
the_graph = ctx->graph;
- ret = bt_private_graph_add_port_added_listener(ctx->graph,
- graph_port_added_listener, NULL, ctx);
- if (ret < 0) {
+ status = bt_private_graph_add_source_component_output_port_added_listener(
+ ctx->graph, graph_source_output_port_added_listener, NULL, ctx,
+ NULL);
+ if (status != BT_GRAPH_STATUS_OK) {
BT_LOGE_STR("Cannot add \"port added\" listener to graph.");
goto error;
}
- ret = bt_private_graph_add_port_removed_listener(ctx->graph,
- graph_port_removed_listener, NULL, ctx);
- if (ret < 0) {
- BT_LOGE_STR("Cannot add \"port removed\" listener to graph.");
- goto error;
- }
-
- ret = bt_private_graph_add_ports_connected_listener(ctx->graph,
- graph_ports_connected_listener, NULL, ctx);
- if (ret < 0) {
- BT_LOGE_STR("Cannot add \"ports connected\" listener to graph.");
- goto error;
- }
-
- ret = bt_private_graph_add_ports_disconnected_listener(ctx->graph,
- graph_ports_disconnected_listener, NULL, ctx);
- if (ret < 0) {
- BT_LOGE_STR("Cannot add \"ports disconnected\" listener to graph.");
+ status = bt_private_graph_add_filter_component_output_port_added_listener(
+ ctx->graph, graph_filter_output_port_added_listener, NULL, ctx,
+ NULL);
+ if (status != BT_GRAPH_STATUS_OK) {
+ BT_LOGE_STR("Cannot add \"port added\" listener to graph.");
goto error;
}
static
int set_stream_intersections(struct cmd_run_ctx *ctx,
struct bt_config_component *cfg_comp,
- struct bt_component_class *comp_cls)
+ struct bt_component_class_source *src_comp_cls)
{
int ret = 0;
uint64_t trace_idx;
struct port_id *port_id = NULL;
struct trace_range *trace_range = NULL;
const char *fail_reason = NULL;
+ struct bt_component_class *comp_cls =
+ bt_component_class_source_borrow_component_class(src_comp_cls);
component_path_value = bt_value_map_borrow_entry_value(
- bt_value_borrow_from_private(cfg_comp->params),
+ bt_private_value_borrow_value(cfg_comp->params),
"path");
if (component_path_value && !bt_value_is_string(component_path_value)) {
BT_LOGD("Cannot get path parameter: component-name=%s",
}
ret = query(comp_cls, "trace-info",
- bt_value_borrow_from_private(query_params), &query_result,
+ bt_private_value_borrow_value(query_params), &query_result,
&fail_reason);
if (ret) {
BT_LOGD("Component class does not support the `trace-info` query: %s: "
struct cmd_run_ctx *ctx, GPtrArray *cfg_components)
{
size_t i;
- struct bt_component_class *comp_cls = NULL;
- struct bt_component *comp = NULL;
+ void *comp_cls = NULL;
+ void *comp = NULL;
int ret = 0;
for (i = 0; i < cfg_components->len; i++) {
g_ptr_array_index(cfg_components, i);
GQuark quark;
- comp_cls = find_component_class(cfg_comp->plugin_name->str,
- cfg_comp->comp_cls_name->str, cfg_comp->type);
+ switch (cfg_comp->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ comp_cls = find_source_component_class(
+ cfg_comp->plugin_name->str,
+ cfg_comp->comp_cls_name->str);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ comp_cls = find_filter_component_class(
+ cfg_comp->plugin_name->str,
+ cfg_comp->comp_cls_name->str);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ comp_cls = find_sink_component_class(
+ cfg_comp->plugin_name->str,
+ cfg_comp->comp_cls_name->str);
+ break;
+ default:
+ abort();
+ }
+
if (!comp_cls) {
BT_LOGE("Cannot find component class: plugin-name=\"%s\", "
"comp-cls-name=\"%s\", comp-cls-type=%d",
goto error;
}
- ret = bt_private_graph_add_component(ctx->graph, comp_cls,
- cfg_comp->instance_name->str,
- bt_value_borrow_from_private(cfg_comp->params), &comp);
+ switch (cfg_comp->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ ret = bt_private_graph_add_source_component(ctx->graph,
+ comp_cls, cfg_comp->instance_name->str,
+ bt_private_value_borrow_value(cfg_comp->params),
+ (void *) &comp);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ ret = bt_private_graph_add_filter_component(ctx->graph,
+ comp_cls, cfg_comp->instance_name->str,
+ bt_private_value_borrow_value(cfg_comp->params),
+ (void *) &comp);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ ret = bt_private_graph_add_sink_component(ctx->graph,
+ comp_cls, cfg_comp->instance_name->str,
+ bt_private_value_borrow_value(cfg_comp->params),
+ (void *) &comp);
+ break;
+ default:
+ abort();
+ }
+
if (ret) {
BT_LOGE("Cannot create component: plugin-name=\"%s\", "
"comp-cls-name=\"%s\", comp-cls-type=%d, "
comp, cfg_comp->instance_name->str);
quark = g_quark_from_string(cfg_comp->instance_name->str);
BT_ASSERT(quark > 0);
- g_hash_table_insert(ctx->components,
- GUINT_TO_POINTER(quark), comp);
+
+ switch (cfg_comp->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ g_hash_table_insert(ctx->src_components,
+ GUINT_TO_POINTER(quark), comp);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ g_hash_table_insert(ctx->flt_components,
+ GUINT_TO_POINTER(quark), comp);
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ g_hash_table_insert(ctx->sink_components,
+ GUINT_TO_POINTER(quark), comp);
+ break;
+ default:
+ abort();
+ }
+
comp = NULL;
BT_OBJECT_PUT_REF_AND_RESET(comp_cls);
}
return ret;
}
+typedef uint64_t (*output_port_count_func_t)(void *);
+typedef struct bt_port_output *(*borrow_output_port_by_index_func_t)(
+ void *, uint64_t);
+
static
int cmd_run_ctx_connect_comp_ports(struct cmd_run_ctx *ctx,
- struct bt_component *comp,
- int64_t (*port_count_fn)(struct bt_component *),
- struct bt_port *(*port_by_index_fn)(struct bt_component *, uint64_t))
+ void *comp, output_port_count_func_t port_count_fn,
+ borrow_output_port_by_index_func_t port_by_index_fn)
{
int ret = 0;
- int64_t count;
+ uint64_t count;
uint64_t i;
count = port_count_fn(comp);
BT_ASSERT(count >= 0);
for (i = 0; i < count; i++) {
- struct bt_port *upstream_port = port_by_index_fn(comp, i);
+ struct bt_port_output *upstream_port = port_by_index_fn(comp, i);
BT_ASSERT(upstream_port);
ret = cmd_run_ctx_connect_upstream_port(ctx, upstream_port);
- bt_object_put_ref(upstream_port);
if (ret) {
goto end;
}
gpointer g_name_quark, g_comp;
ctx->connect_ports = true;
- g_hash_table_iter_init(&iter, ctx->components);
+ g_hash_table_iter_init(&iter, ctx->src_components);
while (g_hash_table_iter_next(&iter, &g_name_quark, &g_comp)) {
- int64_t (*port_count_fn)(struct bt_component *);
- struct bt_port *(*port_by_index_fn)(struct bt_component *, uint64_t);
-
- if (bt_component_is_source(g_comp)) {
- port_count_fn =
- bt_component_source_get_output_port_count;
- port_by_index_fn =
- bt_component_source_get_output_port_by_index;
- } else if (bt_component_is_filter(g_comp)) {
- port_count_fn =
- bt_component_filter_get_output_port_count;
- port_by_index_fn =
- bt_component_filter_get_output_port_by_index;
- } else {
- continue;
+ ret = cmd_run_ctx_connect_comp_ports(ctx, g_comp,
+ (output_port_count_func_t)
+ bt_component_source_get_output_port_count,
+ (borrow_output_port_by_index_func_t)
+ bt_component_source_borrow_output_port_by_index);
+ if (ret) {
+ goto end;
}
+ }
+
+ g_hash_table_iter_init(&iter, ctx->flt_components);
- ret = cmd_run_ctx_connect_comp_ports(ctx,
- g_comp, port_count_fn, port_by_index_fn);
+ while (g_hash_table_iter_next(&iter, &g_name_quark, &g_comp)) {
+ ret = cmd_run_ctx_connect_comp_ports(ctx, g_comp,
+ (output_port_count_func_t)
+ bt_component_filter_get_output_port_count,
+ (borrow_output_port_by_index_func_t)
+ bt_component_filter_borrow_output_port_by_index);
if (ret) {
goto end;
}
const char *bt_graph_status_str(enum bt_graph_status status)
{
switch (status) {
- case BT_GRAPH_STATUS_CANCELED:
- return "BT_GRAPH_STATUS_CANCELED";
- case BT_GRAPH_STATUS_AGAIN:
- return "BT_GRAPH_STATUS_AGAIN";
- case BT_GRAPH_STATUS_END:
- return "BT_GRAPH_STATUS_END";
case BT_GRAPH_STATUS_OK:
return "BT_GRAPH_STATUS_OK";
- case BT_GRAPH_STATUS_INVALID:
- return "BT_GRAPH_STATUS_INVALID";
- case BT_GRAPH_STATUS_NO_SINK:
- return "BT_GRAPH_STATUS_NO_SINK";
+ case BT_GRAPH_STATUS_END:
+ 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_GRAPH_STATUS_ERROR";
+ case BT_GRAPH_STATUS_NO_SINK:
+ return "BT_GRAPH_STATUS_NO_SINK";
+ case BT_GRAPH_STATUS_NOMEM:
+ return "BT_GRAPH_STATUS_NOMEM";
default:
return "(unknown)";
}
goto error;
case BT_GRAPH_STATUS_AGAIN:
if (bt_graph_is_canceled(
- bt_graph_borrow_from_private(ctx.graph))) {
+ bt_private_graph_borrow_graph(ctx.graph))) {
BT_LOGI_STR("Graph was canceled by user.");
goto error;
}
if (usleep(cfg->cmd_data.run.retry_duration_us)) {
if (bt_graph_is_canceled(
- bt_graph_borrow_from_private(ctx.graph))) {
+ bt_private_graph_borrow_graph(ctx.graph))) {
BT_LOGI_STR("Graph was canceled by user.");
goto error;
}
}
}
break;
- case BT_COMPONENT_STATUS_END:
+ case BT_GRAPH_STATUS_END:
goto end;
default:
BT_LOGE_STR("Graph failed to complete successfully");
if (cfg->command_needs_plugins) {
ret = load_all_plugins(
- bt_value_borrow_from_private(cfg->plugin_paths));
+ bt_private_value_borrow_value(cfg->plugin_paths));
if (ret) {
BT_LOGE("Failed to load plugins: ret=%d", ret);
retcode = 1;
/*
* Babeltrace API
*
- * Copyright 2010-2017 EfficiOS Inc. <http://www.efficios.com/>
+ * Copyright 2010-2018 EfficiOS Inc. <http://www.efficios.com/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
babeltrace/babeltrace.h \
babeltrace/logging.h \
babeltrace/object.h \
- babeltrace/types.h \
babeltrace/private-values.h \
+ babeltrace/property.h \
+ babeltrace/types.h \
babeltrace/values.h \
babeltrace/version.h
babeltrace/trace-ir/packet.h \
babeltrace/trace-ir/private-clock-class.h \
babeltrace/trace-ir/private-event-class.h \
- babeltrace/trace-ir/private-event-header-field.h \
babeltrace/trace-ir/private-event.h \
+ babeltrace/trace-ir/private-event-header-field.h \
babeltrace/trace-ir/private-field-classes.h \
babeltrace/trace-ir/private-fields.h \
babeltrace/trace-ir/private-packet-context-field.h \
- babeltrace/trace-ir/private-packet-header-field.h \
babeltrace/trace-ir/private-packet.h \
+ babeltrace/trace-ir/private-packet-header-field.h \
babeltrace/trace-ir/private-stream-class.h \
babeltrace/trace-ir/private-stream.h \
babeltrace/trace-ir/private-trace.h \
babeltracegraphincludedir = "$(includedir)/babeltrace/graph"
babeltracegraphinclude_HEADERS = \
babeltrace/graph/component-class-filter.h \
+ babeltrace/graph/component-class.h \
babeltrace/graph/component-class-sink.h \
babeltrace/graph/component-class-source.h \
- babeltrace/graph/component-class.h \
babeltrace/graph/component-filter.h \
+ babeltrace/graph/component.h \
babeltrace/graph/component-sink.h \
babeltrace/graph/component-source.h \
- babeltrace/graph/component-status.h \
- babeltrace/graph/component.h \
babeltrace/graph/connection.h \
babeltrace/graph/graph.h \
babeltrace/graph/notification-event.h \
babeltrace/graph/notification-packet.h \
babeltrace/graph/notification-stream.h \
babeltrace/graph/notification.h \
- babeltrace/graph/output-port-notification-iterator.h \
+ babeltrace/graph/port-input.h \
+ babeltrace/graph/port-output-notification-iterator.h \
+ babeltrace/graph/port-output.h \
babeltrace/graph/port.h \
- babeltrace/graph/private-component-filter.h \
- babeltrace/graph/private-component-sink.h \
- babeltrace/graph/private-component-source.h \
- babeltrace/graph/private-component.h \
- babeltrace/graph/private-connection-notification-iterator.h \
- babeltrace/graph/private-connection-private-notification-iterator.h \
- babeltrace/graph/private-connection.h \
+ babeltrace/graph/private-component-class-filter.h \
+ babeltrace/graph/private-component-class-sink.h \
+ babeltrace/graph/private-component-class-source.h \
+ babeltrace/graph/private-component-class.h \
babeltrace/graph/private-graph.h \
babeltrace/graph/private-notification-event.h \
babeltrace/graph/private-notification-inactivity.h \
babeltrace/graph/private-notification-packet.h \
babeltrace/graph/private-notification-stream.h \
babeltrace/graph/private-notification.h \
- babeltrace/graph/private-port.h \
- babeltrace/graph/query-executor.h
+ babeltrace/graph/private-query-executor.h \
+ babeltrace/graph/query-executor.h \
+ babeltrace/graph/self-component-class-filter.h \
+ babeltrace/graph/self-component-class-sink.h \
+ babeltrace/graph/self-component-class-source.h \
+ babeltrace/graph/self-component-filter.h \
+ babeltrace/graph/self-component-port-input-notification-iterator.h \
+ babeltrace/graph/self-component-port-input.h \
+ babeltrace/graph/self-component-port-output.h \
+ babeltrace/graph/self-component-port.h \
+ babeltrace/graph/self-component-sink.h \
+ babeltrace/graph/self-component-source.h \
+ babeltrace/graph/self-component.h \
+ babeltrace/graph/self-notification-iterator.h
noinst_HEADERS = \
babeltrace/compat/stdlib-internal.h \
babeltrace/align-internal.h \
babeltrace/logging-internal.h \
babeltrace/endian-internal.h \
- babeltrace/trace-ir/packet-internal.h \
+ babeltrace/trace-ir/attributes-internal.h \
+ babeltrace/trace-ir/clock-class-internal.h \
+ babeltrace/trace-ir/clock-value-internal.h \
+ babeltrace/trace-ir/clock-value-set-internal.h \
babeltrace/trace-ir/event-class-internal.h \
- babeltrace/trace-ir/utils-internal.h \
- babeltrace/trace-ir/fields-internal.h \
- babeltrace/trace-ir/stream-class-internal.h \
babeltrace/trace-ir/event-internal.h \
+ babeltrace/trace-ir/field-classes-internal.h \
babeltrace/trace-ir/field-path-internal.h \
+ babeltrace/trace-ir/fields-internal.h \
babeltrace/trace-ir/field-wrapper-internal.h \
- babeltrace/trace-ir/trace-internal.h \
- babeltrace/trace-ir/clock-class-internal.h \
- babeltrace/trace-ir/field-classes-internal.h \
- babeltrace/trace-ir/clock-value-internal.h \
- babeltrace/trace-ir/attributes-internal.h \
- babeltrace/trace-ir/stream-internal.h \
+ babeltrace/trace-ir/packet-internal.h \
babeltrace/trace-ir/resolve-field-path-internal.h \
+ babeltrace/trace-ir/stream-class-internal.h \
+ babeltrace/trace-ir/stream-internal.h \
+ babeltrace/trace-ir/trace-internal.h \
+ babeltrace/trace-ir/utils-internal.h \
babeltrace/prio-heap-internal.h \
babeltrace/lib-logging-internal.h \
babeltrace/compiler-internal.h \
babeltrace/babeltrace-internal.h \
babeltrace/assert-pre-internal.h \
+ babeltrace/graph/component-class-internal.h \
+ babeltrace/graph/component-class-sink-colander-internal.h \
+ babeltrace/graph/component-filter-internal.h \
babeltrace/graph/component-internal.h \
- babeltrace/graph/notification-stream-internal.h \
+ babeltrace/graph/component-sink-internal.h \
+ babeltrace/graph/component-source-internal.h \
babeltrace/graph/connection-internal.h \
- babeltrace/graph/notification-event-internal.h \
- babeltrace/graph/query-executor-internal.h \
babeltrace/graph/graph-internal.h \
- babeltrace/graph/component-class-sink-colander-internal.h \
+ babeltrace/graph/notification-event-internal.h \
babeltrace/graph/notification-inactivity-internal.h \
- babeltrace/graph/component-source-internal.h \
- babeltrace/graph/notification-packet-internal.h \
- babeltrace/graph/notification-iterator-internal.h \
babeltrace/graph/notification-internal.h \
- babeltrace/graph/component-filter-internal.h \
- babeltrace/graph/component-class-internal.h \
- babeltrace/graph/component-sink-internal.h \
+ babeltrace/graph/notification-iterator-internal.h \
+ babeltrace/graph/notification-packet-internal.h \
+ babeltrace/graph/notification-stream-internal.h \
babeltrace/graph/port-internal.h \
+ babeltrace/graph/query-executor-internal.h \
babeltrace/list-internal.h \
version.h \
version.i
#define _BABELTRACE_ALIGN_H
/*
- * BabelTrace align.h - alignment header
- *
* Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define _BABELTRACE_INTERNAL_H
/*
- * babeltrace/babeltrace-internal.h
- *
* Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
/*
* Babeltrace API
*
- * Copyright 2010-2017 EfficiOS Inc. <http://www.efficios.com/>
+ * Copyright 2010-2018 EfficiOS Inc. <http://www.efficios.com/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#include <babeltrace/logging.h>
#include <babeltrace/object.h>
#include <babeltrace/private-values.h>
+#include <babeltrace/property.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
#include <babeltrace/version.h>
#include <babeltrace/graph/component-filter.h>
#include <babeltrace/graph/component-sink.h>
#include <babeltrace/graph/component-source.h>
-#include <babeltrace/graph/component-status.h>
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/connection.h>
#include <babeltrace/graph/graph.h>
#include <babeltrace/graph/notification-packet.h>
#include <babeltrace/graph/notification-stream.h>
#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/output-port-notification-iterator.h>
+#include <babeltrace/graph/port-input.h>
+#include <babeltrace/graph/port-output-notification-iterator.h>
+#include <babeltrace/graph/port-output.h>
#include <babeltrace/graph/port.h>
-#include <babeltrace/graph/private-component-filter.h>
-#include <babeltrace/graph/private-component-sink.h>
-#include <babeltrace/graph/private-component-source.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-connection-notification-iterator.h>
-#include <babeltrace/graph/private-connection-private-notification-iterator.h>
-#include <babeltrace/graph/private-connection.h>
+#include <babeltrace/graph/private-component-class-filter.h>
+#include <babeltrace/graph/private-component-class-sink.h>
+#include <babeltrace/graph/private-component-class-source.h>
+#include <babeltrace/graph/private-component-class.h>
#include <babeltrace/graph/private-graph.h>
#include <babeltrace/graph/private-notification-event.h>
#include <babeltrace/graph/private-notification-inactivity.h>
#include <babeltrace/graph/private-notification-packet.h>
#include <babeltrace/graph/private-notification-stream.h>
#include <babeltrace/graph/private-notification.h>
-#include <babeltrace/graph/private-port.h>
+#include <babeltrace/graph/private-query-executor.h>
#include <babeltrace/graph/query-executor.h>
+#include <babeltrace/graph/self-component-class-filter.h>
+#include <babeltrace/graph/self-component-class-sink.h>
+#include <babeltrace/graph/self-component-class-source.h>
+#include <babeltrace/graph/self-component-filter.h>
+#include <babeltrace/graph/self-component-port-input-notification-iterator.h>
+#include <babeltrace/graph/self-component-port-input.h>
+#include <babeltrace/graph/self-component-port-output.h>
+#include <babeltrace/graph/self-component-port.h>
+#include <babeltrace/graph/self-component-sink.h>
+#include <babeltrace/graph/self-component-source.h>
+#include <babeltrace/graph/self-component.h>
+#include <babeltrace/graph/self-notification-iterator.h>
#endif /* BABELTRACE_BABELTRACE_H */
#define _BABELTRACE_BITFIELD_H
/*
- * BabelTrace
- *
- * Bitfields read/write functions.
- *
* Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#ifndef BABELTRACE_COMMON_INTERNAL_H
#define BABELTRACE_COMMON_INTERNAL_H
+/*
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include <stdbool.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/babeltrace-internal.h>
#define _BABELTRACE_COMPAT_FCNTL_H
/*
- * babeltrace/compat/fcntl.h
- *
* Copyright 2015 (c) - Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* fcntl compatibility layer.
#define _BABELTRACE_COMPAT_GLIB_H
/*
- * babeltrace/compat/glib.h
- *
* Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
/*
- * format/ctf/memstream.h
- *
* Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* memstream compatibility layer.
#define _BABELTRACE_COMPAT_MMAN_H
/*
- * babeltrace/compat/mman.h
- *
* Copyright (C) 2015-2016 Michael Jeanson <mjeanson@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define _BABELTRACE_COMPAT_SOCKET_H
/*
- * babeltrace/compat/socket.h
- *
* Copyright (C) 2015-2017 Michael Jeanson <mjeanson@efficios.com>
* 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
#define _BABELTRACE_COMPAT_STDLIB_H
/*
- * babeltrace/compat/stdlib.h
- *
* Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define _BABELTRACE_INCLUDE_COMPAT_TIME_H
/*
- * babeltrace/compat/time.h
- *
* Copyright (C) 2013 JP Ikaheimonen <jp_ikaheimonen@mentor.com>
* 2016 Michael Jeanson <mjeanson@efficios.com>
*
#define _BABELTRACE_COMPAT_UNISTD_H
/*
- * babeltrace/compat/unistd.h
- *
* (C) Copyright 2016 - Michael Jeanson <mjeanson@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define _BABELTRACE_COMPAT_UUID_H
/*
- * babeltrace/compat/uuid.h
- *
* Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define _BABELTRACE_COMPILER_H
/*
- * compiler.h
- *
* Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define BABELTRACE_CTF_WRITER_ATTRIBUTES_H
/*
- * attributes.c
- *
- * Babeltrace - CTF writer: Attributes internal
- *
* Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
* Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
*
#define BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H
/*
- * BabelTrace - CTF writer: Clock class internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H
/*
- * BabelTrace - CTF writer: Clock internal
- *
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define BABELTRACE_CTF_WRITER_CLOCK_H
/*
- * BabelTrace - CTF Writer: Clock
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_EVENT_CLASS_INTERNAL_H
/*
- * Babeltrace - CTF writer: Event class internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
/*
- * BabelTrace - CTF Writer: Event Fields
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H
/*
- * BabelTrace - CTF Writer: Event
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_EVENT_TYPES_H
/*
- * BabelTrace - CTF Writer: Event Types
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_EVENT_H
/*
- * BabelTrace - CTF Writer: Event
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_FIELD_PATH_INTERNAL
/*
- * BabelTrace - CTF writer: Field path
- *
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define BABELTRACE_CTF_WRITER_FIELD_TYPES_INTERNAL_H
/*
- * Babeltrace - CTF writer: Event Fields
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_FIELD_TYPES_H
/*
- * Babeltrace - CTF writer: Event Fields
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
/*
- * Babeltrace - CTF writer: Event Fields
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_FIELDS_H
/*
- * Babeltrace - CTF writer: Event Fields
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_FUNCTOR_INTERNAL_H
/*
- * BabelTrace - CTF Writer: Functors for use with glib data structures
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_RESOLVE_INTERNAL_H
/*
- * Babeltrace - CTF writer: Type resolving internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
#define BABELTRACE_CTF_WRITER_STREAM_CLASS_INTERNAL_H
/*
- * BabelTrace - CTF Writer: Stream Class
- *
* Copyright 2014 EfficiOS Inc.
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_STREAM_CLASS_H
/*
- * BabelTrace - CTF Writer: Stream Class
- *
* Copyright 2014 EfficiOS Inc.
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
/*
- * BabelTrace - CTF Writer: Stream
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_STREAM_H
/*
- * BabelTrace - CTF Writer: Stream
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H
/*
- * BabelTrace - CTF Writer: Trace
- *
* Copyright 2014 EfficiOS Inc.
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_TRACE_H
/*
- * BabelTrace - CTF Writer: Stream Class
- *
* Copyright 2014 EfficiOS Inc.
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_UTILS_INTERNAL_H
/*
- * Babeltrace - Internal CTF writer utilities
- *
* 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
#define BABELTRACE_CTF_WRITER_UTILS_H
/*
- * BabelTrace - CTF writer: Utilities
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
/*
- * Babeltrace - CTF writer: Validation of trace, stream class, and event class
- *
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define BABELTRACE_CTF_WRITER_VISITOR_INTERNAL_H
/*
- * BabelTrace - CTF writer: Visitor internal
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_VISITOR_H
/*
- * BabelTrace - CTF writer: Visitor
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_WRITER_INTERNAL_H
/*
- * BabelTrace - CTF Writer: Writer internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_CTF_WRITER_WRITER_H
/*
- * BabelTrace - CTF Writer: Writer
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define _BABELTRACE_ENDIAN_H
/*
- * babeltrace/endian.h
- *
* Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* endian.h compatibility layer.
#define BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_H
/*
- * Babeltrace - Component Class Interface.
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* SOFTWARE.
*/
-/* For component class method type definitions */
-#include <babeltrace/graph/component-class.h>
-
#ifdef __cplusplus
extern "C" {
#endif
struct bt_component_class;
-
-extern
-struct bt_component_class *bt_component_class_filter_create(const char *name,
- bt_component_class_notification_iterator_next_method method);
-
-extern
-int bt_component_class_filter_set_notification_iterator_init_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_init_method method);
-
-extern
-int bt_component_class_filter_set_notification_iterator_finalize_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_finalize_method method);
+struct bt_component_class_filter;
+
+static inline
+struct bt_component_class *
+bt_component_class_filter_borrow_component_class(
+ struct bt_component_class_filter *comp_cls_filter)
+{
+ return (void *) comp_cls_filter;
+}
#ifdef __cplusplus
}
#define BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
/*
- * BabelTrace - Component Class Internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-sink.h>
+#include <babeltrace/graph/private-component-class-source.h>
+#include <babeltrace/graph/private-component-class-filter.h>
+#include <babeltrace/graph/private-component-class-sink.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/list-internal.h>
GString *name;
GString *description;
GString *help;
- struct {
- bt_component_class_init_method init;
- bt_component_class_finalize_method finalize;
- bt_component_class_query_method query;
- bt_component_class_accept_port_connection_method accept_port_connection;
- bt_component_class_port_connected_method port_connected;
- bt_component_class_port_disconnected_method port_disconnected;
- } methods;
+
/* Array of struct bt_component_class_destroy_listener */
GArray *destroy_listeners;
- bt_bool frozen;
+ bool frozen;
struct bt_list_head node;
struct bt_plugin_so_shared_lib_handle *so_handle;
};
-struct bt_component_class_notification_iterator_methods {
- bt_component_class_notification_iterator_init_method init;
- bt_component_class_notification_iterator_finalize_method finalize;
- bt_component_class_notification_iterator_next_method next;
-};
-
struct bt_component_class_source {
struct bt_component_class parent;
struct {
- struct bt_component_class_notification_iterator_methods iterator;
+ bt_private_component_class_source_init_method init;
+ bt_private_component_class_source_finalize_method finalize;
+ bt_private_component_class_source_notification_iterator_init_method notif_iter_init;
+ bt_private_component_class_source_notification_iterator_finalize_method notif_iter_finalize;
+ bt_private_component_class_source_notification_iterator_next_method notif_iter_next;
+ bt_private_component_class_source_query_method query;
+ bt_private_component_class_source_accept_output_port_connection_method accept_output_port_connection;
+ bt_private_component_class_source_output_port_connected_method output_port_connected;
+ bt_private_component_class_source_output_port_disconnected_method output_port_disconnected;
} methods;
};
struct bt_component_class_sink {
struct bt_component_class parent;
struct {
- bt_component_class_sink_consume_method consume;
+ bt_private_component_class_sink_init_method init;
+ bt_private_component_class_sink_finalize_method finalize;
+ bt_private_component_class_sink_query_method query;
+ bt_private_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
+ bt_private_component_class_sink_input_port_connected_method input_port_connected;
+ bt_private_component_class_sink_input_port_disconnected_method input_port_disconnected;
+ bt_private_component_class_sink_consume_method consume;
} methods;
};
struct bt_component_class_filter {
struct bt_component_class parent;
struct {
- struct bt_component_class_notification_iterator_methods iterator;
+ bt_private_component_class_filter_init_method init;
+ bt_private_component_class_filter_finalize_method finalize;
+ bt_private_component_class_filter_notification_iterator_init_method notif_iter_init;
+ bt_private_component_class_filter_notification_iterator_finalize_method notif_iter_finalize;
+ bt_private_component_class_filter_notification_iterator_next_method notif_iter_next;
+ bt_private_component_class_filter_query_method query;
+ bt_private_component_class_filter_accept_input_port_connection_method accept_input_port_connection;
+ bt_private_component_class_filter_accept_output_port_connection_method accept_output_port_connection;
+ bt_private_component_class_filter_input_port_connected_method input_port_connected;
+ bt_private_component_class_filter_output_port_connected_method output_port_connected;
+ bt_private_component_class_filter_input_port_disconnected_method input_port_disconnected;
+ bt_private_component_class_filter_output_port_disconnected_method output_port_disconnected;
} methods;
};
void bt_component_class_add_destroy_listener(struct bt_component_class *class,
bt_component_class_destroy_listener_func func, void *data);
+BT_HIDDEN
+void _bt_component_class_freeze(struct bt_component_class *component_class);
+
+#ifdef BT_DEV_MODE
+# define bt_component_class_freeze _bt_component_class_freeze
+#else
+# define bt_component_class_freeze(_cc)
+#endif
+
static inline
const char *bt_component_class_type_string(enum bt_component_class_type type)
{
switch (type) {
- case BT_COMPONENT_CLASS_TYPE_UNKNOWN:
- return "BT_COMPONENT_CLASS_TYPE_UNKNOWN";
case BT_COMPONENT_CLASS_TYPE_SOURCE:
return "BT_COMPONENT_CLASS_TYPE_SOURCE";
case BT_COMPONENT_CLASS_TYPE_SINK:
uint64_t *count_addr;
};
-extern struct bt_component_class *bt_component_class_sink_colander_get(void);
+extern struct bt_component_class_sink *
+bt_component_class_sink_colander_get(void);
#ifdef __cplusplus
}
#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H
/*
- * Babeltrace - Component Class Interface.
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* SOFTWARE.
*/
-/* For component class method type definitions */
-#include <babeltrace/graph/component-class.h>
-
#ifdef __cplusplus
extern "C" {
#endif
struct bt_component_class;
-struct bt_private_component;
-
-typedef enum bt_component_status (*bt_component_class_sink_consume_method)(
- struct bt_private_component *private_component);
-
-extern
-struct bt_component_class *bt_component_class_sink_create(const char *name,
- bt_component_class_sink_consume_method consume_method);
+struct bt_component_class_sink;
+
+static inline
+struct bt_component_class *
+bt_component_class_sink_borrow_component_class(
+ struct bt_component_class_sink *comp_cls_sink)
+{
+ return (void *) comp_cls_sink;
+}
#ifdef __cplusplus
}
#define BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_H
/*
- * Babeltrace - Component Class Interface.
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* SOFTWARE.
*/
-/* For component class method type definitions */
-#include <babeltrace/graph/component-class.h>
-
#ifdef __cplusplus
extern "C" {
#endif
struct bt_component_class;
-
-extern
-struct bt_component_class *bt_component_class_source_create(const char *name,
- bt_component_class_notification_iterator_next_method method);
-
-extern
-int bt_component_class_source_set_notification_iterator_init_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_init_method method);
-
-extern
-int bt_component_class_source_set_notification_iterator_finalize_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_finalize_method method);
+struct bt_component_class_source;
+
+static inline
+struct bt_component_class *
+bt_component_class_source_borrow_component_class(
+ struct bt_component_class_source *comp_cls_source)
+{
+ return (void *) comp_cls_source;
+}
#ifdef __cplusplus
}
#define BABELTRACE_GRAPH_COMPONENT_CLASS_H
/*
- * Babeltrace - Component Class Interface.
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* SOFTWARE.
*/
-#include <stdint.h>
-
-/* For enum bt_component_status */
-#include <babeltrace/graph/component-status.h>
-
-/* For enum bt_notification_iterator_status */
-#include <babeltrace/graph/notification-iterator.h>
-
-/* For enum bt_query_status */
-#include <babeltrace/graph/query-executor.h>
-
/* For bt_bool */
#include <babeltrace/types.h>
-/* For bt_notification_array */
-#include <babeltrace/graph/notification.h>
-
#ifdef __cplusplus
extern "C" {
#endif
struct bt_component_class;
-struct bt_component;
-struct bt_private_component;
-struct bt_private_port;
-struct bt_port;
-struct bt_value;
-struct bt_private_connection_private_notification_iterator;
-struct bt_query_executor;
-/**
- * Component class type.
- */
enum bt_component_class_type {
- BT_COMPONENT_CLASS_TYPE_UNKNOWN = -1,
-
- /** A source component is a notification generator. */
BT_COMPONENT_CLASS_TYPE_SOURCE = 0,
-
- /** A sink component handles incoming notifications. */
- BT_COMPONENT_CLASS_TYPE_SINK = 1,
-
- /** A filter component implements both Source and Sink interfaces. */
- BT_COMPONENT_CLASS_TYPE_FILTER = 2,
+ BT_COMPONENT_CLASS_TYPE_FILTER = 1,
+ BT_COMPONENT_CLASS_TYPE_SINK = 2,
};
-struct bt_component_class_query_method_return {
- struct bt_value *result;
- enum bt_query_status status;
-};
-
-typedef enum bt_component_status (*bt_component_class_init_method)(
- struct bt_private_component *private_component,
- struct bt_value *params, void *init_method_data);
-
-typedef void (*bt_component_class_finalize_method)(
- struct bt_private_component *private_component);
-
-typedef enum bt_notification_iterator_status
- (*bt_component_class_notification_iterator_init_method)(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
- struct bt_private_port *private_port);
-
-typedef void (*bt_component_class_notification_iterator_finalize_method)(
- struct bt_private_connection_private_notification_iterator *notification_iterator);
-
-typedef enum bt_notification_iterator_status
-(*bt_component_class_notification_iterator_next_method)(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
- bt_notification_array notifs, uint64_t capacity,
- uint64_t *count);
-
-typedef struct bt_component_class_query_method_return (*bt_component_class_query_method)(
- struct bt_component_class *component_class,
- struct bt_query_executor *query_executor,
- const char *object, struct bt_value *params);
-
-typedef enum bt_component_status (*bt_component_class_accept_port_connection_method)(
- struct bt_private_component *private_component,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port);
-
-typedef enum bt_component_status (*bt_component_class_port_connected_method)(
- struct bt_private_component *private_component,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port);
-
-typedef void (*bt_component_class_port_disconnected_method)(
- struct bt_private_component *private_component,
- struct bt_private_port *private_port);
-
-extern int bt_component_class_set_init_method(
- struct bt_component_class *component_class,
- bt_component_class_init_method method);
-
-extern int bt_component_class_set_finalize_method(
- struct bt_component_class *component_class,
- bt_component_class_finalize_method method);
-
-extern int bt_component_class_set_accept_port_connection_method(
- struct bt_component_class *component_class,
- bt_component_class_accept_port_connection_method method);
-
-extern int bt_component_class_set_port_connected_method(
- struct bt_component_class *component_class,
- bt_component_class_port_connected_method method);
-
-extern int bt_component_class_set_port_disconnected_method(
- struct bt_component_class *component_class,
- bt_component_class_port_disconnected_method method);
-
-extern int bt_component_class_set_query_method(
- struct bt_component_class *component_class,
- bt_component_class_query_method method);
-
-extern int bt_component_class_set_description(
- struct bt_component_class *component_class,
- const char *description);
-
-extern int bt_component_class_set_help(
- struct bt_component_class *component_class,
- const char *help);
-
-extern int bt_component_class_freeze(
- struct bt_component_class *component_class);
-
-/**
- * Get a component class' name.
- *
- * @param component_class Component class of which to get the name
- * @returns Name of the component class
- */
extern const char *bt_component_class_get_name(
struct bt_component_class *component_class);
-/**
- * Get a component class' description.
- *
- * Component classes may provide an optional description. It may, however,
- * opt not to.
- *
- * @param component_class Component class of which to get the description
- * @returns Description of the component class, or NULL.
- */
extern const char *bt_component_class_get_description(
struct bt_component_class *component_class);
extern const char *bt_component_class_get_help(
struct bt_component_class *component_class);
-/**
- * Get a component class' type.
- *
- * @param component_class Component class of which to get the type
- * @returns One of #bt_component_type
- */
extern enum bt_component_class_type bt_component_class_get_type(
struct bt_component_class *component_class);
#define BABELTRACE_GRAPH_COMPONENT_FILTER_INTERNAL_H
/*
- * BabelTrace - Filter Component Internal
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/component-class-internal.h>
-struct bt_value;
-
struct bt_component_filter {
struct bt_component parent;
};
-/**
- * Allocate a filter component.
- *
- * @param class Component class
- * @param params A dictionary of component parameters
- * @returns A filter component instance
- */
BT_HIDDEN
struct bt_component *bt_component_filter_create(
struct bt_component_class *class);
#define BABELTRACE_GRAPH_COMPONENT_FILTER_H
/*
- * BabelTrace - Filter Plug-in Interface
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
extern "C" {
#endif
-struct bt_port;
struct bt_component;
+struct bt_component_filter;
+struct bt_port_input;
+struct bt_port_output;
+
+static inline
+struct bt_component *bt_component_filter_borrow_component(
+ struct bt_component_filter *component)
+{
+ return (void *) component;
+}
+
+extern uint64_t bt_component_filter_get_input_port_count(
+ struct bt_component_filter *component);
+
+extern struct bt_port_input *bt_component_filter_borrow_input_port_by_name(
+ struct bt_component_filter *component, const char *name);
+
+extern struct bt_port_input *bt_component_filter_borrow_input_port_by_index(
+ struct bt_component_filter *component, uint64_t index);
+
+extern uint64_t bt_component_filter_get_output_port_count(
+ struct bt_component_filter *component);
+
+extern struct bt_port_output *bt_component_filter_borrow_output_port_by_name(
+ struct bt_component_filter *component, const char *name);
-extern int64_t bt_component_filter_get_input_port_count(
- struct bt_component *component);
-extern struct bt_port *bt_component_filter_get_input_port_by_name(
- struct bt_component *component, const char *name);
-extern struct bt_port *bt_component_filter_get_input_port_by_index(
- struct bt_component *component, uint64_t index);
-
-extern int64_t bt_component_filter_get_output_port_count(
- struct bt_component *component);
-extern struct bt_port *bt_component_filter_get_output_port_by_name(
- struct bt_component *component, const char *name);
-extern struct bt_port *bt_component_filter_get_output_port_by_index(
- struct bt_component *component, uint64_t index);
+extern struct bt_port_output *bt_component_filter_borrow_output_port_by_index(
+ struct bt_component_filter *component, uint64_t index);
#ifdef __cplusplus
}
#define BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
/*
- * BabelTrace - Component internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bool initialized;
};
-static inline
-struct bt_private_component *bt_private_component_from_component(
- struct bt_component *component)
-{
- return (void *) component;
-}
-
static inline
struct bt_graph *bt_component_borrow_graph(struct bt_component *comp)
{
}
BT_HIDDEN
-enum bt_component_status bt_component_create(
- struct bt_component_class *component_class,
+int bt_component_create(struct bt_component_class *component_class,
const char *name, struct bt_component **component);
BT_HIDDEN
-enum bt_component_status bt_component_accept_port_connection(
+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_component_status bt_component_port_connected(
+enum bt_self_component_status bt_component_port_connected(
struct bt_component *comp,
struct bt_port *self_port, struct bt_port *other_port);
struct bt_graph *graph);
BT_HIDDEN
-int64_t bt_component_get_input_port_count(struct bt_component *comp);
+uint64_t bt_component_get_input_port_count(struct bt_component *comp);
BT_HIDDEN
-int64_t bt_component_get_output_port_count(struct bt_component *comp);
+uint64_t bt_component_get_output_port_count(struct bt_component *comp);
BT_HIDDEN
-struct bt_port *bt_component_get_input_port_by_index(struct bt_component *comp,
- uint64_t index);
+struct bt_port_input *bt_component_borrow_input_port_by_index(
+ struct bt_component *comp, uint64_t index);
BT_HIDDEN
-struct bt_port *bt_component_get_output_port_by_index(struct bt_component *comp,
- uint64_t index);
+struct bt_port_output *bt_component_borrow_output_port_by_index(
+ struct bt_component *comp, uint64_t index);
BT_HIDDEN
-struct bt_port *bt_component_get_input_port_by_name(struct bt_component *comp,
- const char *name);
+struct bt_port_input *bt_component_borrow_input_port_by_name(
+ struct bt_component *comp, const char *name);
BT_HIDDEN
-struct bt_port *bt_component_get_output_port_by_name(struct bt_component *comp,
- const char *name);
+struct bt_port_output *bt_component_borrow_output_port_by_name(
+ struct bt_component *comp, const char *name);
BT_HIDDEN
-struct bt_port *bt_component_add_input_port(
+struct bt_port_input *bt_component_add_input_port(
struct bt_component *component, const char *name,
void *user_data);
BT_HIDDEN
-struct bt_port *bt_component_add_output_port(
+struct bt_port_output *bt_component_add_output_port(
struct bt_component *component, const char *name,
void *user_data);
BT_HIDDEN
-enum bt_component_status bt_component_remove_port(
- struct bt_component *component, struct bt_port *port);
+void bt_component_remove_port(struct bt_component *component,
+ struct bt_port *port);
BT_HIDDEN
void bt_component_add_destroy_listener(struct bt_component *component,
bt_component_destroy_listener_func func, void *data);
static inline
-const char *bt_component_status_string(enum bt_component_status status)
+const char *bt_self_component_status_string(
+ enum bt_self_component_status status)
{
switch (status) {
- case BT_COMPONENT_STATUS_OK:
- return "BT_COMPONENT_STATUS_OK";
- case BT_COMPONENT_STATUS_END:
- return "BT_COMPONENT_STATUS_END";
- case BT_COMPONENT_STATUS_AGAIN:
- return "BT_COMPONENT_STATUS_AGAIN";
- case BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION:
- return "BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION";
- case BT_COMPONENT_STATUS_ERROR:
- return "BT_COMPONENT_STATUS_ERROR";
- case BT_COMPONENT_STATUS_UNSUPPORTED:
- return "BT_COMPONENT_STATUS_UNSUPPORTED";
- case BT_COMPONENT_STATUS_INVALID:
- return "BT_COMPONENT_STATUS_INVALID";
- case BT_COMPONENT_STATUS_NOMEM:
- return "BT_COMPONENT_STATUS_NOMEM";
- case BT_COMPONENT_STATUS_NOT_FOUND:
- return "BT_COMPONENT_STATUS_NOT_FOUND";
- case BT_COMPONENT_STATUS_GRAPH_IS_CANCELED:
- return "BT_COMPONENT_STATUS_GRAPH_IS_CANCELED";
+ case BT_SELF_COMPONENT_STATUS_OK:
+ return "BT_SELF_COMPONENT_STATUS_OK";
+ case BT_SELF_COMPONENT_STATUS_END:
+ 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_SELF_COMPONENT_STATUS_NOMEM";
default:
return "(unknown)";
}
#define BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H
/*
- * BabelTrace - Sink Component internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/component-class-internal.h>
-struct bt_value;
-
-//typedef uint32_t notification_mask_t;
-
struct bt_component_sink {
struct bt_component parent;
};
-/**
- * Allocate a sink component.
- *
- * @param class Component class
- * @param params A dictionary of component parameters
- * @returns A sink component instance
- */
BT_HIDDEN
struct bt_component *bt_component_sink_create(
struct bt_component_class *class);
BT_HIDDEN
void bt_component_sink_destroy(struct bt_component *component);
-static inline
-enum bt_component_status bt_component_sink_consume(
- struct bt_component *component)
-{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- struct bt_component_class_sink *sink_class = NULL;
-
- BT_ASSERT(component);
- BT_ASSERT(bt_component_get_class_type(component) ==
- BT_COMPONENT_CLASS_TYPE_SINK);
- sink_class = container_of(component->class,
- struct bt_component_class_sink, parent);
- BT_ASSERT(sink_class->methods.consume);
- BT_LOGD("Calling user's consume method: "
- "comp-addr=%p, comp-name=\"%s\"",
- component, bt_component_get_name(component));
- ret = sink_class->methods.consume(
- bt_private_component_from_component(component));
- BT_LOGD("User method returned: status=%s",
- bt_component_status_string(ret));
- if (ret < 0) {
- BT_LOGW_STR("Consume method failed.");
- }
-
- return ret;
-}
-
#endif /* BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H */
#define BABELTRACE_GRAPH_COMPONENT_SINK_H
/*
- * BabelTrace - Sink Component Interface
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#endif
struct bt_component;
+struct bt_component_sink;
+struct bt_port_input;
+
+static inline
+struct bt_component *bt_component_sink_borrow_component(
+ struct bt_component_sink *component)
+{
+ return (void *) component;
+}
+
+extern uint64_t bt_component_sink_get_input_port_count(
+ struct bt_component_sink *component);
+
+extern struct bt_port_input *bt_component_sink_borrow_input_port_by_name(
+ struct bt_component_sink *component, const char *name);
-extern int64_t bt_component_sink_get_input_port_count(
- struct bt_component *component);
-extern struct bt_port *bt_component_sink_get_input_port_by_name(
- struct bt_component *component, const char *name);
-extern struct bt_port *bt_component_sink_get_input_port_by_index(
- struct bt_component *component, uint64_t index);
+extern struct bt_port_input *bt_component_sink_borrow_input_port_by_index(
+ struct bt_component_sink *component, uint64_t index);
#ifdef __cplusplus
}
#define BABELTRACE_GRAPH_COMPONENT_SOURCE_INTERNAL_H
/*
- * BabelTrace - Source Component internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/component-class-internal.h>
-struct bt_value;
-
struct bt_component_source {
struct bt_component parent;
};
-/**
- * Allocate a source component.
- *
- * @param class Component class
- * @param params A dictionary of component parameters
- * @returns A source component instance
- */
BT_HIDDEN
struct bt_component *bt_component_source_create(
struct bt_component_class *class);
#define BABELTRACE_GRAPH_COMPONENT_SOURCE_H
/*
- * BabelTrace - Source Plug-in Interface
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#endif
struct bt_component;
+struct bt_component_source;
+struct bt_port_output;
+
+static inline
+struct bt_component *bt_component_source_borrow_component(
+ struct bt_component_source *component)
+{
+ return (void *) component;
+}
+
+extern uint64_t bt_component_source_get_output_port_count(
+ struct bt_component_source *component);
+
+extern struct bt_port_output *bt_component_source_borrow_output_port_by_name(
+ struct bt_component_source *component, const char *name);
-extern int64_t bt_component_source_get_output_port_count(
- struct bt_component *component);
-extern struct bt_port *bt_component_source_get_output_port_by_name(
- struct bt_component *component, const char *name);
-extern struct bt_port *bt_component_source_get_output_port_by_index(
- struct bt_component *component, uint64_t index);
+extern struct bt_port_output *bt_component_source_borrow_output_port_by_index(
+ struct bt_component_source *component, uint64_t index);
#ifdef __cplusplus
}
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_STATUS_H
-#define BABELTRACE_GRAPH_COMPONENT_STATUS_H
-
-/*
- * BabelTrace - Babeltrace Component Interface
- *
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Status code. Errors are always negative.
- */
-enum bt_component_status {
- /** No error, okay. */
- BT_COMPONENT_STATUS_OK = 0,
- /** No more work to be done by this component. **/
- BT_COMPONENT_STATUS_END = 1,
- /**
- * Component can't process a notification at this time
- * (e.g. would block), try again later.
- */
- BT_COMPONENT_STATUS_AGAIN = 11,
- /** Refuse port connection. */
- BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111,
- /** General error. */
- BT_COMPONENT_STATUS_ERROR = -1,
- /** Unsupported component feature. */
- BT_COMPONENT_STATUS_UNSUPPORTED = -2,
- /** Invalid arguments. */
- BT_COMPONENT_STATUS_INVALID = -22,
- /** Memory allocation failure. */
- BT_COMPONENT_STATUS_NOMEM = -12,
- /** Element not found. */
- BT_COMPONENT_STATUS_NOT_FOUND = -19,
- BT_COMPONENT_STATUS_GRAPH_IS_CANCELED = 125,
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_STATUS_H */
#define BABELTRACE_GRAPH_COMPONENT_H
/*
- * BabelTrace - Babeltrace Component Interface
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
/* For bt_bool */
#include <babeltrace/types.h>
-/* For bt_object_get_ref */
-#include <babeltrace/object.h>
-
#ifdef __cplusplus
extern "C" {
#endif
#define BABELTRACE_GRAPH_CONNECTION_INTERNAL_H
/*
- * BabelTrace - Component Connection Internal
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/graph/connection.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-iterator-internal.h>
-#include <babeltrace/graph/private-connection.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/assert-internal.h>
#include <stdbool.h>
GPtrArray *iterators;
bool notified_upstream_port_connected;
+ bool notified_upstream_port_disconnected;
bool notified_downstream_port_connected;
+ bool notified_downstream_port_disconnected;
bool notified_graph_ports_connected;
+ bool notified_graph_ports_disconnected;
};
-static inline
-struct bt_private_connection *bt_private_connection_from_connection(
- struct bt_connection *connection)
-{
- return (void *) connection;
-}
-
BT_HIDDEN
struct bt_connection *bt_connection_create(struct bt_graph *graph,
struct bt_port *upstream_port,
BT_HIDDEN
void bt_connection_remove_iterator(struct bt_connection *conn,
- struct bt_notification_iterator_private_connection *iterator);
+ struct bt_self_component_port_input_notification_iterator *iterator);
static inline
struct bt_graph *bt_connection_borrow_graph(struct bt_connection *conn)
return (void *) conn->base.parent;
}
-static inline
-enum bt_connection_status
-bt_connection_status_from_notification_iterator_status(
- enum bt_notification_iterator_status iter_status)
-{
- switch (iter_status) {
- case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED:
- return BT_CONNECTION_STATUS_ERROR;
- case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
- return BT_CONNECTION_STATUS_ERROR;
- case BT_NOTIFICATION_ITERATOR_STATUS_END:
- return BT_CONNECTION_STATUS_ERROR;
- case BT_NOTIFICATION_ITERATOR_STATUS_OK:
- return BT_CONNECTION_STATUS_OK;
- case BT_NOTIFICATION_ITERATOR_STATUS_INVALID:
- return BT_CONNECTION_STATUS_INVALID;
- case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
- return BT_CONNECTION_STATUS_ERROR;
- case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
- return BT_CONNECTION_STATUS_NOMEM;
- case BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED:
- return BT_CONNECTION_STATUS_ERROR;
- default:
-#ifdef BT_LOGF
- BT_LOGF("Unknown notification iterator status: status=%d",
- iter_status);
-#endif
- abort();
- }
-}
-
-static inline
-const char *bt_connection_status_string(enum bt_connection_status status)
-{
- switch (status) {
- case BT_CONNECTION_STATUS_GRAPH_IS_CANCELED:
- return "BT_CONNECTION_STATUS_GRAPH_IS_CANCELED";
- case BT_CONNECTION_STATUS_OK:
- return "BT_CONNECTION_STATUS_OK";
- case BT_CONNECTION_STATUS_INVALID:
- return "BT_CONNECTION_STATUS_INVALID";
- case BT_CONNECTION_STATUS_ERROR:
- return "BT_CONNECTION_STATUS_ERROR";
- case BT_CONNECTION_STATUS_NOMEM:
- return "BT_CONNECTION_STATUS_NOMEM";
- case BT_CONNECTION_STATUS_IS_ENDED:
- return "BT_CONNECTION_STATUS_IS_ENDED";
- default:
- return "(unknown)";
- }
-}
-
#endif /* BABELTRACE_GRAPH_CONNECTION_INTERNAL_H */
#define BABELTRACE_GRAPH_CONNECTION_H
/*
- * BabelTrace - Babeltrace Component Connection Interface
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
extern "C" {
#endif
-struct bt_component;
+struct bt_port_input;
+struct bt_port_output;
struct bt_connection;
-enum bt_connection_status {
- BT_CONNECTION_STATUS_GRAPH_IS_CANCELED = 125,
- BT_CONNECTION_STATUS_OK = 0,
- BT_CONNECTION_STATUS_INVALID = -22,
- BT_CONNECTION_STATUS_ERROR = -1,
- BT_CONNECTION_STATUS_NOMEM = -12,
- BT_CONNECTION_STATUS_IS_ENDED = 104,
-};
-
-/* Returns the "downstream" input port. */
-extern struct bt_port *bt_connection_get_downstream_port(
+extern struct bt_port_input *bt_connection_borrow_downstream_port(
struct bt_connection *connection);
-/* Returns the "upstream" output port. */
-extern struct bt_port *bt_connection_get_upstream_port(
+
+extern struct bt_port_output *bt_connection_borrow_upstream_port(
struct bt_connection *connection);
extern bt_bool bt_connection_is_ended(struct bt_connection *connection);
#define BABELTRACE_GRAPH_GRAPH_INTERNAL_H
/*
- * BabelTrace - Component Graph Internal
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/graph/graph.h>
#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/component-status.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
/* Queue of pointers (weak references) to sink bt_components. */
GQueue *sinks_to_consume;
- bt_bool canceled;
- bt_bool in_remove_listener;
- bt_bool has_sink;
+ bool canceled;
+ bool in_remove_listener;
+ bool has_sink;
/*
- * If this is BT_FALSE, then the public API's consuming
+ * If this is false, then the public API's consuming
* functions (bt_graph_consume() and bt_graph_run()) return
* BT_GRAPH_STATUS_CANNOT_CONSUME. The internal "no check"
* functions always work.
*
- * In bt_output_port_notification_iterator_create(), on success,
+ * In bt_port_output_notification_iterator_create(), on success,
* this flag is cleared so that the iterator remains the only
* consumer for the graph's lifetime.
*/
- bt_bool can_consume;
+ bool can_consume;
struct {
- GArray *port_added;
- GArray *port_removed;
- GArray *ports_connected;
- GArray *ports_disconnected;
+ GArray *source_output_port_added;
+ GArray *filter_output_port_added;
+ GArray *filter_input_port_added;
+ GArray *sink_input_port_added;
+ GArray *source_output_port_removed;
+ GArray *filter_output_port_removed;
+ GArray *filter_input_port_removed;
+ GArray *sink_input_port_removed;
+ GArray *source_filter_ports_connected;
+ GArray *source_sink_ports_connected;
+ GArray *filter_sink_ports_connected;
+ GArray *source_filter_ports_disconnected;
+ GArray *source_sink_ports_disconnected;
+ GArray *filter_sink_ports_disconnected;
} listeners;
/* Pool of `struct bt_notification_event *` */
};
static inline
-void _bt_graph_set_can_consume(struct bt_graph *graph, bt_bool can_consume)
+void _bt_graph_set_can_consume(struct bt_graph *graph, bool can_consume)
{
BT_ASSERT(graph);
graph->can_consume = can_consume;
BT_HIDDEN
enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph,
- struct bt_component *sink);
+ struct bt_component_sink *sink);
BT_HIDDEN
void bt_graph_notify_port_added(struct bt_graph *graph, struct bt_port *port);
return "BT_GRAPH_STATUS_END";
case BT_GRAPH_STATUS_OK:
return "BT_GRAPH_STATUS_OK";
- case BT_GRAPH_STATUS_INVALID:
- return "BT_GRAPH_STATUS_INVALID";
case BT_GRAPH_STATUS_NO_SINK:
return "BT_GRAPH_STATUS_NO_SINK";
case BT_GRAPH_STATUS_ERROR:
}
}
-static inline
-enum bt_graph_status bt_graph_status_from_component_status(
- enum bt_component_status comp_status)
-{
- switch (comp_status) {
- case BT_COMPONENT_STATUS_OK:
- return BT_GRAPH_STATUS_OK;
- case BT_COMPONENT_STATUS_END:
- return BT_GRAPH_STATUS_END;
- case BT_COMPONENT_STATUS_AGAIN:
- return BT_GRAPH_STATUS_AGAIN;
- case BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION:
- return BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION;
- case BT_COMPONENT_STATUS_ERROR:
- return BT_GRAPH_STATUS_ERROR;
- case BT_COMPONENT_STATUS_UNSUPPORTED:
- return BT_GRAPH_STATUS_ERROR;
- case BT_COMPONENT_STATUS_INVALID:
- return BT_GRAPH_STATUS_INVALID;
- case BT_COMPONENT_STATUS_NOMEM:
- return BT_GRAPH_STATUS_NOMEM;
- case BT_COMPONENT_STATUS_NOT_FOUND:
- return BT_GRAPH_STATUS_ERROR;
- default:
-#ifdef BT_LOGF
- BT_LOGF("Unknown component status: status=%d", comp_status);
-#endif
- abort();
- }
-}
-
#endif /* BABELTRACE_GRAPH_GRAPH_INTERNAL_H */
/* For bt_bool */
#include <babeltrace/types.h>
-/* For enum bt_component_status */
-#include <babeltrace/graph/component-status.h>
-
#ifdef __cplusplus
extern "C" {
#endif
struct bt_graph;
enum bt_graph_status {
+ BT_GRAPH_STATUS_OK = 0,
+ BT_GRAPH_STATUS_END = 1,
+ BT_GRAPH_STATUS_AGAIN = 11,
BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111,
- /** Canceled. */
- BT_GRAPH_STATUS_CANCELED = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED,
- /** No sink can consume at the moment. */
- BT_GRAPH_STATUS_AGAIN = BT_COMPONENT_STATUS_AGAIN,
- /** Downstream component does not support multiple inputs. */
- BT_GRAPH_STATUS_END = BT_COMPONENT_STATUS_END,
- BT_GRAPH_STATUS_OK = BT_COMPONENT_STATUS_OK,
- /** Invalid arguments. */
- BT_GRAPH_STATUS_INVALID = BT_COMPONENT_STATUS_INVALID,
- /** No sink in graph. */
+ BT_GRAPH_STATUS_CANCELED = 125,
+ BT_GRAPH_STATUS_ERROR = -1,
BT_GRAPH_STATUS_NO_SINK = -6,
- /** General error. */
- BT_GRAPH_STATUS_ERROR = BT_COMPONENT_STATUS_ERROR,
- BT_GRAPH_STATUS_NOMEM = BT_COMPONENT_STATUS_NOMEM,
+ BT_GRAPH_STATUS_NOMEM = -12,
};
extern bt_bool bt_graph_is_canceled(struct bt_graph *graph);
#define BABELTRACE_GRAPH_NOTIFICATION_EVENT_INTERNAL_H
/*
- * BabelTrace - Plug-in Event Notification internal
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_GRAPH_NOTIFICATION_NOTIFICATION_INTERNAL_H
/*
- * BabelTrace - Plug-in Notification internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_INTERNAL_H
/*
- * BabelTrace - Notification Iterator Internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
#include <babeltrace/graph/connection.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/graph/notification-iterator.h>
-#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
#include <stdbool.h>
struct bt_graph;
enum bt_notification_iterator_type {
- BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION,
- BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT,
-};
-
-enum bt_private_connection_notification_iterator_notif_type {
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_EVENT = (1U << 0),
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_INACTIVITY = (1U << 1),
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_STREAM_BEGIN = (1U << 2),
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_STREAM_END = (1U << 3),
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_PACKET_BEGIN = (1U << 4),
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_PACKET_END = (1U << 5),
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_DISCARDED_EVENTS = (1U << 6),
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_NOTIF_TYPE_DISCARDED_PACKETS = (1U << 7),
+ BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT,
+ BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT,
};
-enum bt_private_connection_notification_iterator_state {
+enum bt_self_component_port_input_notification_iterator_state {
/* Iterator is not initialized. */
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED,
+ BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED,
/* Iterator is active, not at the end yet, and not finalized. */
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE,
+ BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE,
/*
* Iterator is ended, not finalized yet: the "next" method
* returns BT_NOTIFICATION_ITERATOR_STATUS_END.
*/
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED,
+ BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED,
/*
* Iterator is finalized, but not at the end yet. This means
* before returning the BT_NOTIFICATION_ITERATOR_STATUS_CANCELED
* status.
*/
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED,
+ BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED,
/*
* Iterator is finalized and ended: the "next" method always
* returns BT_NOTIFICATION_ITERATOR_STATUS_CANCELED.
*/
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED,
+ BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED,
};
struct bt_notification_iterator {
GPtrArray *notifs;
};
-struct bt_notification_iterator_private_connection {
+struct bt_self_component_port_input_notification_iterator {
struct bt_notification_iterator base;
struct bt_component *upstream_component; /* Weak */
struct bt_port *upstream_port; /* Weak */
*/
GHashTable *stream_states;
- enum bt_private_connection_notification_iterator_state state;
+ enum bt_self_component_port_input_notification_iterator_state state;
void *user_data;
};
-struct bt_notification_iterator_output_port {
+struct bt_port_output_notification_iterator {
struct bt_notification_iterator base;
struct bt_graph *graph; /* Owned by this */
- struct bt_component *colander; /* Owned by this */
+ struct bt_component_sink *colander; /* Owned by this */
/*
* Only used temporarily as a bridge between a colander sink and
uint64_t count;
};
-static inline
-struct bt_private_connection_private_notification_iterator *
-bt_private_connection_private_notification_iterator_from_notification_iterator(
- struct bt_notification_iterator_private_connection *iterator)
-{
- return (void *) iterator;
-}
-
-BT_HIDDEN
-enum bt_connection_status bt_private_connection_notification_iterator_create(
- struct bt_component *upstream_comp,
- struct bt_port *upstream_port,
- struct bt_connection *connection,
- struct bt_notification_iterator_private_connection **iterator);
-
BT_HIDDEN
-void bt_private_connection_notification_iterator_finalize(
- struct bt_notification_iterator_private_connection *iterator);
+void bt_self_component_port_input_notification_iterator_finalize(
+ struct bt_self_component_port_input_notification_iterator *iterator);
BT_HIDDEN
-void bt_private_connection_notification_iterator_set_connection(
- struct bt_notification_iterator_private_connection *iterator,
+void bt_self_component_port_input_notification_iterator_set_connection(
+ struct bt_self_component_port_input_notification_iterator *iterator,
struct bt_connection *connection);
static inline
return "BT_NOTIFICATION_ITERATOR_STATUS_END";
case BT_NOTIFICATION_ITERATOR_STATUS_OK:
return "BT_NOTIFICATION_ITERATOR_STATUS_OK";
- case BT_NOTIFICATION_ITERATOR_STATUS_INVALID:
- return "BT_NOTIFICATION_ITERATOR_STATUS_INVALID";
case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
return "BT_NOTIFICATION_ITERATOR_STATUS_ERROR";
case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
return "BT_NOTIFICATION_ITERATOR_STATUS_NOMEM";
- case BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED:
- return "BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED";
default:
return "(unknown)";
}
};
static inline
-const char *bt_private_connection_notification_iterator_state_string(
- enum bt_private_connection_notification_iterator_state state)
+const char *bt_self_component_port_input_notification_iterator_state_string(
+ enum bt_self_component_port_input_notification_iterator_state state)
{
switch (state) {
- case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE:
- return "BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE";
- case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED:
- return "BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED";
- case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED:
- return "BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED";
- case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED:
- return "BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED";
+ case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE:
+ return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE";
+ case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED:
+ return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED";
+ case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED:
+ return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED";
+ case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED:
+ return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED";
default:
return "(unknown)";
}
struct bt_notification;
struct bt_notification_iterator;
-/**
- * Status code. Errors are always negative.
- */
enum bt_notification_iterator_status {
- /** Canceled. */
- BT_NOTIFICATION_ITERATOR_STATUS_CANCELED = 125,
- /** No notifications available for now. Try again later. */
- BT_NOTIFICATION_ITERATOR_STATUS_AGAIN = 11,
- /** No more notifications to be delivered. */
- BT_NOTIFICATION_ITERATOR_STATUS_END = 1,
- /** No error, okay. */
BT_NOTIFICATION_ITERATOR_STATUS_OK = 0,
- /** Invalid arguments. */
- BT_NOTIFICATION_ITERATOR_STATUS_INVALID = -22,
- /** General error. */
+ BT_NOTIFICATION_ITERATOR_STATUS_END = 1,
+ BT_NOTIFICATION_ITERATOR_STATUS_AGAIN = 11,
+ BT_NOTIFICATION_ITERATOR_STATUS_CANCELED = 125,
BT_NOTIFICATION_ITERATOR_STATUS_ERROR = -1,
- /** Out of memory. */
BT_NOTIFICATION_ITERATOR_STATUS_NOMEM = -12,
- /** Unsupported iterator feature. */
- BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED = -2,
};
#ifdef __cplusplus
#define BABELTRACE_GRAPH_NOTIFICATION_PACKET_INTERNAL_H
/*
- * BabelTrace - Packet-related Notifications
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_GRAPH_NOTIFICATION_STREAM_INTERNAL_H
/*
- * BabelTrace - Stream-related Notifications
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#endif
struct bt_notification;
-struct bt_private_connection_private_notification_iterator;
+struct bt_self_notification_iterator;
struct bt_clock_value;
struct bt_stream;
#define BABELTRACE_GRAPH_NOTIFICATION_H
/*
- * BabelTrace - Plug-in Notification
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_OUTPUT_PORT_NOTIFICATION_ITERATOR_H
-#define BABELTRACE_GRAPH_OUTPUT_PORT_NOTIFICATION_ITERATOR_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* For enum bt_notification_iterator_status */
-#include <babeltrace/graph/notification-iterator.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_port;
-struct bt_notification;
-struct bt_notification_iterator;
-
-extern struct bt_notification_iterator *bt_output_port_notification_iterator_create(
- struct bt_port *port, const char *colander_component_name);
-
-extern enum bt_notification_iterator_status
-bt_output_port_notification_iterator_next(
- struct bt_notification_iterator *iterator,
- bt_notification_array *notifs, uint64_t *count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_OUTPUT_PORT_NOTIFICATION_ITERATOR_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_INPUT_H
+#define BABELTRACE_GRAPH_PORT_INPUT_H
+
+/*
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_port;
+struct bt_port_input;
+
+static inline
+struct bt_port *bt_port_input_borrow_port(struct bt_port_input *port_input)
+{
+ return (void *) port_input;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PORT_INPUT_H */
#define BABELTRACE_GRAPH_PORT_INTERNAL_H
/*
- * BabelTrace - Babeltrace Component Port
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
void *user_data;
};
-static inline
-struct bt_private_port *bt_private_port_from_port(
- struct bt_port *port)
-{
- return (void *) port;
-}
-
BT_HIDDEN
struct bt_port *bt_port_create(struct bt_component *parent_component,
enum bt_port_type type, const char *name, void *user_data);
return "BT_PORT_TYPE_INPUT";
case BT_PORT_TYPE_OUTPUT:
return "BT_PORT_TYPE_OUTPUT";
- case BT_PORT_TYPE_UNKOWN:
- return "BT_PORT_TYPE_UNKOWN";
default:
return "(unknown)";
}
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_NOTIFICATION_ITERATOR_H
+#define BABELTRACE_GRAPH_PORT_OUTPUT_NOTIFICATION_ITERATOR_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_notification_iterator_status */
+#include <babeltrace/graph/notification-iterator.h>
+
+/* For bt_notification_array */
+#include <babeltrace/graph/notification.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_port;
+struct bt_notification;
+struct bt_notification_iterator;
+struct bt_port_output_notification_iterator;
+struct bt_private_graph;
+struct bt_port_output;
+
+static inline
+struct bt_notification_iterator *
+bt_port_output_notification_iterator_borrow_notification_iterator(
+ struct bt_port_output_notification_iterator *iterator)
+{
+ return (void *) iterator;
+}
+
+extern struct bt_port_output_notification_iterator *bt_port_output_notification_iterator_create(
+ struct bt_private_graph *graph,
+ struct bt_port_output *output_port,
+ const char *colander_component_name);
+
+extern enum bt_notification_iterator_status
+bt_port_output_notification_iterator_next(
+ struct bt_port_output_notification_iterator *iterator,
+ bt_notification_array *notifs, uint64_t *count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_NOTIFICATION_ITERATOR_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_H
+#define BABELTRACE_GRAPH_PORT_OUTPUT_H
+
+/*
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_port;
+struct bt_port_output;
+
+static inline
+struct bt_port *bt_port_output_borrow_port(struct bt_port_output *port_output)
+{
+ return (void *) port_output;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_H */
#define BABELTRACE_GRAPH_PORT_H
/*
- * BabelTrace - Babeltrace Component Connection Interface
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
struct bt_port;
struct bt_connection;
-
-enum bt_port_status {
- BT_PORT_STATUS_OK = 0,
- BT_PORT_STATUS_ERROR = -1,
- BT_PORT_STATUS_INVALID = -2,
-};
+struct bt_component;
enum bt_port_type {
BT_PORT_TYPE_INPUT = 0,
BT_PORT_TYPE_OUTPUT = 1,
- BT_PORT_TYPE_UNKOWN = -1,
};
extern const char *bt_port_get_name(struct bt_port *port);
+
extern enum bt_port_type bt_port_get_type(struct bt_port *port);
-extern struct bt_connection *bt_port_get_connection(struct bt_port *port);
-extern struct bt_component *bt_port_get_component(struct bt_port *port);
-extern enum bt_port_status bt_port_disconnect(struct bt_port *port);
+
+extern struct bt_connection *bt_port_borrow_connection(struct bt_port *port);
+
+extern struct bt_component *bt_port_borrow_component(struct bt_port *port);
+
extern bt_bool bt_port_is_connected(struct bt_port *port);
static inline
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_FILTER_H
+#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_FILTER_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_notification_array */
+#include <babeltrace/graph/notification.h>
+
+/* For enum bt_self_component_status */
+#include <babeltrace/graph/self-component.h>
+
+/* For enum bt_query_status */
+#include <babeltrace/graph/query-executor.h>
+
+/* For enum bt_self_notification_iterator_status */
+#include <babeltrace/graph/self-notification-iterator.h>
+
+/* For struct bt_private_component_class_query_method_return */
+#include <babeltrace/graph/private-component-class.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_self_component_class_filter;
+struct bt_component_class_filter;
+struct bt_self_component_filter;
+struct bt_private_component_class;
+struct bt_private_component_class_filter;
+struct bt_self_component_port_input;
+struct bt_self_component_port_output;
+struct bt_port_input;
+struct bt_port_output;
+struct bt_query_executor;
+struct bt_value;
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_filter_init_method)(
+ struct bt_self_component_filter *self_component,
+ struct bt_value *params, void *init_method_data);
+
+typedef void (*bt_private_component_class_filter_finalize_method)(
+ struct bt_self_component_filter *self_component);
+
+typedef enum bt_self_notification_iterator_status
+(*bt_private_component_class_filter_notification_iterator_init_method)(
+ struct bt_self_notification_iterator *notification_iterator,
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_output *port);
+
+typedef void
+(*bt_private_component_class_filter_notification_iterator_finalize_method)(
+ struct bt_self_notification_iterator *notification_iterator);
+
+typedef enum bt_self_notification_iterator_status
+(*bt_private_component_class_filter_notification_iterator_next_method)(
+ struct bt_self_notification_iterator *notification_iterator,
+ bt_notification_array notifs, uint64_t capacity,
+ uint64_t *count);
+
+typedef enum bt_query_status
+(*bt_private_component_class_filter_query_method)(
+ struct bt_self_component_class_filter *comp_class,
+ struct bt_query_executor *query_executor,
+ const char *object, struct bt_value *params,
+ struct bt_value **result);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_filter_accept_input_port_connection_method)(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_filter_accept_output_port_connection_method)(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_output *self_port,
+ struct bt_port_input *other_port);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_filter_input_port_connected_method)(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_filter_output_port_connected_method)(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_output *self_port,
+ struct bt_port_input *other_port);
+
+typedef void
+(*bt_private_component_class_filter_input_port_disconnected_method)(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_input *self_port);
+
+typedef void
+(*bt_private_component_class_filter_output_port_disconnected_method)(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_output *self_port);
+
+static inline
+struct bt_private_component_class *
+bt_private_component_class_filter_borrow_private_component_class(
+ struct bt_private_component_class_filter *priv_comp_cls_filter)
+{
+ return (void *) priv_comp_cls_filter;
+}
+
+static inline
+struct bt_component_class_filter *
+bt_private_component_class_filter_borrow_component_class_filter(
+ struct bt_private_component_class_filter *priv_comp_cls_filter)
+{
+ return (void *) priv_comp_cls_filter;
+}
+
+extern
+struct bt_private_component_class_filter *
+bt_private_component_class_filter_create(
+ const char *name,
+ bt_private_component_class_filter_notification_iterator_next_method method);
+
+extern int bt_private_component_class_filter_set_init_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_init_method method);
+
+extern int bt_private_component_class_filter_set_finalize_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_finalize_method method);
+
+extern int bt_private_component_class_filter_set_accept_input_port_connection_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_accept_input_port_connection_method method);
+
+extern int bt_private_component_class_filter_set_accept_output_port_connection_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_accept_output_port_connection_method method);
+
+extern int bt_private_component_class_filter_set_input_port_connected_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_input_port_connected_method method);
+
+extern int bt_private_component_class_filter_set_output_port_connected_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_output_port_connected_method method);
+
+extern int bt_private_component_class_filter_set_input_port_disconnected_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_input_port_disconnected_method method);
+
+extern int bt_private_component_class_filter_set_output_port_disconnected_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_output_port_disconnected_method method);
+
+extern int bt_private_component_class_filter_set_query_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_query_method method);
+
+extern int bt_private_component_class_filter_set_notification_iterator_init_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_notification_iterator_init_method method);
+
+extern int bt_private_component_class_filter_set_notification_iterator_finalize_method(
+ struct bt_private_component_class_filter *comp_class,
+ bt_private_component_class_filter_notification_iterator_finalize_method method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_FILTER_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SINK_H
+#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SINK_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_notification_array */
+#include <babeltrace/graph/notification.h>
+
+/* For enum bt_self_component_status */
+#include <babeltrace/graph/self-component.h>
+
+/* For enum bt_query_status */
+#include <babeltrace/graph/query-executor.h>
+
+/* For struct bt_private_component_class_query_method_return */
+#include <babeltrace/graph/private-component-class.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_self_component_class_sink;
+struct bt_component_class_sink;
+struct bt_self_component_sink;
+struct bt_private_component_class;
+struct bt_private_component_class_sink;
+struct bt_self_component_port_input;
+struct bt_port_output;
+struct bt_query_executor;
+struct bt_value;
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_sink_init_method)(
+ struct bt_self_component_sink *self_component,
+ struct bt_value *params, void *init_method_data);
+
+typedef void (*bt_private_component_class_sink_finalize_method)(
+ struct bt_self_component_sink *self_component);
+
+typedef enum bt_query_status
+(*bt_private_component_class_sink_query_method)(
+ struct bt_self_component_class_sink *comp_class,
+ struct bt_query_executor *query_executor,
+ const char *object, struct bt_value *params,
+ struct bt_value **result);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_sink_accept_input_port_connection_method)(
+ struct bt_self_component_sink *self_component,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_sink_input_port_connected_method)(
+ struct bt_self_component_sink *self_component,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
+
+typedef void
+(*bt_private_component_class_sink_input_port_disconnected_method)(
+ struct bt_self_component_sink *self_component,
+ struct bt_self_component_port_input *self_port);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_sink_consume_method)(
+ struct bt_self_component_sink *self_component);
+
+static inline
+struct bt_private_component_class *
+bt_private_component_class_sink_borrow_private_component_class(
+ struct bt_private_component_class_sink *priv_comp_cls_sink)
+{
+ return (void *) priv_comp_cls_sink;
+}
+
+static inline
+struct bt_component_class_sink *
+bt_private_component_class_sink_borrow_component_class_sink(
+ struct bt_private_component_class_sink *priv_comp_cls_sink)
+{
+ return (void *) priv_comp_cls_sink;
+}
+
+extern
+struct bt_private_component_class_sink *bt_private_component_class_sink_create(
+ const char *name,
+ bt_private_component_class_sink_consume_method method);
+
+extern int bt_private_component_class_sink_set_init_method(
+ struct bt_private_component_class_sink *comp_class,
+ bt_private_component_class_sink_init_method method);
+
+extern int bt_private_component_class_sink_set_finalize_method(
+ struct bt_private_component_class_sink *comp_class,
+ bt_private_component_class_sink_finalize_method method);
+
+extern int bt_private_component_class_sink_set_accept_input_port_connection_method(
+ struct bt_private_component_class_sink *comp_class,
+ bt_private_component_class_sink_accept_input_port_connection_method method);
+
+extern int bt_private_component_class_sink_set_input_port_connected_method(
+ struct bt_private_component_class_sink *comp_class,
+ bt_private_component_class_sink_input_port_connected_method method);
+
+extern int bt_private_component_class_sink_set_input_port_disconnected_method(
+ struct bt_private_component_class_sink *comp_class,
+ bt_private_component_class_sink_input_port_disconnected_method method);
+
+extern int bt_private_component_class_sink_set_query_method(
+ struct bt_private_component_class_sink *comp_class,
+ bt_private_component_class_sink_query_method method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SINK_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SOURCE_H
+#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SOURCE_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_notification_array */
+#include <babeltrace/graph/notification.h>
+
+/* For enum bt_self_component_status */
+#include <babeltrace/graph/self-component.h>
+
+/* For enum bt_query_status */
+#include <babeltrace/graph/query-executor.h>
+
+/* For enum bt_self_notification_iterator_status */
+#include <babeltrace/graph/self-notification-iterator.h>
+
+/* For struct bt_private_component_class_query_method_return */
+#include <babeltrace/graph/private-component-class.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_self_component_class_source;
+struct bt_component_class_source;
+struct bt_self_component_source;
+struct bt_private_component_class;
+struct bt_private_component_class_source;
+struct bt_self_component_port_output;
+struct bt_port_input;
+struct bt_query_executor;
+struct bt_value;
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_source_init_method)(
+ struct bt_self_component_source *self_component,
+ struct bt_value *params, void *init_method_data);
+
+typedef void (*bt_private_component_class_source_finalize_method)(
+ struct bt_self_component_source *self_component);
+
+typedef enum bt_self_notification_iterator_status
+(*bt_private_component_class_source_notification_iterator_init_method)(
+ struct bt_self_notification_iterator *notification_iterator,
+ struct bt_self_component_source *self_component,
+ struct bt_self_component_port_output *port);
+
+typedef void
+(*bt_private_component_class_source_notification_iterator_finalize_method)(
+ struct bt_self_notification_iterator *notification_iterator);
+
+typedef enum bt_self_notification_iterator_status
+(*bt_private_component_class_source_notification_iterator_next_method)(
+ struct bt_self_notification_iterator *notification_iterator,
+ bt_notification_array notifs, uint64_t capacity,
+ uint64_t *count);
+
+typedef enum bt_query_status
+(*bt_private_component_class_source_query_method)(
+ struct bt_self_component_class_source *comp_class,
+ struct bt_query_executor *query_executor,
+ const char *object, struct bt_value *params,
+ struct bt_value **result);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_source_accept_output_port_connection_method)(
+ struct bt_self_component_source *self_component,
+ struct bt_self_component_port_output *self_port,
+ struct bt_port_input *other_port);
+
+typedef enum bt_self_component_status
+(*bt_private_component_class_source_output_port_connected_method)(
+ struct bt_self_component_source *self_component,
+ struct bt_self_component_port_output *self_port,
+ struct bt_port_input *other_port);
+
+typedef void
+(*bt_private_component_class_source_output_port_disconnected_method)(
+ struct bt_self_component_source *self_component,
+ struct bt_self_component_port_output *self_port);
+
+static inline
+struct bt_private_component_class *
+bt_private_component_class_source_borrow_private_component_class(
+ struct bt_private_component_class_source *priv_comp_cls_source)
+{
+ return (void *) priv_comp_cls_source;
+}
+
+static inline
+struct bt_component_class_source *
+bt_private_component_class_source_borrow_component_class_source(
+ struct bt_private_component_class_source *priv_comp_cls_source)
+{
+ return (void *) priv_comp_cls_source;
+}
+
+extern
+struct bt_private_component_class_source *
+bt_private_component_class_source_create(
+ const char *name,
+ bt_private_component_class_source_notification_iterator_next_method method);
+
+extern int bt_private_component_class_source_set_init_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_init_method method);
+
+extern int bt_private_component_class_source_set_finalize_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_finalize_method method);
+
+extern int bt_private_component_class_source_set_accept_output_port_connection_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_accept_output_port_connection_method method);
+
+extern int bt_private_component_class_source_set_output_port_connected_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_output_port_connected_method method);
+
+extern int bt_private_component_class_source_set_output_port_disconnected_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_output_port_disconnected_method method);
+
+extern int bt_private_component_class_source_set_query_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_query_method method);
+
+extern int bt_private_component_class_source_set_notification_iterator_init_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_notification_iterator_init_method method);
+
+extern int bt_private_component_class_source_set_notification_iterator_finalize_method(
+ struct bt_private_component_class_source *comp_class,
+ bt_private_component_class_source_notification_iterator_finalize_method method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SOURCE_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_H
+#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* For enum bt_query_status */
+#include <babeltrace/graph/query-executor.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class;
+struct bt_private_component_class;
+
+static inline
+struct bt_component_class *
+bt_private_component_class_borrow_component_class(
+ struct bt_private_component_class *priv_comp_cls)
+{
+ return (void *) priv_comp_cls;
+}
+
+extern int bt_private_component_class_set_description(
+ struct bt_private_component_class *component_class,
+ const char *description);
+
+extern int bt_private_component_class_set_help(
+ struct bt_private_component_class *component_class,
+ const char *help);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_FILTER_H
-#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_FILTER_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdint.h>
-
-/* For enum bt_component_status */
-#include <babeltrace/graph/component-status.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_component;
-struct bt_private_component;
-struct bt_private_port;
-
-extern struct bt_private_port *
-bt_private_component_filter_get_output_port_by_name(
- struct bt_private_component *private_component,
- const char *name);
-
-extern struct bt_private_port *
-bt_private_component_filter_get_output_port_by_index(
- struct bt_private_component *private_component, uint64_t index);
-
-extern enum bt_component_status
-bt_private_component_filter_add_output_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **private_port);
-
-extern struct bt_private_port *
-bt_private_component_filter_get_input_port_by_name(
- struct bt_private_component *private_component,
- const char *name);
-
-extern struct bt_private_port *
-bt_private_component_filter_get_input_port_by_index(
- struct bt_private_component *private_component, uint64_t index);
-
-extern enum bt_component_status
-bt_private_component_filter_add_input_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **private_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_FILTER_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_SINK_H
-#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_SINK_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdint.h>
-
-/* For enum bt_component_status */
-#include <babeltrace/graph/component-status.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_component;
-struct bt_private_component;
-struct bt_private_port;
-
-extern struct bt_private_port *
-bt_private_component_sink_get_input_port_by_name(
- struct bt_private_component *private_component,
- const char *name);
-
-extern struct bt_private_port *
-bt_private_component_sink_get_input_port_by_index(
- struct bt_private_component *private_component, uint64_t index);
-
-extern enum bt_component_status
-bt_private_component_sink_add_input_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **private_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_SINK_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_SOURCE_H
-#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_SOURCE_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdint.h>
-
-/* For enum bt_component_status */
-#include <babeltrace/graph/component-status.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_component;
-struct bt_private_component;
-struct bt_private_port;
-
-extern struct bt_private_port *
-bt_private_component_source_get_output_port_by_name(
- struct bt_private_component *private_component,
- const char *name);
-
-extern struct bt_private_port *
-bt_private_component_source_get_output_port_by_index(
- struct bt_private_component *private_component,
- uint64_t index);
-
-extern enum bt_component_status
-bt_private_component_source_add_output_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **private_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_SOURCE_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_H
-#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_component;
-struct bt_private_component;
-
-extern struct bt_component *bt_component_borrow_from_private(
- struct bt_private_component *private_component);
-
-extern void *bt_private_component_get_user_data(
- struct bt_private_component *private_component);
-
-extern enum bt_component_status bt_private_component_set_user_data(
- struct bt_private_component *private_component,
- void *user_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_COMPONENT_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_H
-#define BABELTRACE_GRAPH_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* For enum bt_notification_iterator_status */
-#include <babeltrace/graph/notification-iterator.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_component;
-struct bt_notification;
-struct bt_notification_iterator;
-
-extern struct bt_component *bt_private_connection_notification_iterator_get_component(
- struct bt_notification_iterator *iterator);
-
-extern enum bt_notification_iterator_status
-bt_private_connection_notification_iterator_next(
- struct bt_notification_iterator *iterator,
- bt_notification_array *notifs, uint64_t *count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_CONNECTION_PRIVATE_NOTIFICATION_ITERATOR_H
-#define BABELTRACE_GRAPH_PRIVATE_CONNECTION_PRIVATE_NOTIFICATION_ITERATOR_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_connection;
-struct bt_private_port;
-struct bt_private_connection;
-struct bt_private_connection_private_notification_iterator;
-
-extern struct bt_notification_iterator *
-bt_private_connection_notification_iterator_borrow_from_private(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator);
-
-extern struct bt_private_component *
-bt_private_connection_private_notification_iterator_get_private_component(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator);
-
-extern enum bt_notification_iterator_status
-bt_private_connection_private_notification_iterator_set_user_data(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator,
- void *user_data);
-
-extern void *bt_private_connection_private_notification_iterator_get_user_data(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator);
-
-extern struct bt_graph *bt_private_connection_private_notification_iterator_borrow_graph(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_CONNECTION_PRIVATE_NOTIFICATION_ITERATOR_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_CONNECTION_H
-#define BABELTRACE_GRAPH_PRIVATE_CONNECTION_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* For enum bt_notification_type */
-#include <babeltrace/graph/notification.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_notification;
-struct bt_connection;
-struct bt_private_port;
-struct bt_private_connection;
-struct bt_notification_iterator;
-
-extern struct bt_connection *bt_connection_borrow_from_private(
- struct bt_private_connection *private_connection);
-
-extern enum bt_connection_status
-bt_private_connection_create_notification_iterator(
- struct bt_private_connection *private_connection,
- struct bt_notification_iterator **iterator);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_CONNECTION_H */
struct bt_graph;
struct bt_private_graph;
-struct bt_port;
+struct bt_port_input;
+struct bt_port_output;
struct bt_connection;
struct bt_component;
+struct bt_component_source;
+struct bt_component_filter;
+struct bt_component_sink;
struct bt_component_class;
struct bt_value;
-typedef void (*bt_private_graph_port_added_listener)(struct bt_port *port,
- void *data);
+typedef void (*bt_private_graph_filter_component_input_port_added_listener)(
+ struct bt_component_filter *component,
+ struct bt_port_input *port, void *data);
+
+typedef void (*bt_private_graph_sink_component_input_port_added_listener)(
+ struct bt_component_sink *component,
+ struct bt_port_input *port, void *data);
+
+typedef void (*bt_private_graph_source_component_output_port_added_listener)(
+ struct bt_component_source *component,
+ struct bt_port_output *port, void *data);
+
+typedef void (*bt_private_graph_filter_component_output_port_added_listener)(
+ struct bt_component_filter *component,
+ struct bt_port_output *port, void *data);
+
+typedef void (*bt_private_graph_filter_component_input_port_removed_listener)(
+ struct bt_component_filter *component,
+ struct bt_port_input *port, void *data);
+
+typedef void (*bt_private_graph_sink_component_input_port_removed_listener)(
+ struct bt_component_sink *component,
+ struct bt_port_input *port, void *data);
+
+typedef void (*bt_private_graph_source_component_output_port_removed_listener)(
+ struct bt_component_source *component,
+ struct bt_port_output *port, void *data);
+
+typedef void (*bt_private_graph_filter_component_output_port_removed_listener)(
+ struct bt_component_filter *component,
+ struct bt_port_output *port, void *data);
+
+typedef void (*bt_private_graph_source_filter_component_ports_connected_listener)(
+ struct bt_component_source *source_component,
+ struct bt_component_filter *filter_component,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port, void *data);
-typedef void (*bt_private_graph_port_removed_listener)(
- struct bt_component *component,
- struct bt_port *port, void *data);
+typedef void (*bt_private_graph_source_sink_component_ports_connected_listener)(
+ struct bt_component_source *source_component,
+ struct bt_component_sink *sink_component,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port, void *data);
-typedef void (*bt_private_graph_ports_connected_listener)(
- struct bt_port *upstream_port,
- struct bt_port *downstream_port, void *data);
+typedef void (*bt_private_graph_filter_sink_component_ports_connected_listener)(
+ struct bt_component_filter *filter_component,
+ struct bt_component_sink *sink_component,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port, void *data);
-typedef void (*bt_private_graph_ports_disconnected_listener)(
- struct bt_component *upstream_component,
- struct bt_component *downstream_component,
- struct bt_port *upstream_port, struct bt_port *downstream_port,
+typedef void (*bt_private_graph_source_filter_component_ports_disconnected_listener)(
+ struct bt_component_source *source_component,
+ struct bt_component_filter *filter_component,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port,
+ void *data);
+
+typedef void (*bt_private_graph_source_sink_component_ports_disconnected_listener)(
+ struct bt_component_source *source_component,
+ struct bt_component_sink *sink_component,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port,
+ void *data);
+
+typedef void (*bt_private_graph_filter_sink_component_ports_disconnected_listener)(
+ struct bt_component_filter *filter_component,
+ struct bt_component_sink *sink_component,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port,
void *data);
typedef void (* bt_private_graph_listener_removed)(void *data);
-extern struct bt_graph *bt_graph_borrow_from_private(
- struct bt_private_graph *priv_graph);
+static inline
+struct bt_graph *bt_private_graph_borrow_graph(struct bt_private_graph *graph)
+{
+ return (void *) graph;
+}
extern struct bt_private_graph *bt_private_graph_create(void);
-extern enum bt_graph_status bt_private_graph_add_component(
+extern enum bt_graph_status bt_private_graph_add_source_component(
struct bt_private_graph *graph,
- struct bt_component_class *component_class,
+ struct bt_component_class_source *component_class,
const char *name, struct bt_value *params,
- struct bt_component **component);
+ struct bt_component_source **component);
extern enum bt_graph_status
-bt_private_graph_add_component_with_init_method_data(
+bt_private_graph_add_source_component_with_init_method_data(
struct bt_private_graph *graph,
- struct bt_component_class *component_class,
+ struct bt_component_class_source *component_class,
const char *name, struct bt_value *params,
- void *init_method_data, struct bt_component **component);
+ void *init_method_data, struct bt_component_source **component);
+
+extern enum bt_graph_status bt_private_graph_add_filter_component(
+ struct bt_private_graph *graph,
+ struct bt_component_class_filter *component_class,
+ const char *name, struct bt_value *params,
+ struct bt_component_filter **component);
+
+extern enum bt_graph_status
+bt_private_graph_add_filter_component_with_init_method_data(
+ struct bt_private_graph *graph,
+ struct bt_component_class_filter *component_class,
+ const char *name, struct bt_value *params,
+ void *init_method_data, struct bt_component_filter **component);
+
+extern enum bt_graph_status bt_private_graph_add_sink_component(
+ struct bt_private_graph *graph,
+ struct bt_component_class_sink *component_class,
+ const char *name, struct bt_value *params,
+ struct bt_component_sink **component);
+
+extern enum bt_graph_status
+bt_private_graph_add_sink_component_with_init_method_data(
+ struct bt_private_graph *graph,
+ struct bt_component_class_sink *component_class,
+ const char *name, struct bt_value *params,
+ void *init_method_data, struct bt_component_sink **component);
-/**
- * Creates a connection between two components using the two ports specified
- * and adds the connection and components (if not already added) to the graph.
- */
extern enum bt_graph_status bt_private_graph_connect_ports(
struct bt_private_graph *graph,
- struct bt_port *upstream, struct bt_port *downstream,
+ struct bt_port_output *upstream,
+ struct bt_port_input *downstream,
struct bt_connection **connection);
-/**
- * Run graph to completion or until a single sink is left and "AGAIN" is received.
- *
- * Runs "bt_component_sink_consume()" on all sinks in round-robin until they all
- * indicate that the end is reached or that an error occured.
- */
extern enum bt_graph_status bt_private_graph_run(
struct bt_private_graph *graph);
-/**
- * Runs "bt_component_sink_consume()" on the graph's sinks. Each invokation will
- * invoke "bt_component_sink_consume()" on the next sink, in round-robin, until
- * they all indicated that the end is reached.
- */
extern enum bt_graph_status bt_private_graph_consume(
struct bt_private_graph *graph);
-extern int bt_private_graph_add_port_added_listener(
+extern enum bt_graph_status
+bt_private_graph_add_filter_component_input_port_added_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_filter_component_input_port_added_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_sink_component_input_port_added_listener(
struct bt_private_graph *graph,
- bt_private_graph_port_added_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data);
+ bt_private_graph_sink_component_input_port_added_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
-extern int bt_private_graph_add_port_removed_listener(
+extern enum bt_graph_status
+bt_private_graph_add_source_component_output_port_added_listener(
struct bt_private_graph *graph,
- bt_private_graph_port_removed_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data);
+ bt_private_graph_source_component_output_port_added_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
-extern int bt_private_graph_add_ports_connected_listener(
+extern enum bt_graph_status
+bt_private_graph_add_filter_component_output_port_added_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_filter_component_output_port_added_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_filter_component_input_port_removed_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_filter_component_input_port_removed_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_sink_component_input_port_removed_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_sink_component_input_port_removed_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_source_component_output_port_removed_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_source_component_output_port_removed_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_filter_component_output_port_removed_listener(
struct bt_private_graph *graph,
- bt_private_graph_ports_connected_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data);
+ bt_private_graph_filter_component_output_port_removed_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
-extern int bt_private_graph_add_ports_disconnected_listener(
+extern enum bt_graph_status
+bt_private_graph_add_source_filter_component_ports_connected_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_source_filter_component_ports_connected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_source_sink_component_ports_connected_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_source_sink_component_ports_connected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_filter_sink_component_ports_connected_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_filter_sink_component_ports_connected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_source_filter_component_ports_disconnected_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_source_filter_component_ports_disconnected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_source_sink_component_ports_disconnected_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_source_sink_component_ports_disconnected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
+
+extern enum bt_graph_status
+bt_private_graph_add_filter_sink_component_ports_disconnected_listener(
struct bt_private_graph *graph,
- bt_private_graph_ports_disconnected_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data);
+ bt_private_graph_filter_sink_component_ports_disconnected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *listener_id);
extern enum bt_graph_status bt_private_graph_cancel(
struct bt_private_graph *graph);
#endif
struct bt_private_notification;
-struct bt_private_connection_private_notification_iterator;
+struct bt_self_notification_iterator;
struct bt_private_event;
struct bt_private_packet;
struct bt_private_event_class;
extern
struct bt_private_notification *bt_private_notification_event_create(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
+ struct bt_self_notification_iterator *notification_iterator,
struct bt_private_event_class *event_class,
struct bt_private_packet *packet);
#endif
struct bt_private_notification;
-struct bt_private_connection_private_notification_iterator;
+struct bt_self_notification_iterator;
struct bt_clock_class;
extern
struct bt_private_notification *bt_private_notification_inactivity_create(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
+ struct bt_self_notification_iterator *notification_iterator,
struct bt_clock_class *default_clock_class);
extern int bt_private_notification_inactivity_set_default_clock_value(
#endif
struct bt_private_notification;
-struct bt_private_connection_private_notification_iterator;
+struct bt_self_notification_iterator;
struct bt_private_packet;
extern
struct bt_private_notification *bt_private_notification_packet_begin_create(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
+ struct bt_self_notification_iterator *notification_iterator,
struct bt_private_packet *packet);
extern
struct bt_private_notification *bt_private_notification_packet_end_create(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
+ struct bt_self_notification_iterator *notification_iterator,
struct bt_private_packet *packet);
extern struct bt_private_packet *
#endif
struct bt_private_notification;
-struct bt_private_connection_private_notification_iterator;
+struct bt_self_notification_iterator;
struct bt_private_stream;
extern
struct bt_private_notification *bt_private_notification_stream_begin_create(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
+ struct bt_self_notification_iterator *notification_iterator,
struct bt_private_stream *stream);
extern
struct bt_private_notification *bt_private_notification_stream_end_create(
- struct bt_private_connection_private_notification_iterator *notification_iterator,
+ struct bt_self_notification_iterator *notification_iterator,
struct bt_private_stream *stream);
extern struct bt_private_stream *
struct bt_notification;
struct bt_private_notification;
-extern struct bt_notification *bt_notification_borrow_from_private(
- struct bt_private_notification *priv_notif);
+static inline
+struct bt_notification *bt_private_notification_borrow_notification(
+ struct bt_private_notification *notification)
+{
+ return (void *) notification;
+}
#ifdef __cplusplus
}
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PRIVATE_PORT_H
-#define BABELTRACE_GRAPH_PRIVATE_PORT_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_port;
-struct bt_private_port;
-struct bt_private_component;
-struct bt_private_connection;
-
-struct bt_port *bt_port_borrow_from_private(
- struct bt_private_port *private_port);
-
-extern struct bt_private_connection *bt_private_port_get_connection(
- struct bt_private_port *private_port);
-
-extern struct bt_private_component *bt_private_port_get_component(
- struct bt_private_port *private_port);
-
-extern enum bt_port_status bt_private_port_remove_from_component(
- struct bt_private_port *private_port);
-
-extern void *bt_private_port_get_user_data(
- struct bt_private_port *private_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PRIVATE_PORT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PRIVATE_QUERY_EXECUTOR_H
+#define BABELTRACE_GRAPH_PRIVATE_QUERY_EXECUTOR_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* For enum bt_query_status */
+#include <babeltrace/graph/query-executor.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_query_executor;
+struct bt_private_query_executor;
+struct bt_component_class;
+struct bt_value;
+
+static inline
+struct bt_query_executor *bt_private_query_executor_borrow_query_executor(
+ struct bt_private_query_executor *priv_query_executor)
+{
+ return (void *) priv_query_executor;
+}
+
+extern
+struct bt_private_query_executor *bt_private_query_executor_create(void);
+
+extern
+enum bt_query_status bt_private_query_executor_query(
+ struct bt_private_query_executor *query_executor,
+ struct bt_component_class *component_class,
+ const char *object, struct bt_value *params,
+ struct bt_value **result);
+
+extern
+enum bt_query_status bt_private_query_executor_cancel(
+ struct bt_private_query_executor *query_executor);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PRIVATE_QUERY_EXECUTOR_H */
struct bt_query_executor {
struct bt_object base;
- bt_bool canceled;
+ bool canceled;
};
static inline const char *bt_query_status_string(enum bt_query_status status)
return "BT_QUERY_STATUS_AGAIN";
case BT_QUERY_STATUS_EXECUTOR_CANCELED:
return "BT_QUERY_STATUS_EXECUTOR_CANCELED";
+ case BT_QUERY_STATUS_UNSUPPORTED:
+ return "BT_QUERY_STATUS_UNSUPPORTED";
case BT_QUERY_STATUS_ERROR:
return "BT_QUERY_STATUS_ERROR";
- case BT_QUERY_STATUS_INVALID:
- return "BT_QUERY_STATUS_INVALID";
case BT_QUERY_STATUS_INVALID_OBJECT:
return "BT_QUERY_STATUS_INVALID_OBJECT";
case BT_QUERY_STATUS_INVALID_PARAMS:
#define BABELTRACE_GRAPH_QUERY_EXECUTOR_H
/*
- * BabelTrace - Babeltrace Component Connection Interface
- *
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
extern "C" {
#endif
-struct bt_value;
struct bt_query_executor;
-struct bt_component_class;
enum bt_query_status {
- BT_QUERY_STATUS_OK = 0,
- BT_QUERY_STATUS_AGAIN = 11,
- BT_QUERY_STATUS_EXECUTOR_CANCELED = 125,
- BT_QUERY_STATUS_ERROR = -1,
- BT_QUERY_STATUS_INVALID = -22,
- BT_QUERY_STATUS_INVALID_OBJECT = -23,
- BT_QUERY_STATUS_INVALID_PARAMS = -24,
- BT_QUERY_STATUS_NOMEM = -12,
+ BT_QUERY_STATUS_OK = 0,
+ BT_QUERY_STATUS_AGAIN = 11,
+ BT_QUERY_STATUS_UNSUPPORTED = 95,
+ BT_QUERY_STATUS_EXECUTOR_CANCELED = 125,
+ BT_QUERY_STATUS_ERROR = -1,
+ BT_QUERY_STATUS_NOMEM = -12,
+ BT_QUERY_STATUS_INVALID_OBJECT = -23,
+ BT_QUERY_STATUS_INVALID_PARAMS = -24,
};
-extern
-struct bt_query_executor *bt_query_executor_create(void);
-
-extern
-enum bt_query_status bt_query_executor_query(
- struct bt_query_executor *query_executor,
- struct bt_component_class *component_class,
- const char *object, struct bt_value *params,
- struct bt_value **result);
-
-extern
-enum bt_query_status bt_query_executor_cancel(
- struct bt_query_executor *query_executor);
-
extern
bt_bool bt_query_executor_is_canceled(struct bt_query_executor *query_executor);
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class_filter;
+struct bt_self_component_class_filter;
+
+static inline
+struct bt_component_class_filter *
+bt_self_component_class_filter_borrow_component_class_filter(
+ struct bt_self_component_class_filter *self_comp_cls_filter)
+{
+ return (void *) self_comp_cls_filter;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class_sink;
+struct bt_self_component_class_sink;
+
+static inline
+struct bt_component_class_sink *
+bt_self_component_class_sink_borrow_component_class_sink(
+ struct bt_self_component_class_sink *self_comp_cls_sink)
+{
+ return (void *) self_comp_cls_sink;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class_source;
+struct bt_self_component_class_source;
+
+static inline
+struct bt_component_class_source *
+bt_self_component_class_source_borrow_component_class_source(
+ struct bt_self_component_class_source *self_comp_cls_source)
+{
+ return (void *) self_comp_cls_source;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_self_component_status */
+#include <babeltrace/graph/self-component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_filter;
+struct bt_self_component;
+struct bt_self_component_filter;
+struct bt_self_component_port_input;
+struct bt_self_component_port_output;
+
+static inline
+struct bt_self_component *bt_self_component_filter_borrow_self_component(
+ struct bt_self_component_filter *self_comp_filter)
+{
+ return (void *) self_comp_filter;
+}
+
+static inline
+struct bt_component_filter *
+bt_self_component_filter_borrow_component_filter(
+ struct bt_self_component_filter *self_comp_filter)
+{
+ return (void *) self_comp_filter;
+}
+
+extern struct bt_self_component *bt_self_component_borrow_from_self_component_filter(
+ struct bt_self_component_filter *self_component);
+
+extern struct bt_component_filter *bt_component_filter_borrow_from_self(
+ struct bt_self_component_filter *self_component);
+
+extern struct bt_self_component_port_output *
+bt_self_component_filter_borrow_output_port_by_name(
+ struct bt_self_component_filter *self_component,
+ const char *name);
+
+extern struct bt_self_component_port_output *
+bt_self_component_filter_borrow_output_port_by_index(
+ struct bt_self_component_filter *self_component,
+ uint64_t index);
+
+extern enum bt_self_component_status
+bt_self_component_filter_add_output_port(
+ struct bt_self_component_filter *self_component,
+ const char *name, void *data,
+ struct bt_self_component_port_output **self_component_port);
+
+extern struct bt_self_component_port_input *
+bt_self_component_filter_borrow_input_port_by_name(
+ struct bt_self_component_filter *self_component,
+ const char *name);
+
+extern struct bt_self_component_port_input *
+bt_self_component_filter_borrow_input_port_by_index(
+ struct bt_self_component_filter *self_component,
+ uint64_t index);
+
+extern enum bt_self_component_status
+bt_self_component_filter_add_input_port(
+ struct bt_self_component_filter *self_component,
+ const char *name, void *data,
+ struct bt_self_component_port_input **self_component_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_notification_iterator_status */
+#include <babeltrace/graph/notification-iterator.h>
+
+/* For bt_notification_array */
+#include <babeltrace/graph/notification.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component;
+struct bt_notification_iterator;
+struct bt_self_component_port_input_notification_iterator;
+struct bt_self_component_port_input;
+
+static inline
+struct bt_notification_iterator *
+bt_self_component_port_input_notification_iterator_borrow_notification_iterator(
+ struct bt_self_component_port_input_notification_iterator *iterator)
+{
+ return (void *) iterator;
+}
+
+extern struct bt_self_component_port_input_notification_iterator *
+bt_self_component_port_input_notification_iterator_create(
+ struct bt_self_component_port_input *input_port);
+
+extern struct bt_component *
+bt_self_component_port_input_notification_iterator_borrow_component(
+ struct bt_self_component_port_input_notification_iterator *iterator);
+
+extern enum bt_notification_iterator_status
+bt_self_component_port_input_notification_iterator_next(
+ struct bt_self_component_port_input_notification_iterator *iterator,
+ bt_notification_array *notifs, uint64_t *count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* For enum bt_self_component_port_status */
+#include <babeltrace/graph/self-component-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_port_input;
+struct bt_self_component_port;
+struct bt_self_component_port_input;
+
+static inline
+struct bt_self_component_port *
+bt_self_component_port_input_borrow_self_component_port(
+ struct bt_self_component_port_input *self_component_port)
+{
+ return (void *) self_component_port;
+}
+
+static inline
+struct bt_port_input *bt_self_component_port_input_borrow_port_input(
+ struct bt_self_component_port_input *self_component_port)
+{
+ return (void *) self_component_port;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* For enum bt_self_component_port_status */
+#include <babeltrace/graph/self-component-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_port_output;
+struct bt_self_component_port;
+struct bt_self_component_port_output;
+
+static inline
+struct bt_self_component_port *
+bt_self_component_port_output_borrow_self_component_port(
+ struct bt_self_component_port_output *self_component_port)
+{
+ return (void *) self_component_port;
+}
+
+static inline
+struct bt_port_output *bt_self_component_port_output_borrow_port_output(
+ struct bt_self_component_port_output *self_component_port)
+{
+ return (void *) self_component_port;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_port;
+struct bt_self_component_port;
+struct bt_self_component;
+struct bt_connection;
+
+enum bt_self_component_port_status {
+ BT_SELF_PORT_STATUS_OK = 0,
+ BT_SELF_PORT_STATUS_ERROR = -1,
+};
+
+static inline
+struct bt_port *bt_self_component_port_borrow_port(
+ struct bt_self_component_port *self_port)
+{
+ return (void *) self_port;
+}
+
+extern struct bt_self_component *bt_self_component_port_borrow_component(
+ struct bt_self_component_port *self_port);
+
+extern enum bt_self_component_port_status
+bt_self_component_port_remove_from_component(
+ struct bt_self_component_port *self_port);
+
+extern void *bt_self_component_port_get_data(
+ struct bt_self_component_port *self_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_self_component_status */
+#include <babeltrace/graph/self-component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_sink;
+struct bt_self_component;
+struct bt_self_component_sink;
+struct bt_self_component_port_input;
+
+static inline
+struct bt_self_component *bt_self_component_sink_borrow_self_component(
+ struct bt_self_component_sink *self_comp_sink)
+{
+ return (void *) self_comp_sink;
+}
+
+static inline
+struct bt_component_sink *
+bt_self_component_sink_borrow_component_sink(
+ struct bt_self_component_sink *self_comp_sink)
+{
+ return (void *) self_comp_sink;
+}
+
+extern struct bt_self_component_port_input *
+bt_self_component_sink_borrow_input_port_by_name(
+ struct bt_self_component_sink *self_component,
+ const char *name);
+
+extern struct bt_self_component_port_input *
+bt_self_component_sink_borrow_input_port_by_index(
+ struct bt_self_component_sink *self_component, uint64_t index);
+
+extern enum bt_self_component_status
+bt_self_component_sink_add_input_port(
+ struct bt_self_component_sink *self_component,
+ const char *name, void *user_data,
+ struct bt_self_component_port_input **self_component_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+/* For enum bt_self_component_status */
+#include <babeltrace/graph/self-component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_source;
+struct bt_self_component;
+struct bt_self_component_source;
+struct bt_self_component_port_output;
+
+static inline
+struct bt_self_component *bt_self_component_source_borrow_self_component(
+ struct bt_self_component_source *self_comp_source)
+{
+ return (void *) self_comp_source;
+}
+
+static inline
+struct bt_component_source *
+bt_self_component_source_borrow_component_source(
+ struct bt_self_component_source *self_comp_source)
+{
+ return (void *) self_comp_source;
+}
+
+extern struct bt_self_component_port_output *
+bt_self_component_source_borrow_output_port_by_name(
+ struct bt_self_component_source *self_component,
+ const char *name);
+
+extern struct bt_self_component_port_output *
+bt_self_component_source_borrow_output_port_by_index(
+ struct bt_self_component_source *self_component,
+ uint64_t index);
+
+extern enum bt_self_component_status
+bt_self_component_source_add_output_port(
+ struct bt_self_component_source *self_component,
+ const char *name, void *user_data,
+ struct bt_self_component_port_output **self_component_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component;
+struct bt_self_component;
+
+enum bt_self_component_status {
+ 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,
+};
+
+static inline
+struct bt_component *bt_self_component_borrow_component(
+ struct bt_self_component *self_component)
+{
+ return (void *) self_component;
+}
+
+extern void *bt_self_component_get_data(
+ struct bt_self_component *private_component);
+
+extern void bt_self_component_set_data(
+ struct bt_self_component *private_component, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_NOTIFICATION_ITERATOR_H
+#define BABELTRACE_GRAPH_SELF_NOTIFICATION_ITERATOR_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* For BT_NOTIFICATION_ITERATOR_STATUS_* */
+#include <babeltrace/graph/notification-iterator.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_self_component;
+struct bt_self_notification_iterator;
+
+enum bt_self_notification_iterator_status {
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK = BT_NOTIFICATION_ITERATOR_STATUS_OK,
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_END = BT_NOTIFICATION_ITERATOR_STATUS_END,
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_AGAIN = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN,
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR = BT_NOTIFICATION_ITERATOR_STATUS_ERROR,
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM,
+};
+
+extern struct bt_self_component *
+bt_self_notification_iterator_borrow_component(
+ struct bt_self_notification_iterator *notification_iterator);
+
+extern struct bt_self_port_output *
+bt_self_notification_iterator_borrow_port(
+ struct bt_self_notification_iterator *notification_iterator);
+
+extern void bt_self_notification_iterator_set_data(
+ struct bt_self_notification_iterator *notification_iterator,
+ void *user_data);
+
+extern void *bt_self_notification_iterator_get_data(
+ struct bt_self_notification_iterator *notification_iterator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_NOTIFICATION_ITERATOR_H */
#define BABELTRACE_LOGGING_H
/*
- * Babeltrace - Logging
- *
* Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define _BABELTRACE_MMAP_ALIGN_H
/*
- * BabelTrace mmap-align.h - mmap alignment header
- *
* Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define BABELTRACE_OBJECT_INTERNAL_H
/*
- * Babeltrace - Base object
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_OBJECT_H
/*
- * BabelTrace: common reference counting
- *
* Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
* Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
* Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_PLUGIN_PLUGIN_DEV_H
/*
- * BabelTrace - Babeltrace Plug-in Development API
- *
* This is the header that you need to include for the development of
* a Babeltrace plug-in.
*
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
/* For enum bt_plugin_status */
#include <babeltrace/plugin/plugin.h>
-/* For component class method type definitions */
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-sink.h>
+/* For private component class method type definitions */
+#include <babeltrace/graph/private-component-class-source.h>
+#include <babeltrace/graph/private-component-class-filter.h>
+#include <babeltrace/graph/private-component-class-sink.h>
/*
* _BT_HIDDEN: set the hidden attribute for internal functions
/* Plugin exit function type */
typedef enum bt_plugin_status (*bt_plugin_exit_func)(void);
-/*
- * Function to call from a plugin's initialization function to add a
- * component class to a plugin object.
- */
-extern enum bt_plugin_status bt_plugin_add_component_class(
- struct bt_plugin *plugin,
- struct bt_component_class *component_class);
-
/* Plugin descriptor: describes a single plugin (internal use) */
struct __bt_plugin_descriptor {
/* Plugin's interface major version number */
union {
/* BT_COMPONENT_CLASS_TYPE_SOURCE */
struct {
- bt_component_class_notification_iterator_next_method notif_iter_next;
+ bt_private_component_class_source_notification_iterator_next_method notif_iter_next;
} source;
/* BT_COMPONENT_CLASS_TYPE_FILTER */
struct {
- bt_component_class_notification_iterator_next_method notif_iter_next;
+ bt_private_component_class_filter_notification_iterator_next_method notif_iter_next;
} filter;
/* BT_COMPONENT_CLASS_TYPE_SINK */
struct {
- bt_component_class_sink_consume_method consume;
+ bt_private_component_class_sink_consume_method consume;
} sink;
} methods;
} __attribute__((packed));
/* Type of a component class attribute (internal use) */
enum __bt_plugin_component_class_descriptor_attribute_type {
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 0,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP = 1,
- 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_PORT_CONNECTION_METHOD = 5,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_CONNECTED_METHOD = 7,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_DISCONNECTED_METHOD = 8,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD = 9,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD = 10,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 0,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP = 1,
+ 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_INPUT_PORT_DISCONNECTED_METHOD = 9,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD = 10,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD = 11,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD = 12,
};
/* Component class attribute (internal use) */
const char *help;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD */
- bt_component_class_init_method init_method;
+ bt_private_component_class_source_init_method source_init_method;
+ bt_private_component_class_filter_init_method filter_init_method;
+ bt_private_component_class_sink_init_method sink_init_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD */
- bt_component_class_finalize_method finalize_method;
+ bt_private_component_class_source_finalize_method source_finalize_method;
+ bt_private_component_class_filter_finalize_method filter_finalize_method;
+ bt_private_component_class_sink_finalize_method sink_finalize_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD */
- bt_component_class_query_method query_method;
+ bt_private_component_class_source_query_method source_query_method;
+ bt_private_component_class_filter_query_method filter_query_method;
+ bt_private_component_class_sink_query_method sink_query_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD */
+ bt_private_component_class_filter_accept_input_port_connection_method filter_accept_input_port_connection_method;
+ bt_private_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_private_component_class_source_accept_output_port_connection_method source_accept_output_port_connection_method;
+ bt_private_component_class_filter_accept_output_port_connection_method filter_accept_output_port_connection_method;
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_PORT_CONNECTION_METHOD */
- bt_component_class_accept_port_connection_method accept_port_connection_method;
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD */
+ bt_private_component_class_filter_input_port_connected_method filter_input_port_connected_method;
+ bt_private_component_class_sink_input_port_connected_method sink_input_port_connected_method;
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_CONNECTED_METHOD */
- bt_component_class_port_connected_method port_connected_method;
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD */
+ bt_private_component_class_source_output_port_connected_method source_output_port_connected_method;
+ bt_private_component_class_filter_output_port_connected_method filter_output_port_connected_method;
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_DISCONNECTED_METHOD */
- bt_component_class_port_disconnected_method port_disconnected_method;
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_DISCONNECTED_METHOD */
+ bt_private_component_class_filter_input_port_disconnected_method filter_input_port_disconnected_method;
+ bt_private_component_class_sink_input_port_disconnected_method sink_input_port_disconnected_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD */
+ bt_private_component_class_source_output_port_disconnected_method source_output_port_disconnected_method;
+ bt_private_component_class_filter_output_port_disconnected_method filter_output_port_disconnected_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD */
- bt_component_class_notification_iterator_init_method notif_iter_init_method;
+ bt_private_component_class_source_notification_iterator_init_method source_notif_iter_init_method;
+ bt_private_component_class_filter_notification_iterator_init_method filter_notif_iter_init_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD */
- bt_component_class_notification_iterator_finalize_method notif_iter_finalize_method;
+ bt_private_component_class_source_notification_iterator_finalize_method source_notif_iter_finalize_method;
+ bt_private_component_class_filter_notification_iterator_finalize_method filter_notif_iter_finalize_method;
} value;
} __attribute__((packed));
* _comp_class_id: Component class ID (C identifier).
* _name: Component class name (C string).
* _notif_iter_next_method: Component class's iterator next method
- * (bt_component_class_notification_iterator_next_method).
+ * (bt_private_component_class_source_notification_iterator_next_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_next_method) \
static struct __bt_plugin_component_class_descriptor __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id = { \
/*
* Defines a filter component class descriptor with a custom ID.
*
- * _id: ID (any valid C identifier except `auto`).
- * _comp_class_id: Component class ID (C identifier).
- * _name: Component class name (C string).
+ * _id: ID (any valid C identifier except `auto`).
+ * _comp_class_id: Component class ID (C identifier).
+ * _name: Component class name (C string).
* _notif_iter_next_method: Component class's iterator next method
- * (bt_component_class_notification_iterator_next_method).
+ * (bt_private_component_class_filter_notification_iterator_next_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_next_method) \
static struct __bt_plugin_component_class_descriptor __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id = { \
* _comp_class_id: Component class ID (C identifier).
* _name: Component class name (C string).
* _consume_method: Component class's iterator consume method
- * (bt_component_class_sink_consume_method).
+ * (bt_private_component_class_sink_consume_method).
*/
#define BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _consume_method) \
static struct __bt_plugin_component_class_descriptor __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id = { \
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Initialization method (bt_component_class_init_method).
+ * _x: Initialization method (bt_private_component_class_source_init_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, source, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, source, _x)
/*
* Defines an initialization method attribute attached to a specific
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Initialization method (bt_component_class_init_method).
+ * _x: Initialization method (bt_private_component_class_filter_init_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, filter, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, filter, _x)
/*
* Defines an initialization method attribute attached to a specific
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Initialization method (bt_component_class_init_method).
+ * _x: Initialization method (bt_private_component_class_sink_init_method).
*/
#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, sink, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, sink, _x)
/*
- * Defines a finalize method attribute attached to a specific source
+ * Defines a finalization 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: Finalize method (bt_component_class_finalize_method).
+ * _x: Finalize method (bt_private_component_class_source_finalize_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, source, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, source, _x)
/*
- * Defines a finalize method attribute attached to a specific filter
+ * Defines a finalization 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: Finalize method (bt_component_class_finalize_method).
+ * _x: Finalize method (bt_private_component_class_filter_finalize_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, filter, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, filter, _x)
/*
- * Defines a finalize method attribute attached to a specific sink
+ * Defines a finalization 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: Finalize method (bt_component_class_finalize_method).
+ * _x: Finalize method (bt_private_component_class_sink_finalize_method).
*/
#define BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, sink, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, sink, _x)
/*
* Defines a query method attribute attached to a specific source
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_query_method).
+ * _x: Finalize method (bt_private_component_class_source_query_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, source, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, source, _x)
/*
* Defines a query method attribute attached to a specific filter
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_query_method).
+ * _x: Finalize method (bt_private_component_class_filter_query_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, filter, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, filter, _x)
/*
* Defines a query method attribute attached to a specific sink
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_query_method).
+ * _x: Finalize method (bt_private_component_class_sink_query_method).
*/
#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, sink, _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 port connection method attribute attached to a
- * specific source component class descriptor.
+ * 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_accept_port_connection_method).
+ * (bt_private_component_class_filter_accept_input_port_connection_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(accept_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_PORT_CONNECTION_METHOD, _id, _comp_class_id, source, _x)
+#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 port connection method attribute attached to a
- * specific filter component class descriptor.
+ * 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_accept_port_connection_method).
+ * (bt_private_component_class_sink_accept_input_port_connection_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(accept_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x)
+#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 port connection method attribute attached to a
- * specific sink component class descriptor.
+ * 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_accept_port_connection_method).
+ * (bt_private_component_class_source_accept_output_port_connection_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(accept_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_PORT_CONNECTION_METHOD, _id, _comp_class_id, sink, _x)
+#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 a port connected method attribute attached to a specific
- * source component class descriptor.
+ * 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_private_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.
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
* _x: Port connected method
- * (bt_component_class_port_connected_method).
+ * (bt_private_component_class_filter_input_port_connected_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_CONNECTED_METHOD, _id, _comp_class_id, source, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_input_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, filter, _x)
/*
- * Defines a port connected method attribute attached to a specific
- * filter component class descriptor.
+ * Defines an input port connected 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: Port connected method
- * (bt_component_class_port_connected_method).
+ * (bt_private_component_class_sink_input_port_connected_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_CONNECTED_METHOD, _id, _comp_class_id, filter, _x)
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_input_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, sink, _x)
/*
- * Defines a port connected method attribute attached to a specific
- * sink component class descriptor.
+ * Defines an output port connected 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: Port connected method
- * (bt_component_class_port_connected_method).
+ * (bt_private_component_class_source_output_port_connected_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_CONNECTED_METHOD, _id, _comp_class_id, sink, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_output_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, source, _x)
/*
- * Defines a port disconnected method attribute attached to a specific
- * source component class descriptor.
+ * Defines an output port connected 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: Port connected method
+ * (bt_private_component_class_filter_output_port_connected_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_output_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an input port disconnected 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: Port disconnected method
- * (bt_component_class_port_disconnected_method).
+ * (bt_private_component_class_filter_input_port_disconnected_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(port_disconnected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_DISCONNECTED_METHOD, _id, _comp_class_id, source, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_input_port_disconnected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_DISCONNECTED_METHOD, _id, _comp_class_id, filter, _x)
/*
- * Defines a port disconnected method attribute attached to a specific
- * filter component class descriptor.
+ * Defines an input port disconnected 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: Port disconnected method
- * (bt_component_class_port_disconnected_method).
+ * (bt_private_component_class_sink_input_port_disconnected_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(port_disconnected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_DISCONNECTED_METHOD, _id, _comp_class_id, filter, _x)
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_input_port_disconnected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_DISCONNECTED_METHOD, _id, _comp_class_id, sink, _x)
/*
- * Defines a port disconnected method attribute attached to a specific
- * sink component class descriptor.
+ * Defines an output port disconnected 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: Port disconnected method
- * (bt_component_class_port_disconnected_method).
+ * (bt_private_component_class_source_output_port_disconnected_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(port_disconnected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_DISCONNECTED_METHOD, _id, _comp_class_id, sink, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_DISCONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_output_port_disconnected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an output port disconnected 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: Port disconnected method
+ * (bt_private_component_class_filter_output_port_disconnected_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_DISCONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_output_port_disconnected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD, _id, _comp_class_id, filter, _x)
/*
* Defines an iterator initialization method attribute attached to a
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
* _x: Iterator initialization method
- * (bt_component_class_notification_iterator_init_method).
+ * (bt_private_component_class_source_notification_iterator_init_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, source, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, source, _x)
/*
* Defines an iterator finalize method attribute attached to a specific
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
* _x: Iterator finalize method
- * (bt_component_class_notification_iterator_finalize_method).
+ * (bt_private_component_class_source_notification_iterator_finalize_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x)
/*
* Defines an iterator initialization method attribute attached to a
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
* _x: Iterator initialization method
- * (bt_component_class_notification_iterator_init_method).
+ * (bt_private_component_class_filter_notification_iterator_init_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, filter, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, filter, _x)
/*
* Defines an iterator finalize method attribute attached to a specific
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
* _x: Iterator finalize method
- * (bt_component_class_notification_iterator_finalize_method).
+ * (bt_private_component_class_filter_notification_iterator_finalize_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x)
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x)
/*
* Defines a plugin descriptor with an automatic ID.
*
* _name: Component class name (C identifier).
* _notif_iter_next_method: Component class's iterator next method
- * (bt_component_class_notification_iterator_next_method).
+ * (bt_private_component_class_source_notification_iterator_next_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _notif_iter_next_method) \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_next_method)
*
* _name: Component class name (C identifier).
* _notif_iter_next_method: Component class's iterator next method
- * (bt_component_class_notification_iterator_next_method).
+ * (bt_private_component_class_filter_notification_iterator_next_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _notif_iter_next_method) \
BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_next_method)
*
* _name: Component class name (C identifier).
* _consume_method: Component class's consume method
- * (bt_component_class_sink_consume_method).
+ * (bt_private_component_class_sink_consume_method).
*/
#define BT_PLUGIN_SINK_COMPONENT_CLASS(_name, _consume_method) \
BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _consume_method)
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_init_method).
+ * _x: Initialization method (bt_private_component_class_source_init_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_init_method).
+ * _x: Initialization method (bt_private_component_class_filter_init_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_init_method).
+ * _x: Initialization method (bt_private_component_class_sink_init_method).
*/
#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a finalize method attribute attached to a source component
+ * Defines a finalization method attribute attached to a source component
* class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_finalize_method).
+ * _x: Initialization method (bt_private_component_class_source_finalize_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a finalize method attribute attached to a filter component
+ * Defines a finalization method attribute attached to a filter component
* class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_finalize_method).
+ * _x: Initialization method (bt_private_component_class_filter_finalize_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a finalize method attribute attached to a sink component class
+ * Defines a finalization method attribute attached to a sink component class
* descriptor which is attached to the automatic plugin descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_finalize_method).
+ * _x: Initialization method (bt_private_component_class_sink_finalize_method).
*/
#define BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_query_method).
+ * _x: Initialization method (bt_private_component_class_source_query_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_query_method).
+ * _x: Initialization method (bt_private_component_class_filter_query_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_query_method).
+ * _x: Initialization method (bt_private_component_class_sink_query_method).
*/
#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 port connection method attribute attached to a
- * source component class descriptor which is attached to the automatic
- * plugin descriptor.
+ * 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_accept_port_connection_method).
+ * (bt_private_component_class_filter_accept_input_port_connection_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
+#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 port connection method attribute attached to a
- * filter component class descriptor which is attached to the automatic
+ * 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_accept_port_connection_method).
+ * (bt_private_component_class_sink_accept_input_port_connection_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
+#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 port connection method attribute attached to a sink
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
+ * 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_accept_port_connection_method).
+ * (bt_private_component_class_source_accept_output_port_connection_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
+#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 a port connected method attribute attached to a source
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
+ * 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: Port connected (bt_component_class_port_connected_method).
+ * _x: Accept port connection method
+ * (bt_private_component_class_filter_accept_output_port_connection_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_PORT_CONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
+#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 a port connected method attribute attached to a filter
+ * Defines an input port connected method attribute attached to a filter
* component class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Port connected (bt_component_class_port_connected_method).
+ * _x: Port connected (bt_private_component_class_filter_input_port_connected_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_CONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a port connected method attribute attached to a sink
+ * Defines an input port connected method attribute attached to a sink
* component class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Port connected (bt_component_class_port_connected_method).
+ * _x: Port connected (bt_private_component_class_sink_input_port_connected_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a port disconnected method attribute attached to a source
+ * Defines an output port connected method attribute attached to a source
* component class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Port disconnected (bt_component_class_port_disconnected_method).
+ * _x: Port connected (bt_private_component_class_source_output_port_connected_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a port disconnected method attribute attached to a filter
+ * Defines an output port connected method attribute attached to a filter
* component class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Port disconnected (bt_component_class_port_disconnected_method).
+ * _x: Port connected (bt_private_component_class_filter_output_port_connected_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a port disconnected method attribute attached to a sink
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
+ * Defines an input port disconnected method attribute attached to a
+ * filter component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Port disconnected (bt_private_component_class_filter_input_port_disconnected_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an input port disconnected method attribute attached to a
+ * sink component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Port disconnected (bt_private_component_class_sink_input_port_disconnected_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an output port disconnected method attribute attached to a
+ * source component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Port disconnected (bt_private_component_class_source_output_port_disconnected_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_DISCONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_DISCONNECTED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an output port disconnected method attribute attached to a
+ * filter component class descriptor which is attached to the automatic
+ * plugin descriptor.
*
* _name: Component class name (C identifier).
- * _x: Port disconnected (bt_component_class_port_disconnected_method).
+ * _x: Port disconnected (bt_private_component_class_filter_output_port_disconnected_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_DISCONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_DISCONNECTED_METHOD_WITH_ID(auto, _name, _x)
/*
* Defines an iterator initialization method attribute attached to a
*
* _name: Component class name (C identifier).
* _x: Iterator initialization method
- * (bt_component_class_notification_iterator_init_method).
+ * (bt_private_component_class_source_notification_iterator_init_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(_name, _x) \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x)
*
* _name: Component class name (C identifier).
* _x: Iterator finalize method
- * (bt_component_class_notification_iterator_finalize_method).
+ * (bt_private_component_class_source_notification_iterator_finalize_method).
*/
#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(_name, _x) \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
*
* _name: Component class name (C identifier).
* _x: Iterator initialization method
- * (bt_component_class_notification_iterator_init_method).
+ * (bt_private_component_class_filter_notification_iterator_init_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(_name, _x) \
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x)
*
* _name: Component class name (C identifier).
* _x: Iterator finalize method
- * (bt_component_class_notification_iterator_finalize_method).
+ * (bt_private_component_class_filter_notification_iterator_finalize_method).
*/
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(_name, _x) \
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
#define BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H
/*
- * BabelTrace - Plug-in Internal
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
*/
#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/plugin/plugin.h>
#include <babeltrace/plugin/plugin-dev.h>
+#include <babeltrace/plugin/plugin-so-internal.h>
#include <babeltrace/object-internal.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
#include <glib.h>
struct bt_plugin {
struct bt_object base;
enum bt_plugin_type type;
- bt_bool frozen;
- /* Array of pointers to bt_component_class (owned by this) */
- GPtrArray *comp_classes;
+ /* Arrays of `struct bt_component_class *` (owned by this) */
+ GPtrArray *src_comp_classes;
+ GPtrArray *flt_comp_classes;
+ GPtrArray *sink_comp_classes;
/* Info (owned by this) */
struct {
unsigned int patch;
GString *extra;
} version;
- bt_bool path_set;
- bt_bool name_set;
- bt_bool author_set;
- bt_bool license_set;
- bt_bool description_set;
- bt_bool version_set;
+ bool path_set;
+ bool name_set;
+ bool author_set;
+ bool license_set;
+ bool description_set;
+ bool version_set;
} info;
/* Value depends on the specific plugin type */
BT_ASSERT(obj);
plugin = container_of(obj, struct bt_plugin, base);
- BT_LOGD("Destroying plugin object: addr=%p, name=\"%s\"",
- plugin, plugin->info.name ? plugin->info.name->str : NULL);
+ BT_LIB_LOGD("Destroying plugin object: %!+l", plugin);
if (plugin->destroy_spec_data) {
plugin->destroy_spec_data(plugin);
}
- if (plugin->comp_classes) {
- BT_LOGD_STR("Putting component classes.");
- g_ptr_array_free(plugin->comp_classes, TRUE);
+ if (plugin->src_comp_classes) {
+ BT_LOGD_STR("Putting source component classes.");
+ g_ptr_array_free(plugin->src_comp_classes, TRUE);
+ }
+
+ if (plugin->flt_comp_classes) {
+ BT_LOGD_STR("Putting filter component classes.");
+ g_ptr_array_free(plugin->flt_comp_classes, TRUE);
+ }
+
+ if (plugin->sink_comp_classes) {
+ BT_LOGD_STR("Putting sink component classes.");
+ g_ptr_array_free(plugin->sink_comp_classes, TRUE);
}
if (plugin->info.name) {
bt_object_init_shared(&plugin->base, bt_plugin_destroy);
plugin->type = type;
- /* Create empty array of component classes */
- plugin->comp_classes =
- g_ptr_array_new_with_free_func((GDestroyNotify) bt_object_put_ref);
- if (!plugin->comp_classes) {
+ /* Create empty arrays of component classes */
+ plugin->src_comp_classes =
+ g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_put_ref);
+ if (!plugin->src_comp_classes) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ plugin->flt_comp_classes =
+ g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_put_ref);
+ if (!plugin->flt_comp_classes) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ plugin->sink_comp_classes =
+ g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_put_ref);
+ if (!plugin->sink_comp_classes) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
goto error;
}
goto error;
}
- BT_LOGD("Created empty plugin object: type=%s, addr=%p",
- bt_plugin_type_string(type), plugin);
+ BT_LIB_LOGD("Created empty plugin object: %!+l", plugin);
goto end;
error:
BT_ASSERT(path);
g_string_assign(plugin->info.path, path);
plugin->info.path_set = BT_TRUE;
- BT_LOGV("Set plugin's path: addr=%p, name=\"%s\", path=\"%s\"",
- plugin, bt_plugin_get_name(plugin), path);
+ BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, path=\"%s\"",
+ plugin, path);
}
static inline
BT_ASSERT(name);
g_string_assign(plugin->info.name, name);
plugin->info.name_set = BT_TRUE;
- BT_LOGV("Set plugin's name: addr=%p, name=\"%s\"",
+ BT_LIB_LOGV("Set plugin's name: %![plugin-]+l, name=\"%s\"",
plugin, name);
}
BT_ASSERT(description);
g_string_assign(plugin->info.description, description);
plugin->info.description_set = BT_TRUE;
- BT_LOGV("Set plugin's description: addr=%p, name=\"%s\"",
- plugin, bt_plugin_get_name(plugin));
+ BT_LIB_LOGV("Set plugin's description: %![plugin-]+l", plugin);
}
static inline
BT_ASSERT(author);
g_string_assign(plugin->info.author, author);
plugin->info.author_set = BT_TRUE;
- BT_LOGV("Set plugin's author: addr=%p, name=\"%s\", author=\"%s\"",
- plugin, bt_plugin_get_name(plugin), author);
+ BT_LIB_LOGV("Set plugin's author: %![plugin-]+l, author=\"%s\"",
+ plugin, author);
}
static inline
BT_ASSERT(license);
g_string_assign(plugin->info.license, license);
plugin->info.license_set = BT_TRUE;
- BT_LOGV("Set plugin's path: addr=%p, name=\"%s\", license=\"%s\"",
- plugin, bt_plugin_get_name(plugin), license);
+ BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, license=\"%s\"",
+ plugin, license);
}
static inline
}
plugin->info.version_set = BT_TRUE;
- BT_LOGV("Set plugin's version: addr=%p, name=\"%s\", "
+ BT_LIB_LOGV("Set plugin's version: %![plugin-]+l, "
"major=%u, minor=%u, patch=%u, extra=\"%s\"",
- plugin, bt_plugin_get_name(plugin),
- major, minor, patch, extra);
+ plugin, major, minor, patch, extra);
}
static inline
-void bt_plugin_freeze(struct bt_plugin *plugin)
+enum bt_plugin_status bt_plugin_add_component_class(
+ struct bt_plugin *plugin, struct bt_component_class *comp_class)
{
+ GPtrArray *comp_classes;
+
BT_ASSERT(plugin);
+ BT_ASSERT(comp_class);
+
+ switch (comp_class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ comp_classes = plugin->src_comp_classes;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ comp_classes = plugin->flt_comp_classes;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ comp_classes = plugin->sink_comp_classes;
+ break;
+ default:
+ abort();
+ }
- if (plugin->frozen) {
- return;
+ /* Add new component class */
+ g_ptr_array_add(comp_classes, bt_object_get_ref(comp_class));
+
+ /* Special case for a shared object plugin */
+ if (plugin->type == BT_PLUGIN_TYPE_SO) {
+ bt_plugin_so_on_add_component_class(plugin, comp_class);
}
- BT_LOGD("Freezing plugin: addr=%p, name=\"%s\", path=\"%s\"",
- plugin, bt_plugin_get_name(plugin),
- bt_plugin_get_path(plugin));
- plugin->frozen = BT_TRUE;
+ BT_LIB_LOGD("Added component class to plugin: "
+ "%![plugin-]+l, %![cc-]+C", plugin, comp_class);
+ return BT_PLUGIN_STATUS_OK;
}
static
BT_ASSERT(plugin_set);
BT_ASSERT(plugin);
g_ptr_array_add(plugin_set->plugins, bt_object_get_ref(plugin));
- BT_LOGV("Added plugin to plugin set: "
- "plugin-set-addr=%p, plugin-addr=%p, plugin-name=\"%s\", "
- "plugin-path=\"%s\"",
- plugin_set, plugin, bt_plugin_get_name(plugin),
- bt_plugin_get_path(plugin));
+ BT_LIB_LOGV("Added plugin to plugin set: "
+ "plugin-set-addr=%p, %![plugin-]+l",
+ plugin_set, plugin);
}
#endif /* BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H */
#define BABELTRACE_PLUGIN_PLUGIN_SO_INTERNAL_H
/*
- * BabelTrace - Babeltrace Plug-in Interface
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
#define BABELTRACE_PLUGIN_PLUGIN_H
/*
- * BabelTrace - Babeltrace Plug-in Interface
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
/* For enum bt_component_class_type */
#include <babeltrace/graph/component-class.h>
+/* For enum bt_component_class_source */
+#include <babeltrace/graph/component-class-source.h>
+
+/* For enum bt_component_class_filter */
+#include <babeltrace/graph/component-class-filter.h>
+
+/* For enum bt_component_class_sink */
+#include <babeltrace/graph/component-class-sink.h>
+
+/* For enum bt_property_availability */
+#include <babeltrace/property.h>
+
#ifdef __cplusplus
extern "C" {
#endif
struct bt_plugin;
struct bt_plugin_set;
struct bt_component_class;
+struct bt_component_class_source;
+struct bt_component_class_filter;
+struct bt_component_class_sink;
-/**
- * Status code. Errors are always negative.
- */
enum bt_plugin_status {
- /** No error, okay. */
BT_PLUGIN_STATUS_OK = 0,
- /** General error. */
BT_PLUGIN_STATUS_ERROR = -1,
- /** Memory allocation failure. */
- BT_PLUGIN_STATUS_NOMEM = -4,
+ BT_PLUGIN_STATUS_NOMEM = -12,
};
extern struct bt_plugin *bt_plugin_find(const char *plugin_name);
-extern struct bt_component_class *bt_plugin_find_component_class(
- const char *plugin_name, const char *component_class_name,
- enum bt_component_class_type component_class_type);
-
extern struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path);
extern struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path,
extern struct bt_plugin_set *bt_plugin_create_all_from_static(void);
-/**
- * Get the name of a plug-in.
- *
- * @param plugin An instance of a plug-in
- * @returns Plug-in name or NULL on error
- */
extern const char *bt_plugin_get_name(struct bt_plugin *plugin);
-/**
- * Get the name of a plug-in's author.
- *
- * @param plugin An instance of a plug-in
- * @returns Plug-in author or NULL on error
- */
extern const char *bt_plugin_get_author(struct bt_plugin *plugin);
-/**
- * Get the license of a plug-in.
- *
- * @param plugin An instance of a plug-in
- * @returns Plug-in license or NULL on error
- */
extern const char *bt_plugin_get_license(struct bt_plugin *plugin);
-/**
- * Get the decription of a plug-in.
- *
- * @param plugin An instance of a plug-in
- * @returns Plug-in description or NULL if none is available
- */
extern const char *bt_plugin_get_description(struct bt_plugin *plugin);
-/**
- * Get the path of a plug-in.
- *
- * @param plugin An instance of a plug-in
- * @returns Plug-in path or NULL on error
- */
extern const char *bt_plugin_get_path(struct bt_plugin *plugin);
-extern enum bt_plugin_status bt_plugin_get_version(struct bt_plugin *plugin,
- unsigned int *major, unsigned int *minor, unsigned int *patch,
- const char **extra);
+extern enum bt_property_availability bt_plugin_get_version(
+ struct bt_plugin *plugin, unsigned int *major,
+ unsigned int *minor, unsigned int *patch, const char **extra);
+
+extern uint64_t bt_plugin_get_source_component_class_count(
+ struct bt_plugin *plugin);
+
+extern uint64_t bt_plugin_get_filter_component_class_count(
+ struct bt_plugin *plugin);
-extern int64_t bt_plugin_get_component_class_count(struct bt_plugin *plugin);
+extern uint64_t bt_plugin_get_sink_component_class_count(
+ struct bt_plugin *plugin);
-extern struct bt_component_class *bt_plugin_get_component_class_by_index(
+extern struct bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_index(
struct bt_plugin *plugin, uint64_t index);
-extern
-struct bt_component_class *bt_plugin_get_component_class_by_name_and_type(
- struct bt_plugin *plugin, const char *name,
- enum bt_component_class_type type);
+extern struct bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_index(
+ struct bt_plugin *plugin, uint64_t index);
+
+extern struct bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_index(
+ struct bt_plugin *plugin, uint64_t index);
+
+extern struct bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_name(struct bt_plugin *plugin,
+ const char *name);
+
+extern struct bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_name(struct bt_plugin *plugin,
+ const char *name);
+
+extern struct bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_name(struct bt_plugin *plugin,
+ const char *name);
-extern
-int64_t bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set);
+extern uint64_t bt_plugin_set_get_plugin_count(
+ struct bt_plugin_set *plugin_set);
-extern
-struct bt_plugin *bt_plugin_set_get_plugin(struct bt_plugin_set *plugin_set,
- uint64_t index);
+extern struct bt_plugin *bt_plugin_set_borrow_plugin_by_index(
+ struct bt_plugin_set *plugin_set, uint64_t index);
#ifdef __cplusplus
}
#define _BABELTRACE_PRIO_HEAP_H
/*
- * prio_heap.h
- *
* Static-sized priority heap containing pointers. Based on CLRS,
* chapter 6.
*
extern struct bt_private_value *bt_private_value_null;
-extern struct bt_value *bt_value_borrow_from_private(
- struct bt_private_value *priv_value);
+static inline
+struct bt_value *bt_private_value_borrow_value(
+ struct bt_private_value *priv_value)
+{
+ return (void *) priv_value;
+}
extern struct bt_private_value *bt_private_value_bool_create(void);
#define BABELTRACE_TRACE_IR_ATTRIBUTES_H
/*
- * attributes.c
- *
* Babeltrace - Trace IR: Attributes internal
*
* Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
#define BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H
/*
- * BabelTrace - Trace IR: Clock internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H
/*
- * Babeltrace - Trace IR: Event class internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_EVENT_INTERNAL_H
/*
- * Babeltrace - Trace IR: Event internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
/*
- * BabelTrace - Trace IR: Event field classes internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
/*
- * BabelTrace - Trace IR: Field path
- *
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H
/*
- * Babeltrace - Trace IR: Event Fields internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_PACKET_INTERNAL_H
/*
- * Babeltrace - Trace IR: Stream packet internal
- *
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
struct bt_clock_class;
struct bt_private_clock_class;
-extern struct bt_clock_class *bt_clock_class_borrow_from_private(
- struct bt_private_clock_class *priv_clock_class);
+static inline
+struct bt_clock_class *bt_private_clock_class_borrow_clock_class(
+ struct bt_private_clock_class *priv_clock_class)
+{
+ return (void *) priv_clock_class;
+}
extern struct bt_private_clock_class *bt_private_clock_class_create(void);
struct bt_private_event_class;
struct bt_private_stream_class;
-extern struct bt_event_class *bt_event_class_borrow_from_private(
- struct bt_private_event_class *priv_event_class);
+static inline
+struct bt_event_class *bt_private_event_class_borrow_event_class(
+ struct bt_private_event_class *priv_event_class)
+{
+ return (void *) priv_event_class;
+}
extern struct bt_private_event_class *bt_private_event_class_create(
struct bt_private_stream_class *stream_class);
struct bt_private_field;
struct bt_private_packet;
-extern struct bt_event *bt_event_borrow_from_private(
- struct bt_private_event *priv_event);
+static inline
+struct bt_event *bt_private_event_borrow_event(
+ struct bt_private_event *priv_event)
+{
+ return (void *) priv_event;
+}
extern struct bt_private_event_class *bt_private_event_borrow_class(
struct bt_private_event *event);
struct bt_private_field_class_signed_enumeration_mapping_ranges;
struct bt_private_field_class_unsigned_enumeration_mapping_ranges;
-extern struct bt_field_class *bt_field_class_borrow_from_private(
- struct bt_private_field_class *priv_field_class);
+static inline
+struct bt_field_class *bt_private_field_class_borrow_field_class(
+ struct bt_private_field_class *priv_field_class)
+{
+ return (void *) priv_field_class;
+}
extern struct bt_private_field_class *
bt_private_field_class_unsigned_integer_create(void);
struct bt_private_field;
struct bt_private_field_class;
-extern struct bt_field *bt_field_borrow_from_private(
- struct bt_private_field *priv_field);
+static inline
+struct bt_field *bt_private_field_borrow_field(
+ struct bt_private_field *priv_field)
+{
+ return (void *) priv_field;
+}
extern struct bt_private_field_class *bt_private_field_borrow_class(
struct bt_private_field *field);
struct bt_private_packet_context_field;
struct bt_private_stream;
-extern struct bt_packet *bt_packet_borrow_from_private(
- struct bt_private_packet *priv_packet);
+static inline
+struct bt_packet *bt_private_packet_borrow_packet(
+ struct bt_private_packet *priv_packet)
+{
+ return (void *) priv_packet;
+}
extern struct bt_private_packet *bt_private_packet_create(
struct bt_private_stream *stream);
struct bt_private_event_class;
struct bt_private_clock_class;
-extern struct bt_stream_class *bt_stream_class_borrow_from_private(
- struct bt_private_stream_class *priv_stream_class);
+static inline
+struct bt_stream_class *bt_private_stream_class_borrow_stream_class(
+ struct bt_private_stream_class *priv_stream_class)
+{
+ return (void *) priv_stream_class;
+}
extern struct bt_private_stream_class *bt_private_stream_class_create(
struct bt_private_trace *trace);
struct bt_private_stream;
struct bt_private_stream_class;
-extern struct bt_stream *bt_stream_borrow_from_private(
- struct bt_private_stream *priv_stream);
+static inline
+struct bt_stream *bt_private_stream_borrow_stream(
+ struct bt_private_stream *priv_stream)
+{
+ return (void *) priv_stream;
+}
extern struct bt_private_stream *bt_private_stream_create(
struct bt_private_stream_class *stream_class);
typedef void (* bt_private_trace_listener_removed)(
struct bt_private_trace *trace, void *data);
-extern struct bt_trace *bt_trace_borrow_from_private(
- struct bt_private_trace *priv_trace);
+static inline
+struct bt_trace *bt_private_trace_borrow_trace(
+ struct bt_private_trace *priv_trace)
+{
+ return (void *) priv_trace;
+}
extern struct bt_private_trace *bt_private_trace_create(void);
#define BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL
/*
- * BabelTrace - Trace IR: Field path
- *
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#define BABELTRACE_TRACE_IR_STREAM_CLASS_INTERNAL_H
/*
- * BabelTrace - Trace IR: Stream class internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_STREAM_INTERNAL_H
/*
- * BabelTrace - CTF Writer: Stream internal
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_TRACE_INTERNAL_H
/*
- * BabelTrace - Trace IR: Trace internal
- *
* Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define BABELTRACE_TRACE_IR_UTILS_INTERNAL_H
/*
- * Babeltrace - Internal Trace IR utilities
- *
* 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
#define BABELTRACE_VALUES_INTERNAL_H
/*
- * Babeltrace - Value objects
- *
* Copyright (c) 2015-2017 EfficiOS Inc. and Linux Foundation
* Copyright (c) 2015-2017 Philippe Proulx <pproulx@efficios.com>
*
#define BABELTRACE_VALUES_H
/*
- * Babeltrace - Value objects
- *
* Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
* Copyright (c) 2015-2016 Philippe Proulx <pproulx@efficios.com>
*
/*
- * babeltrace.c
- *
- * Babeltrace Library
- *
* Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
*
* Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
BT_HIDDEN
int64_t bt_ctf_attributes_get_count(struct bt_private_value *attr_obj)
{
- return bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
+ return bt_value_array_get_size(bt_private_value_borrow_value(attr_obj));
}
BT_HIDDEN
goto end;
}
- if (index >= bt_value_array_get_size(bt_value_borrow_from_private(attr_obj))) {
+ if (index >= bt_value_array_get_size(bt_private_value_borrow_value(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(bt_value_borrow_from_private(attr_obj)));
+ index, bt_value_array_get_size(bt_private_value_borrow_value(attr_obj)));
goto end;
}
}
ret = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj));
+ bt_private_value_borrow_value(attr_field_name_obj));
end:
return ret;
goto end;
}
- if (index >= bt_value_array_get_size(bt_value_borrow_from_private(attr_obj))) {
+ if (index >= bt_value_array_get_size(bt_private_value_borrow_value(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(bt_value_borrow_from_private(attr_obj)));
+ index, bt_value_array_get_size(bt_private_value_borrow_value(attr_obj)));
goto end;
}
struct bt_private_value *value_obj = NULL;
struct bt_private_value *attr_field_name_obj = NULL;
- attr_size = bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
+ attr_size = bt_value_array_get_size(bt_private_value_borrow_value(attr_obj));
if (attr_size < 0) {
BT_LOGE("Cannot get array value's size: value-addr=%p",
attr_obj);
}
field_name = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj));
+ bt_private_value_borrow_value(attr_field_name_obj));
if (!strcmp(field_name, name)) {
break;
if (attr_field_obj) {
ret = bt_private_value_array_set_element_by_index(
attr_field_obj, BT_CTF_ATTR_VALUE_INDEX,
- bt_value_borrow_from_private(value_obj));
+ bt_private_value_borrow_value(value_obj));
attr_field_obj = NULL;
goto end;
}
ret = bt_private_value_array_append_string_element(attr_field_obj, name);
ret |= bt_private_value_array_append_element(attr_field_obj,
- bt_value_borrow_from_private(value_obj));
+ bt_private_value_borrow_value(value_obj));
if (ret) {
BT_LOGE("Cannot append elements to array value: addr=%p",
attr_field_obj);
}
ret = bt_private_value_array_append_element(attr_obj,
- bt_value_borrow_from_private(attr_field_obj));
+ bt_private_value_borrow_value(attr_field_obj));
if (ret) {
BT_LOGE("Cannot append element to array value: "
"array-value-addr=%p, element-value-addr=%p",
}
BT_LOGD("Freezing attributes object: value-addr=%p", attr_obj);
- count = bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
+ count = bt_value_array_get_size(bt_private_value_borrow_value(attr_obj));
BT_ASSERT(count >= 0);
/*
goto end;
}
- bt_value_freeze(bt_value_borrow_from_private(obj));
+ bt_value_freeze(bt_private_value_borrow_value(obj));
}
end:
goto end;
}
- if (!bt_value_is_integer(bt_value_borrow_from_private(value)) &&
- !bt_value_is_string(bt_value_borrow_from_private(value))) {
+ if (!bt_value_is_integer(bt_private_value_borrow_value(value)) &&
+ !bt_value_is_string(bt_private_value_borrow_value(value))) {
BT_LOGW("Invalid parameter: environment field's value is not an integer or string value: "
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\", env-value-type=%s",
trace, bt_ctf_trace_common_get_name(trace), name,
bt_common_value_type_string(
bt_value_get_type(
- bt_value_borrow_from_private(value))));
+ bt_private_value_borrow_value(value))));
ret = -1;
goto end;
}
goto end;
}
- bt_value_freeze(bt_value_borrow_from_private(value));
+ bt_value_freeze(bt_private_value_borrow_value(value));
}
ret = bt_ctf_attributes_set_field_value(trace->environment, name,
BT_ASSERT(env_field_value_obj);
switch (bt_value_get_type(
- bt_value_borrow_from_private(env_field_value_obj))) {
+ bt_private_value_borrow_value(env_field_value_obj))) {
case BT_VALUE_TYPE_INTEGER:
{
int64_t int_value;
int_value = bt_value_integer_get(
- bt_value_borrow_from_private(
+ bt_private_value_borrow_value(
env_field_value_obj));
g_string_append_printf(context->string,
"\t%s = %" PRId64 ";\n", entry_name,
char *escaped_str = NULL;
str_value = bt_value_string_get(
- bt_value_borrow_from_private(
+ bt_private_value_borrow_value(
env_field_value_obj));
escaped_str = g_strescape(str_value, NULL);
if (!escaped_str) {
# Graph library
libgraph_la_SOURCES = \
- component.c \
+ component-class-sink-colander.c \
component-class.c \
- graph.c \
+ component-filter.c \
+ component-sink.c \
+ component-source.c \
+ component.c \
connection.c \
- port.c \
- source.c \
- sink.c \
- filter.c \
+ graph.c \
iterator.c \
- component-class-sink-colander.c \
+ port.c \
query-executor.c
libgraph_la_LIBADD = \
#include <babeltrace/object.h>
#include <babeltrace/graph/connection.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/graph/private-component-sink.h>
-#include <babeltrace/graph/private-port.h>
-#include <babeltrace/graph/private-connection.h>
-#include <babeltrace/graph/private-connection-notification-iterator.h>
-#include <babeltrace/graph/private-component.h>
+#include <babeltrace/graph/private-component-class-sink.h>
+#include <babeltrace/graph/self-component-sink.h>
+#include <babeltrace/graph/self-component-port.h>
+#include <babeltrace/graph/self-component-port-input-notification-iterator.h>
+#include <babeltrace/graph/self-component.h>
#include <babeltrace/graph/component-class-sink-colander-internal.h>
#include <babeltrace/assert-internal.h>
#include <glib.h>
static
-struct bt_component_class *colander_comp_cls;
+struct bt_private_component_class_sink *colander_comp_cls;
struct colander_data {
bt_notification_array notifs;
uint64_t *count_addr;
- struct bt_notification_iterator *notif_iter;
+ struct bt_self_component_port_input_notification_iterator *notif_iter;
};
static
-enum bt_component_status colander_init(
- struct bt_private_component *priv_comp,
+enum bt_self_component_status colander_init(
+ struct bt_self_component_sink *self_comp,
struct bt_value *params, void *init_method_data)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct colander_data *colander_data = NULL;
struct bt_component_class_sink_colander_data *user_provided_data =
init_method_data;
if (!init_method_data) {
BT_LOGW_STR("Component initialization method data is NULL.");
- status = BT_COMPONENT_STATUS_INVALID;
+ status = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
}
colander_data = g_new0(struct colander_data, 1);
if (!colander_data) {
BT_LOGE_STR("Failed to allocate colander data.");
- status = BT_COMPONENT_STATUS_NOMEM;
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
colander_data->notifs = user_provided_data->notifs;
colander_data->count_addr = user_provided_data->count_addr;
- status = bt_private_component_sink_add_input_port(
- priv_comp, "in", NULL, NULL);
- if (status != BT_COMPONENT_STATUS_OK) {
+ status = bt_self_component_sink_add_input_port(self_comp, "in",
+ NULL, NULL);
+ if (status != BT_SELF_COMPONENT_STATUS_OK) {
BT_LOGE_STR("Cannot add input port.");
goto end;
}
- (void) bt_private_component_set_user_data(priv_comp, colander_data);
+ bt_self_component_set_data(
+ bt_self_component_sink_borrow_self_component(self_comp),
+ colander_data);
end:
return status;
}
static
-void colander_finalize(struct bt_private_component *priv_comp)
+void colander_finalize(struct bt_self_component_sink *self_comp)
{
struct colander_data *colander_data =
- bt_private_component_get_user_data(priv_comp);
+ bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(self_comp));
if (!colander_data) {
return;
}
- if (colander_data->notif_iter) {
- bt_object_put_ref(colander_data->notif_iter);
- }
-
+ BT_OBJECT_PUT_REF_AND_RESET(colander_data->notif_iter);
g_free(colander_data);
}
static
-enum bt_component_status colander_port_connected(struct bt_private_component *priv_comp,
- struct bt_private_port *self_priv_port,
- struct bt_port *other_port)
+enum bt_self_component_status colander_input_port_connected(
+ struct bt_self_component_sink *self_comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- enum bt_connection_status conn_status;
- struct bt_private_connection *priv_conn =
- bt_private_port_get_connection(self_priv_port);
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct colander_data *colander_data =
- bt_private_component_get_user_data(priv_comp);
+ bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(self_comp));
- BT_ASSERT(priv_conn);
BT_ASSERT(colander_data);
BT_OBJECT_PUT_REF_AND_RESET(colander_data->notif_iter);
- conn_status = bt_private_connection_create_notification_iterator(
- priv_conn, &colander_data->notif_iter);
- if (conn_status) {
- BT_LOGE("Cannot create notification iterator from connection: "
- "comp-addr=%p, conn-addr=%p", priv_comp, priv_conn);
- status = BT_COMPONENT_STATUS_ERROR;
+ colander_data->notif_iter =
+ bt_self_component_port_input_notification_iterator_create(
+ self_port);
+ if (!colander_data->notif_iter) {
+ BT_LIB_LOGE("Cannot create notification iterator on "
+ "self component input port: %![port-]+p",
+ self_port);
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
end:
- bt_object_put_ref(priv_conn);
return status;
}
static
-enum bt_component_status colander_consume(
- struct bt_private_component *priv_comp)
+enum bt_self_component_status colander_consume(
+ struct bt_self_component_sink *self_comp)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
enum bt_notification_iterator_status notif_iter_status;
struct colander_data *colander_data =
- bt_private_component_get_user_data(priv_comp);
+ bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(self_comp));
bt_notification_array notifs;
BT_ASSERT(colander_data);
if (!colander_data->notif_iter) {
- BT_LOGW("Trying to consume without an upstream notification iterator: "
- "comp-addr=%p", priv_comp);
+ BT_LIB_LOGW("Trying to consume without an "
+ "upstream notification iterator: %![comp-]+c",
+ self_comp);
goto end;
}
- notif_iter_status = bt_private_connection_notification_iterator_next(
- colander_data->notif_iter, ¬ifs, colander_data->count_addr);
+ notif_iter_status =
+ bt_self_component_port_input_notification_iterator_next(
+ colander_data->notif_iter, ¬ifs,
+ colander_data->count_addr);
switch (notif_iter_status) {
case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED:
- status = BT_COMPONENT_STATUS_OK;
+ status = BT_SELF_COMPONENT_STATUS_OK;
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
- status = BT_COMPONENT_STATUS_AGAIN;
+ status = BT_SELF_COMPONENT_STATUS_AGAIN;
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_END:
- status = BT_COMPONENT_STATUS_END;
+ status = BT_SELF_COMPONENT_STATUS_END;
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_OK:
/* Move notifications to user (count already set) */
sizeof(*notifs) * *colander_data->count_addr);
break;
default:
- status = BT_COMPONENT_STATUS_ERROR;
+ status = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
}
end:
- /* Move notification to user's pointer, even if NULL. */
return status;
}
-struct bt_component_class *bt_component_class_sink_colander_get(void)
+struct bt_component_class_sink *bt_component_class_sink_colander_get(void)
{
if (colander_comp_cls) {
goto end;
}
- colander_comp_cls = bt_component_class_sink_create("colander",
- colander_consume);
+ colander_comp_cls = bt_private_component_class_sink_create(
+ "colander", colander_consume);
if (!colander_comp_cls) {
BT_LOGE_STR("Cannot create sink colander component class.");
goto end;
}
- (void) bt_component_class_set_init_method(colander_comp_cls,
- colander_init);
- (void) bt_component_class_set_finalize_method(colander_comp_cls,
- colander_finalize);
- (void) bt_component_class_set_port_connected_method(colander_comp_cls,
- colander_port_connected);
- (void) bt_component_class_freeze(colander_comp_cls);
+ (void) bt_private_component_class_sink_set_init_method(
+ colander_comp_cls, colander_init);
+ (void) bt_private_component_class_sink_set_finalize_method(
+ colander_comp_cls, colander_finalize);
+ (void) bt_private_component_class_sink_set_input_port_connected_method(
+ colander_comp_cls, colander_input_port_connected);
end:
- return bt_object_get_ref(colander_comp_cls);
+ return bt_object_get_ref(
+ bt_private_component_class_sink_borrow_component_class_sink(
+ colander_comp_cls));
}
__attribute__((destructor)) static
/*
- * component-class.c
- *
- * Babeltrace Plugin Component Class
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/graph/private-component-class.h>
+#include <babeltrace/graph/private-component-class-source.h>
+#include <babeltrace/graph/private-component-class-filter.h>
+#include <babeltrace/graph/private-component-class-sink.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <glib.h>
+#define BT_ASSERT_PRE_COMP_CLS_HOT(_cc) \
+ BT_ASSERT_PRE_HOT(((struct bt_component_class *) (_cc)), \
+ "Component class", ": %!+C", (_cc))
+
static
-void bt_component_class_destroy(struct bt_object *obj)
+void destroy_component_class(struct bt_object *obj)
{
struct bt_component_class *class;
int i;
BT_ASSERT(obj);
class = container_of(obj, struct bt_component_class, base);
- BT_LOGD("Destroying component class: "
- "addr=%p, name=\"%s\", type=%s",
- class, bt_component_class_get_name(class),
- bt_component_class_type_string(class->type));
+ BT_LIB_LOGD("Destroying component class: %!+C", class);
/* Call destroy listeners in reverse registration order */
for (i = class->destroy_listeners->len - 1; i >= 0; i--) {
if (class->name) {
g_string_free(class->name, TRUE);
+ class->name = NULL;
}
+
if (class->description) {
g_string_free(class->description, TRUE);
+ class->description = NULL;
}
+
if (class->help) {
g_string_free(class->help, TRUE);
+ class->help = NULL;
}
+
if (class->destroy_listeners) {
g_array_free(class->destroy_listeners, TRUE);
+ class->destroy_listeners = NULL;
}
g_free(class);
{
int ret = 0;
- bt_object_init_shared(&class->base, bt_component_class_destroy);
+ bt_object_init_shared(&class->base, destroy_component_class);
class->type = type;
class->name = g_string_new(name);
if (!class->name) {
return ret;
}
-struct bt_component_class *bt_component_class_source_create(const char *name,
- bt_component_class_notification_iterator_next_method method)
+struct bt_private_component_class_source *
+bt_private_component_class_source_create(
+ const char *name,
+ bt_private_component_class_source_notification_iterator_next_method method)
{
struct bt_component_class_source *source_class = NULL;
int ret;
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_NON_NULL(method, "Notification iterator next method");
BT_LOGD("Creating source component class: "
"name=\"%s\", notif-iter-next-method-addr=%p",
name, method);
goto end;
}
- source_class->methods.iterator.next = method;
- BT_LOGD("Created source component class: "
- "name=\"%s\", notif-iter-next-method-addr=%p, addr=%p",
- name, method, &source_class->parent);
+ source_class->methods.notif_iter_next = method;
+ BT_LIB_LOGD("Created source component class: %!+C", source_class);
end:
- return &source_class->parent;
+ return (void *) source_class;
}
-struct bt_component_class *bt_component_class_filter_create(const char *name,
- bt_component_class_notification_iterator_next_method method)
+struct bt_private_component_class_filter *
+bt_private_component_class_filter_create(const char *name,
+ bt_private_component_class_filter_notification_iterator_next_method method)
{
struct bt_component_class_filter *filter_class = NULL;
int ret;
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_NON_NULL(method, "Notification iterator next method");
BT_LOGD("Creating filter component class: "
"name=\"%s\", notif-iter-next-method-addr=%p",
name, method);
goto end;
}
- filter_class->methods.iterator.next = method;
- BT_LOGD("Created filter component class: "
- "name=\"%s\", notif-iter-next-method-addr=%p, addr=%p",
- name, method, &filter_class->parent);
+ filter_class->methods.notif_iter_next = method;
+ BT_LIB_LOGD("Created filter component class: %!+C", filter_class);
end:
- return &filter_class->parent;
+ return (void *) filter_class;
}
-struct bt_component_class *bt_component_class_sink_create(const char *name,
- bt_component_class_sink_consume_method method)
+struct bt_private_component_class_sink *bt_private_component_class_sink_create(
+ const char *name,
+ bt_private_component_class_sink_consume_method method)
{
struct bt_component_class_sink *sink_class = NULL;
int ret;
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_NON_NULL(method, "Consume next method");
BT_LOGD("Creating sink component class: "
"name=\"%s\", consume-method-addr=%p",
name, method);
}
sink_class->methods.consume = method;
- BT_LOGD("Created sink component class: "
- "name=\"%s\", consume-method-addr=%p, addr=%p",
- name, method, &sink_class->parent);
+ BT_LIB_LOGD("Created sink component class: %!+C", sink_class);
end:
- return &sink_class->parent;
+ return (void *) sink_class;
}
-int bt_component_class_set_init_method(
- struct bt_component_class *component_class,
- bt_component_class_init_method method)
+int bt_private_component_class_source_set_init_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_init_method method)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- component_class->methods.init = method;
- BT_LOGV("Set component class's initialization method: "
- "addr=%p, name=\"%s\", type=%s, method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type),
- method);
-
-end:
- return ret;
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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.init = method;
+ BT_LIB_LOGV("Set source component class's initialization method: "
+ "%!+C", comp_cls);
+ return 0;
}
-int bt_component_class_set_query_method(
- struct bt_component_class *component_class,
- bt_component_class_query_method method)
+int bt_private_component_class_filter_set_init_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_init_method method)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- component_class->methods.query = method;
- BT_LOGV("Set component class's query method: "
- "addr=%p, name=\"%s\", type=%s, method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type),
- method);
-
-end:
- return ret;
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.init = method;
+ BT_LIB_LOGV("Set filter component class's initialization method: "
+ "%!+C", comp_cls);
+ return 0;
}
-int bt_component_class_set_accept_port_connection_method(
- struct bt_component_class *component_class,
- bt_component_class_accept_port_connection_method method)
+int bt_private_component_class_sink_set_init_method(
+ struct bt_private_component_class_sink *priv_comp_cls,
+ bt_private_component_class_sink_init_method method)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- component_class->methods.accept_port_connection = method;
- BT_LOGV("Set component class's \"accept port connection\" method: "
- "addr=%p, name=\"%s\", type=%s, method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type),
- method);
-
-end:
- return ret;
+ struct bt_component_class_sink *comp_cls = (void *) priv_comp_cls;
+
+ 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.init = method;
+ BT_LIB_LOGV("Set sink component class's initialization method: "
+ "%!+C", comp_cls);
+ return 0;
}
-int bt_component_class_set_port_connected_method(
- struct bt_component_class *component_class,
- bt_component_class_port_connected_method method)
+int bt_private_component_class_source_set_finalize_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_finalize_method method)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- component_class->methods.port_connected = method;
- BT_LOGV("Set component class's \"port connected\" method: "
- "addr=%p, name=\"%s\", type=%s, method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type),
- method);
-
-end:
- return ret;
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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.finalize = method;
+ BT_LIB_LOGV("Set source component class's finalization method: "
+ "%!+C", comp_cls);
+ return 0;
}
-int bt_component_class_set_port_disconnected_method(
- struct bt_component_class *component_class,
- bt_component_class_port_disconnected_method method)
+int bt_private_component_class_filter_set_finalize_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_finalize_method method)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- component_class->methods.port_disconnected = method;
- BT_LOGV("Set component class's \"port disconnected\" method: "
- "addr=%p, name=\"%s\", type=%s, method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type),
- method);
-
-end:
- return ret;
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.finalize = method;
+ BT_LIB_LOGV("Set filter component class's finalization method: "
+ "%!+C", comp_cls);
+ return 0;
}
-int bt_component_class_set_finalize_method(
- struct bt_component_class *component_class,
- bt_component_class_finalize_method method)
+int bt_private_component_class_sink_set_finalize_method(
+ struct bt_private_component_class_sink *priv_comp_cls,
+ bt_private_component_class_sink_finalize_method method)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- component_class->methods.finalize = method;
- BT_LOGV("Set component class's finalization method: "
- "addr=%p, name=\"%s\", type=%s, method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type),
- method);
-
-end:
- return ret;
+ struct bt_component_class_sink *comp_cls = (void *) priv_comp_cls;
+
+ 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.finalize = method;
+ BT_LIB_LOGV("Set sink component class's finalization method: "
+ "%!+C", comp_cls);
+ return 0;
}
-int bt_component_class_source_set_notification_iterator_init_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_init_method method)
+int bt_private_component_class_source_set_query_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_query_method method)
{
- struct bt_component_class_source *source_class;
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- BT_LOGW("Invalid parameter: component class is not a source component class: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- source_class = container_of(component_class,
- struct bt_component_class_source, parent);
- source_class->methods.iterator.init = method;
- BT_LOGV("Set filter component class's notification iterator initialization method: "
- "addr=%p, name=\"%s\", method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- method);
-
-end:
- return ret;
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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.query = method;
+ BT_LIB_LOGV("Set source component class's query method: "
+ "%!+C", comp_cls);
+ return 0;
}
-int bt_component_class_source_set_notification_iterator_finalize_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_finalize_method method)
+int bt_private_component_class_filter_set_query_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_query_method method)
{
- struct bt_component_class_source *source_class;
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- BT_LOGW("Invalid parameter: component class is not a source component class: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.query = method;
+ BT_LIB_LOGV("Set filter component class's query method: "
+ "%!+C", comp_cls);
+ return 0;
+}
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
+int bt_private_component_class_sink_set_query_method(
+ struct bt_private_component_class_sink *priv_comp_cls,
+ bt_private_component_class_sink_query_method method)
+{
+ struct bt_component_class_sink *comp_cls = (void *) priv_comp_cls;
+
+ 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.query = method;
+ BT_LIB_LOGV("Set sink component class's query method: "
+ "%!+C", comp_cls);
+ return 0;
+}
- source_class = container_of(component_class,
- struct bt_component_class_source, parent);
- source_class->methods.iterator.finalize =
- method;
- BT_LOGV("Set filter component class's notification iterator finalization method: "
- "addr=%p, name=\"%s\", method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- method);
+int bt_private_component_class_filter_set_accept_input_port_connection_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_accept_input_port_connection_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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_LOGV("Set filter component class's \"accept input port connection\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
-end:
- return ret;
+int bt_private_component_class_sink_set_accept_input_port_connection_method(
+ struct bt_private_component_class_sink *priv_comp_cls,
+ bt_private_component_class_sink_accept_input_port_connection_method method)
+{
+ struct bt_component_class_sink *comp_cls = (void *) priv_comp_cls;
+
+ 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_LOGV("Set sink component class's \"accept input port connection\" method"
+ ": %!+C", comp_cls);
+ return 0;
}
-int bt_component_class_filter_set_notification_iterator_init_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_init_method method)
+int bt_private_component_class_source_set_accept_output_port_connection_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_accept_output_port_connection_method method)
{
- struct bt_component_class_filter *filter_class;
- int ret = 0;
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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_LOGV("Set source component class's \"accept output port connection\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
+int bt_private_component_class_filter_set_accept_output_port_connection_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_accept_output_port_connection_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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_LOGV("Set filter component class's \"accept output port connection\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
+int bt_private_component_class_filter_set_input_port_connected_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_input_port_connected_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.input_port_connected = method;
+ BT_LIB_LOGV("Set filter component class's \"input port connected\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (component_class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component class is not a filter component class: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
+int bt_private_component_class_sink_set_input_port_connected_method(
+ struct bt_private_component_class_sink *priv_comp_cls,
+ bt_private_component_class_sink_input_port_connected_method method)
+{
+ struct bt_component_class_sink *comp_cls = (void *) priv_comp_cls;
+
+ 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.input_port_connected = method;
+ BT_LIB_LOGV("Set sink component class's \"input port connected\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
+int bt_private_component_class_source_set_output_port_connected_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_output_port_connected_method method)
+{
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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.output_port_connected = method;
+ BT_LIB_LOGV("Set source component class's \"output port connected\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- filter_class = container_of(component_class,
- struct bt_component_class_filter, parent);
- filter_class->methods.iterator.init = method;
- BT_LOGV("Set filter component class's notification iterator initialization method: "
- "addr=%p, name=\"%s\", method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- method);
+int bt_private_component_class_filter_set_output_port_connected_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_output_port_connected_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.output_port_connected = method;
+ BT_LIB_LOGV("Set filter component class's \"output port connected\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
-end:
- return ret;
+int bt_private_component_class_filter_set_input_port_disconnected_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_input_port_disconnected_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.input_port_disconnected = method;
+ BT_LIB_LOGV("Set filter component class's \"input port disconnected\" method"
+ ": %!+C", comp_cls);
+ return 0;
}
-int bt_component_class_filter_set_notification_iterator_finalize_method(
- struct bt_component_class *component_class,
- bt_component_class_notification_iterator_finalize_method method)
+int bt_private_component_class_sink_set_input_port_disconnected_method(
+ struct bt_private_component_class_sink *priv_comp_cls,
+ bt_private_component_class_sink_input_port_disconnected_method method)
{
- struct bt_component_class_filter *filter_class;
- int ret = 0;
+ struct bt_component_class_sink *comp_cls = (void *) priv_comp_cls;
+
+ 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.input_port_disconnected = method;
+ BT_LIB_LOGV("Set sink component class's \"input port disconnected\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
+int bt_private_component_class_source_set_output_port_disconnected_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_output_port_disconnected_method method)
+{
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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.output_port_disconnected = method;
+ BT_LIB_LOGV("Set source component class's \"output port disconnected\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (!method) {
- BT_LOGW_STR("Invalid parameter: method is NULL.");
- ret = -1;
- goto end;
- }
+int bt_private_component_class_filter_set_output_port_disconnected_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_output_port_disconnected_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.output_port_disconnected = method;
+ BT_LIB_LOGV("Set filter component class's \"output port disconnected\" method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (component_class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component class is not a filter component class: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
+int bt_private_component_class_source_set_notification_iterator_init_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_notification_iterator_init_method method)
+{
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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.notif_iter_init = method;
+ BT_LIB_LOGV("Set source component class's notification iterator initialization method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
+int bt_private_component_class_filter_set_notification_iterator_init_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_notification_iterator_init_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.notif_iter_init = method;
+ BT_LIB_LOGV("Set filter component class's notification iterator initialization method"
+ ": %!+C", comp_cls);
+ return 0;
+}
- filter_class = container_of(component_class,
- struct bt_component_class_filter, parent);
- filter_class->methods.iterator.finalize =
- method;
- BT_LOGV("Set filter component class's notification iterator finalization method: "
- "addr=%p, name=\"%s\", method-addr=%p",
- component_class,
- bt_component_class_get_name(component_class),
- method);
+int bt_private_component_class_source_set_notification_iterator_finalize_method(
+ struct bt_private_component_class_source *priv_comp_cls,
+ bt_private_component_class_source_notification_iterator_finalize_method method)
+{
+ struct bt_component_class_source *comp_cls = (void *) priv_comp_cls;
+
+ 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.notif_iter_finalize = method;
+ BT_LIB_LOGV("Set source component class's notification iterator finalization method"
+ ": %!+C", comp_cls);
+ return 0;
+}
-end:
- return ret;
+int bt_private_component_class_filter_set_notification_iterator_finalize_method(
+ struct bt_private_component_class_filter *priv_comp_cls,
+ bt_private_component_class_filter_notification_iterator_finalize_method method)
+{
+ struct bt_component_class_filter *comp_cls = (void *) priv_comp_cls;
+
+ 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.notif_iter_finalize = method;
+ BT_LIB_LOGV("Set filter component class's notification iterator finalization method"
+ ": %!+C", comp_cls);
+ return 0;
}
-int bt_component_class_set_description(
- struct bt_component_class *component_class,
+int bt_private_component_class_set_description(
+ struct bt_private_component_class *priv_comp_cls,
const char *description)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!description) {
- BT_LOGW_STR("Invalid parameter: description is NULL.");
- ret = -1;
- goto end;
- }
+ struct bt_component_class *comp_cls = (void *) priv_comp_cls;
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- g_string_assign(component_class->description, description);
- BT_LOGV("Set component class's description: "
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ BT_ASSERT_PRE_NON_NULL(description, "Description");
+ BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls);
+ g_string_assign(comp_cls->description, description);
+ BT_LIB_LOGV("Set component class's description: "
"addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
-
-end:
- return ret;
+ comp_cls,
+ bt_component_class_get_name(comp_cls),
+ bt_component_class_type_string(comp_cls->type));
+ return 0;
}
-int bt_component_class_set_help(
- struct bt_component_class *component_class,
+int bt_private_component_class_set_help(
+ struct bt_private_component_class *priv_comp_cls,
const char *help)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!help) {
- BT_LOGW_STR("Invalid parameter: help is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- BT_LOGW("Invalid parameter: component class is frozen: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret = -1;
- goto end;
- }
-
- g_string_assign(component_class->help, help);
- BT_LOGV("Set component class's help text: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
-
-end:
- return ret;
+ struct bt_component_class *comp_cls = (void *) priv_comp_cls;
+
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ BT_ASSERT_PRE_NON_NULL(help, "Help");
+ BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls);
+ g_string_assign(comp_cls->help, help);
+ BT_LIB_LOGV("Set component class's help text: %!+C", comp_cls);
+ return 0;
}
-const char *bt_component_class_get_name(
- struct bt_component_class *component_class)
+const char *bt_component_class_get_name(struct bt_component_class *comp_cls)
{
- return component_class ? component_class->name->str : NULL;
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ return comp_cls->name->str;
}
enum bt_component_class_type bt_component_class_get_type(
- struct bt_component_class *component_class)
+ struct bt_component_class *comp_cls)
{
- return component_class ? component_class->type :
- BT_COMPONENT_CLASS_TYPE_UNKNOWN;
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ return comp_cls->type;
}
const char *bt_component_class_get_description(
- struct bt_component_class *component_class)
+ struct bt_component_class *comp_cls)
{
- return component_class && component_class->description &&
- component_class->description->str[0] != '\0' ?
- component_class->description->str : NULL;
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ return comp_cls->description &&
+ comp_cls->description->str[0] != '\0' ?
+ comp_cls->description->str : NULL;
}
const char *bt_component_class_get_help(
- struct bt_component_class *component_class)
+ struct bt_component_class *comp_cls)
{
- return component_class && component_class->help &&
- component_class->help->str[0] != '\0' ?
- component_class->help->str : NULL;
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ return comp_cls->help &&
+ comp_cls->help->str[0] != '\0' ? comp_cls->help->str : NULL;
}
BT_HIDDEN
-void bt_component_class_add_destroy_listener(struct bt_component_class *class,
+void bt_component_class_add_destroy_listener(
+ struct bt_component_class *comp_cls,
bt_component_class_destroy_listener_func func, void *data)
{
struct bt_component_class_destroy_listener listener;
- BT_ASSERT(class);
+ BT_ASSERT(comp_cls);
BT_ASSERT(func);
listener.func = func;
listener.data = data;
- g_array_append_val(class->destroy_listeners, listener);
- BT_LOGV("Component class has no registered query method: "
- "comp-class-addr=%p, comp-class-name=\"%s\", comp-class-type=%s"
- "func-addr=%p, data-addr=%p",
- class,
- bt_component_class_get_name(class),
- bt_component_class_type_string(class->type),
- func, data);
+ g_array_append_val(comp_cls->destroy_listeners, listener);
+ BT_LIB_LOGV("Added destroy listener to component class: "
+ "%![cc-]+C, listener-func-addr=%p", comp_cls, func);
}
-int bt_component_class_freeze(
- struct bt_component_class *component_class)
+BT_HIDDEN
+void _bt_component_class_freeze(struct bt_component_class *comp_cls)
{
- int ret = 0;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (component_class->frozen) {
- goto end;
- }
-
- BT_LOGD("Freezing component class: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- component_class->frozen = BT_TRUE;
-
-end:
- return ret;
+ BT_ASSERT(comp_cls);
+ BT_LIB_LOGD("Freezing component class: %!+C", comp_cls);
+ comp_cls->frozen = true;
}
--- /dev/null
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_TAG "COMP-FILTER"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/values.h>
+#include <babeltrace/graph/self-component-filter.h>
+#include <babeltrace/graph/component-filter.h>
+#include <babeltrace/graph/component-filter-internal.h>
+#include <babeltrace/graph/component-internal.h>
+#include <babeltrace/graph/component-class-internal.h>
+#include <babeltrace/graph/notification.h>
+#include <babeltrace/graph/notification-iterator-internal.h>
+#include <babeltrace/graph/graph.h>
+#include <babeltrace/object.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
+
+BT_HIDDEN
+void bt_component_filter_destroy(struct bt_component *component)
+{
+}
+
+BT_HIDDEN
+struct bt_component *bt_component_filter_create(
+ struct bt_component_class *class)
+{
+ struct bt_component_filter *filter = NULL;
+
+ filter = g_new0(struct bt_component_filter, 1);
+ if (!filter) {
+ BT_LOGE_STR("Failed to allocate one filter component.");
+ goto end;
+ }
+
+end:
+ return (void *) filter;
+}
+
+uint64_t bt_component_filter_get_output_port_count(
+ struct bt_component_filter *comp)
+{
+ return bt_component_get_output_port_count((void *) comp);
+}
+
+struct bt_port_output *bt_component_filter_borrow_output_port_by_name(
+ struct bt_component_filter *comp, const char *name)
+{
+ return bt_component_borrow_output_port_by_name(
+ (void *) comp, name);
+}
+
+struct bt_self_component_port_output *
+bt_self_component_filter_borrow_output_port_by_name(
+ struct bt_self_component_filter *comp, const char *name)
+{
+ return (void *) bt_component_borrow_output_port_by_name(
+ (void *) comp, name);
+}
+
+struct bt_port_output *bt_component_filter_borrow_output_port_by_index(
+ struct bt_component_filter *comp, uint64_t index)
+{
+ return bt_component_borrow_output_port_by_index(
+ (void *) comp, index);
+}
+
+struct bt_self_component_port_output *
+bt_self_component_filter_borrow_output_port_by_index(
+ struct bt_self_component_filter *comp, uint64_t index)
+{
+ return (void *) bt_component_borrow_output_port_by_index(
+ (void *) comp, index);
+}
+
+enum bt_self_component_status bt_self_component_filter_add_output_port(
+ struct bt_self_component_filter *self_comp,
+ const char *name, void *user_data,
+ struct bt_self_component_port_output **self_port)
+{
+ struct bt_component *comp = (void *) self_comp;
+ int status = BT_SELF_COMPONENT_STATUS_OK;
+ struct bt_port *port = NULL;
+
+ /* bt_component_add_output_port() logs details and errors */
+ port = (void *) bt_component_add_output_port(comp, name, user_data);
+ if (!port) {
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
+ goto end;
+ }
+
+ if (self_port) {
+ /* Move reference to user */
+ *self_port = (void *) port;
+ port = NULL;
+ }
+
+end:
+ bt_object_put_ref(port);
+ return status;
+}
+
+uint64_t bt_component_filter_get_input_port_count(
+ struct bt_component_filter *component)
+{
+ /* bt_component_get_input_port_count() logs details/errors */
+ return bt_component_get_input_port_count((void *) component);
+}
+
+struct bt_port_input *bt_component_filter_borrow_input_port_by_name(
+ struct bt_component_filter *component, const char *name)
+{
+ /* bt_component_borrow_input_port_by_name() logs details/errors */
+ return bt_component_borrow_input_port_by_name(
+ (void *) component, name);
+}
+
+struct bt_self_component_port_input *
+bt_self_component_filter_borrow_input_port_by_name(
+ struct bt_self_component_filter *component, const char *name)
+{
+ /* bt_component_borrow_input_port_by_name() logs details/errors */
+ return (void *) bt_component_borrow_input_port_by_name(
+ (void *) component, name);
+}
+
+struct bt_port_input *bt_component_filter_borrow_input_port_by_index(
+ struct bt_component_filter *component, uint64_t index)
+{
+ /* bt_component_borrow_input_port_by_index() logs details/errors */
+ return bt_component_borrow_input_port_by_index(
+ (void *) component, index);
+}
+
+struct bt_self_component_port_input *
+bt_self_component_filter_borrow_input_port_by_index(
+ struct bt_self_component_filter *component, uint64_t index)
+{
+ /* bt_component_borrow_input_port_by_index() logs details/errors */
+ return (void *) bt_component_borrow_input_port_by_index(
+ (void *) component, index);
+}
+
+enum bt_self_component_status bt_self_component_filter_add_input_port(
+ struct bt_self_component_filter *self_comp,
+ const char *name, void *user_data,
+ struct bt_self_component_port_input **self_port)
+{
+ int status = BT_SELF_COMPONENT_STATUS_OK;
+ struct bt_port *port = NULL;
+ struct bt_component *comp = (void *) self_comp;
+
+ /* bt_component_add_input_port() logs details/errors */
+ port = (void *) bt_component_add_input_port(comp, name, user_data);
+ if (!port) {
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
+ goto end;
+ }
+
+ if (self_port) {
+ /* Move reference to user */
+ *self_port = (void *) port;
+ port = NULL;
+ }
+
+end:
+ bt_object_put_ref(port);
+ return status;
+}
--- /dev/null
+/*
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_TAG "COMP-SINK"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/values.h>
+#include <babeltrace/graph/self-component-sink.h>
+#include <babeltrace/graph/component-sink.h>
+#include <babeltrace/graph/component-sink-internal.h>
+#include <babeltrace/graph/component-internal.h>
+#include <babeltrace/graph/notification.h>
+#include <babeltrace/graph/graph.h>
+#include <babeltrace/object.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
+
+BT_HIDDEN
+void bt_component_sink_destroy(struct bt_component *component)
+{
+}
+
+BT_HIDDEN
+struct bt_component *bt_component_sink_create(struct bt_component_class *class)
+{
+ struct bt_component_sink *sink = NULL;
+
+ sink = g_new0(struct bt_component_sink, 1);
+ if (!sink) {
+ BT_LOGE_STR("Failed to allocate one sink component.");
+ goto end;
+ }
+
+end:
+ return (void *) sink;
+}
+
+uint64_t bt_component_sink_get_input_port_count(
+ struct bt_component_sink *component)
+{
+ /* bt_component_get_input_port_count() logs details/errors */
+ return bt_component_get_input_port_count((void *) component);
+}
+
+struct bt_port_input *bt_component_sink_borrow_input_port_by_name(
+ struct bt_component_sink *component, const char *name)
+{
+ /* bt_component_borrow_input_port_by_name() logs details/errors */
+ return bt_component_borrow_input_port_by_name((void *) component, name);
+}
+
+struct bt_self_component_port_input *
+bt_self_component_sink_borrow_input_port_by_name(
+ struct bt_self_component_sink *component, const char *name)
+{
+ /* bt_component_borrow_input_port_by_name() logs details/errors */
+ return (void *) bt_component_borrow_input_port_by_name(
+ (void *) component, name);
+}
+
+struct bt_port_input *bt_component_sink_borrow_input_port_by_index(
+ struct bt_component_sink *component, uint64_t index)
+{
+ /* bt_component_borrow_input_port_by_index() logs details/errors */
+ return bt_component_borrow_input_port_by_index(
+ (void *) component, index);
+}
+
+struct bt_self_component_port_input *
+bt_self_component_sink_borrow_input_port_by_index(
+ struct bt_self_component_sink *component, uint64_t index)
+{
+ /* bt_component_borrow_input_port_by_index() logs details/errors */
+ return (void *) bt_component_borrow_input_port_by_index(
+ (void *) component, index);
+}
+
+enum bt_self_component_status bt_self_component_sink_add_input_port(
+ struct bt_self_component_sink *self_comp,
+ const char *name, void *user_data,
+ struct bt_self_component_port_input **self_port)
+{
+ int status = BT_SELF_COMPONENT_STATUS_OK;
+ struct bt_port *port = NULL;
+ struct bt_component *comp = (void *) self_comp;
+
+ /* bt_component_add_input_port() logs details/errors */
+ port = (void *) bt_component_add_input_port(comp, name, user_data);
+ if (!port) {
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
+ goto end;
+ }
+
+ if (self_port) {
+ /* Move reference to user */
+ *self_port = (void *) port;
+ port = NULL;
+ }
+
+end:
+ bt_object_put_ref(port);
+ return status;
+}
--- /dev/null
+/*
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_TAG "COMP-SOURCE"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/object.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/graph/self-component-source.h>
+#include <babeltrace/graph/component-source.h>
+#include <babeltrace/graph/component-source-internal.h>
+#include <babeltrace/graph/component-internal.h>
+#include <babeltrace/graph/port-internal.h>
+#include <babeltrace/graph/notification-iterator.h>
+#include <babeltrace/graph/notification-iterator-internal.h>
+#include <babeltrace/graph/graph.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
+
+BT_HIDDEN
+void bt_component_source_destroy(struct bt_component *component)
+{
+}
+
+BT_HIDDEN
+struct bt_component *bt_component_source_create(
+ struct bt_component_class *class)
+{
+ struct bt_component_source *source = NULL;
+
+ source = g_new0(struct bt_component_source, 1);
+ if (!source) {
+ BT_LOGE_STR("Failed to allocate one source component.");
+ goto end;
+ }
+
+end:
+ return (void *) source;
+}
+
+uint64_t bt_component_source_get_output_port_count(
+ struct bt_component_source *comp)
+{
+ return bt_component_get_output_port_count((void *) comp);
+}
+
+struct bt_port_output *bt_component_source_borrow_output_port_by_name(
+ struct bt_component_source *comp, const char *name)
+{
+ return bt_component_borrow_output_port_by_name((void *) comp, name);
+}
+
+struct bt_self_component_port_output *
+bt_self_component_source_borrow_output_port_by_name(
+ struct bt_self_component_source *comp, const char *name)
+{
+ return (void *) bt_component_borrow_output_port_by_name(
+ (void *) comp, name);
+}
+
+struct bt_port_output *bt_component_source_borrow_output_port_by_index(
+ struct bt_component_source *comp, uint64_t index)
+{
+ return bt_component_borrow_output_port_by_index((void *) comp, index);
+}
+
+struct bt_self_component_port_output *
+bt_self_component_source_borrow_output_port_by_index(
+ struct bt_self_component_source *comp, uint64_t index)
+{
+ return (void *) bt_component_borrow_output_port_by_index(
+ (void *) comp, index);
+}
+
+enum bt_self_component_status bt_self_component_source_add_output_port(
+ struct bt_self_component_source *self_comp,
+ const char *name, void *user_data,
+ struct bt_self_component_port_output **self_port)
+{
+ struct bt_component *comp = (void *) self_comp;
+ int status = BT_SELF_COMPONENT_STATUS_OK;
+ struct bt_port *port = NULL;
+
+ /* bt_component_add_output_port() logs details and errors */
+ port = (void *) bt_component_add_output_port(comp, name, user_data);
+ if (!port) {
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
+ goto end;
+ }
+
+ if (self_port) {
+ /* Move reference to user */
+ *self_port = (void *) port;
+ port = NULL;
+ }
+
+end:
+ bt_object_put_ref(port);
+ return status;
+}
#define BT_LOG_TAG "COMP"
#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/graph/private-component.h>
+#include <babeltrace/graph/self-component.h>
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/graph/component-source-internal.h>
#include <babeltrace/graph/component-filter-internal.h>
#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/graph/private-connection.h>
#include <babeltrace/graph/connection-internal.h>
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/notification-iterator-internal.h>
-#include <babeltrace/graph/private-connection-private-notification-iterator.h>
+#include <babeltrace/graph/port-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/values.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <stdint.h>
#include <inttypes.h>
};
static
-void bt_component_destroy(struct bt_object *obj)
+void finalize_component(struct bt_component *comp)
+{
+ typedef void (*method_t)(void *);
+
+ method_t method = NULL;
+
+ BT_ASSERT(comp);
+
+ switch (comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ struct bt_component_class_source *src_cc = (void *) comp->class;
+
+ method = (method_t) src_cc->methods.finalize;
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ struct bt_component_class_filter *flt_cc = (void *) comp->class;
+
+ method = (method_t) flt_cc->methods.finalize;
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ {
+ struct bt_component_class_sink *sink_cc = (void *) comp->class;
+
+ method = (method_t) sink_cc->methods.finalize;
+ break;
+ }
+ default:
+ abort();
+ }
+
+ if (method) {
+ BT_LIB_LOGD("Calling user's finalization method: "
+ "%![comp-]+c", comp);
+ method(comp);
+ }
+}
+
+static
+void destroy_component(struct bt_object *obj)
{
struct bt_component *component = NULL;
- struct bt_component_class *component_class = NULL;
int i;
if (!obj) {
* The component's reference count is 0 if we're here. Increment
* it to avoid a double-destroy (possibly infinitely recursive).
* This could happen for example if the component's finalization
- * function does bt_object_get_ref() (or anything that causes bt_object_get_ref() to
- * be called) on itself (ref. count goes from 0 to 1), and then
- * bt_object_put_ref(): the reference count would go from 1 to 0 again and
- * this function would be called again.
+ * function does bt_object_get_ref() (or anything that causes
+ * bt_object_get_ref() to be called) on itself (ref. count goes
+ * from 0 to 1), and then bt_object_put_ref(): the reference
+ * count would go from 1 to 0 again and this function would be
+ * called again.
*/
obj->ref_count++;
component = container_of(obj, struct bt_component, base);
- BT_LOGD("Destroying component: addr=%p, name=\"%s\", graph-addr=%p",
- component, bt_component_get_name(component),
- obj->parent);
+ BT_LIB_LOGD("Destroying component: %![comp-]+c, %![graph-]+g",
+ component, bt_component_borrow_graph(component));
/* Call destroy listeners in reverse registration order */
BT_LOGD_STR("Calling destroy listeners.");
listener->func(component, listener->data);
}
- component_class = component->class;
-
/*
* User data is destroyed first, followed by the concrete
* component instance. Do not finalize if the component's user
* initialization method failed in the first place.
*/
- if (component->initialized && component->class->methods.finalize) {
- BT_LOGD_STR("Calling user's finalization method.");
- component->class->methods.finalize(
- bt_private_component_from_component(component));
+ if (component->initialized) {
+ finalize_component(component);
}
if (component->destroy) {
if (component->input_ports) {
BT_LOGD_STR("Destroying input ports.");
g_ptr_array_free(component->input_ports, TRUE);
+ component->input_ports = NULL;
}
if (component->output_ports) {
BT_LOGD_STR("Destroying output ports.");
g_ptr_array_free(component->output_ports, TRUE);
+ component->output_ports = NULL;
}
if (component->destroy_listeners) {
g_array_free(component->destroy_listeners, TRUE);
+ component->destroy_listeners = NULL;
}
if (component->name) {
g_string_free(component->name, TRUE);
+ component->name = NULL;
}
- BT_LOGD("Putting component class.");
- bt_object_put_ref(component_class);
+ BT_LOGD_STR("Putting component class.");
+ BT_OBJECT_PUT_REF_AND_RESET(component->class);
g_free(component);
}
-struct bt_component *bt_component_borrow_from_private(
- struct bt_private_component *private_component)
-{
- return (void *) private_component;
-}
-
enum bt_component_class_type bt_component_get_class_type(
struct bt_component *component)
{
- return component ? component->class->type : BT_COMPONENT_CLASS_TYPE_UNKNOWN;
+ BT_ASSERT_PRE_NON_NULL(component, "Component");
+ return component->class->type;
}
static
-struct bt_port *bt_component_add_port(
+struct bt_port *add_port(
struct bt_component *component, GPtrArray *ports,
enum bt_port_type port_type, const char *name, void *user_data)
{
- size_t i;
struct bt_port *new_port = NULL;
struct bt_graph *graph = NULL;
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(component, "Component");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE(strlen(name) > 0, "Name is empty");
+ graph = bt_component_borrow_graph(component);
+ BT_ASSERT_PRE(graph && !bt_graph_is_canceled(graph),
+ "Component's graph is canceled: %![comp-]+c, %![graph-]+g",
+ component, graph);
- if (strlen(name) == 0) {
- BT_LOGW_STR("Invalid parameter: name is an empty string.");
- goto end;
- }
+ // TODO: Validate that the name is not already used.
- BT_LOGD("Adding port to component: comp-addr=%p, comp-name=\"%s\", "
+ BT_LIB_LOGD("Adding port to component: %![comp-]+c, "
"port-type=%s, port-name=\"%s\"", component,
- bt_component_get_name(component),
bt_port_type_string(port_type), name);
- /* Look for a port having the same name. */
- for (i = 0; i < ports->len; i++) {
- const char *port_name;
- struct bt_port *port = g_ptr_array_index(ports, i);
-
- port_name = bt_port_get_name(port);
- BT_ASSERT(port_name);
-
- if (!strcmp(name, port_name)) {
- /* Port name clash, abort. */
- BT_LOGW("Invalid parameter: another port with the same name already exists in the component: "
- "other-port-addr=%p", port);
- goto end;
- }
- }
-
new_port = bt_port_create(component, port_type, name, user_data);
if (!new_port) {
- BT_LOGE("Cannot create port object.");
+ BT_LOGE_STR("Cannot create port object.");
goto end;
}
BT_OBJECT_PUT_REF_AND_RESET(graph);
}
- BT_LOGD("Created and added port to component: comp-addr=%p, comp-name=\"%s\", "
- "port-type=%s, port-name=\"%s\", port-addr=%p", component,
- bt_component_get_name(component),
- bt_port_type_string(port_type), name, new_port);
+ BT_LIB_LOGD("Created and added port to component: "
+ "%![comp-]+c, %![port-]+p", component, new_port);
end:
return new_port;
}
BT_HIDDEN
-int64_t bt_component_get_input_port_count(struct bt_component *comp)
+uint64_t bt_component_get_input_port_count(struct bt_component *comp)
{
- BT_ASSERT(comp);
- return (int64_t) comp->input_ports->len;
+ BT_ASSERT_PRE_NON_NULL(comp, "Component");
+ return (uint64_t) comp->input_ports->len;
}
BT_HIDDEN
-int64_t bt_component_get_output_port_count(struct bt_component *comp)
+uint64_t bt_component_get_output_port_count(struct bt_component *comp)
{
- BT_ASSERT(comp);
- return (int64_t) comp->output_ports->len;
+ BT_ASSERT_PRE_NON_NULL(comp, "Component");
+ return (uint64_t) comp->output_ports->len;
}
BT_HIDDEN
-enum bt_component_status bt_component_create(
- struct bt_component_class *component_class,
+int bt_component_create(struct bt_component_class *component_class,
const char *name, struct bt_component **user_component)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_component *component = NULL;
enum bt_component_class_type type;
BT_ASSERT(name);
type = bt_component_class_get_type(component_class);
- BT_LOGD("Creating empty component from component class: "
- "comp-cls-addr=%p, comp-cls-type=%s, name=\"%s\"",
- component_class, bt_component_class_type_string(type), name);
+ BT_LIB_LOGD("Creating empty component from component class: %![cc-]+C, "
+ "comp-name=\"%s\"", component_class, name);
component = component_create_funcs[type](component_class);
if (!component) {
BT_LOGE_STR("Cannot create specific component object.");
- status = BT_COMPONENT_STATUS_NOMEM;
+ ret = -1;
goto end;
}
bt_object_init_shared_with_parent(&component->base,
- bt_component_destroy);
+ destroy_component);
component->class = bt_object_get_ref(component_class);
component->destroy = component_destroy_funcs[type];
component->name = g_string_new(name);
if (!component->name) {
BT_LOGE_STR("Failed to allocate one GString.");
- status = BT_COMPONENT_STATUS_NOMEM;
+ ret = -1;
goto end;
}
(GDestroyNotify) bt_object_try_spec_release);
if (!component->input_ports) {
BT_LOGE_STR("Failed to allocate one GPtrArray.");
- status = BT_COMPONENT_STATUS_NOMEM;
+ ret = -1;
goto end;
}
(GDestroyNotify) bt_object_try_spec_release);
if (!component->output_ports) {
BT_LOGE_STR("Failed to allocate one GPtrArray.");
- status = BT_COMPONENT_STATUS_NOMEM;
+ ret = -1;
goto end;
}
sizeof(struct bt_component_destroy_listener));
if (!component->destroy_listeners) {
BT_LOGE_STR("Failed to allocate one GArray.");
- status = BT_COMPONENT_STATUS_NOMEM;
+ ret = -1;
goto end;
}
- BT_LOGD("Created empty component from component class: "
- "comp-cls-addr=%p, comp-cls-type=%s, name=\"%s\", comp-addr=%p",
- component_class, bt_component_class_type_string(type), name,
- component);
+ BT_LIB_LOGD("Created empty component from component class: "
+ "%![cc-]+C, %![comp-]+c", component_class, component);
BT_OBJECT_MOVE_REF(*user_component, component);
end:
bt_object_put_ref(component);
- return status;
+ return ret;
}
const char *bt_component_get_name(struct bt_component *component)
{
- const char *ret = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- ret = component->name->len == 0 ? NULL : component->name->str;
-
-end:
- return ret;
+ BT_ASSERT_PRE_NON_NULL(component, "Component");
+ return component->name->str;
}
-struct bt_component_class *bt_component_get_class(
+struct bt_component_class *bt_component_borrow_class(
struct bt_component *component)
{
- return component ? bt_object_get_ref(component->class) : NULL;
+ BT_ASSERT_PRE_NON_NULL(component, "Component");
+ return component->class;
}
-void *bt_private_component_get_user_data(
- struct bt_private_component *private_component)
+void *bt_self_component_get_data(struct bt_self_component *self_comp)
{
- struct bt_component *component =
- bt_component_borrow_from_private(private_component);
+ struct bt_component *component = (void *) self_comp;
- return component ? component->user_data : NULL;
+ BT_ASSERT_PRE_NON_NULL(component, "Component");
+ return component->user_data;
}
-enum bt_component_status bt_private_component_set_user_data(
- struct bt_private_component *private_component,
+void bt_self_component_set_data(struct bt_self_component *self_comp,
void *data)
{
- struct bt_component *component =
- bt_component_borrow_from_private(private_component);
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- ret = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
+ struct bt_component *component = (void *) self_comp;
+ BT_ASSERT_PRE_NON_NULL(component, "Component");
component->user_data = data;
- BT_LOGV("Set component's user data: "
- "comp-addr=%p, comp-name=\"%s\", user-data-addr=%p",
- component, bt_component_get_name(component), data);
-
-end:
- return ret;
+ BT_LIB_LOGV("Set component's user data: %!+c", component);
}
BT_HIDDEN
}
static
-struct bt_port *bt_component_get_port_by_name(GPtrArray *ports,
+struct bt_port *borrow_port_by_name(GPtrArray *ports,
const char *name)
{
- size_t i;
+ uint64_t i;
struct bt_port *ret_port = NULL;
BT_ASSERT(name);
for (i = 0; i < ports->len; i++) {
struct bt_port *port = g_ptr_array_index(ports, i);
- const char *port_name = bt_port_get_name(port);
- if (!port_name) {
- continue;
- }
-
- if (!strcmp(name, port_name)) {
- ret_port = bt_object_get_ref(port);
+ if (!strcmp(name, port->name->str)) {
+ ret_port = port;
break;
}
}
}
BT_HIDDEN
-struct bt_port *bt_component_get_input_port_by_name(struct bt_component *comp,
- const char *name)
+struct bt_port_input *bt_component_borrow_input_port_by_name(
+ struct bt_component *comp, const char *name)
{
BT_ASSERT(comp);
-
- return bt_component_get_port_by_name(comp->input_ports, name);
+ return (void *) borrow_port_by_name(comp->input_ports, name);
}
BT_HIDDEN
-struct bt_port *bt_component_get_output_port_by_name(struct bt_component *comp,
- const char *name)
+struct bt_port_output *bt_component_borrow_output_port_by_name(
+ struct bt_component *comp, const char *name)
{
- BT_ASSERT(comp);
-
- return bt_component_get_port_by_name(comp->output_ports, name);
+ BT_ASSERT_PRE_NON_NULL(comp, "Component");
+ return (void *)
+ borrow_port_by_name(comp->output_ports, name);
}
static
-struct bt_port *bt_component_get_port_by_index(GPtrArray *ports, uint64_t index)
+struct bt_port *borrow_port_by_index(GPtrArray *ports, uint64_t index)
{
- struct bt_port *port = NULL;
-
- if (index >= ports->len) {
- BT_LOGW("Invalid parameter: index is out of bounds: "
- "index=%" PRIu64 ", count=%u",
- index, ports->len);
- goto end;
- }
-
- port = bt_object_get_ref(g_ptr_array_index(ports, index));
-end:
- return port;
+ BT_ASSERT(index < ports->len);
+ return g_ptr_array_index(ports, index);
}
BT_HIDDEN
-struct bt_port *bt_component_get_input_port_by_index(struct bt_component *comp,
- uint64_t index)
+struct bt_port_input *bt_component_borrow_input_port_by_index(
+ struct bt_component *comp, uint64_t index)
{
- BT_ASSERT(comp);
-
- return bt_component_get_port_by_index(comp->input_ports, index);
+ BT_ASSERT_PRE_NON_NULL(comp, "Component");
+ BT_ASSERT_PRE_VALID_INDEX(index, comp->input_ports->len);
+ return (void *)
+ borrow_port_by_index(comp->input_ports, index);
}
BT_HIDDEN
-struct bt_port *bt_component_get_output_port_by_index(struct bt_component *comp,
- uint64_t index)
+struct bt_port_output *bt_component_borrow_output_port_by_index(
+ struct bt_component *comp, uint64_t index)
{
- BT_ASSERT(comp);
-
- return bt_component_get_port_by_index(comp->output_ports, index);
+ BT_ASSERT_PRE_NON_NULL(comp, "Component");
+ BT_ASSERT_PRE_VALID_INDEX(index, comp->output_ports->len);
+ return (void *)
+ borrow_port_by_index(comp->output_ports, index);
}
BT_HIDDEN
-struct bt_port *bt_component_add_input_port(
+struct bt_port_input *bt_component_add_input_port(
struct bt_component *component, const char *name,
void *user_data)
{
- /* bt_component_add_port() logs details */
- return bt_component_add_port(component, component->input_ports,
- BT_PORT_TYPE_INPUT, name, user_data);
+ /* add_port() logs details */
+ return (void *)
+ add_port(component, component->input_ports,
+ BT_PORT_TYPE_INPUT, name, user_data);
}
BT_HIDDEN
-struct bt_port *bt_component_add_output_port(
+struct bt_port_output *bt_component_add_output_port(
struct bt_component *component, const char *name,
void *user_data)
{
- /* bt_component_add_port() logs details */
- return bt_component_add_port(component, component->output_ports,
- BT_PORT_TYPE_OUTPUT, name, user_data);
+ /* add_port() logs details */
+ return (void *)
+ add_port(component, component->output_ports,
+ BT_PORT_TYPE_OUTPUT, name, user_data);
}
static
-void bt_component_remove_port_by_index(struct bt_component *component,
- GPtrArray *ports, size_t index)
+void remove_port_by_index(struct bt_component *component,
+ GPtrArray *ports, uint64_t index)
{
struct bt_port *port;
struct bt_graph *graph;
BT_ASSERT(ports);
BT_ASSERT(index < ports->len);
port = g_ptr_array_index(ports, index);
-
- BT_LOGD("Removing port from component: "
- "comp-addr=%p, comp-name=\"%s\", "
- "port-addr=%p, port-name=\"%s\"",
- component, bt_component_get_name(component),
- port, bt_port_get_name(port));
+ BT_LIB_LOGD("Removing port from component: %![comp-]+c, %![port-]+p",
+ component, port);
/* Disconnect both ports of this port's connection, if any */
if (port->connection) {
bt_connection_end(port->connection, true);
}
- /* Remove from parent's array of ports (weak refs) */
+ /*
+ * The port's current reference count can be 0 at this point,
+ * which means its parent (component) keeps it alive. We are
+ * about to remove the port from its parent's container (with
+ * the g_ptr_array_remove_index() call below), which in this
+ * case would destroy it. This is not good because we still
+ * need the port for the bt_graph_notify_port_removed() call
+ * below (in which its component is `NULL` as expected because
+ * of the bt_object_set_parent() call below).
+ *
+ * To avoid a destroyed port during the notification callback,
+ * get a reference now, and put it (destroying the port if its
+ * reference count is 0 at this point) after notifying the
+ * private graph's user.
+ */
+ bt_object_get_no_null_check(&port->base);
+
+ /*
+ * Remove from parent's array of ports (weak refs). This never
+ * destroys the port object because its reference count is at
+ * least 1 thanks to the bt_object_get_no_null_check() call
+ * above.
+ */
g_ptr_array_remove_index(ports, index);
/* Detach port from its component parent */
- BT_OBJECT_PUT_REF_AND_RESET(port->base.parent);
+ bt_object_set_parent(&port->base, NULL);
/*
* Notify the graph's creator that a port is removed.
*/
- graph = bt_object_get_ref(bt_component_borrow_graph(component));
+ graph = bt_component_borrow_graph(component);
if (graph) {
bt_graph_notify_port_removed(graph, component, port);
- BT_OBJECT_PUT_REF_AND_RESET(graph);
}
- BT_LOGD("Removed port from component: "
- "comp-addr=%p, comp-name=\"%s\", "
- "port-addr=%p, port-name=\"%s\"",
- component, bt_component_get_name(component),
- port, bt_port_get_name(port));
+ BT_LIB_LOGD("Removed port from component: %![comp-]+c, %![port-]+p",
+ component, port);
+
+ /*
+ * Put the local reference. If this port's reference count was 0
+ * when entering this function, it is 1 now, so it is destroyed
+ * immediately.
+ */
+ bt_object_put_no_null_check(&port->base);
}
BT_HIDDEN
-enum bt_component_status bt_component_remove_port(
- struct bt_component *component, struct bt_port *port)
+void bt_component_remove_port(struct bt_component *component,
+ struct bt_port *port)
{
- size_t i;
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ uint64_t i;
GPtrArray *ports = NULL;
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (!port) {
- BT_LOGW_STR("Invalid parameter: port is NULL.");
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
+ BT_ASSERT(component);
+ BT_ASSERT(port);
- if (bt_port_get_type(port) == BT_PORT_TYPE_INPUT) {
+ switch (port->type) {
+ case BT_PORT_TYPE_INPUT:
ports = component->input_ports;
- } else if (bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT) {
+ break;
+ case BT_PORT_TYPE_OUTPUT:
ports = component->output_ports;
+ break;
+ default:
+ abort();
}
BT_ASSERT(ports);
struct bt_port *cur_port = g_ptr_array_index(ports, i);
if (cur_port == port) {
- bt_component_remove_port_by_index(component,
+ remove_port_by_index(component,
ports, i);
goto end;
}
}
- status = BT_COMPONENT_STATUS_NOT_FOUND;
- BT_LOGW("Port to remove from component was not found: "
- "comp-addr=%p, comp-name=\"%s\", "
- "port-addr=%p, port-name=\"%s\"",
- component, bt_component_get_name(component),
- port, bt_port_get_name(port));
+ BT_LIB_LOGW("Port to remove from component was not found: "
+ "%![comp-]+c, %![port-]+p", component, port);
end:
- return status;
+ return;
}
BT_HIDDEN
-enum bt_component_status bt_component_accept_port_connection(
+enum bt_self_component_status bt_component_accept_port_connection(
struct bt_component *comp, struct bt_port *self_port,
struct bt_port *other_port)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ typedef enum bt_self_component_status (*method_t)(
+ void *, void *, 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);
- if (comp->class->methods.accept_port_connection) {
- BT_LOGD("Calling user's \"accept port connection\" method: "
- "comp-addr=%p, comp-name=\"%s\", "
- "self-port-addr=%p, self-port-name=\"%s\", "
- "other-port-addr=%p, other-port-name=\"%s\"",
- comp, bt_component_get_name(comp),
- self_port, bt_port_get_name(self_port),
- other_port, bt_port_get_name(other_port));
- status = comp->class->methods.accept_port_connection(
- bt_private_component_from_component(comp),
- bt_private_port_from_port(self_port),
- 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, other_port);
BT_LOGD("User method returned: status=%s",
- bt_component_status_string(status));
+ bt_self_component_status_string(status));
}
return status;
}
BT_HIDDEN
-enum bt_component_status bt_component_port_connected(struct bt_component *comp,
- struct bt_port *self_port, struct bt_port *other_port)
+enum bt_self_component_status bt_component_port_connected(
+ struct bt_component *comp, struct bt_port *self_port,
+ struct bt_port *other_port)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ typedef enum bt_self_component_status (*method_t)(
+ void *, void *, 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);
- if (comp->class->methods.port_connected) {
- BT_LOGD("Calling user's \"port connected\" method: "
- "comp-addr=%p, comp-name=\"%s\", "
- "self-port-addr=%p, self-port-name=\"%s\", "
- "other-port-addr=%p, other-port-name=\"%s\"",
- comp, bt_component_get_name(comp),
- self_port, bt_port_get_name(self_port),
- other_port, bt_port_get_name(other_port));
- status = comp->class->methods.port_connected(
- bt_private_component_from_component(comp),
- bt_private_port_from_port(self_port), 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.output_port_connected;
+ 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.input_port_connected;
+ break;
+ case BT_PORT_TYPE_OUTPUT:
+ method = (method_t) flt_cc->methods.output_port_connected;
+ 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.input_port_connected;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ default:
+ abort();
+ }
+
+ if (method) {
+ BT_LIB_LOGD("Calling user's \"port connected\" method: "
+ "%![comp-]+c, %![self-port-]+p, %![other-port-]+p",
+ comp, self_port, other_port);
+ status = method(comp, self_port, other_port);
+ BT_LOGD("User method returned: status=%s",
+ bt_self_component_status_string(status));
}
return status;
void bt_component_port_disconnected(struct bt_component *comp,
struct bt_port *port)
{
+ typedef void (*method_t)(void *, void *);
+
+ method_t method = NULL;
+
BT_ASSERT(comp);
BT_ASSERT(port);
- if (comp->class->methods.port_disconnected) {
- BT_LOGD("Calling user's \"port disconnected\" method: "
- "comp-addr=%p, comp-name=\"%s\", "
- "port-addr=%p, port-name=\"%s\"",
- comp, bt_component_get_name(comp),
- port, bt_port_get_name(port));
- comp->class->methods.port_disconnected(
- bt_private_component_from_component(comp),
- bt_private_port_from_port(port));
+ switch (comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ struct bt_component_class_source *src_cc = (void *) comp->class;
+
+ switch (port->type) {
+ case BT_PORT_TYPE_OUTPUT:
+ method = (method_t) src_cc->methods.output_port_disconnected;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ struct bt_component_class_filter *flt_cc = (void *) comp->class;
+
+ switch (port->type) {
+ case BT_PORT_TYPE_INPUT:
+ method = (method_t) flt_cc->methods.input_port_disconnected;
+ break;
+ case BT_PORT_TYPE_OUTPUT:
+ method = (method_t) flt_cc->methods.output_port_disconnected;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ {
+ struct bt_component_class_sink *sink_cc = (void *) comp->class;
+
+ switch (port->type) {
+ case BT_PORT_TYPE_INPUT:
+ method = (method_t) sink_cc->methods.input_port_disconnected;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ default:
+ abort();
+ }
+
+ if (method) {
+ BT_LIB_LOGD("Calling user's \"port disconnected\" method: "
+ "%![comp-]+c, %![port-]+p", comp, port);
+ method(comp, port);
}
}
listener.func = func;
listener.data = data;
g_array_append_val(component->destroy_listeners, listener);
- BT_LOGV("Added destroy listener: "
- "comp-addr=%p, comp-name=\"%s\", "
+ BT_LIB_LOGV("Added destroy listener: %![comp-]+c, "
"func-addr=%p, data-addr=%p",
- component, bt_component_get_name(component),
- func, data);
+ component, func, data);
}
BT_HIDDEN
void bt_component_remove_destroy_listener(struct bt_component *component,
bt_component_destroy_listener_func func, void *data)
{
- size_t i;
+ uint64_t i;
BT_ASSERT(component);
BT_ASSERT(func);
if (listener->func == func && listener->data == data) {
g_array_remove_index(component->destroy_listeners, i);
i--;
- BT_LOGV("Removed destroy listener: "
- "comp-addr=%p, comp-name=\"%s\", "
+ BT_LIB_LOGV("Removed destroy listener: %![comp-]+c, "
"func-addr=%p, data-addr=%p",
- component, bt_component_get_name(component),
- func, data);
+ component, func, data);
}
}
}
/*
- * connection.c
- *
- * Babeltrace Connection
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/graph/notification-iterator-internal.h>
#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-source-internal.h>
-#include <babeltrace/graph/component-filter-internal.h>
#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/private-connection.h>
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <stdlib.h>
#include <glib.h>
static
-void bt_connection_destroy(struct bt_object *obj)
+void destroy_connection(struct bt_object *obj)
{
struct bt_connection *connection = container_of(obj,
struct bt_connection, base);
- BT_LOGD("Destroying connection: addr=%p", connection);
+ BT_LIB_LOGD("Destroying connection: %!+x", connection);
/*
* Make sure that each notification iterator which was created
*/
bt_connection_end(connection, false);
g_ptr_array_free(connection->iterators, TRUE);
+ connection->iterators = NULL;
/*
* No bt_object_put_ref on ports as a connection only holds _weak_
}
static
-void bt_connection_try_remove_from_graph(struct bt_connection *connection)
+void try_remove_connection_from_graph(struct bt_connection *connection)
{
void *graph = (void *) bt_object_borrow_parent(&connection->base);
* It is safe to remove the connection from the graph, therefore
* destroying it.
*/
- BT_LOGD("Removing self from graph's connections: "
- "graph-addr=%p, conn-addr=%p", graph, connection);
+ BT_LIB_LOGD("Removing self from graph's connections: "
+ "%![graph-]+g, %![conn-]+x", graph, connection);
bt_graph_remove_connection(graph, connection);
}
static
-void bt_connection_parent_is_owner(struct bt_object *obj)
+void parent_is_owner(struct bt_object *obj)
{
struct bt_connection *connection = container_of(obj,
struct bt_connection, base);
- bt_connection_try_remove_from_graph(connection);
-}
-
-struct bt_connection *bt_connection_borrow_from_private(
- struct bt_private_connection *private_connection)
-{
- return (void *) private_connection;
+ try_remove_connection_from_graph(connection);
}
BT_HIDDEN
-struct bt_connection *bt_connection_create(
- struct bt_graph *graph,
+struct bt_connection *bt_connection_create(struct bt_graph *graph,
struct bt_port *upstream_port,
struct bt_port *downstream_port)
{
struct bt_connection *connection = NULL;
- if (bt_port_get_type(upstream_port) != BT_PORT_TYPE_OUTPUT) {
- BT_LOGW_STR("Invalid parameter: upstream port is not an output port.");
- goto end;
- }
- if (bt_port_get_type(downstream_port) != BT_PORT_TYPE_INPUT) {
- BT_LOGW_STR("Invalid parameter: downstream port is not an input port.");
- goto end;
- }
-
- BT_LOGD("Creating connection: "
- "graph-addr=%p, upstream-port-addr=%p, uptream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- graph, upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
+ BT_LIB_LOGD("Creating connection: "
+ "%![graph-]+g, %![up-port-]+p, %![down-port-]+p",
+ graph, upstream_port, downstream_port);
connection = g_new0(struct bt_connection, 1);
if (!connection) {
BT_LOGE_STR("Failed to allocate one connection.");
}
bt_object_init_shared_with_parent(&connection->base,
- bt_connection_destroy);
+ destroy_connection);
bt_object_set_parent_is_owner_listener_func(&connection->base,
- bt_connection_parent_is_owner);
+ parent_is_owner);
connection->iterators = g_ptr_array_new();
if (!connection->iterators) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
/* Weak references are taken, see comment in header. */
connection->upstream_port = upstream_port;
connection->downstream_port = downstream_port;
- BT_LOGD_STR("Setting upstream port's connection.");
+ BT_LIB_LOGD("Setting upstream port's connection: %!+p", upstream_port);
bt_port_set_connection(upstream_port, connection);
- BT_LOGD_STR("Setting downstream port's connection.");
+ BT_LIB_LOGD("Setting downstream port's connection: %!+p",
+ downstream_port);
bt_port_set_connection(downstream_port, connection);
bt_object_set_parent(&connection->base, &graph->base);
- BT_LOGD("Created connection: "
- "graph-addr=%p, upstream-port-addr=%p, uptream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\", "
- "conn-addr=%p",
- graph, upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port),
- connection);
+ BT_LIB_LOGD("Created connection: %!+x", connection);
end:
return connection;
}
BT_HIDDEN
-void bt_connection_end(struct bt_connection *conn,
- bool try_remove_from_graph)
+void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
{
struct bt_component *downstream_comp = NULL;
struct bt_component *upstream_comp = NULL;
struct bt_graph *graph = bt_connection_borrow_graph(conn);
size_t i;
- BT_LOGD("Ending connection: conn-addr=%p, try-remove-from-graph=%d",
+ BT_LIB_LOGD("Ending connection: %!+x, try-remove-from-graph=%d",
conn, try_remove_from_graph);
+ /*
+ * Any of the following notification callback functions could
+ * remove one of the connection's ports from its component. To
+ * make sure that at least logging in called functions works
+ * with existing objects, get a local reference on both ports.
+ */
+ bt_object_get_ref(downstream_port);
+ bt_object_get_ref(upstream_port);
+
if (downstream_port) {
- BT_LOGD("Disconnecting connection's downstream port: "
- "port-addr=%p, port-name=\"%s\"",
- downstream_port, bt_port_get_name(downstream_port));
- downstream_comp = bt_port_get_component(downstream_port);
+ BT_LIB_LOGD("Disconnecting connection's downstream port: %!+p",
+ downstream_port);
+ downstream_comp = bt_port_borrow_component(downstream_port);
bt_port_set_connection(downstream_port, NULL);
conn->downstream_port = NULL;
}
if (upstream_port) {
- BT_LOGD("Disconnecting connection's upstream port: "
- "port-addr=%p, port-name=\"%s\"",
- upstream_port, bt_port_get_name(upstream_port));
- upstream_comp = bt_port_get_component(upstream_port);
+ BT_LIB_LOGD("Disconnecting connection's upstream port: %!+p",
+ upstream_port);
+ upstream_comp = bt_port_borrow_component(upstream_port);
bt_port_set_connection(upstream_port, NULL);
conn->upstream_port = NULL;
}
- if (downstream_comp && conn->notified_downstream_port_connected) {
+ if (downstream_comp && conn->notified_downstream_port_connected &&
+ !conn->notified_downstream_port_disconnected) {
/* bt_component_port_disconnected() logs details */
bt_component_port_disconnected(downstream_comp,
downstream_port);
+ conn->notified_downstream_port_disconnected = true;
}
- if (upstream_comp && conn->notified_upstream_port_connected) {
+ if (upstream_comp && conn->notified_upstream_port_connected &&
+ !conn->notified_upstream_port_disconnected) {
/* bt_component_port_disconnected() logs details */
bt_component_port_disconnected(upstream_comp, upstream_port);
+ conn->notified_upstream_port_disconnected = true;
}
BT_ASSERT(graph);
- if (conn->notified_graph_ports_connected) {
+ if (conn->notified_graph_ports_connected &&
+ !conn->notified_graph_ports_disconnected) {
/* bt_graph_notify_ports_disconnected() logs details */
bt_graph_notify_ports_disconnected(graph, upstream_comp,
downstream_comp, upstream_port, downstream_port);
+ conn->notified_graph_ports_disconnected = true;
}
- bt_object_put_ref(downstream_comp);
- bt_object_put_ref(upstream_comp);
+ /*
+ * It is safe to put the local port references now that we don't
+ * need them anymore. This could indeed destroy them.
+ */
+ bt_object_put_ref(downstream_port);
+ bt_object_put_ref(upstream_port);
/*
* Because this connection is ended, finalize (cancel) each
* notification iterator created from it.
*/
for (i = 0; i < conn->iterators->len; i++) {
- struct bt_notification_iterator_private_connection *iterator =
+ struct bt_self_component_port_input_notification_iterator *iterator =
g_ptr_array_index(conn->iterators, i);
- BT_LOGD("Finalizing notification iterator created by this ended connection: "
- "conn-addr=%p, iter-addr=%p", conn, iterator);
- bt_private_connection_notification_iterator_finalize(iterator);
+ BT_LIB_LOGD("Finalizing notification iterator created by "
+ "this ended connection: %![iter-]+i", iterator);
+ bt_self_component_port_input_notification_iterator_finalize(
+ iterator);
/*
* Make sure this iterator does not try to remove itself
* from this connection's iterators on destruction
* because this connection won't exist anymore.
*/
- bt_private_connection_notification_iterator_set_connection(
+ bt_self_component_port_input_notification_iterator_set_connection(
iterator, NULL);
}
g_ptr_array_set_size(conn->iterators, 0);
if (try_remove_from_graph) {
- bt_connection_try_remove_from_graph(conn);
+ try_remove_connection_from_graph(conn);
}
}
-struct bt_port *bt_connection_get_upstream_port(
+struct bt_port_output *bt_connection_borrow_upstream_port(
struct bt_connection *connection)
{
- return connection ? bt_object_get_ref(connection->upstream_port) : NULL;
+ BT_ASSERT_PRE_NON_NULL(connection, "Connection");
+ return (void *) connection->upstream_port;
}
-struct bt_port *bt_connection_get_downstream_port(
+struct bt_port_input *bt_connection_borrow_downstream_port(
struct bt_connection *connection)
{
- return connection ? bt_object_get_ref(connection->downstream_port) : NULL;
-}
-
-enum bt_connection_status
-bt_private_connection_create_notification_iterator(
- struct bt_private_connection *private_connection,
- struct bt_notification_iterator **user_iterator)
-{
- enum bt_component_class_type upstream_comp_class_type;
- struct bt_notification_iterator_private_connection *iterator = NULL;
- struct bt_port *upstream_port = NULL;
- struct bt_component *upstream_component = NULL;
- struct bt_component_class *upstream_comp_class = NULL;
- struct bt_connection *connection = NULL;
- bt_component_class_notification_iterator_init_method init_method = NULL;
- enum bt_connection_status status;
-
- if (!private_connection) {
- BT_LOGW_STR("Invalid parameter: private connection is NULL.");
- status = BT_CONNECTION_STATUS_INVALID;
- goto end;
- }
-
- if (!user_iterator) {
- BT_LOGW_STR("Invalid parameter: notification iterator pointer is NULL.");
- status = BT_CONNECTION_STATUS_INVALID;
- goto end;
- }
-
- connection = bt_connection_borrow_from_private(private_connection);
-
- if (bt_graph_is_canceled(bt_connection_borrow_graph(connection))) {
- BT_LOGW("Cannot create notification iterator from connection: "
- "connection's graph is canceled: "
- "conn-addr=%p, upstream-port-addr=%p, "
- "upstream-port-name=\"%s\", upstream-comp-addr=%p, "
- "upstream-comp-name=\"%s\", graph-addr=%p",
- connection, connection->upstream_port,
- bt_port_get_name(connection->upstream_port),
- upstream_component,
- bt_component_get_name(upstream_component),
- bt_connection_borrow_graph(connection));
- status = BT_CONNECTION_STATUS_GRAPH_IS_CANCELED;
- goto end;
- }
-
- if (bt_connection_is_ended(connection)) {
- BT_LOGW("Invalid parameter: connection is ended: "
- "conn-addr=%p", connection);
- status = BT_CONNECTION_STATUS_IS_ENDED;
- goto end;
- }
-
- upstream_port = connection->upstream_port;
- BT_ASSERT(upstream_port);
- upstream_component = bt_port_get_component(upstream_port);
- BT_ASSERT(upstream_component);
- upstream_comp_class = upstream_component->class;
- BT_LOGD("Creating notification iterator from connection: "
- "conn-addr=%p, upstream-port-addr=%p, "
- "upstream-port-name=\"%s\", upstream-comp-addr=%p, "
- "upstream-comp-name=\"%s\"",
- connection, connection->upstream_port,
- bt_port_get_name(connection->upstream_port),
- upstream_component, bt_component_get_name(upstream_component));
- upstream_comp_class_type =
- bt_component_get_class_type(upstream_component);
- BT_ASSERT(upstream_comp_class_type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
- upstream_comp_class_type == BT_COMPONENT_CLASS_TYPE_FILTER);
- status = bt_private_connection_notification_iterator_create(upstream_component,
- upstream_port, connection, &iterator);
- if (status != BT_CONNECTION_STATUS_OK) {
- BT_LOGW("Cannot create notification iterator from connection.");
- goto end;
- }
-
- switch (upstream_comp_class_type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- {
- struct bt_component_class_source *source_class =
- container_of(upstream_comp_class,
- struct bt_component_class_source, parent);
- init_method = source_class->methods.iterator.init;
- break;
- }
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- {
- struct bt_component_class_filter *filter_class =
- container_of(upstream_comp_class,
- struct bt_component_class_filter, parent);
- init_method = filter_class->methods.iterator.init;
- break;
- }
- default:
- /* Unreachable. */
- BT_LOGF("Unknown component class type: type=%d",
- upstream_comp_class_type);
- abort();
- }
-
- if (init_method) {
- enum bt_notification_iterator_status iter_status;
-
- BT_LOGD("Calling user's initialization method: iter-addr=%p",
- iterator);
- iter_status = init_method(
- bt_private_connection_private_notification_iterator_from_notification_iterator((void *) iterator),
- bt_private_port_from_port(upstream_port));
- BT_LOGD("User method returned: status=%s",
- bt_notification_iterator_status_string(iter_status));
- if (iter_status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
- BT_LOGW_STR("Initialization method failed.");
- status = bt_connection_status_from_notification_iterator_status(
- iter_status);
- goto end;
- }
- }
-
- iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE;
- g_ptr_array_add(connection->iterators, iterator);
- BT_LOGD("Created notification iterator from connection: "
- "conn-addr=%p, upstream-port-addr=%p, "
- "upstream-port-name=\"%s\", upstream-comp-addr=%p, "
- "upstream-comp-name=\"%s\", iter-addr=%p",
- connection, connection->upstream_port,
- bt_port_get_name(connection->upstream_port),
- upstream_component, bt_component_get_name(upstream_component),
- iterator);
-
- /* Move reference to user */
- *user_iterator = (void *) iterator;
- iterator = NULL;
-
-end:
- bt_object_put_ref(upstream_component);
- bt_object_put_ref(iterator);
- return status;
+ BT_ASSERT_PRE_NON_NULL(connection, "Connection");
+ return (void *) connection->downstream_port;
}
BT_HIDDEN
void bt_connection_remove_iterator(struct bt_connection *conn,
- struct bt_notification_iterator_private_connection *iterator)
+ struct bt_self_component_port_input_notification_iterator *iterator)
{
g_ptr_array_remove(conn->iterators, iterator);
- BT_LOGV("Removed notification iterator from connection: "
- "conn-addr=%p, iter-addr=%p", conn, iterator);
- bt_connection_try_remove_from_graph(conn);
+ BT_LIB_LOGV("Removed notification iterator from connection: "
+ "%![conn-]+x, %![iter-]+i", conn, iterator);
+ try_remove_connection_from_graph(conn);
}
bt_bool bt_connection_is_ended(struct bt_connection *connection)
+++ /dev/null
-/*
- * filter.c
- *
- * Babeltrace Filter Component
- *
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_TAG "COMP-FILTER"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/values.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/component-filter-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/notification-iterator-internal.h>
-#include <babeltrace/graph/graph.h>
-
-BT_HIDDEN
-void bt_component_filter_destroy(struct bt_component *component)
-{
-}
-
-BT_HIDDEN
-struct bt_component *bt_component_filter_create(
- struct bt_component_class *class)
-{
- struct bt_component_filter *filter = NULL;
-
- filter = g_new0(struct bt_component_filter, 1);
- if (!filter) {
- BT_LOGE_STR("Failed to allocate one filter component.");
- goto end;
- }
-
-end:
- return filter ? &filter->parent : NULL;
-}
-
-int64_t bt_component_filter_get_input_port_count(
- struct bt_component *component)
-{
- int64_t ret;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- ret = (int64_t) -1;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- ret = (int64_t) -1;
- goto end;
- }
-
- ret = (int64_t) bt_component_get_input_port_count(component);
-
-end:
- return ret;
-}
-
-struct bt_port *bt_component_filter_get_input_port_by_name(
- struct bt_component *component, const char *name)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_input_port_by_name() logs details/errors */
- port = bt_component_get_input_port_by_name(component, name);
-
-end:
- return port;
-}
-
-struct bt_port *bt_component_filter_get_input_port_by_index(
- struct bt_component *component, uint64_t index)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_input_port_by_index() logs details/errors */
- port = bt_component_get_input_port_by_index(component, index);
-
-end:
- return port;
-}
-
-int64_t bt_component_filter_get_output_port_count(
- struct bt_component *component)
-{
- int64_t ret;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- ret = (int64_t) -1;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- ret = (int64_t) -1;
- goto end;
- }
-
- /* bt_component_get_output_port_count() logs details/errors */
- ret = bt_component_get_output_port_count(component);
-
-end:
- return ret;
-}
-
-struct bt_port *bt_component_filter_get_output_port_by_name(
- struct bt_component *component, const char *name)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_output_port_by_name() logs details/errors */
- port = bt_component_get_output_port_by_name(component, name);
-
-end:
- return port;
-}
-
-struct bt_port *bt_component_filter_get_output_port_by_index(
- struct bt_component *component, uint64_t index)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_output_port_by_index() logs details/errors */
- port = bt_component_get_output_port_by_index(component, index);
-
-end:
- return port;
-}
-
-struct bt_private_port *
-bt_private_component_filter_get_input_port_by_index(
- struct bt_private_component *private_component, uint64_t index)
-{
- /* bt_component_filter_get_input_port_by_index() logs details/errors */
- return bt_private_port_from_port(
- bt_component_filter_get_input_port_by_index(
- bt_component_borrow_from_private(private_component), index));
-}
-
-struct bt_private_port *
-bt_private_component_filter_get_input_port_by_name(
- struct bt_private_component *private_component,
- const char *name)
-{
- /* bt_component_filter_get_input_port_by_name() logs details/errors */
- return bt_private_port_from_port(
- bt_component_filter_get_input_port_by_name(
- bt_component_borrow_from_private(private_component), name));
-}
-
-enum bt_component_status bt_private_component_filter_add_input_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **user_priv_port)
-{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- struct bt_port *port = NULL;
- struct bt_component *component =
- bt_component_borrow_from_private(private_component);
- struct bt_graph *graph;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- graph = bt_component_borrow_graph(component);
-
- if (graph && bt_graph_is_canceled(graph)) {
- BT_LOGW("Cannot add input port to filter component: graph is canceled: "
- "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
- component, bt_component_get_name(component),
- bt_component_borrow_graph(component));
- status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
- goto end;
- }
-
- /* bt_component_add_input_port() logs details/errors */
- port = bt_component_add_input_port(component, name, user_data);
- if (!port) {
- status = BT_COMPONENT_STATUS_NOMEM;
- goto end;
- }
-
- if (user_priv_port) {
- /* Move reference to user */
- *user_priv_port = bt_private_port_from_port(port);
- port = NULL;
- }
-
-end:
- bt_object_put_ref(port);
- return status;
-}
-
-struct bt_private_port *
-bt_private_component_filter_get_output_port_by_index(
- struct bt_private_component *private_component, uint64_t index)
-{
- /* bt_component_filter_get_output_port_by_index() logs details/errors */
- return bt_private_port_from_port(
- bt_component_filter_get_output_port_by_index(
- bt_component_borrow_from_private(private_component), index));
-}
-
-struct bt_private_port *
-bt_private_component_filter_get_output_port_by_name(
- struct bt_private_component *private_component,
- const char *name)
-{
- /* bt_component_filter_get_output_port_by_name() logs details/errors */
- return bt_private_port_from_port(
- bt_component_filter_get_output_port_by_name(
- bt_component_borrow_from_private(private_component), name));
-}
-
-enum bt_component_status bt_private_component_filter_add_output_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **user_priv_port)
-{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- struct bt_port *port = NULL;
- struct bt_component *component =
- bt_component_borrow_from_private(private_component);
- struct bt_graph *graph;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
- BT_LOGW("Invalid parameter: component's class is not a filter component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- graph = bt_component_borrow_graph(component);
-
- if (graph && bt_graph_is_canceled(graph)) {
- BT_LOGW("Cannot add output port to filter component: graph is canceled: "
- "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
- component, bt_component_get_name(component),
- bt_component_borrow_graph(component));
- status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
- goto end;
- }
-
- /* bt_component_add_output_port() logs details/errors */
- port = bt_component_add_output_port(component, name, user_data);
- if (!port) {
- status = BT_COMPONENT_STATUS_NOMEM;
- goto end;
- }
-
- if (user_priv_port) {
- /* Move reference to user */
- *user_priv_port = bt_private_port_from_port(port);
- port = NULL;
- }
-
-end:
- bt_object_put_ref(port);
- return status;
-}
#include <babeltrace/values.h>
#include <babeltrace/private-values.h>
#include <babeltrace/values-internal.h>
+#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-pre-internal.h>
#include <unistd.h>
#include <glib.h>
+typedef void (*port_added_func_t)(void *, void *, void *);
+typedef void (*port_removed_func_t)(void *, void *, void *);
+typedef void (*ports_connected_func_t)(void *, void *, void *, void *, void *);
+typedef void (*ports_disconnected_func_t)(void *, void *, void *, void *, void *);
+typedef enum bt_self_component_status (*comp_init_method_t)(void *, void *, void *);
+
struct bt_graph_listener {
- void *func;
bt_private_graph_listener_removed removed;
void *data;
};
-static
-int init_listeners_array(GArray **listeners)
-{
- int ret = 0;
-
- BT_ASSERT(listeners);
- *listeners = g_array_new(FALSE, TRUE, sizeof(struct bt_graph_listener));
- if (!*listeners) {
- BT_LOGE_STR("Failed to allocate one GArray.");
- ret = -1;
- goto end;
- }
+struct bt_graph_listener_port_added {
+ struct bt_graph_listener base;
+ port_added_func_t func;
+};
-end:
- return ret;
-}
+struct bt_graph_listener_port_removed {
+ struct bt_graph_listener base;
+ port_removed_func_t func;
+};
-static
-void call_remove_listeners(GArray *listeners)
-{
- size_t i;
+struct bt_graph_listener_ports_connected {
+ struct bt_graph_listener base;
+ ports_connected_func_t func;
+};
- for (i = 0; i < listeners->len; i++) {
- struct bt_graph_listener listener =
- g_array_index(listeners, struct bt_graph_listener, i);
+struct bt_graph_listener_ports_disconnected {
+ struct bt_graph_listener base;
+ ports_disconnected_func_t func;
+};
- if (listener.removed) {
- listener.removed(listener.data);
- }
- }
-}
+#define INIT_LISTENERS_ARRAY(_type, _listeners) \
+ do { \
+ _listeners = g_array_new(FALSE, TRUE, sizeof(_type)); \
+ if (!(_listeners)) { \
+ BT_LOGE_STR("Failed to allocate one GArray."); \
+ } \
+ } while (0)
+
+#define CALL_REMOVE_LISTENERS(_type, _listeners) \
+ do { \
+ size_t i; \
+ \
+ for (i = 0; i < (_listeners)->len; i++) { \
+ _type *listener = \
+ &g_array_index((_listeners), _type, i); \
+ \
+ if (listener->base.removed) { \
+ listener->base.removed(listener->base.data); \
+ } \
+ } \
+ } while (0)
static
-void bt_graph_destroy(struct bt_object *obj)
+void destroy_graph(struct bt_object *obj)
{
struct bt_graph *graph = container_of(obj,
struct bt_graph, base);
* step 4 goes from 1 to 2, and from 2 to 1 at step 6. This
* ensures that this function is not called two times.
*/
- BT_LOGD("Destroying graph: addr=%p", graph);
+ BT_LIB_LOGD("Destroying graph: %!+g", graph);
obj->ref_count++;
/*
(void) bt_private_graph_cancel((void *) graph);
/* Call all remove listeners */
- call_remove_listeners(graph->listeners.port_added);
- call_remove_listeners(graph->listeners.port_removed);
- call_remove_listeners(graph->listeners.ports_connected);
- call_remove_listeners(graph->listeners.ports_disconnected);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
+ graph->listeners.source_output_port_added);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
+ graph->listeners.filter_output_port_added);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
+ graph->listeners.filter_input_port_added);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
+ graph->listeners.sink_input_port_added);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_removed,
+ graph->listeners.source_output_port_removed);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_removed,
+ graph->listeners.filter_output_port_removed);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_removed,
+ graph->listeners.filter_input_port_removed);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_removed,
+ graph->listeners.sink_input_port_removed);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_connected,
+ graph->listeners.source_filter_ports_connected);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_connected,
+ graph->listeners.source_sink_ports_connected);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_connected,
+ graph->listeners.filter_sink_ports_connected);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_disconnected,
+ graph->listeners.source_filter_ports_disconnected);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_disconnected,
+ graph->listeners.source_sink_ports_disconnected);
+ CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_disconnected,
+ graph->listeners.filter_sink_ports_disconnected);
if (graph->notifications) {
g_ptr_array_free(graph->notifications, TRUE);
+ graph->notifications = NULL;
}
if (graph->connections) {
BT_LOGD_STR("Destroying connections.");
g_ptr_array_free(graph->connections, TRUE);
+ graph->connections = NULL;
}
if (graph->components) {
BT_LOGD_STR("Destroying components.");
g_ptr_array_free(graph->components, TRUE);
+ graph->components = NULL;
}
if (graph->sinks_to_consume) {
g_queue_free(graph->sinks_to_consume);
+ graph->sinks_to_consume = NULL;
+ }
+
+ if (graph->listeners.source_output_port_added) {
+ g_array_free(graph->listeners.source_output_port_added, TRUE);
+ graph->listeners.source_output_port_added = NULL;
+ }
+
+ if (graph->listeners.filter_output_port_added) {
+ g_array_free(graph->listeners.filter_output_port_added, TRUE);
+ graph->listeners.filter_output_port_added = NULL;
+ }
+
+ if (graph->listeners.filter_input_port_added) {
+ g_array_free(graph->listeners.filter_input_port_added, TRUE);
+ graph->listeners.filter_input_port_added = NULL;
}
- if (graph->listeners.port_added) {
- g_array_free(graph->listeners.port_added, TRUE);
+ if (graph->listeners.sink_input_port_added) {
+ g_array_free(graph->listeners.sink_input_port_added, TRUE);
+ graph->listeners.sink_input_port_added = NULL;
}
- if (graph->listeners.port_removed) {
- g_array_free(graph->listeners.port_removed, TRUE);
+ if (graph->listeners.source_output_port_removed) {
+ g_array_free(graph->listeners.source_output_port_removed, TRUE);
+ graph->listeners.source_output_port_removed = NULL;
}
- if (graph->listeners.ports_connected) {
- g_array_free(graph->listeners.ports_connected, TRUE);
+ if (graph->listeners.filter_output_port_removed) {
+ g_array_free(graph->listeners.filter_output_port_removed, TRUE);
+ graph->listeners.filter_output_port_removed = NULL;
}
- if (graph->listeners.ports_disconnected) {
- g_array_free(graph->listeners.ports_disconnected, TRUE);
+ if (graph->listeners.filter_input_port_removed) {
+ g_array_free(graph->listeners.filter_input_port_removed, TRUE);
+ graph->listeners.filter_input_port_removed = NULL;
+ }
+
+ if (graph->listeners.sink_input_port_removed) {
+ g_array_free(graph->listeners.sink_input_port_removed, TRUE);
+ graph->listeners.sink_input_port_removed = NULL;
+ }
+
+ if (graph->listeners.source_filter_ports_connected) {
+ g_array_free(graph->listeners.source_filter_ports_connected,
+ TRUE);
+ graph->listeners.source_filter_ports_connected = NULL;
+ }
+
+ if (graph->listeners.source_sink_ports_connected) {
+ g_array_free(graph->listeners.source_sink_ports_connected,
+ TRUE);
+ graph->listeners.source_sink_ports_connected = NULL;
+ }
+
+ if (graph->listeners.filter_sink_ports_connected) {
+ g_array_free(graph->listeners.filter_sink_ports_connected,
+ TRUE);
+ graph->listeners.filter_sink_ports_connected = NULL;
+ }
+
+ if (graph->listeners.source_filter_ports_disconnected) {
+ g_array_free(graph->listeners.source_filter_ports_disconnected,
+ TRUE);
+ graph->listeners.source_filter_ports_disconnected = NULL;
+ }
+
+ if (graph->listeners.source_sink_ports_disconnected) {
+ g_array_free(graph->listeners.source_sink_ports_disconnected,
+ TRUE);
+ graph->listeners.source_sink_ports_disconnected = NULL;
+ }
+
+ if (graph->listeners.filter_sink_ports_disconnected) {
+ g_array_free(graph->listeners.filter_sink_ports_disconnected,
+ TRUE);
+ graph->listeners.filter_sink_ports_disconnected = NULL;
}
bt_object_pool_finalize(&graph->event_notif_pool);
goto end;
}
- bt_object_init_shared(&graph->base, bt_graph_destroy);
+ bt_object_init_shared(&graph->base, destroy_graph);
graph->connections = g_ptr_array_new_with_free_func(
(GDestroyNotify) bt_object_try_spec_release);
if (!graph->connections) {
goto error;
}
- bt_graph_set_can_consume(graph, BT_TRUE);
- ret = init_listeners_array(&graph->listeners.port_added);
- if (ret) {
- BT_LOGE_STR("Cannot create the \"port added\" listener array.");
+ bt_graph_set_can_consume(graph, true);
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
+ graph->listeners.source_output_port_added);
+
+ if (!graph->listeners.source_output_port_added) {
+ ret = -1;
goto error;
}
- ret = init_listeners_array(&graph->listeners.port_removed);
- if (ret) {
- BT_LOGE_STR("Cannot create the \"port removed\" listener array.");
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
+ graph->listeners.filter_output_port_added);
+
+ if (!graph->listeners.filter_output_port_added) {
+ ret = -1;
goto error;
}
- ret = init_listeners_array(&graph->listeners.ports_connected);
- if (ret) {
- BT_LOGE_STR("Cannot create the \"port connected\" listener array.");
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
+ graph->listeners.filter_input_port_added);
+
+ if (!graph->listeners.filter_input_port_added) {
+ ret = -1;
goto error;
}
- ret = init_listeners_array(&graph->listeners.ports_disconnected);
- if (ret) {
- BT_LOGE_STR("Cannot create the \"port disconneted\" listener array.");
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
+ graph->listeners.sink_input_port_added);
+
+ if (!graph->listeners.sink_input_port_added) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_removed,
+ graph->listeners.source_output_port_removed);
+
+ if (!graph->listeners.source_output_port_removed) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_removed,
+ graph->listeners.filter_output_port_removed);
+
+ if (!graph->listeners.filter_output_port_removed) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_removed,
+ graph->listeners.filter_input_port_removed);
+
+ if (!graph->listeners.filter_input_port_removed) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_removed,
+ graph->listeners.sink_input_port_removed);
+
+ if (!graph->listeners.sink_input_port_removed) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_connected,
+ graph->listeners.source_filter_ports_connected);
+
+ if (!graph->listeners.source_filter_ports_connected) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_connected,
+ graph->listeners.source_sink_ports_connected);
+
+ if (!graph->listeners.source_sink_ports_connected) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_connected,
+ graph->listeners.filter_sink_ports_connected);
+
+ if (!graph->listeners.filter_sink_ports_connected) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_disconnected,
+ graph->listeners.source_filter_ports_disconnected);
+
+ if (!graph->listeners.source_filter_ports_disconnected) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_disconnected,
+ graph->listeners.source_sink_ports_disconnected);
+
+ if (!graph->listeners.source_sink_ports_disconnected) {
+ ret = -1;
+ goto error;
+ }
+
+ INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_disconnected,
+ graph->listeners.filter_sink_ports_disconnected);
+
+ if (!graph->listeners.filter_sink_ports_disconnected) {
+ ret = -1;
goto error;
}
graph->notifications = g_ptr_array_new_with_free_func(
(GDestroyNotify) notify_notification_graph_is_destroyed);
- BT_LOGD("Created graph object: addr=%p", graph);
+ BT_LIB_LOGD("Created graph object: %!+g", graph);
end:
return (void *) graph;
+
error:
BT_OBJECT_PUT_REF_AND_RESET(graph);
goto end;
enum bt_graph_status bt_private_graph_connect_ports(
struct bt_private_graph *priv_graph,
- struct bt_port *upstream_port, struct bt_port *downstream_port,
+ struct bt_port_output *upstream_port_out,
+ struct bt_port_input *downstream_port_in,
struct bt_connection **user_connection)
{
struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status status = BT_GRAPH_STATUS_OK;
struct bt_connection *connection = NULL;
- struct bt_graph *upstream_graph = NULL;
- struct bt_graph *downstream_graph = NULL;
+ struct bt_port *upstream_port = (void *) upstream_port_out;
+ struct bt_port *downstream_port = (void *) downstream_port_in;
struct bt_component *upstream_component = NULL;
struct bt_component *downstream_component = NULL;
- enum bt_component_status component_status;
- bt_bool init_can_consume;
+ enum bt_self_component_status component_status;
+ bool init_can_consume;
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(upstream_port, "Upstream port");
+ BT_ASSERT_PRE_NON_NULL(downstream_port, "Downstream port port");
+ BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
+ BT_ASSERT_PRE(!bt_port_is_connected(upstream_port),
+ "Upstream port is already connected: %!+p", upstream_port);
+ BT_ASSERT_PRE(!bt_port_is_connected(downstream_port),
+ "Downstream port is already connected: %!+p", downstream_port);
+ BT_ASSERT_PRE(bt_port_borrow_component((void *) upstream_port),
+ "Upstream port does not belong to a component: %!+p",
+ upstream_port);
+ BT_ASSERT_PRE(bt_port_borrow_component((void *) downstream_port),
+ "Downstream port does not belong to a component: %!+p",
+ downstream_port);
init_can_consume = graph->can_consume;
-
- if (!upstream_port) {
- BT_LOGW_STR("Invalid parameter: upstream port is NULL.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- if (!downstream_port) {
- BT_LOGW_STR("Invalid parameter: downstream port is NULL.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- BT_LOGD("Connecting component ports within graph: "
- "graph-addr=%p, "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- graph, upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
-
- if (graph->canceled) {
- BT_LOGW_STR("Invalid parameter: graph is canceled.");
- status = BT_GRAPH_STATUS_CANCELED;
- goto end;
- }
-
- bt_graph_set_can_consume(graph, BT_FALSE);
-
- /* Ensure appropriate types for upstream and downstream ports. */
- if (bt_port_get_type(upstream_port) != BT_PORT_TYPE_OUTPUT) {
- BT_LOGW_STR("Invalid parameter: upstream port is not an output port.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
- if (bt_port_get_type(downstream_port) != BT_PORT_TYPE_INPUT) {
- BT_LOGW_STR("Invalid parameter: downstream port is not an input port.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- /* Ensure that both ports are currently unconnected. */
- if (bt_port_is_connected(upstream_port)) {
- BT_LOGW_STR("Invalid parameter: upstream port is already connected.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- if (bt_port_is_connected(downstream_port)) {
- BT_LOGW_STR("Invalid parameter: downstream port is already connected.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- /*
- * Ensure that both ports are still attached to their creating
- * component.
- */
- upstream_component = bt_port_get_component(upstream_port);
- if (!upstream_component) {
- BT_LOGW_STR("Invalid parameter: upstream port is loose (does not belong to a component)");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- downstream_component = bt_port_get_component(downstream_port);
- if (!downstream_component) {
- BT_LOGW_STR("Invalid parameter: downstream port is loose (does not belong to a component)");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- BT_LOGD("Connecting component ports: "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "downstream-comp-addr=%p, downstream-comp-name=\"%s\"",
- upstream_component, bt_component_get_name(upstream_component),
- downstream_component, bt_component_get_name(downstream_component));
+ BT_LIB_LOGD("Connecting component ports within graph: "
+ "%![graph-]+g, %![up-port-]+p, %![down-port-]+p",
+ graph, upstream_port, downstream_port);
+ bt_graph_set_can_consume(graph, false);
+ upstream_component = bt_port_borrow_component(
+ (void *) upstream_port);
+ downstream_component = bt_port_borrow_component(
+ (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_LOGD_STR("Asking upstream component to accept the connection.");
+ BT_LIB_LOGD("Asking upstream component to accept the connection: "
+ "%![comp-]+c", upstream_component);
component_status = bt_component_accept_port_connection(
- upstream_component, upstream_port, downstream_port);
- if (component_status != BT_COMPONENT_STATUS_OK) {
- if (component_status == BT_COMPONENT_STATUS_REFUSE_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_component_status_string(component_status));
+ "status=%s", bt_self_component_status_string(component_status));
}
- status = bt_graph_status_from_component_status(
- component_status);
+ status = (int) component_status;
goto end;
}
- BT_LOGD_STR("Asking downstream component to accept the connection.");
+ BT_LIB_LOGD("Asking downstream component to accept the connection: "
+ "%![comp-]+c", downstream_component);
component_status = bt_component_accept_port_connection(
- downstream_component, downstream_port, upstream_port);
- if (component_status != BT_COMPONENT_STATUS_OK) {
- if (component_status == BT_COMPONENT_STATUS_REFUSE_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_component_status_string(component_status));
+ "status=%s", bt_self_component_status_string(component_status));
}
- status = bt_graph_status_from_component_status(
- component_status);
+ status = (int) component_status;
goto end;
}
BT_LOGD_STR("Creating connection.");
- connection = bt_connection_create(graph, upstream_port,
- downstream_port);
+ connection = bt_connection_create(graph, (void *) upstream_port,
+ (void *) downstream_port);
if (!connection) {
BT_LOGW("Cannot create connection object.");
status = BT_GRAPH_STATUS_NOMEM;
goto end;
}
- BT_LOGD("Connection object created: conn-addr=%p", connection);
+ BT_LIB_LOGD("Connection object created: %!+x", connection);
/*
* Ownership of upstream_component/downstream_component and of
/*
* Notify both components that their port is connected.
*/
- BT_LOGD_STR("Notifying upstream component that its port is connected.");
+ BT_LIB_LOGD("Notifying upstream component that its port is connected: "
+ "%![comp-]+c, %![port-]+p", upstream_component, upstream_port);
component_status = bt_component_port_connected(upstream_component,
- upstream_port, downstream_port);
- if (component_status != BT_COMPONENT_STATUS_OK) {
- BT_LOGW("Error while notifying upstream component that its port is connected: "
- "status=%s, graph-addr=%p, "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "downstream-comp-addr=%p, downstream-comp-name=\"%s\", "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- bt_component_status_string(component_status), graph,
- upstream_component, bt_component_get_name(upstream_component),
- downstream_component, bt_component_get_name(downstream_component),
- upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
+ (void *) upstream_port, (void *) downstream_port);
+ if (component_status != BT_SELF_COMPONENT_STATUS_OK) {
+ BT_LIB_LOGW("Error while notifying upstream component that its port is connected: "
+ "status=%s, %![graph-]+g, %![up-comp-]+c, "
+ "%![down-comp-]+c, %![up-port-]+p, %![down-port-]+p",
+ bt_self_component_status_string(component_status),
+ graph, upstream_component, downstream_component,
+ upstream_port, downstream_port);
bt_connection_end(connection, true);
- status = bt_graph_status_from_component_status(
- component_status);
+ status = (int) component_status;
goto end;
}
connection->notified_upstream_port_connected = true;
- BT_LOGD_STR("Notifying downstream component that its port is connected.");
+ BT_LIB_LOGD("Notifying downstream component that its port is connected: "
+ "%![comp-]+c, %![port-]+p", downstream_component,
+ downstream_port);
component_status = bt_component_port_connected(downstream_component,
- downstream_port, upstream_port);
- if (component_status != BT_COMPONENT_STATUS_OK) {
- BT_LOGW("Error while notifying downstream component that its port is connected: "
- "status=%s, graph-addr=%p, "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "downstream-comp-addr=%p, downstream-comp-name=\"%s\", "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- bt_component_status_string(component_status), graph,
- upstream_component, bt_component_get_name(upstream_component),
- downstream_component, bt_component_get_name(downstream_component),
- upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
+ (void *) downstream_port, (void *) upstream_port);
+ if (component_status != BT_SELF_COMPONENT_STATUS_OK) {
+ BT_LIB_LOGW("Error while notifying downstream component that its port is connected: "
+ "status=%s, %![graph-]+g, %![up-comp-]+c, "
+ "%![down-comp-]+c, %![up-port-]+p, %![down-port-]+p",
+ bt_self_component_status_string(component_status),
+ graph, upstream_component, downstream_component,
+ upstream_port, downstream_port);
bt_connection_end(connection, true);
- status = bt_graph_status_from_component_status(
- component_status);
+ status = (int) component_status;
goto end;
}
BT_LOGD_STR("Notifying graph's user that new component ports are connected.");
bt_graph_notify_ports_connected(graph, upstream_port, downstream_port);
connection->notified_graph_ports_connected = true;
- BT_LOGD("Connected component ports within graph: "
- "graph-addr=%p, "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "downstream-comp-addr=%p, downstream-comp-name=\"%s\", "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- graph,
- upstream_component, bt_component_get_name(upstream_component),
- downstream_component, bt_component_get_name(downstream_component),
- upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
+ BT_LIB_LOGD("Connected component ports within graph: "
+ "%![graph-]+g, %![up-comp-]+c, %![down-comp-]+c, "
+ "%![up-port-]+p, %![down-port-]+p",
+ graph, upstream_component, downstream_component,
+ upstream_port, downstream_port);
if (user_connection) {
/* Move reference to user */
}
end:
- bt_object_put_ref(upstream_graph);
- bt_object_put_ref(downstream_graph);
- bt_object_put_ref(upstream_component);
- bt_object_put_ref(downstream_component);
bt_object_put_ref(connection);
- if (graph) {
- (void) init_can_consume;
- bt_graph_set_can_consume(graph, init_can_consume);
- }
+ (void) init_can_consume;
+ bt_graph_set_can_consume(graph, init_can_consume);
return status;
}
static inline
-enum bt_graph_status consume_graph_sink(struct bt_component *sink)
+enum bt_graph_status consume_graph_sink(struct bt_component_sink *comp)
{
- enum bt_component_status comp_status;
-
- BT_ASSERT(sink);
- comp_status = bt_component_sink_consume(sink);
- BT_LOGV("Consumed from sink: addr=%p, name=\"%s\", status=%s",
- sink, bt_component_get_name(sink),
- bt_component_status_string(comp_status));
- BT_ASSERT_PRE(comp_status == BT_COMPONENT_STATUS_OK ||
- comp_status == BT_COMPONENT_STATUS_END ||
- comp_status == BT_COMPONENT_STATUS_AGAIN ||
- comp_status == BT_COMPONENT_STATUS_ERROR ||
- comp_status == BT_COMPONENT_STATUS_NOMEM,
- "Invalid component status returned by consuming function: "
- "status=%s", bt_component_status_string(comp_status));
- return (enum bt_graph_status) comp_status;
+ enum bt_self_component_status comp_status;
+ struct bt_component_class_sink *sink_class = NULL;
+
+ BT_ASSERT(comp);
+ sink_class = (void *) comp->parent.class;
+ BT_ASSERT(sink_class->methods.consume);
+ BT_LIB_LOGD("Calling user's consume method: %!+c", comp);
+ comp_status = sink_class->methods.consume((void *) comp);
+ BT_LOGD("User method returned: status=%s",
+ bt_self_component_status_string(comp_status));
+ BT_ASSERT_PRE(comp_status == BT_SELF_COMPONENT_STATUS_OK ||
+ comp_status == BT_SELF_COMPONENT_STATUS_END ||
+ comp_status == BT_SELF_COMPONENT_STATUS_AGAIN ||
+ comp_status == BT_SELF_COMPONENT_STATUS_ERROR ||
+ comp_status == BT_SELF_COMPONENT_STATUS_NOMEM,
+ "Invalid component status returned by consuming method: "
+ "status=%s", bt_self_component_status_string(comp_status));
+ if (comp_status < 0) {
+ BT_LOGW_STR("Consume method failed.");
+ goto end;
+ }
+
+ BT_LIB_LOGV("Consumed from sink: %![comp-]+c, status=%s",
+ comp, bt_self_component_status_string(comp_status));
+
+end:
+ return (int) comp_status;
}
/*
* still something to consume afterwards.
*/
static inline
-enum bt_graph_status consume_sink_node(struct bt_graph *graph,
- GList *node)
+enum bt_graph_status consume_sink_node(struct bt_graph *graph, GList *node)
{
enum bt_graph_status status;
- struct bt_component *sink;
+ struct bt_component_sink *sink;
sink = node->data;
status = consume_graph_sink(sink);
}
end:
- BT_LOGV("Consumed sink node: status=%s", bt_graph_status_string(status));
+ BT_LIB_LOGV("Consumed sink node: %![comp-]+c, status=%s",
+ sink, bt_graph_status_string(status));
return status;
}
BT_HIDDEN
enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph,
- struct bt_component *sink)
+ struct bt_component_sink *sink)
{
enum bt_graph_status status;
GList *sink_node;
int index;
- BT_LOGV("Making specific sink consume: addr=%p, "
- "comp-addr=%p, comp-name=\"%s\"",
- graph, sink, bt_component_get_name(sink));
-
- BT_ASSERT(bt_component_borrow_graph(sink) == graph);
+ BT_LIB_LOGV("Making specific sink consume: %![comp-]+c", sink);
+ BT_ASSERT(bt_component_borrow_graph((void *) sink) == graph);
if (g_queue_is_empty(graph->sinks_to_consume)) {
BT_LOGV_STR("Graph's sink queue is empty: end of graph.");
}
static inline
-enum bt_graph_status bt_graph_consume_no_check(struct bt_graph *graph)
+enum bt_graph_status consume_no_check(struct bt_graph *graph)
{
enum bt_graph_status status = BT_GRAPH_STATUS_OK;
struct bt_component *sink;
GList *current_node;
- BT_LOGV("Making next sink consume: addr=%p", graph);
BT_ASSERT_PRE(graph->has_sink,
"Graph has no sink component: %!+g", graph);
+ BT_LIB_LOGV("Making next sink consume: %![graph-]+g", graph);
if (unlikely(g_queue_is_empty(graph->sinks_to_consume))) {
BT_LOGV_STR("Graph's sink queue is empty: end of graph.");
current_node = g_queue_pop_head_link(graph->sinks_to_consume);
sink = current_node->data;
- BT_LOGV("Chose next sink to consume: comp-addr=%p, comp-name=\"%s\"",
- sink, bt_component_get_name(sink));
+ BT_LIB_LOGV("Chose next sink to consume: %!+c", sink);
status = consume_sink_node(graph, current_node);
end:
BT_ASSERT_PRE(graph->can_consume,
"Cannot consume graph in its current state: %!+g", graph);
bt_graph_set_can_consume(graph, BT_FALSE);
- status = bt_graph_consume_no_check(graph);
+ status = consume_no_check(graph);
bt_graph_set_can_consume(graph, BT_TRUE);
return status;
}
-enum bt_graph_status bt_private_graph_run(
- struct bt_private_graph *priv_graph)
+enum bt_graph_status bt_private_graph_run(struct bt_private_graph *priv_graph)
{
struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status status = BT_GRAPH_STATUS_OK;
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- if (graph->canceled) {
- BT_LOGW("Invalid parameter: graph is canceled: "
- "graph-addr=%p", graph);
- status = BT_GRAPH_STATUS_CANCELED;
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
BT_ASSERT_PRE(graph->can_consume,
"Cannot consume graph in its current state: %!+g", graph);
bt_graph_set_can_consume(graph, BT_FALSE);
- BT_LOGV("Running graph: addr=%p", graph);
+ BT_LIB_LOGV("Running graph: %!+g", graph);
do {
/*
* Check if the graph is canceled at each iteration. If
* the graph was canceled by another thread or by a
- * signal, this is not a warning nor an error, it was
- * intentional: log with a DEBUG level only.
+ * signal handler, this is not a warning nor an error,
+ * it was intentional: log with a DEBUG level only.
*/
if (unlikely(graph->canceled)) {
- BT_LOGD("Stopping the graph: graph is canceled: "
- "graph-addr=%p", graph);
+ BT_LIB_LOGD("Stopping the graph: graph is canceled: "
+ "%!+g", graph);
status = BT_GRAPH_STATUS_CANCELED;
goto end;
}
- status = bt_graph_consume_no_check(graph);
+ status = consume_no_check(graph);
if (unlikely(status == BT_GRAPH_STATUS_AGAIN)) {
/*
* If AGAIN is received and there are multiple
*
* However, in the case where a single sink is
* left, the caller can decide to busy-wait and
- * call bt_graph_run() continuously until the
- * source is ready or it can decide to sleep for
- * an arbitrary amount of time.
+ * call bt_private_graph_run() continuously
+ * until the source is ready or it can decide to
+ * sleep for an arbitrary amount of time.
*/
if (graph->sinks_to_consume->length > 1) {
status = BT_GRAPH_STATUS_OK;
}
end:
- BT_LOGV("Graph ran: status=%s", bt_graph_status_string(status));
- if (graph) {
- bt_graph_set_can_consume(graph, BT_TRUE);
- }
+ BT_LIB_LOGV("Graph ran: %![graph-]+g, status=%s", graph,
+ bt_graph_status_string(status));
+ bt_graph_set_can_consume(graph, BT_TRUE);
return status;
}
-static
-int add_listener(GArray *listeners, void *func, void *removed, void *data)
+enum bt_graph_status
+bt_private_graph_add_source_component_output_port_added_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_source_component_output_port_added_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
{
- struct bt_graph_listener listener = {
- .func = func,
- .removed = removed,
- .data = data,
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_port_added listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_added_func_t) func,
};
+ int listener_id;
- g_array_append_val(listeners, listener);
- return listeners->len - 1;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.source_output_port_added, listener);
+ listener_id = graph->listeners.source_output_port_added->len - 1;
+ BT_LIB_LOGV("Added \"source component output port added\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
}
-int bt_private_graph_add_port_added_listener(
+enum bt_graph_status
+bt_private_graph_add_filter_component_output_port_added_listener(
struct bt_private_graph *priv_graph,
- bt_private_graph_port_added_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data)
+ bt_private_graph_filter_component_output_port_added_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
{
struct bt_graph *graph = (void *) priv_graph;
- int ret;
+ struct bt_graph_listener_port_added listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_added_func_t) func,
+ };
+ int listener_id;
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.filter_output_port_added, listener);
+ listener_id = graph->listeners.filter_output_port_added->len - 1;
+ BT_LIB_LOGV("Added \"filter component output port added\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- if (graph->in_remove_listener) {
- BT_LOGW("Cannot call this function during the execution of a remove listener: "
- "addr=%p", graph);
- ret = -1;
- goto end;
- }
+enum bt_graph_status
+bt_private_graph_add_filter_component_input_port_added_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_filter_component_input_port_added_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_port_added listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_added_func_t) func,
+ };
+ int listener_id;
- if (!listener) {
- BT_LOGW_STR("Invalid parameter: listener is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.filter_input_port_added, listener);
+ listener_id = graph->listeners.filter_input_port_added->len - 1;
+ BT_LIB_LOGV("Added \"filter component input port added\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- ret = add_listener(graph->listeners.port_added, listener,
- listener_removed, data);
- BT_LOGV("Added \"port added\" listener to graph: "
- "graph-addr=%p, listener-addr=%p, pos=%d",
- graph, listener, ret);
+enum bt_graph_status
+bt_private_graph_add_sink_component_input_port_added_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_sink_component_input_port_added_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_port_added listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_added_func_t) func,
+ };
+ int listener_id;
-end:
- return ret;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.sink_input_port_added, listener);
+ listener_id = graph->listeners.sink_input_port_added->len - 1;
+ BT_LIB_LOGV("Added \"sink component input port added\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
}
-int bt_private_graph_add_port_removed_listener(
+enum bt_graph_status
+bt_private_graph_add_source_component_output_port_removed_listener(
struct bt_private_graph *priv_graph,
- bt_private_graph_port_removed_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data)
+ bt_private_graph_source_component_output_port_removed_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
{
struct bt_graph *graph = (void *) priv_graph;
- int ret;
+ struct bt_graph_listener_port_removed listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_removed_func_t) func,
+ };
+ int listener_id;
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.source_output_port_removed, listener);
+ listener_id = graph->listeners.source_output_port_removed->len - 1;
+ BT_LIB_LOGV("Added \"source component output port removed\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- if (graph->in_remove_listener) {
- BT_LOGW("Cannot call this function during the execution of a remove listener: "
- "addr=%p", graph);
- ret = -1;
- goto end;
- }
+enum bt_graph_status
+bt_private_graph_add_filter_component_output_port_removed_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_filter_component_output_port_removed_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_port_removed listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_removed_func_t) func,
+ };
+ int listener_id;
- if (!listener) {
- BT_LOGW_STR("Invalid parameter: listener is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.filter_output_port_removed, listener);
+ listener_id = graph->listeners.filter_output_port_removed->len - 1;
+ BT_LIB_LOGV("Added \"filter component output port removed\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- ret = add_listener(graph->listeners.port_removed, listener,
- listener_removed, data);
- BT_LOGV("Added \"port removed\" listener to graph: "
- "graph-addr=%p, listener-addr=%p, pos=%d",
- graph, listener, ret);
+enum bt_graph_status
+bt_private_graph_add_filter_component_input_port_removed_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_filter_component_input_port_removed_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_port_removed listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_removed_func_t) func,
+ };
+ int listener_id;
-end:
- return ret;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.filter_input_port_removed, listener);
+ listener_id = graph->listeners.filter_input_port_removed->len - 1;
+ BT_LIB_LOGV("Added \"filter component input port removed\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
}
-int bt_private_graph_add_ports_connected_listener(
+enum bt_graph_status
+bt_private_graph_add_sink_component_input_port_removed_listener(
struct bt_private_graph *priv_graph,
- bt_private_graph_ports_connected_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data)
+ bt_private_graph_sink_component_input_port_removed_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
{
struct bt_graph *graph = (void *) priv_graph;
- int ret;
+ struct bt_graph_listener_port_removed listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (port_removed_func_t) func,
+ };
+ int listener_id;
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.sink_input_port_removed, listener);
+ listener_id = graph->listeners.sink_input_port_removed->len - 1;
+ BT_LIB_LOGV("Added \"sink component input port removed\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- if (graph->in_remove_listener) {
- BT_LOGW("Cannot call this function during the execution of a remove listener: "
- "addr=%p", graph);
- ret = -1;
- goto end;
- }
+enum bt_graph_status
+bt_private_graph_add_source_filter_component_ports_connected_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_source_filter_component_ports_connected_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_ports_connected listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (ports_connected_func_t) func,
+ };
+ int listener_id;
- if (!listener) {
- BT_LOGW_STR("Invalid parameter: listener is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.source_filter_ports_connected,
+ listener);
+ listener_id = graph->listeners.source_filter_ports_connected->len - 1;
+ BT_LIB_LOGV("Added \"source to filter component ports connected\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- ret = add_listener(graph->listeners.ports_connected, listener,
- listener_removed, data);
- BT_LOGV("Added \"port connected\" listener to graph: "
- "graph-addr=%p, listener-addr=%p, pos=%d",
- graph, listener, ret);
+enum bt_graph_status
+bt_private_graph_add_source_sink_component_ports_connected_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_source_sink_component_ports_connected_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_ports_connected listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (ports_connected_func_t) func,
+ };
+ int listener_id;
-end:
- return ret;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.source_sink_ports_connected,
+ listener);
+ listener_id = graph->listeners.source_sink_ports_connected->len - 1;
+ BT_LIB_LOGV("Added \"source to sink component ports connected\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
}
-int bt_private_graph_add_ports_disconnected_listener(
+enum bt_graph_status
+bt_private_graph_add_filter_sink_component_ports_connected_listener(
struct bt_private_graph *priv_graph,
- bt_private_graph_ports_disconnected_listener listener,
- bt_private_graph_listener_removed listener_removed, void *data)
+ bt_private_graph_filter_sink_component_ports_connected_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
{
struct bt_graph *graph = (void *) priv_graph;
- int ret;
+ struct bt_graph_listener_ports_connected listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (ports_connected_func_t) func,
+ };
+ int listener_id;
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.filter_sink_ports_connected,
+ listener);
+ listener_id = graph->listeners.filter_sink_ports_connected->len - 1;
+ BT_LIB_LOGV("Added \"filter to sink component ports connected\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- if (graph->in_remove_listener) {
- BT_LOGW("Cannot call this function during the execution of a remove listener: "
- "addr=%p", graph);
- ret = -1;
- goto end;
- }
+enum bt_graph_status
+bt_private_graph_add_source_filter_component_ports_disconnected_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_source_filter_component_ports_disconnected_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_ports_disconnected listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (ports_disconnected_func_t) func,
+ };
+ int listener_id;
- if (!listener) {
- BT_LOGW_STR("Invalid parameter: listener is NULL.");
- ret = -1;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.source_filter_ports_disconnected,
+ listener);
+ listener_id = graph->listeners.source_filter_ports_disconnected->len - 1;
+ BT_LIB_LOGV("Added \"source to filter component ports disconnected\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
- ret = add_listener(graph->listeners.ports_disconnected, listener,
- listener_removed, data);
- BT_LOGV("Added \"port disconnected\" listener to graph: "
- "graph-addr=%p, listener-addr=%p, pos=%d",
- graph, listener, ret);
+enum bt_graph_status
+bt_private_graph_add_source_sink_component_ports_disconnected_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_source_sink_component_ports_disconnected_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_ports_disconnected listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (ports_disconnected_func_t) func,
+ };
+ int listener_id;
-end:
- return ret;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.source_sink_ports_disconnected,
+ listener);
+ listener_id = graph->listeners.source_sink_ports_disconnected->len - 1;
+ BT_LIB_LOGV("Added \"source to sink component ports disconnected\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
+}
+
+enum bt_graph_status
+bt_private_graph_add_filter_sink_component_ports_disconnected_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_filter_sink_component_ports_disconnected_listener func,
+ bt_private_graph_listener_removed listener_removed, void *data,
+ int *out_listener_id)
+{
+ struct bt_graph *graph = (void *) priv_graph;
+ struct bt_graph_listener_ports_disconnected listener = {
+ .base = {
+ .removed = listener_removed,
+ .data = data,
+ },
+ .func = (ports_disconnected_func_t) func,
+ };
+ int listener_id;
+
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(func, "Listener");
+ BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
+ BT_ASSERT_PRE(!graph->in_remove_listener,
+ "Graph currently executing a \"listener removed\" listener: "
+ "%!+g", graph);
+ g_array_append_val(graph->listeners.filter_sink_ports_disconnected,
+ listener);
+ listener_id = graph->listeners.filter_sink_ports_disconnected->len - 1;
+ BT_LIB_LOGV("Added \"filter to sink component ports disconnected\" listener to graph: "
+ "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
+ listener_id);
+
+ if (listener_id) {
+ *out_listener_id = listener_id;
+ }
+
+ return BT_GRAPH_STATUS_OK;
}
BT_HIDDEN
void bt_graph_notify_port_added(struct bt_graph *graph, struct bt_port *port)
{
- size_t i;
+ uint64_t i;
+ GArray *listeners;
+ struct bt_component *comp;
- BT_LOGV("Notifying graph listeners that a port was added: "
- "graph-addr=%p, port-addr=%p, port-name=\"%s\"",
- graph, port, bt_port_get_name(port));
+ BT_ASSERT(graph);
+ BT_ASSERT(port);
+ BT_LIB_LOGV("Notifying graph listeners that a port was added: "
+ "%![graph-]+g, %![port-]+p", graph, port);
+ comp = bt_port_borrow_component(port);
+ BT_ASSERT(comp);
+
+ switch (comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ switch (port->type) {
+ case BT_PORT_TYPE_OUTPUT:
+ listeners = graph->listeners.source_output_port_added;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ switch (port->type) {
+ case BT_PORT_TYPE_INPUT:
+ listeners = graph->listeners.filter_input_port_added;
+ break;
+ case BT_PORT_TYPE_OUTPUT:
+ listeners = graph->listeners.filter_output_port_added;
+ break;
+ default:
+ abort();
+ }
- for (i = 0; i < graph->listeners.port_added->len; i++) {
- struct bt_graph_listener listener =
- g_array_index(graph->listeners.port_added,
- struct bt_graph_listener, i);
- bt_private_graph_port_added_listener func = listener.func;
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ {
+ switch (port->type) {
+ case BT_PORT_TYPE_INPUT:
+ listeners = graph->listeners.sink_input_port_added;
+ break;
+ default:
+ abort();
+ }
- BT_ASSERT(func);
- func(port, listener.data);
+ break;
+ }
+ default:
+ abort();
+ }
+
+ for (i = 0; i < listeners->len; i++) {
+ struct bt_graph_listener_port_added *listener =
+ &g_array_index(listeners,
+ struct bt_graph_listener_port_added, i);
+
+ BT_ASSERT(listener->func);
+ listener->func(comp, port, listener->base.data);
}
}
void bt_graph_notify_port_removed(struct bt_graph *graph,
struct bt_component *comp, struct bt_port *port)
{
- size_t i;
+ uint64_t i;
+ GArray *listeners;
+
+ BT_ASSERT(graph);
+ BT_ASSERT(port);
+ BT_LIB_LOGV("Notifying graph listeners that a port was removed: "
+ "%![graph-]+g, %![comp-]+c, %![port-]+p", graph, comp, port);
+
+ switch (comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ switch (port->type) {
+ case BT_PORT_TYPE_OUTPUT:
+ listeners = graph->listeners.source_output_port_removed;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ switch (port->type) {
+ case BT_PORT_TYPE_INPUT:
+ listeners = graph->listeners.filter_input_port_removed;
+ break;
+ case BT_PORT_TYPE_OUTPUT:
+ listeners = graph->listeners.filter_output_port_removed;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ {
+ switch (port->type) {
+ case BT_PORT_TYPE_INPUT:
+ listeners = graph->listeners.sink_input_port_removed;
+ break;
+ default:
+ abort();
+ }
- BT_LOGV("Notifying graph listeners that a port was removed: "
- "graph-addr=%p, port-addr=%p, port-name=\"%s\"",
- graph, port, bt_port_get_name(port));
+ break;
+ }
+ default:
+ abort();
+ }
- for (i = 0; i < graph->listeners.port_removed->len; i++) {
- struct bt_graph_listener listener =
- g_array_index(graph->listeners.port_removed,
- struct bt_graph_listener, i);
- bt_private_graph_port_removed_listener func = listener.func;
+ for (i = 0; i < listeners->len; i++) {
+ struct bt_graph_listener_port_removed *listener =
+ &g_array_index(listeners,
+ struct bt_graph_listener_port_removed, i);
- BT_ASSERT(func);
- func(comp, port, listener.data);
+ BT_ASSERT(listener->func);
+ listener->func(comp, port, listener->base.data);
}
}
void bt_graph_notify_ports_connected(struct bt_graph *graph,
struct bt_port *upstream_port, struct bt_port *downstream_port)
{
- size_t i;
+ uint64_t i;
+ GArray *listeners;
+ struct bt_component *upstream_comp;
+ struct bt_component *downstream_comp;
- BT_LOGV("Notifying graph listeners that two ports were connected: "
- "graph-addr=%p, "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- graph, upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
+ BT_ASSERT(graph);
+ BT_ASSERT(upstream_port);
+ BT_ASSERT(downstream_port);
+ BT_LIB_LOGV("Notifying graph listeners that ports were connected: "
+ "%![graph-]+g, %![up-port-]+p, %![down-port-]+p",
+ graph, upstream_port, downstream_port);
+ upstream_comp = bt_port_borrow_component(upstream_port);
+ BT_ASSERT(upstream_comp);
+ downstream_comp = bt_port_borrow_component(downstream_port);
+ BT_ASSERT(downstream_comp);
+
+ switch (upstream_comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ switch (downstream_comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ listeners =
+ graph->listeners.source_filter_ports_connected;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ listeners =
+ graph->listeners.source_sink_ports_connected;
+ break;
+ default:
+ abort();
+ }
- for (i = 0; i < graph->listeners.ports_connected->len; i++) {
- struct bt_graph_listener listener =
- g_array_index(graph->listeners.ports_connected,
- struct bt_graph_listener, i);
- bt_private_graph_ports_connected_listener func = listener.func;
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ switch (downstream_comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ listeners =
+ graph->listeners.filter_sink_ports_connected;
+ break;
+ default:
+ abort();
+ }
- BT_ASSERT(func);
- func(upstream_port, downstream_port, listener.data);
+ break;
+ }
+ default:
+ abort();
+ }
+
+ for (i = 0; i < listeners->len; i++) {
+ struct bt_graph_listener_ports_connected *listener =
+ &g_array_index(listeners,
+ struct bt_graph_listener_ports_connected, i);
+
+ BT_ASSERT(listener->func);
+ listener->func(upstream_comp, downstream_comp,
+ upstream_port, downstream_port, listener->base.data);
}
}
void bt_graph_notify_ports_disconnected(struct bt_graph *graph,
struct bt_component *upstream_comp,
struct bt_component *downstream_comp,
- struct bt_port *upstream_port, struct bt_port *downstream_port)
+ struct bt_port *upstream_port,
+ struct bt_port *downstream_port)
{
- size_t i;
+ uint64_t i;
+ GArray *listeners;
+
+ BT_ASSERT(graph);
+ BT_ASSERT(upstream_comp);
+ BT_ASSERT(downstream_comp);
+ BT_ASSERT(upstream_port);
+ BT_ASSERT(downstream_port);
+ BT_LIB_LOGV("Notifying graph listeners that ports were disconnected: "
+ "%![graph-]+g, %![up-port-]+p, %![down-port-]+p, "
+ "%![up-comp-]+c, %![down-comp-]+c",
+ graph, upstream_port, downstream_port, upstream_comp,
+ downstream_comp);
+
+ switch (upstream_comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ switch (downstream_comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ listeners =
+ graph->listeners.source_filter_ports_disconnected;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ listeners =
+ graph->listeners.source_sink_ports_disconnected;
+ break;
+ default:
+ abort();
+ }
- BT_LOGV("Notifying graph listeners that two ports were disconnected: "
- "graph-addr=%p, "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "downstream-port-addr=%p, downstream-port-name=\"%s\"",
- graph, upstream_port, bt_port_get_name(upstream_port),
- downstream_port, bt_port_get_name(downstream_port));
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ switch (downstream_comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ listeners =
+ graph->listeners.filter_sink_ports_disconnected;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ default:
+ abort();
+ }
- for (i = 0; i < graph->listeners.ports_disconnected->len; i++) {
- struct bt_graph_listener listener =
- g_array_index(graph->listeners.ports_disconnected,
- struct bt_graph_listener, i);
- bt_private_graph_ports_disconnected_listener func = listener.func;
+ for (i = 0; i < listeners->len; i++) {
+ struct bt_graph_listener_ports_disconnected *listener =
+ &g_array_index(listeners,
+ struct bt_graph_listener_ports_disconnected, i);
- BT_ASSERT(func);
- func(upstream_comp, downstream_comp, upstream_port,
- downstream_port, listener.data);
+ BT_ASSERT(listener->func);
+ listener->func(upstream_comp, downstream_comp,
+ upstream_port, downstream_port, listener->base.data);
}
}
struct bt_private_graph *priv_graph)
{
struct bt_graph *graph = (void *) priv_graph;
- enum bt_graph_status ret = BT_GRAPH_STATUS_OK;
-
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- ret = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- graph->canceled = BT_TRUE;
- BT_LOGV("Canceled graph: addr=%p", graph);
-end:
- return ret;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ graph->canceled = true;
+ BT_LIB_LOGV("Canceled graph: %!+i", graph);
+ return BT_GRAPH_STATUS_OK;
}
bt_bool bt_graph_is_canceled(struct bt_graph *graph)
{
- bt_bool canceled = BT_FALSE;
-
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- goto end;
- }
-
- canceled = graph->canceled;
-
-end:
- return canceled;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ return graph->canceled ? BT_TRUE : BT_FALSE;
}
BT_HIDDEN
{
BT_ASSERT(graph);
BT_ASSERT(connection);
- BT_LOGV("Removing graph's connection: graph-addr=%p, conn-addr=%p",
+ BT_LIB_LOGV("Removing graph's connection: %![graph-]+g, %![conn-]+x",
graph, connection);
g_ptr_array_remove(graph->connections, connection);
}
-enum bt_graph_status bt_private_graph_add_component_with_init_method_data(
+BT_ASSERT_PRE_FUNC
+static inline
+bool component_name_exists(struct bt_graph *graph, const char *name)
+{
+ bool exists = false;
+ uint64_t i;
+
+ for (i = 0; i < graph->components->len; i++) {
+ struct bt_component *other_comp = graph->components->pdata[i];
+
+ if (strcmp(name, bt_component_get_name(other_comp)) == 0) {
+ BT_ASSERT_PRE_MSG("Another component with the same name already exists in the graph: "
+ "%![other-comp-]+c, name=\"%s\"",
+ other_comp, name);
+ exists = true;
+ goto end;
+ }
+ }
+
+end:
+ return exists;
+}
+
+static
+enum bt_graph_status add_component_with_init_method_data(
struct bt_private_graph *priv_graph,
- struct bt_component_class *component_class,
+ struct bt_component_class *comp_cls,
+ comp_init_method_t init_method,
const char *name, struct bt_value *params,
- void *init_method_data,
- struct bt_component **user_component)
+ void *init_method_data, struct bt_component **user_component)
{
struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
- enum bt_component_status comp_status;
+ enum bt_self_component_status comp_status;
struct bt_component *component = NULL;
- enum bt_component_class_type type;
- size_t i;
- bt_bool init_can_consume;
+ int ret;
+ bool init_can_consume;
+ BT_ASSERT(comp_cls);
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
+ BT_ASSERT_PRE(!component_name_exists(graph, name),
+ "Duplicate component name: %!+g, name=\"%s\"", graph, name);
+ BT_ASSERT_PRE(!params || bt_value_is_map(params),
+ "Parameter value is not a map value: %!+v", params);
bt_object_get_ref(params);
-
- if (!graph) {
- BT_LOGW_STR("Invalid parameter: graph is NULL.");
- graph_status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
init_can_consume = graph->can_consume;
-
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- graph_status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- graph->can_consume = BT_FALSE;
- type = bt_component_class_get_type(component_class);
- BT_LOGD("Adding component to graph: "
- "graph-addr=%p, comp-cls-addr=%p, "
- "comp-cls-type=%s, name=\"%s\", params-addr=%p, "
+ bt_graph_set_can_consume(graph, false);
+ BT_LIB_LOGD("Adding component to graph: "
+ "%![graph-]+g, %![cc-]+C, name=\"%s\", %![params-]+v, "
"init-method-data-addr=%p",
- graph, component_class, bt_component_class_type_string(type),
- name, params, init_method_data);
+ graph, comp_cls, name, params, init_method_data);
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- graph_status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- if (graph->canceled) {
- BT_LOGW_STR("Invalid parameter: graph is canceled.");
- graph_status = BT_GRAPH_STATUS_CANCELED;
- goto end;
- }
-
- if (type != BT_COMPONENT_CLASS_TYPE_SOURCE &&
- type != BT_COMPONENT_CLASS_TYPE_FILTER &&
- type != BT_COMPONENT_CLASS_TYPE_SINK) {
- BT_LOGW("Invalid parameter: unknown component class type: "
- "type=%d", type);
- graph_status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
-
- for (i = 0; i < graph->components->len; i++) {
- void *other_comp = graph->components->pdata[i];
-
- if (strcmp(name, bt_component_get_name(other_comp)) == 0) {
- BT_LOGW("Invalid parameter: another component with the same name already exists in the graph: "
- "other-comp-addr=%p, name=\"%s\"",
- other_comp, name);
- graph_status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
- }
-
- /*
- * Parameters must be a map value, but we create a convenient
- * empty one if it's NULL.
- */
- if (params) {
- if (!bt_value_is_map(params)) {
- BT_LOGW("Invalid parameter: initialization parameters must be a map value: "
- "type=%s",
- bt_common_value_type_string(
- bt_value_get_type(params)));
- graph_status = BT_GRAPH_STATUS_INVALID;
- goto end;
- }
- } else {
- params = bt_value_borrow_from_private(
+ if (!params) {
+ params = bt_private_value_borrow_value(
bt_private_value_map_create());
if (!params) {
BT_LOGE_STR("Cannot create map value object.");
}
}
- comp_status = bt_component_create(component_class, name, &component);
- if (comp_status != BT_COMPONENT_STATUS_OK) {
- BT_LOGE("Cannot create empty component object: status=%s",
- bt_component_status_string(comp_status));
- graph_status = bt_graph_status_from_component_status(
- comp_status);
+ ret = bt_component_create(comp_cls, name, &component);
+ if (ret) {
+ BT_LOGE("Cannot create empty component object: ret=%d",
+ ret);
+ graph_status = BT_GRAPH_STATUS_NOMEM;
goto end;
}
g_ptr_array_add(graph->components, component);
bt_component_set_graph(component, graph);
- if (component_class->methods.init) {
+ if (init_method) {
BT_LOGD_STR("Calling user's initialization method.");
- comp_status = component_class->methods.init(
- bt_private_component_from_component(component), params,
- init_method_data);
+ comp_status = init_method(component, params, init_method_data);
BT_LOGD("User method returned: status=%s",
- bt_component_status_string(comp_status));
- if (comp_status != BT_COMPONENT_STATUS_OK) {
+ bt_self_component_status_string(comp_status));
+ if (comp_status != BT_SELF_COMPONENT_STATUS_OK) {
BT_LOGW_STR("Initialization method failed.");
- graph_status = bt_graph_status_from_component_status(
- comp_status);
+ graph_status = (int) comp_status;
bt_component_set_graph(component, NULL);
g_ptr_array_remove_fast(graph->components, component);
goto end;
* sink queue to be consumed by bt_graph_consume().
*/
if (bt_component_is_sink(component)) {
- graph->has_sink = BT_TRUE;
+ graph->has_sink = true;
g_queue_push_tail(graph->sinks_to_consume, component);
}
* least once.
*/
BT_LOGD_STR("Freezing component class.");
- bt_component_class_freeze(component->class);
- BT_LOGD("Added component to graph: "
- "graph-addr=%p, comp-cls-addr=%p, "
- "comp-cls-type=%s, name=\"%s\", params-addr=%p, "
- "init-method-data-addr=%p, comp-addr=%p",
- graph, component_class, bt_component_class_type_string(type),
- name, params, init_method_data, component);
+ bt_component_class_freeze(comp_cls);
+ BT_LIB_LOGD("Added component to graph: "
+ "%![graph-]+g, %![cc-]+C, name=\"%s\", %![params-]+v, "
+ "init-method-data-addr=%p, %![comp-]+c",
+ graph, comp_cls, name, params, init_method_data, component);
if (user_component) {
/* Move reference to user */
end:
bt_object_put_ref(component);
bt_object_put_ref(params);
- if (graph) {
- graph->can_consume = init_can_consume;
- }
+ (void) init_can_consume;
+ bt_graph_set_can_consume(graph, init_can_consume);
return graph_status;
}
-enum bt_graph_status bt_private_graph_add_component(
+enum bt_graph_status
+bt_private_graph_add_source_component_with_init_method_data(
+ struct bt_private_graph *graph,
+ struct bt_component_class_source *comp_cls,
+ const char *name, struct bt_value *params,
+ void *init_method_data, struct bt_component_source **component)
+{
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ return add_component_with_init_method_data(graph,
+ (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
+ name, params, init_method_data, (void *) component);
+}
+
+enum bt_graph_status bt_private_graph_add_source_component(
+ struct bt_private_graph *graph,
+ struct bt_component_class_source *comp_cls,
+ const char *name, struct bt_value *params,
+ struct bt_component_source **component)
+{
+ return bt_private_graph_add_source_component_with_init_method_data(
+ graph, comp_cls, name, params, NULL, component);
+}
+
+enum bt_graph_status
+bt_private_graph_add_filter_component_with_init_method_data(
+ struct bt_private_graph *graph,
+ struct bt_component_class_filter *comp_cls,
+ const char *name, struct bt_value *params,
+ void *init_method_data, struct bt_component_filter **component)
+{
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ return add_component_with_init_method_data(graph,
+ (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
+ name, params, init_method_data, (void *) component);
+}
+
+enum bt_graph_status bt_private_graph_add_filter_component(
+ struct bt_private_graph *graph,
+ struct bt_component_class_filter *comp_cls,
+ const char *name, struct bt_value *params,
+ struct bt_component_filter **component)
+{
+ return bt_private_graph_add_filter_component_with_init_method_data(
+ graph, comp_cls, name, params, NULL, component);
+}
+
+enum bt_graph_status
+bt_private_graph_add_sink_component_with_init_method_data(
struct bt_private_graph *graph,
- struct bt_component_class *component_class,
+ struct bt_component_class_sink *comp_cls,
const char *name, struct bt_value *params,
- struct bt_component **component)
+ void *init_method_data, struct bt_component_sink **component)
{
- return bt_private_graph_add_component_with_init_method_data(graph,
- component_class, name, params, NULL, component);
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ return add_component_with_init_method_data(graph,
+ (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
+ name, params, init_method_data, (void *) component);
+}
+
+enum bt_graph_status bt_private_graph_add_sink_component(
+ struct bt_private_graph *graph,
+ struct bt_component_class_sink *comp_cls,
+ const char *name, struct bt_value *params,
+ struct bt_component_sink **component)
+{
+ return bt_private_graph_add_sink_component_with_init_method_data(
+ graph, comp_cls, name, params, NULL, component);
}
BT_HIDDEN
int bt_graph_remove_unconnected_component(struct bt_graph *graph,
struct bt_component *component)
{
- bt_bool init_can_consume;
- int64_t count;
+ bool init_can_consume;
+ uint64_t count;
uint64_t i;
int ret = 0;
count = bt_component_get_input_port_count(component);
for (i = 0; i < count; i++) {
- struct bt_port *port =
- bt_component_get_input_port_by_index(component, i);
+ struct bt_port *port = (void *)
+ bt_component_borrow_input_port_by_index(component, i);
BT_ASSERT(port);
- bt_object_put_ref(port);
if (bt_port_is_connected(port)) {
- BT_LOGW("Cannot remove component from graph: "
+ BT_LIB_LOGW("Cannot remove component from graph: "
"an input port is connected: "
- "graph-addr=%p, comp-addr=%p, "
- "comp-name=\"%s\", connected-port-addr=%p, "
- "connected-port-name=\"%s\"",
- graph, component,
- bt_component_get_name(component),
- port, bt_port_get_name(port));
+ "%![graph-]+g, %![comp-]+c, %![port-]+p",
+ graph, component, port);
goto error;
}
}
count = bt_component_get_output_port_count(component);
for (i = 0; i < count; i++) {
- struct bt_port *port =
- bt_component_get_output_port_by_index(component, i);
+ struct bt_port *port = (void *)
+ bt_component_borrow_output_port_by_index(component, i);
BT_ASSERT(port);
- bt_object_put_ref(port);
if (bt_port_is_connected(port)) {
- BT_LOGW("Cannot remove component from graph: "
+ BT_LIB_LOGW("Cannot remove component from graph: "
"an output port is connected: "
- "graph-addr=%p, comp-addr=%p, "
- "comp-name=\"%s\", connected-port-addr=%p, "
- "connected-port-name=\"%s\"",
- graph, component,
- bt_component_get_name(component),
- port, bt_port_get_name(port));
+ "%![graph-]+g, %![comp-]+c, %![port-]+p",
+ graph, component, port);
goto error;
}
}
- graph->can_consume = BT_FALSE;
+ bt_graph_set_can_consume(graph, false);
/* Possibly remove from sinks to consume */
(void) g_queue_remove(graph->sinks_to_consume, component);
if (graph->sinks_to_consume->length == 0) {
- graph->has_sink = BT_FALSE;
+ graph->has_sink = false;
}
/*
ret = -1;
end:
- graph->can_consume = init_can_consume;
+ (void) init_can_consume;
+ bt_graph_set_can_consume(graph, init_can_consume);
return ret;
}
*/
g_ptr_array_add(graph->notifications, notif);
}
-
-struct bt_graph *bt_graph_borrow_from_private(
- struct bt_private_graph *priv_graph)
-{
- return (void *) priv_graph;
-}
/*
- * iterator.c
- *
- * Babeltrace Notification Iterator
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
#include <babeltrace/graph/notification.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-iterator-internal.h>
+#include <babeltrace/graph/self-component-port-input-notification-iterator.h>
+#include <babeltrace/graph/port-output-notification-iterator.h>
#include <babeltrace/graph/notification-internal.h>
#include <babeltrace/graph/notification-event.h>
#include <babeltrace/graph/notification-event-internal.h>
BT_LOGV("Destroying stream state: stream-state-addr=%p", stream_state);
BT_LOGV_STR("Putting stream state's current packet.");
- bt_object_put_ref(stream_state->cur_packet);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_state->cur_packet);
BT_LOGV_STR("Putting stream state's stream.");
- bt_object_put_ref(stream_state->stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_state->stream);
g_free(stream_state);
}
* We keep a reference to the stream until we know it's ended.
*/
stream_state->stream = bt_object_get_ref(stream);
- BT_LOGV("Created stream state: stream-addr=%p, stream-name=\"%s\", "
+ BT_LIB_LOGV("Created stream state: %![stream-]+s, "
"stream-state-addr=%p",
- stream, bt_stream_get_name(stream), stream_state);
+ stream, stream_state);
end:
return stream_state;
if (iterator->notifs) {
g_ptr_array_free(iterator->notifs, TRUE);
+ iterator->notifs = NULL;
}
g_free(iterator);
}
static
-void bt_private_connection_notification_iterator_destroy(struct bt_object *obj)
+void bt_self_component_port_input_notification_iterator_destroy(struct bt_object *obj)
{
- struct bt_notification_iterator_private_connection *iterator;
+ struct bt_self_component_port_input_notification_iterator *iterator;
BT_ASSERT(obj);
* The notification iterator's reference count is 0 if we're
* here. Increment it to avoid a double-destroy (possibly
* infinitely recursive). This could happen for example if the
- * notification iterator's finalization function does bt_object_get_ref()
- * (or anything that causes bt_object_get_ref() to be called) on itself
- * (ref. count goes from 0 to 1), and then bt_object_put_ref(): the
- * reference count would go from 1 to 0 again and this function
- * would be called again.
+ * notification iterator's finalization function does
+ * bt_object_get_ref() (or anything that causes
+ * bt_object_get_ref() to be called) on itself (ref. count goes
+ * from 0 to 1), and then bt_object_put_ref(): the reference
+ * count would go from 1 to 0 again and this function would be
+ * called again.
*/
obj->ref_count++;
iterator = (void *) obj;
- BT_LOGD("Destroying private connection notification iterator object: addr=%p",
- iterator);
- bt_private_connection_notification_iterator_finalize(iterator);
+ BT_LIB_LOGD("Destroying self component input port notification iterator object: "
+ "%!+i", iterator);
+ bt_self_component_port_input_notification_iterator_finalize(iterator);
if (iterator->stream_states) {
/*
* notification iterator object.
*/
g_hash_table_destroy(iterator->stream_states);
+ iterator->stream_states = NULL;
}
if (iterator->connection) {
* later.
*/
bt_connection_remove_iterator(iterator->connection, iterator);
+ iterator->connection = NULL;
}
destroy_base_notification_iterator(obj);
}
BT_HIDDEN
-void bt_private_connection_notification_iterator_finalize(
- struct bt_notification_iterator_private_connection *iterator)
+void bt_self_component_port_input_notification_iterator_finalize(
+ struct bt_self_component_port_input_notification_iterator *iterator)
{
+ typedef void (*method_t)(void *);
+
struct bt_component_class *comp_class = NULL;
- bt_component_class_notification_iterator_finalize_method
- finalize_method = NULL;
+ method_t method = NULL;
BT_ASSERT(iterator);
switch (iterator->state) {
- case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED:
+ case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED:
/* Skip user finalization if user initialization failed */
- BT_LOGD("Not finalizing non-initialized notification iterator: "
- "addr=%p", iterator);
+ BT_LIB_LOGD("Not finalizing non-initialized notification iterator: "
+ "%!+i", iterator);
return;
- case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED:
- case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED:
+ case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED:
+ case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED:
/* Already finalized */
- BT_LOGD("Not finalizing notification iterator: already finalized: "
- "addr=%p", iterator);
+ BT_LIB_LOGD("Not finalizing notification iterator: already finalized: "
+ "%!+i", iterator);
return;
default:
break;
}
- BT_LOGD("Finalizing notification iterator: addr=%p", iterator);
+ BT_LIB_LOGD("Finalizing notification iterator: %!+i", iterator);
- if (iterator->state == BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED) {
- BT_LOGD("Updating notification iterator's state: "
- "new-state=BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED");
- iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED;
+ if (iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED) {
+ BT_LIB_LOGD("Updating notification iterator's state: "
+ "new-state=BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED");
+ iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED;
} else {
- BT_LOGD("Updating notification iterator's state: "
- "new-state=BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED");
- iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED;
+ BT_LIB_LOGD("Updating notification iterator's state: "
+ "new-state=BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED");
+ iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED;
}
BT_ASSERT(iterator->upstream_component);
switch (comp_class->type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
{
- struct bt_component_class_source *source_class;
+ struct bt_component_class_source *src_comp_cls =
+ (void *) comp_class;
- source_class = container_of(comp_class, struct bt_component_class_source, parent);
- finalize_method = source_class->methods.iterator.finalize;
+ method = (method_t) src_comp_cls->methods.notif_iter_finalize;
break;
}
case BT_COMPONENT_CLASS_TYPE_FILTER:
{
- struct bt_component_class_filter *filter_class;
+ struct bt_component_class_filter *flt_comp_cls =
+ (void *) comp_class;
- filter_class = container_of(comp_class, struct bt_component_class_filter, parent);
- finalize_method = filter_class->methods.iterator.finalize;
+ method = (method_t) flt_comp_cls->methods.notif_iter_finalize;
break;
}
default:
abort();
}
- if (finalize_method) {
- BT_LOGD("Calling user's finalization method: addr=%p",
+ if (method) {
+ BT_LIB_LOGD("Calling user's finalization method: %!+i",
iterator);
- finalize_method(
- bt_private_connection_private_notification_iterator_from_notification_iterator(iterator));
+ method(iterator);
}
iterator->upstream_component = NULL;
iterator->upstream_port = NULL;
- BT_LOGD("Finalized notification iterator: addr=%p", iterator);
+ BT_LIB_LOGD("Finalized notification iterator: %!+i", iterator);
}
BT_HIDDEN
-void bt_private_connection_notification_iterator_set_connection(
- struct bt_notification_iterator_private_connection *iterator,
+void bt_self_component_port_input_notification_iterator_set_connection(
+ struct bt_self_component_port_input_notification_iterator *iterator,
struct bt_connection *connection)
{
BT_ASSERT(iterator);
iterator->connection = connection;
- BT_LOGV("Set notification iterator's connection: "
- "iter-addr=%p, conn-addr=%p", iterator, connection);
+ BT_LIB_LOGV("Set notification iterator's connection: "
+ "%![iter-]+i, %![conn-]+x", iterator, connection);
}
static
return ret;
}
-BT_HIDDEN
-enum bt_connection_status bt_private_connection_notification_iterator_create(
+static
+struct bt_self_component_port_input_notification_iterator *
+bt_self_component_port_input_notification_iterator_create_initial(
struct bt_component *upstream_comp,
- struct bt_port *upstream_port,
- struct bt_connection *connection,
- struct bt_notification_iterator_private_connection **user_iterator)
+ struct bt_port *upstream_port)
{
- enum bt_connection_status status = BT_CONNECTION_STATUS_OK;
- enum bt_component_class_type type;
- struct bt_notification_iterator_private_connection *iterator = NULL;
int ret;
+ struct bt_self_component_port_input_notification_iterator *iterator = NULL;
BT_ASSERT(upstream_comp);
BT_ASSERT(upstream_port);
BT_ASSERT(bt_port_is_connected(upstream_port));
- BT_ASSERT(user_iterator);
- BT_LOGD("Creating notification iterator on private connection: "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "conn-addr=%p",
- upstream_comp, bt_component_get_name(upstream_comp),
- upstream_port, bt_port_get_name(upstream_port),
- connection);
- type = bt_component_get_class_type(upstream_comp);
- BT_ASSERT(type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
- type == BT_COMPONENT_CLASS_TYPE_FILTER);
- iterator = g_new0(struct bt_notification_iterator_private_connection, 1);
+ BT_LIB_LOGD("Creating initial notification iterator on self component input port: "
+ "%![up-comp-]+c, %![up-port-]+p", upstream_comp, upstream_port);
+ BT_ASSERT(bt_component_get_class_type(upstream_comp) ==
+ BT_COMPONENT_CLASS_TYPE_SOURCE ||
+ bt_component_get_class_type(upstream_comp) ==
+ BT_COMPONENT_CLASS_TYPE_FILTER);
+ iterator = g_new0(
+ struct bt_self_component_port_input_notification_iterator, 1);
if (!iterator) {
- BT_LOGE_STR("Failed to allocate one private connection notification iterator.");
- status = BT_CONNECTION_STATUS_NOMEM;
+ BT_LOGE_STR("Failed to allocate one self component input port "
+ "notification iterator.");
goto end;
}
ret = init_notification_iterator((void *) iterator,
- BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION,
- bt_private_connection_notification_iterator_destroy);
+ BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT,
+ bt_self_component_port_input_notification_iterator_destroy);
if (ret) {
/* init_notification_iterator() logs errors */
- status = BT_CONNECTION_STATUS_NOMEM;
+ BT_OBJECT_PUT_REF_AND_RESET(iterator);
goto end;
}
g_direct_equal, NULL, (GDestroyNotify) destroy_stream_state);
if (!iterator->stream_states) {
BT_LOGE_STR("Failed to allocate a GHashTable.");
- status = BT_CONNECTION_STATUS_NOMEM;
+ BT_OBJECT_PUT_REF_AND_RESET(iterator);
goto end;
}
iterator->upstream_component = upstream_comp;
iterator->upstream_port = upstream_port;
- iterator->connection = connection;
+ iterator->connection = iterator->upstream_port->connection;
iterator->graph = bt_component_borrow_graph(upstream_comp);
- iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED;
- BT_LOGD("Created notification iterator: "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "upstream-port-addr=%p, upstream-port-name=\"%s\", "
- "conn-addr=%p, iter-addr=%p",
- upstream_comp, bt_component_get_name(upstream_comp),
- upstream_port, bt_port_get_name(upstream_port),
- connection, iterator);
-
- /* Move reference to user */
- *user_iterator = iterator;
- iterator = NULL;
+ iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED;
+ BT_LIB_LOGD("Created initial notification iterator on self component input port: "
+ "%![up-port-]+p, %![up-comp-]+c, %![iter-]+i",
+ upstream_port, upstream_comp, iterator);
end:
- bt_object_put_ref(iterator);
- return status;
+ return iterator;
}
-void *bt_private_connection_private_notification_iterator_get_user_data(
- struct bt_private_connection_private_notification_iterator *private_iterator)
+struct bt_self_component_port_input_notification_iterator *
+bt_self_component_port_input_notification_iterator_create(
+ struct bt_self_component_port_input *self_port)
{
- struct bt_notification_iterator_private_connection *iterator = (void *)
- bt_private_connection_notification_iterator_borrow_from_private(private_iterator);
+ typedef enum bt_self_notification_iterator_status (*init_method_t)(
+ void *, void *, void *);
+
+ init_method_t init_method = NULL;
+ struct bt_self_component_port_input_notification_iterator *iterator =
+ NULL;
+ struct bt_port *port = (void *) self_port;
+ struct bt_port *upstream_port;
+ struct bt_component *comp;
+ struct bt_component *upstream_comp;
+ struct bt_component_class *upstream_comp_cls;
+
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ comp = bt_port_borrow_component(port);
+ BT_ASSERT_PRE(bt_port_is_connected(port),
+ "Port is not connected: %![port-]+p", port);
+ BT_ASSERT_PRE(comp, "Port is not part of a component: %![port-]+p",
+ port);
+ BT_ASSERT_PRE(!bt_component_graph_is_canceled(comp),
+ "Port's component's graph is canceled: "
+ "%![port-]+p, %![comp-]+c", port, comp);
+ BT_ASSERT(port->connection);
+ upstream_port = port->connection->upstream_port;
+ BT_ASSERT(upstream_port);
+ upstream_comp = bt_port_borrow_component(upstream_port);
+ BT_ASSERT(upstream_comp);
+ upstream_comp_cls = upstream_comp->class;
+ BT_ASSERT(upstream_comp->class->type ==
+ BT_COMPONENT_CLASS_TYPE_SOURCE ||
+ upstream_comp->class->type ==
+ BT_COMPONENT_CLASS_TYPE_FILTER);
+ iterator = bt_self_component_port_input_notification_iterator_create_initial(
+ upstream_comp, upstream_port);
+ if (!iterator) {
+ BT_LOGW_STR("Cannot create self component input port "
+ "notification iterator.");
+ goto end;
+ }
- BT_ASSERT_PRE_NON_NULL(private_iterator, "Notification iterator");
- return iterator->user_data;
+ switch (upstream_comp_cls->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ struct bt_component_class_source *src_comp_cls =
+ (void *) upstream_comp_cls;
+
+ init_method =
+ (init_method_t) src_comp_cls->methods.notif_iter_init;
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ struct bt_component_class_filter *flt_comp_cls =
+ (void *) upstream_comp_cls;
+
+ init_method =
+ (init_method_t) flt_comp_cls->methods.notif_iter_init;
+ break;
+ }
+ default:
+ /* Unreachable */
+ abort();
+ }
+
+ if (init_method) {
+ int iter_status;
+
+ BT_LIB_LOGD("Calling user's initialization method: %!+i", iterator);
+ iter_status = init_method(iterator, upstream_comp,
+ upstream_port);
+ BT_LOGD("User method returned: status=%s",
+ bt_notification_iterator_status_string(iter_status));
+ if (iter_status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ BT_LOGW_STR("Initialization method failed.");
+ goto end;
+ }
+ }
+
+ iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE;
+ g_ptr_array_add(port->connection->iterators, iterator);
+ BT_LIB_LOGD("Created notification iterator on self component input port: "
+ "%![up-port-]+p, %![up-comp-]+c, %![iter-]+i",
+ upstream_port, upstream_comp, iterator);
+
+end:
+ return iterator;
}
-enum bt_notification_iterator_status
-bt_private_connection_private_notification_iterator_set_user_data(
- struct bt_private_connection_private_notification_iterator *private_iterator,
- void *data)
+void *bt_self_notification_iterator_get_data(
+ struct bt_self_notification_iterator *self_iterator)
{
- struct bt_notification_iterator_private_connection *iterator = (void *)
- bt_private_connection_notification_iterator_borrow_from_private(private_iterator);
+ struct bt_self_component_port_input_notification_iterator *iterator =
+ (void *) self_iterator;
BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
- iterator->user_data = data;
- BT_LOGV("Set notification iterator's user data: "
- "iter-addr=%p, user-data-addr=%p", iterator, data);
- return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ return iterator->user_data;
}
-struct bt_graph *bt_private_connection_private_notification_iterator_borrow_graph(
- struct bt_private_connection_private_notification_iterator *private_iterator)
+void bt_self_notification_iterator_set_data(
+ struct bt_self_notification_iterator *self_iterator, void *data)
{
- struct bt_notification_iterator_private_connection *iterator = (void *)
- bt_private_connection_notification_iterator_borrow_from_private(
- private_iterator);
+ struct bt_self_component_port_input_notification_iterator *iterator =
+ (void *) self_iterator;
BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
- return iterator->graph;
+ iterator->user_data = data;
+ BT_LIB_LOGV("Set notification iterator's user data: "
+ "%!+i, user-data-addr=%p", iterator, data);
}
BT_ASSERT_PRE_FUNC
BT_ASSERT_PRE_FUNC
static inline
bool validate_notification(
- struct bt_notification_iterator_private_connection *iterator,
+ struct bt_self_component_port_input_notification_iterator *iterator,
struct bt_notification *notif)
{
bool is_valid = true;
BT_ASSERT_PRE_FUNC
static inline
bool validate_notifications(
- struct bt_notification_iterator_private_connection *iterator,
+ struct bt_self_component_port_input_notification_iterator *iterator,
uint64_t count)
{
bool ret = true;
BT_ASSERT_PRE_FUNC
static inline bool priv_conn_notif_iter_can_end(
- struct bt_notification_iterator_private_connection *iterator)
+ struct bt_self_component_port_input_notification_iterator *iterator)
{
GHashTableIter iter;
gpointer stream_key, state_value;
}
enum bt_notification_iterator_status
-bt_private_connection_notification_iterator_next(
- struct bt_notification_iterator *user_iterator,
- struct bt_notification ***user_notifs, uint64_t *user_count)
+bt_self_component_port_input_notification_iterator_next(
+ struct bt_self_component_port_input_notification_iterator *iterator,
+ bt_notification_array *notifs, uint64_t *user_count)
{
- struct bt_notification_iterator_private_connection *iterator =
- (void *) user_iterator;
- struct bt_private_connection_private_notification_iterator *priv_iterator =
- bt_private_connection_private_notification_iterator_from_notification_iterator(iterator);
- bt_component_class_notification_iterator_next_method next_method = NULL;
- enum bt_notification_iterator_status status =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
-
- BT_ASSERT_PRE_NON_NULL(user_iterator, "Notification iterator");
- BT_ASSERT_PRE_NON_NULL(user_notifs, "Notification array");
- BT_ASSERT_PRE_NON_NULL(user_count, "Notification count");
- BT_ASSERT_PRE(user_iterator->type ==
- BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION,
- "Notification iterator was not created from a private connection: "
- "%!+i", iterator);
- BT_LIB_LOGD("Getting next private connection notification iterator's notification: %!+i",
- iterator);
+ typedef enum bt_self_notification_iterator_status (*method_t)(
+ void *, bt_notification_array, uint64_t, uint64_t *);
+
+ method_t method = NULL;
+ struct bt_component_class *comp_cls;
+ int status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
+
+ BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
+ BT_ASSERT_PRE_NON_NULL(notifs, "Notification array (output)");
+ BT_ASSERT_PRE_NON_NULL(user_count, "Notification count (output)");
BT_ASSERT_PRE(iterator->state ==
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE,
+ BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE,
"Notification iterator's \"next\" called, but "
"iterator is in the wrong state: %!+i", iterator);
BT_ASSERT(iterator->upstream_component);
BT_ASSERT(iterator->upstream_component->class);
+ BT_LIB_LOGD("Getting next self component input port "
+ "notification iterator's notifications: %!+i", iterator);
+ comp_cls = iterator->upstream_component->class;
/* Pick the appropriate "next" method */
- switch (iterator->upstream_component->class->type) {
+ switch (comp_cls->type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
{
- struct bt_component_class_source *source_class =
- container_of(iterator->upstream_component->class,
- struct bt_component_class_source, parent);
+ struct bt_component_class_source *src_comp_cls =
+ (void *) comp_cls;
- BT_ASSERT(source_class->methods.iterator.next);
- next_method = source_class->methods.iterator.next;
+ method = (method_t) src_comp_cls->methods.notif_iter_next;
break;
}
case BT_COMPONENT_CLASS_TYPE_FILTER:
{
- struct bt_component_class_filter *filter_class =
- container_of(iterator->upstream_component->class,
- struct bt_component_class_filter, parent);
+ struct bt_component_class_filter *flt_comp_cls =
+ (void *) comp_cls;
- BT_ASSERT(filter_class->methods.iterator.next);
- next_method = filter_class->methods.iterator.next;
+ method = (method_t) flt_comp_cls->methods.notif_iter_next;
break;
}
default:
}
/*
- * Call the user's "next" method to get the next notification
+ * Call the user's "next" method to get the next notifications
* and status.
*/
- BT_ASSERT(next_method);
+ BT_ASSERT(method);
BT_LOGD_STR("Calling user's \"next\" method.");
- status = next_method(priv_iterator,
- (void *) user_iterator->notifs->pdata,
+ status = method(iterator,
+ (void *) iterator->base.notifs->pdata,
NOTIF_BATCH_SIZE, user_count);
BT_LOGD("User method returned: status=%s",
bt_notification_iterator_status_string(status));
goto end;
}
- if (iterator->state == BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED ||
- iterator->state == BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED) {
+ if (iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED ||
+ iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED) {
/*
* The user's "next" method, somehow, cancelled its own
* notification iterator. This can happen, for example,
* all its notification iterators are finalized.
*
* Only bt_object_put_ref() the returned notification if
- * the status is
- * BT_NOTIFICATION_ITERATOR_STATUS_OK because
- * otherwise this field could be garbage.
+ * the status is BT_NOTIFICATION_ITERATOR_STATUS_OK
+ * because otherwise this field could be garbage.
*/
if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
uint64_t i;
bt_notification_array notifs =
- (void *) user_iterator->notifs->pdata;
+ (void *) iterator->base.notifs->pdata;
for (i = 0; i < *user_count; i++) {
bt_object_put_ref(notifs[i]);
"Notifications are invalid at this point: "
"%![notif-iter-]+i, count=%" PRIu64,
iterator, *user_count);
- *user_notifs = (void *) user_iterator->notifs->pdata;
+ *notifs = (void *) iterator->base.notifs->pdata;
break;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
- status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN;
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_END:
BT_ASSERT_PRE(priv_conn_notif_iter_can_end(iterator),
"Notification iterator cannot end at this point: "
"%!+i", iterator);
BT_ASSERT(iterator->state ==
- BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE);
- iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED;
- status = BT_NOTIFICATION_ITERATOR_STATUS_END;
+ BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE);
+ iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED;
BT_LOGD("Set new status: status=%s",
bt_notification_iterator_status_string(status));
goto end;
}
enum bt_notification_iterator_status
-bt_output_port_notification_iterator_next(
- struct bt_notification_iterator *iterator,
+bt_port_output_notification_iterator_next(
+ struct bt_port_output_notification_iterator *iterator,
bt_notification_array *notifs_to_user,
uint64_t *count_to_user)
{
enum bt_notification_iterator_status status;
- struct bt_notification_iterator_output_port *out_port_iter =
- (void *) iterator;
enum bt_graph_status graph_status;
BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
- BT_ASSERT_PRE_NON_NULL(notifs_to_user, "Notification array");
- BT_ASSERT_PRE_NON_NULL(count_to_user, "Notification count");
- BT_ASSERT_PRE(iterator->type ==
- BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT,
- "Notification iterator was not created from an output port: "
+ BT_ASSERT_PRE_NON_NULL(notifs_to_user, "Notification array (output)");
+ BT_ASSERT_PRE_NON_NULL(count_to_user, "Notification count (output)");
+ BT_LIB_LOGD("Getting next output port notification iterator's notifications: "
"%!+i", iterator);
- BT_LIB_LOGD("Getting next output port notification iterator's notification: %!+i",
- iterator);
- graph_status = bt_graph_consume_sink_no_check(
- out_port_iter->graph, out_port_iter->colander);
+ graph_status = bt_graph_consume_sink_no_check(iterator->graph,
+ iterator->colander);
switch (graph_status) {
case BT_GRAPH_STATUS_CANCELED:
- status = BT_NOTIFICATION_ITERATOR_STATUS_CANCELED;
- break;
case BT_GRAPH_STATUS_AGAIN:
- status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN;
- break;
case BT_GRAPH_STATUS_END:
- status = BT_NOTIFICATION_ITERATOR_STATUS_END;
- break;
case BT_GRAPH_STATUS_NOMEM:
- status = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+ status = (int) graph_status;
break;
case BT_GRAPH_STATUS_OK:
status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
* to this iterator's array and sets this iterator's
* notification count: move them to the user.
*/
- *notifs_to_user = (void *) iterator->notifs->pdata;
- *count_to_user = out_port_iter->count;
+ *notifs_to_user = (void *) iterator->base.notifs->pdata;
+ *count_to_user = iterator->count;
break;
default:
/* Other errors */
return status;
}
-struct bt_component *bt_private_connection_notification_iterator_get_component(
- struct bt_notification_iterator *iterator)
+struct bt_component *bt_self_component_port_input_notification_iterator_borrow_component(
+ struct bt_self_component_port_input_notification_iterator *iterator)
+{
+ BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
+ return iterator->upstream_component;
+}
+
+struct bt_self_component *bt_self_notification_iterator_borrow_component(
+ struct bt_self_notification_iterator *self_iterator)
{
- struct bt_notification_iterator_private_connection *iter_priv_conn;
+ struct bt_self_component_port_input_notification_iterator *iterator =
+ (void *) self_iterator;
BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
- BT_ASSERT_PRE(iterator->type ==
- BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION,
- "Notification iterator was not created from a private connection: "
- "%!+i", iterator);
- iter_priv_conn = (void *) iterator;
- return bt_object_get_ref(iter_priv_conn->upstream_component);
+ return (void *) iterator->upstream_component;
}
-struct bt_private_component *
-bt_private_connection_private_notification_iterator_get_private_component(
- struct bt_private_connection_private_notification_iterator *private_iterator)
+struct bt_self_port_output *bt_self_notification_iterator_borrow_port(
+ struct bt_self_notification_iterator *self_iterator)
{
- return bt_private_component_from_component(
- bt_private_connection_notification_iterator_get_component(
- (void *) bt_private_connection_notification_iterator_borrow_from_private(private_iterator)));
+ struct bt_self_component_port_input_notification_iterator *iterator =
+ (void *) self_iterator;
+
+ BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
+ return (void *) iterator->upstream_port;
}
static
-void bt_output_port_notification_iterator_destroy(struct bt_object *obj)
+void bt_port_output_notification_iterator_destroy(struct bt_object *obj)
{
- struct bt_notification_iterator_output_port *iterator =
- (void *) container_of(obj, struct bt_notification_iterator, base);
+ struct bt_port_output_notification_iterator *iterator = (void *) obj;
- BT_LOGD("Destroying output port notification iterator object: addr=%p",
+ BT_LIB_LOGD("Destroying output port notification iterator object: %!+i",
iterator);
BT_LOGD_STR("Putting graph.");
- bt_object_put_ref(iterator->graph);
+ BT_OBJECT_PUT_REF_AND_RESET(iterator->graph);
BT_LOGD_STR("Putting colander sink component.");
- bt_object_put_ref(iterator->colander);
+ BT_OBJECT_PUT_REF_AND_RESET(iterator->colander);
destroy_base_notification_iterator(obj);
}
-struct bt_notification_iterator *bt_output_port_notification_iterator_create(
- struct bt_port *output_port,
+struct bt_port_output_notification_iterator *
+bt_port_output_notification_iterator_create(
+ struct bt_private_graph *priv_graph,
+ struct bt_port_output *output_port,
const char *colander_component_name)
{
- struct bt_notification_iterator_output_port *iterator = NULL;
- struct bt_component_class *colander_comp_cls = NULL;
+ struct bt_port_output_notification_iterator *iterator = NULL;
+ struct bt_component_class_sink *colander_comp_cls = NULL;
struct bt_component *output_port_comp = NULL;
- struct bt_component *colander_comp;
- struct bt_graph *graph = NULL;
+ struct bt_component_sink *colander_comp;
+ struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status graph_status;
const char *colander_comp_name;
- struct bt_port *colander_in_port = NULL;
+ struct bt_port_input *colander_in_port = NULL;
struct bt_component_class_sink_colander_data colander_data;
int ret;
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
BT_ASSERT_PRE_NON_NULL(output_port, "Output port");
- BT_ASSERT_PRE(bt_port_get_type(output_port) == BT_PORT_TYPE_OUTPUT,
- "Port is not an output port: %!+p", output_port);
- output_port_comp = bt_port_get_component(output_port);
+ output_port_comp = bt_port_borrow_component((void *) output_port);
BT_ASSERT_PRE(output_port_comp,
"Output port has no component: %!+p", output_port);
- graph = bt_object_get_ref(bt_component_borrow_graph(output_port_comp));
- BT_ASSERT(graph);
+ BT_ASSERT_PRE(bt_component_borrow_graph(output_port_comp) ==
+ (void *) graph,
+ "Output port is not part of graph: %![graph-]+g, %![port-]+p",
+ graph, output_port);
/* Create notification iterator */
- BT_LOGD("Creating notification iterator on output port: "
- "comp-addr=%p, comp-name\"%s\", port-addr=%p, port-name=\"%s\"",
- output_port_comp, bt_component_get_name(output_port_comp),
- output_port, bt_port_get_name(output_port));
- iterator = g_new0(struct bt_notification_iterator_output_port, 1);
+ BT_LIB_LOGD("Creating notification iterator on output port: "
+ "%![port-]+p, %![comp-]+c", output_port, output_port_comp);
+ iterator = g_new0(struct bt_port_output_notification_iterator, 1);
if (!iterator) {
BT_LOGE_STR("Failed to allocate one output port notification iterator.");
goto error;
}
ret = init_notification_iterator((void *) iterator,
- BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT,
- bt_output_port_notification_iterator_destroy);
+ BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT,
+ bt_port_output_notification_iterator_destroy);
if (ret) {
/* init_notification_iterator() logs errors */
BT_OBJECT_PUT_REF_AND_RESET(iterator);
goto error;
}
- BT_OBJECT_MOVE_REF(iterator->graph, graph);
+ iterator->graph = bt_object_get_ref(graph);
colander_comp_name =
colander_component_name ? colander_component_name : "colander";
colander_data.notifs = (void *) iterator->base.notifs->pdata;
colander_data.count_addr = &iterator->count;
-
- graph_status = bt_private_graph_add_component_with_init_method_data(
- (void *) iterator->graph, colander_comp_cls, colander_comp_name,
- NULL, &colander_data, &iterator->colander);
+ graph_status =
+ bt_private_graph_add_sink_component_with_init_method_data(
+ (void *) graph, colander_comp_cls, colander_comp_name,
+ NULL, &colander_data, &iterator->colander);
if (graph_status != BT_GRAPH_STATUS_OK) {
- BT_LOGW("Cannot add colander sink component to graph: "
- "graph-addr=%p, name=\"%s\", graph-status=%s",
- iterator->graph, colander_comp_name,
+ BT_LIB_LOGW("Cannot add colander sink component to graph: "
+ "%1[graph-]+g, status=%s", graph,
bt_graph_status_string(graph_status));
goto error;
}
* Connect provided output port to the colander component's
* input port.
*/
- colander_in_port = bt_component_sink_get_input_port_by_index(
+ colander_in_port = bt_component_sink_borrow_input_port_by_index(
iterator->colander, 0);
BT_ASSERT(colander_in_port);
- graph_status = bt_private_graph_connect_ports((void *) iterator->graph,
+ graph_status = bt_private_graph_connect_ports(priv_graph,
output_port, colander_in_port, NULL);
if (graph_status != BT_GRAPH_STATUS_OK) {
- BT_LOGW("Cannot add colander sink component to graph: "
- "graph-addr=%p, name=\"%s\", graph-status=%s",
- iterator->graph, colander_comp_name,
+ BT_LIB_LOGW("Cannot add colander sink component to graph: "
+ "%![graph-]+g, %![comp-]+c, status=%s", graph,
+ iterator->colander,
bt_graph_status_string(graph_status));
goto error;
}
* sink and moved to the notification iterator's notification
* member.
*/
- bt_graph_set_can_consume(iterator->graph, BT_FALSE);
+ bt_graph_set_can_consume(iterator->graph, false);
goto end;
error:
* succeeds.
*/
ret = bt_graph_remove_unconnected_component(iterator->graph,
- colander_comp);
+ (void *) colander_comp);
BT_ASSERT(ret == 0);
}
BT_OBJECT_PUT_REF_AND_RESET(iterator);
end:
- bt_object_put_ref(colander_in_port);
bt_object_put_ref(colander_comp_cls);
- bt_object_put_ref(output_port_comp);
- bt_object_put_ref(graph);
return (void *) iterator;
}
-
-struct bt_notification_iterator *
-bt_private_connection_notification_iterator_borrow_from_private(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator)
-{
- return (void *) private_notification_iterator;
-}
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/private-notification-event.h>
#include <babeltrace/graph/notification-event-internal.h>
-#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-pre-internal.h>
}
struct bt_private_notification *bt_private_notification_event_create(
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *self_notif_iter,
struct bt_private_event_class *priv_event_class,
struct bt_private_packet *priv_packet)
{
+ struct bt_self_component_port_input_notification_iterator *notif_iter =
+ (void *) self_notif_iter;
struct bt_event_class *event_class = (void *) priv_event_class;
struct bt_packet *packet = (void *) priv_packet;
struct bt_notification_event *notification = NULL;
struct bt_event *event;
- struct bt_graph *graph;
BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator");
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- BT_LOGD("Creating event notification object: "
- "event-class-addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event_class,
- bt_event_class_get_name(event_class),
- bt_event_class_get_id(event_class));
BT_ASSERT_PRE(event_class_has_trace(event_class),
"Event class is not part of a trace: %!+E", event_class);
+ BT_LIB_LOGD("Creating event notification object: %![ec-]+E",
+ event_class);
event = bt_event_create(event_class, packet);
if (unlikely(!event)) {
BT_LIB_LOGE("Cannot create event from event class: "
- "%![event-class-]+E", event_class);
+ "%![ec-]+E", event_class);
goto error;
}
* to notify the graph (pool owner) so that it removes the
* notification from its notification array.
*/
- graph = bt_private_connection_private_notification_iterator_borrow_graph(
- notif_iter);
notification = (void *) bt_notification_create_from_pool(
- &graph->event_notif_pool, graph);
+ ¬if_iter->graph->event_notif_pool, notif_iter->graph);
if (unlikely(!notification)) {
/* bt_notification_create_from_pool() logs errors */
goto error;
notification->event = event;
bt_packet_set_is_frozen(packet, true);
bt_event_class_freeze(event_class);
- BT_LOGD("Created event notification object: "
- "event-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
- "notif-addr=%p",
- notification->event, event_class,
- bt_event_class_get_name(event_class),
- bt_event_class_get_id(event_class),
- notification);
+ BT_LIB_LOGD("Created event notification object: "
+ "%![notif-]+n, %![event-]+e", notification, event);
goto end;
error:
{
struct bt_notification_event *event_notif = (void *) notif;
- BT_LOGD("Destroying event notification: addr=%p", notif);
+ BT_LIB_LOGD("Destroying event notification: %!+n", notif);
if (event_notif->event) {
- BT_LOGD_STR("Recycling event.");
+ BT_LIB_LOGD("Recycling event: %!+e", event_notif->event);
bt_event_recycle(event_notif->event);
+ event_notif->event = NULL;
}
g_free(notif);
return;
}
- BT_LOGD("Recycling event notification: addr=%p", notif);
+ BT_LIB_LOGD("Recycling event notification: %![notif-]+n, %![event-]+e",
+ notif, event_notif->event);
bt_notification_reset(notif);
BT_ASSERT(event_notif->event);
- BT_LOGD_STR("Recycling event.");
bt_event_recycle(event_notif->event);
event_notif->event = NULL;
graph = notif->graph;
#include <babeltrace/graph/notification-internal.h>
#include <babeltrace/graph/private-notification-inactivity.h>
#include <babeltrace/graph/notification-inactivity-internal.h>
-#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/object.h>
struct bt_notification_inactivity *notification =
(struct bt_notification_inactivity *) obj;
- BT_LOGD("Destroying inactivity notification: addr=%p", notification);
+ BT_LIB_LOGD("Destroying inactivity notification: %!+n", notification);
if (notification->default_cv) {
bt_clock_value_recycle(notification->default_cv);
}
struct bt_private_notification *bt_private_notification_inactivity_create(
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *self_notif_iter,
struct bt_clock_class *default_clock_class)
{
+ struct bt_self_component_port_input_notification_iterator *notif_iter =
+ (void *) self_notif_iter;
struct bt_notification_inactivity *notification;
struct bt_notification *ret_notif = NULL;
BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator");
BT_ASSERT_PRE_NON_NULL(default_clock_class, "Default clock class");
- BT_LOGD_STR("Creating inactivity notification object.");
+ BT_LIB_LOGD("Creating inactivity notification object: "
+ "%![iter-]+i, %![default-cc-]+K", notif_iter,
+ default_clock_class);
notification = g_new0(struct bt_notification_inactivity, 1);
if (!notification) {
BT_LOGE_STR("Failed to allocate one inactivity notification.");
goto error;
}
- BT_LOGD("Created inactivity notification object: addr=%p",
- ret_notif);
+ BT_LIB_LOGD("Created inactivity notification object: %!+n", ret_notif);
goto end;
error:
/*
- * Babeltrace Plug-in Notification
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
BT_ASSERT(notif);
notif->graph = NULL;
}
-
-struct bt_notification *bt_notification_borrow_from_private(
- struct bt_private_notification *priv_notif)
-{
- return (void *) priv_notif;
-}
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/private-notification-packet.h>
#include <babeltrace/graph/notification-packet-internal.h>
-#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-pre-internal.h>
}
struct bt_private_notification *bt_private_notification_packet_begin_create(
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *self_notif_iter,
struct bt_private_packet *priv_packet)
{
+ struct bt_self_component_port_input_notification_iterator *notif_iter =
+ (void *) self_notif_iter;
struct bt_packet *packet = (void *) priv_packet;
struct bt_notification_packet_begin *notification = NULL;
struct bt_stream *stream;
struct bt_stream_class *stream_class;
- struct bt_graph *graph;
BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator");
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
BT_ASSERT(stream);
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
- BT_LOGD("Creating packet beginning notification object: "
- "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64,
- packet, stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class));
- graph = bt_private_connection_private_notification_iterator_borrow_graph(
- notif_iter);
+ BT_LIB_LOGD("Creating packet beginning notification object: "
+ "%![packet-]+a, %![stream-]+s, %![sc-]+S",
+ packet, stream, stream_class);
notification = (void *) bt_notification_create_from_pool(
- &graph->packet_begin_notif_pool, graph);
+ ¬if_iter->graph->packet_begin_notif_pool, notif_iter->graph);
if (!notification) {
/* bt_notification_create_from_pool() logs errors */
goto end;
bt_object_get_no_null_check_no_parent_check(
¬ification->packet->base);
bt_packet_set_is_frozen(packet, true);
- BT_LOGD("Created packet beginning notification object: "
- "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64 ", addr=%p",
- packet, stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class), notification);
+ BT_LIB_LOGD("Created packet beginning notification object: "
+ "%![notif-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S",
+ notification, packet, stream, stream_class);
goto end;
end:
{
struct bt_notification_packet_begin *packet_begin_notif = (void *) notif;
- BT_LOGD("Destroying packet beginning notification: addr=%p", notif);
- BT_LOGD_STR("Putting packet.");
+ BT_LIB_LOGD("Destroying packet beginning notification: %!+n", notif);
+ BT_LIB_LOGD("Putting packet: %!+a", packet_begin_notif->packet);
BT_OBJECT_PUT_REF_AND_RESET(packet_begin_notif->packet);
g_free(notif);
}
return;
}
- BT_LOGD("Recycling packet beginning notification: addr=%p", notif);
+ BT_LIB_LOGD("Recycling packet beginning notification: %!+n", notif);
bt_notification_reset(notif);
bt_object_put_no_null_check(&packet_begin_notif->packet->base);
packet_begin_notif->packet = NULL;
}
struct bt_private_notification *bt_private_notification_packet_end_create(
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *self_notif_iter,
struct bt_private_packet *priv_packet)
{
+ struct bt_self_component_port_input_notification_iterator *notif_iter =
+ (void *) self_notif_iter;
struct bt_packet *packet = (void *) priv_packet;
struct bt_notification_packet_end *notification = NULL;
struct bt_stream *stream;
struct bt_stream_class *stream_class;
- struct bt_graph *graph;
BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator");
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
BT_ASSERT(stream);
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
- BT_LOGD("Creating packet end notification object: "
- "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64,
- packet, stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class));
- graph = bt_private_connection_private_notification_iterator_borrow_graph(
- notif_iter);
+ BT_LIB_LOGD("Creating packet end notification object: "
+ "%![packet-]+a, %![stream-]+s, %![sc-]+S",
+ packet, stream, stream_class);
notification = (void *) bt_notification_create_from_pool(
- &graph->packet_end_notif_pool, graph);
+ ¬if_iter->graph->packet_end_notif_pool, notif_iter->graph);
if (!notification) {
/* bt_notification_create_from_pool() logs errors */
goto end;
bt_object_get_no_null_check_no_parent_check(
¬ification->packet->base);
bt_packet_set_is_frozen(packet, true);
- BT_LOGD("Created packet end notification object: "
- "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64 ", addr=%p",
- packet, stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class), notification);
+ BT_LIB_LOGD("Created packet end notification object: "
+ "%![notif-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S",
+ notification, packet, stream, stream_class);
goto end;
end:
{
struct bt_notification_packet_end *packet_end_notif = (void *) notif;
- BT_LOGD("Destroying packet end notification: addr=%p", notif);
- BT_LOGD_STR("Putting packet.");
+ BT_LIB_LOGD("Destroying packet end notification: %!+n", notif);
+ BT_LIB_LOGD("Putting packet: %!+a", packet_end_notif->packet);
BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet);
g_free(notif);
}
return;
}
- BT_LOGD("Recycling packet end notification: addr=%p", notif);
+ BT_LIB_LOGD("Recycling packet end notification: %!+n", notif);
bt_notification_reset(notif);
BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet);
graph = notif->graph;
#include <babeltrace/trace-ir/stream-class-internal.h>
#include <babeltrace/graph/private-notification-stream.h>
#include <babeltrace/graph/notification-stream-internal.h>
-#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/object.h>
#include <inttypes.h>
struct bt_notification_stream_end *notification =
(struct bt_notification_stream_end *) obj;
- BT_LOGD("Destroying stream end notification: addr=%p",
+ BT_LIB_LOGD("Destroying stream end notification: %!+n",
notification);
- BT_LOGD_STR("Putting stream.");
+ BT_LIB_LOGD("Putting stream: %!+s", notification->stream);
BT_OBJECT_PUT_REF_AND_RESET(notification->stream);
if (notification->default_cv) {
bt_clock_value_recycle(notification->default_cv);
+ notification->default_cv = NULL;
}
g_free(notification);
}
struct bt_private_notification *bt_private_notification_stream_end_create(
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *self_notif_iter,
struct bt_private_stream *priv_stream)
{
struct bt_stream *stream = (void *) priv_stream;
struct bt_notification_stream_end *notification;
struct bt_stream_class *stream_class;
+ BT_ASSERT_PRE_NON_NULL(self_notif_iter, "Notification iterator");
BT_ASSERT_PRE_NON_NULL(stream, "Stream");
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
- BT_LOGD("Creating stream end notification object: "
- "stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64,
- stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class));
+ BT_LIB_LOGD("Creating stream end notification object: "
+ "%![stream-]+s, %![sc-]+S", stream, stream_class);
notification = g_new0(struct bt_notification_stream_end, 1);
if (!notification) {
BT_LOGE_STR("Failed to allocate one stream end notification.");
BT_NOTIFICATION_TYPE_STREAM_END,
bt_notification_stream_end_destroy, NULL);
notification->stream = bt_object_get_ref(stream);
- BT_LOGD("Created stream end notification object: "
- "stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64 ", addr=%p",
- stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class), notification);
+ BT_LIB_LOGD("Created stream end notification object: "
+ "%![notif-]+n, %![stream-]+s, %![sc-]+S", notification,
+ stream, stream_class);
return (void *) ¬ification->parent;
error:
struct bt_notification_stream_begin *notification =
(struct bt_notification_stream_begin *) obj;
- BT_LOGD("Destroying stream beginning notification: addr=%p",
+ BT_LIB_LOGD("Destroying stream beginning notification: %!+n",
notification);
- BT_LOGD_STR("Putting stream.");
+ BT_LIB_LOGD("Putting stream: %!+s", notification->stream);
BT_OBJECT_PUT_REF_AND_RESET(notification->stream);
if (notification->default_cv) {
bt_clock_value_recycle(notification->default_cv);
+ notification->default_cv = NULL;
}
g_free(notification);
}
struct bt_private_notification *bt_private_notification_stream_begin_create(
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *self_notif_iter,
struct bt_private_stream *priv_stream)
{
struct bt_stream *stream = (void *) priv_stream;
struct bt_notification_stream_begin *notification;
struct bt_stream_class *stream_class;
+ BT_ASSERT_PRE_NON_NULL(self_notif_iter, "Notification iterator");
BT_ASSERT_PRE_NON_NULL(stream, "Stream");
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
- BT_LOGD("Creating stream beginning notification object: "
- "stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64,
- stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class));
+ BT_LIB_LOGD("Creating stream beginning notification object: "
+ "%![stream-]+s, %![sc-]+S", stream, stream_class);
notification = g_new0(struct bt_notification_stream_begin, 1);
if (!notification) {
BT_LOGE_STR("Failed to allocate one stream beginning notification.");
BT_NOTIFICATION_TYPE_STREAM_BEGIN,
bt_notification_stream_begin_destroy, NULL);
notification->stream = bt_object_get_ref(stream);
- BT_LOGD("Created stream beginning notification object: "
- "stream-addr=%p, stream-name=\"%s\", "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64 ", addr=%p",
- stream, bt_stream_get_name(stream),
- stream_class,
- bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class), notification);
+ BT_LIB_LOGD("Created stream beginning notification object: "
+ "%![notif-]+n, %![stream-]+s, %![sc-]+S", notification,
+ stream, stream_class);
return (void *) ¬ification->parent;
error:
return NULL;
/*
- * port.c
- *
- * Babeltrace Port
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/graph/port.h>
+#include <babeltrace/graph/self-component-port.h>
+#include <babeltrace/graph/self-component-port-input.h>
+#include <babeltrace/graph/self-component-port-output.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/graph/connection-internal.h>
#include <babeltrace/object-internal.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
static
-void bt_port_destroy(struct bt_object *obj)
+void destroy_port(struct bt_object *obj)
{
- struct bt_port *port = container_of(obj, struct bt_port, base);
+ struct bt_port *port = (void *) obj;
- BT_LOGD("Destroying port: addr=%p, name=\"%s\", comp-addr=%p",
- port, bt_port_get_name(port), obj->parent);
+ BT_LIB_LOGD("Destroying port: %!+p", port);
if (port->name) {
g_string_free(port->name, TRUE);
+ port->name = NULL;
}
g_free(port);
}
-struct bt_port *bt_port_borrow_from_private(
- struct bt_private_port *private_port)
-{
- return (void *) private_port;
-}
-
BT_HIDDEN
struct bt_port *bt_port_create(struct bt_component *parent_component,
enum bt_port_type type, const char *name, void *user_data)
BT_ASSERT(name);
BT_ASSERT(parent_component);
BT_ASSERT(type == BT_PORT_TYPE_INPUT || type == BT_PORT_TYPE_OUTPUT);
-
- if (strlen(name) == 0) {
- BT_LOGW_STR("Invalid parameter: name is an empty string.");
- goto end;
- }
-
+ BT_ASSERT(strlen(name) > 0);
port = g_new0(struct bt_port, 1);
if (!port) {
BT_LOGE_STR("Failed to allocate one port.");
goto end;
}
- BT_LOGD("Creating port for component: "
- "comp-addr=%p, comp-name=\"%s\", port-type=%s, "
- "port-name=\"%s\"",
- parent_component, bt_component_get_name(parent_component),
- bt_port_type_string(type), name);
-
- bt_object_init_shared_with_parent(&port->base, bt_port_destroy);
+ BT_LIB_LOGD("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.");
port->type = type;
port->user_data = user_data;
bt_object_set_parent(&port->base, &parent_component->base);
- BT_LOGD("Created port for component: "
- "comp-addr=%p, comp-name=\"%s\", port-type=%s, "
- "port-name=\"%s\", port-addr=%p",
- parent_component, bt_component_get_name(parent_component),
- bt_port_type_string(type), name, port);
+ BT_LIB_LOGD("Created port for component: "
+ "%![comp-]+c, %![port-]+p", parent_component, port);
end:
return port;
const char *bt_port_get_name(struct bt_port *port)
{
- return port ? port->name->str : NULL;
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ return port->name->str;
}
enum bt_port_type bt_port_get_type(struct bt_port *port)
{
- return port ? port->type : BT_PORT_TYPE_UNKOWN;
-}
-
-struct bt_connection *bt_port_get_connection(struct bt_port *port)
-{
- struct bt_connection *connection = NULL;
-
- if (!port) {
- BT_LOGW_STR("Invalid parameter: port is NULL.");
- goto end;
- }
-
- if (!port->connection) {
- /* Not an error: means disconnected */
- goto end;
- }
-
- connection = bt_object_get_ref(port->connection);
-
-end:
- return connection;
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ return port->type;
}
-struct bt_component *bt_port_get_component(struct bt_port *port)
+struct bt_connection *bt_port_borrow_connection(struct bt_port *port)
{
- return (struct bt_component *) bt_object_get_parent(&port->base);
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ return port->connection;
}
-struct bt_private_connection *bt_private_port_get_connection(
- struct bt_private_port *private_port)
+struct bt_component *bt_port_borrow_component(struct bt_port *port)
{
- return bt_private_connection_from_connection(bt_port_get_connection(
- bt_port_borrow_from_private(private_port)));
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ return (struct bt_component *) bt_object_borrow_parent(&port->base);
}
-struct bt_private_component *bt_private_port_get_component(
- struct bt_private_port *private_port)
+struct bt_self_component *bt_self_component_port_borrow_component(
+ struct bt_self_component_port *port)
{
- return bt_private_component_from_component(bt_port_get_component(
- bt_port_borrow_from_private(private_port)));
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ return (void *) bt_object_borrow_parent((void *) port);
}
BT_HIDDEN
* connection exists.
*/
port->connection = connection;
- BT_LOGV("Set port's connection: "
- "port-addr=%p, port-name=\"%s\", conn-addr=%p",
- port, bt_port_get_name(port), connection);
+ BT_LIB_LOGV("Set port's connection: %![port-]+p, %![conn-]+x", port,
+ connection);
}
-enum bt_port_status bt_private_port_remove_from_component(
- struct bt_private_port *private_port)
+enum bt_self_component_port_status bt_self_component_port_remove_from_component(
+ struct bt_self_component_port *self_port)
{
- enum bt_port_status status = BT_PORT_STATUS_OK;
- struct bt_port *port = bt_port_borrow_from_private(private_port);
+ struct bt_port *port = (void *) self_port;
struct bt_component *comp = NULL;
- enum bt_component_status comp_status;
- if (!port) {
- BT_LOGW_STR("Invalid parameter: private port is NULL.");
- status = BT_PORT_STATUS_INVALID;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
- comp = (void *) bt_object_get_parent(&port->base);
+ comp = (void *) bt_object_borrow_parent(&port->base);
if (!comp) {
- BT_LOGV("Port already removed from its component: "
- "port-addr=%p, port-name=\"%s\", ",
- port, bt_port_get_name(port));
+ BT_LIB_LOGV("Port already removed from its component: %!+p",
+ port);
goto end;
}
/* bt_component_remove_port() logs details */
- comp_status = bt_component_remove_port(comp, port);
- BT_ASSERT(comp_status != BT_COMPONENT_STATUS_INVALID);
- if (comp_status < 0) {
- status = BT_PORT_STATUS_ERROR;
- goto end;
- }
+ bt_component_remove_port(comp, port);
end:
- bt_object_put_ref(comp);
- return status;
-}
-
-enum bt_port_status bt_port_disconnect(struct bt_port *port)
-{
- enum bt_port_status status = BT_PORT_STATUS_OK;
-
- if (!port) {
- BT_LOGW_STR("Invalid parameter: port is NULL.");
- status = BT_PORT_STATUS_INVALID;
- goto end;
- }
-
- if (port->connection) {
- bt_connection_end(port->connection, true);
- BT_LOGV("Disconnected port: "
- "port-addr=%p, port-name=\"%s\"",
- port, bt_port_get_name(port));
- }
-
-end:
- return status;
+ return BT_SELF_PORT_STATUS_OK;
}
bt_bool bt_port_is_connected(struct bt_port *port)
{
- int ret;
-
- if (!port) {
- BT_LOGW_STR("Invalid parameter: port is NULL.");
- ret = -1;
- goto end;
- }
-
- ret = port->connection ? 1 : 0;
-
-end:
- return ret;
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ return port->connection ? BT_TRUE : BT_FALSE;
}
-void *bt_private_port_get_user_data(
- struct bt_private_port *private_port)
+void *bt_self_component_port_get_data(struct bt_self_component_port *port)
{
- return private_port ?
- bt_port_borrow_from_private(private_port)->user_data : NULL;
+ BT_ASSERT_PRE_NON_NULL(port, "Port");
+ return ((struct bt_port *) port)->user_data;
}
#define BT_LOG_TAG "QUERY-EXECUTOR"
#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/graph/private-query-executor.h>
#include <babeltrace/graph/query-executor.h>
#include <babeltrace/graph/query-executor-internal.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/object-internal.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
static
void bt_query_executor_destroy(struct bt_object *obj)
struct bt_query_executor *query_exec =
container_of(obj, struct bt_query_executor, base);
- BT_LOGD("Destroying port: addr=%p", query_exec);
+ BT_LOGD("Destroying query executor: addr=%p", query_exec);
g_free(query_exec);
}
-struct bt_query_executor *bt_query_executor_create(void)
+struct bt_private_query_executor *bt_private_query_executor_create(void)
{
struct bt_query_executor *query_exec;
BT_LOGD("Created query executor: addr=%p", query_exec);
end:
- return query_exec;
+ return (void *) query_exec;
}
-enum bt_query_status bt_query_executor_query(
- struct bt_query_executor *query_exec,
- struct bt_component_class *component_class,
+enum bt_query_status bt_private_query_executor_query(
+ struct bt_private_query_executor *priv_query_exec,
+ struct bt_component_class *comp_cls,
const char *object, struct bt_value *params,
struct bt_value **user_result)
{
- struct bt_component_class_query_method_return ret = {
- .result = NULL,
- .status = BT_QUERY_STATUS_OK,
- };
+ typedef enum bt_query_status (*method_t)(void *, void *,
+ const void *, void *, void *);
- if (!query_exec) {
- BT_LOGW_STR("Invalid parameter: query executor is NULL.");
- ret.status = BT_QUERY_STATUS_INVALID;
- goto end;
- }
+ struct bt_query_executor *query_exec = (void *) priv_query_exec;
+ enum bt_query_status status;
+ method_t method = NULL;
- if (query_exec->canceled) {
- BT_LOGW_STR("Invalid parameter: query executor is canceled.");
- ret.status = BT_QUERY_STATUS_EXECUTOR_CANCELED;
- goto end;
+ BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor");
+ BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
+ BT_ASSERT_PRE_NON_NULL(object, "Object");
+ BT_ASSERT_PRE_NON_NULL(user_result, "Result (output)");
+ BT_ASSERT_PRE(!query_exec->canceled, "Query executor is canceled.");
+
+ if (!params) {
+ params = bt_value_null;
}
- if (!component_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- ret.status = BT_QUERY_STATUS_INVALID;
- goto end;
+ switch (comp_cls->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ struct bt_component_class_source *src_cc = (void *) comp_cls;
+
+ method = (method_t) src_cc->methods.query;
+ break;
}
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ struct bt_component_class_filter *flt_cc = (void *) comp_cls;
- if (!object) {
- BT_LOGW_STR("Invalid parameter: object string is NULL.");
- ret.status = BT_QUERY_STATUS_INVALID;
- goto end;
+ method = (method_t) flt_cc->methods.query;
+ break;
}
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ {
+ struct bt_component_class_sink *sink_cc = (void *) comp_cls;
- if (!params) {
- params = bt_value_null;
+ method = (method_t) sink_cc->methods.query;
+ break;
+ }
+ default:
+ abort();
}
- if (!component_class->methods.query) {
+ if (!method) {
/* Not an error: nothing to query */
- BT_LOGD("Component class has no registered query method: "
- "addr=%p, name=\"%s\", type=%s",
- component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type));
- ret.status = BT_QUERY_STATUS_ERROR;
+ BT_LIB_LOGD("Component class has no registered query method: "
+ "%!+C", comp_cls);
+ status = BT_QUERY_STATUS_UNSUPPORTED;
goto end;
}
- BT_LOGD("Calling user's query method: "
- "query-exec-addr=%p, comp-class-addr=%p, "
- "comp-class-name=\"%s\", comp-class-type=%s, "
- "object=\"%s\", params-addr=%p",
- query_exec, component_class,
- bt_component_class_get_name(component_class),
- bt_component_class_type_string(component_class->type),
- object, params);
- ret = component_class->methods.query(component_class, query_exec,
- object, params);
- BT_LOGD("User method returned: status=%s, result-addr=%p",
- bt_query_status_string(ret.status), ret.result);
+ BT_LIB_LOGD("Calling user's query method: "
+ "query-exec-addr=%p, %![cc-]+C, object=\"%s\", %![params-]+v",
+ query_exec, comp_cls, object, params);
+ *user_result = NULL;
+ status = method(comp_cls, query_exec, object, params, user_result);
+ BT_LIB_LOGD("User method returned: status=%s, %![res-]+v",
+ bt_query_status_string(status), *user_result);
+ BT_ASSERT_PRE(status != BT_QUERY_STATUS_EXECUTOR_CANCELED &&
+ status != BT_QUERY_STATUS_UNSUPPORTED,
+ "Unexpected (illegal) returned status: status=%s",
+ bt_query_status_string(status));
+ BT_ASSERT_PRE(status != BT_QUERY_STATUS_OK || *user_result,
+ "User method returned `BT_QUERY_STATUS_OK` without a result.");
if (query_exec->canceled) {
- BT_OBJECT_PUT_REF_AND_RESET(ret.result);
- ret.status = BT_QUERY_STATUS_EXECUTOR_CANCELED;
+ BT_OBJECT_PUT_REF_AND_RESET(*user_result);
+ status = BT_QUERY_STATUS_EXECUTOR_CANCELED;
goto end;
- } else {
- if (ret.status == BT_QUERY_STATUS_EXECUTOR_CANCELED) {
- /*
- * The user cannot decide that the executor is
- * canceled if it's not.
- */
- BT_OBJECT_PUT_REF_AND_RESET(ret.result);
- ret.status = BT_QUERY_STATUS_ERROR;
- goto end;
- }
- }
-
- switch (ret.status) {
- case BT_QUERY_STATUS_INVALID:
- /*
- * This is reserved for invalid parameters passed to
- * this function.
- */
- BT_OBJECT_PUT_REF_AND_RESET(ret.result);
- ret.status = BT_QUERY_STATUS_ERROR;
- break;
- case BT_QUERY_STATUS_OK:
- if (!ret.result) {
- ret.result = bt_value_null;
- }
- break;
- default:
- if (ret.result) {
- BT_LOGW("User method did not return BT_QUERY_STATUS_OK, but result is not NULL: "
- "status=%s, result-addr=%p",
- bt_query_status_string(ret.status), ret.result);
- BT_OBJECT_PUT_REF_AND_RESET(ret.result);
- }
}
end:
- if (user_result) {
- *user_result = ret.result;
- ret.result = NULL;
- }
-
- bt_object_put_ref(ret.result);
- return ret.status;
+ return status;
}
-enum bt_query_status bt_query_executor_cancel(
- struct bt_query_executor *query_exec)
+enum bt_query_status bt_private_query_executor_cancel(
+ struct bt_private_query_executor *priv_query_exec)
{
- enum bt_query_status ret = BT_QUERY_STATUS_OK;
-
- if (!query_exec) {
- BT_LOGW_STR("Invalid parameter: query executor is NULL.");
- ret = BT_QUERY_STATUS_INVALID;
- goto end;
- }
+ struct bt_query_executor *query_exec = (void *) priv_query_exec;
+ BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor");
query_exec->canceled = BT_TRUE;
BT_LOGV("Canceled query executor: addr=%p", query_exec);
-
-end:
- return ret;
+ return BT_QUERY_STATUS_OK;
}
bt_bool bt_query_executor_is_canceled(struct bt_query_executor *query_exec)
{
- bt_bool canceled = BT_FALSE;
-
- if (!query_exec) {
- BT_LOGW_STR("Invalid parameter: query executor is NULL.");
- goto end;
- }
-
- canceled = query_exec->canceled;
-
-end:
- return canceled;
+ BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor");
+ return query_exec->canceled;
}
+++ /dev/null
-/*
- * sink.c
- *
- * Babeltrace Sink Component
- *
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_TAG "COMP-SINK"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/values.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-internal.h>
-
-BT_HIDDEN
-void bt_component_sink_destroy(struct bt_component *component)
-{
-}
-
-BT_HIDDEN
-struct bt_component *bt_component_sink_create(
- struct bt_component_class *class)
-{
- struct bt_component_sink *sink = NULL;
-
- sink = g_new0(struct bt_component_sink, 1);
- if (!sink) {
- BT_LOGE_STR("Failed to allocate one sink component.");
- goto end;
- }
-
-end:
- return sink ? &sink->parent : NULL;
-}
-
-int64_t bt_component_sink_get_input_port_count(struct bt_component *component)
-{
- int64_t ret;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- ret = (int64_t) -1;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
- BT_LOGW("Invalid parameter: component's class is not a sink component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- ret = (int64_t) -1;
- goto end;
- }
-
- /* bt_component_get_input_port_count() logs details/errors */
- ret = bt_component_get_input_port_count(component);
-
-end:
- return ret;
-}
-
-struct bt_port *bt_component_sink_get_input_port_by_name(
- struct bt_component *component, const char *name)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
- BT_LOGW("Invalid parameter: component's class is not a sink component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_input_port_by_name() logs details/errors */
- port = bt_component_get_input_port_by_name(component, name);
-
-end:
- return port;
-}
-
-struct bt_port *bt_component_sink_get_input_port_by_index(
- struct bt_component *component, uint64_t index)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
- BT_LOGW("Invalid parameter: component's class is not a sink component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_input_port_by_index() logs details/errors */
- port = bt_component_get_input_port_by_index(component, index);
-
-end:
- return port;
-}
-
-struct bt_private_port *
-bt_private_component_sink_get_input_port_by_index(
- struct bt_private_component *private_component, uint64_t index)
-{
- /* bt_component_sink_get_input_port_by_index() logs details/errors */
- return bt_private_port_from_port(
- bt_component_sink_get_input_port_by_index(
- bt_component_borrow_from_private(private_component), index));
-}
-
-struct bt_private_port *
-bt_private_component_sink_get_input_port_by_name(
- struct bt_private_component *private_component,
- const char *name)
-{
- /* bt_component_sink_get_input_port_by_name() logs details/errors */
- return bt_private_port_from_port(
- bt_component_sink_get_input_port_by_name(
- bt_component_borrow_from_private(private_component), name));
-}
-
-enum bt_component_status bt_private_component_sink_add_input_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **user_priv_port)
-{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- struct bt_port *port = NULL;
- struct bt_component *component =
- bt_component_borrow_from_private(private_component);
- struct bt_graph *graph;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
- BT_LOGW("Invalid parameter: component's class is not a sink component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- graph = bt_component_borrow_graph(component);
-
- if (graph && bt_graph_is_canceled(graph)) {
- BT_LOGW("Cannot add input port to sink component: graph is canceled: "
- "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
- component, bt_component_get_name(component),
- bt_component_borrow_graph(component));
- status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
- goto end;
- }
-
- /* bt_component_add_input_port() logs details/errors */
- port = bt_component_add_input_port(component, name, user_data);
- if (!port) {
- status = BT_COMPONENT_STATUS_NOMEM;
- goto end;
- }
-
- if (user_priv_port) {
- /* Move reference to user */
- *user_priv_port = bt_private_port_from_port(port);
- port = NULL;
- }
-
-end:
- bt_object_put_ref(port);
- return status;
-}
+++ /dev/null
-/*
- * source.c
- *
- * Babeltrace Source Component
- *
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_TAG "COMP-SOURCE"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/object.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/component-source-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/port-internal.h>
-#include <babeltrace/graph/notification-iterator.h>
-#include <babeltrace/graph/notification-iterator-internal.h>
-#include <babeltrace/graph/graph.h>
-
-BT_HIDDEN
-void bt_component_source_destroy(struct bt_component *component)
-{
-}
-
-BT_HIDDEN
-struct bt_component *bt_component_source_create(
- struct bt_component_class *class)
-{
- struct bt_component_source *source = NULL;
-
- source = g_new0(struct bt_component_source, 1);
- if (!source) {
- BT_LOGE_STR("Failed to allocate one source component.");
- goto end;
- }
-
-end:
- return source ? &source->parent : NULL;
-}
-
-int64_t bt_component_source_get_output_port_count(
- struct bt_component *component)
-{
- int64_t ret;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- ret = (int64_t) -1;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- BT_LOGW("Invalid parameter: component's class is not a source component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- ret = (int64_t) -1;
- goto end;
- }
-
- /* bt_component_get_output_port_count() logs details/errors */
- ret = bt_component_get_output_port_count(component);
-
-end:
- return ret;
-}
-
-struct bt_port *bt_component_source_get_output_port_by_name(
- struct bt_component *component, const char *name)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- BT_LOGW("Invalid parameter: component's class is not a source component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_output_port_by_name() logs details/errors */
- port = bt_component_get_output_port_by_name(component, name);
-
-end:
- return port;
-}
-
-struct bt_port *bt_component_source_get_output_port_by_index(
- struct bt_component *component, uint64_t index)
-{
- struct bt_port *port = NULL;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- BT_LOGW("Invalid parameter: component's class is not a source component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- goto end;
- }
-
- /* bt_component_get_output_port_by_index() logs details/errors */
- port = bt_component_get_output_port_by_index(component, index);
-
-end:
- return port;
-}
-
-struct bt_private_port *
-bt_private_component_source_get_output_port_by_name(
- struct bt_private_component *private_component,
- const char *name)
-{
- /* bt_component_source_get_output_port_by_name() logs details/errors */
- return bt_private_port_from_port(
- bt_component_source_get_output_port_by_name(
- bt_component_borrow_from_private(private_component), name));
-}
-
-struct bt_private_port *
-bt_private_component_source_get_output_port_by_index(
- struct bt_private_component *private_component, uint64_t index)
-{
- /* bt_component_source_get_output_port_by_index() logs details/errors */
- return bt_private_port_from_port(
- bt_component_source_get_output_port_by_index(
- bt_component_borrow_from_private(private_component), index));
-}
-
-enum bt_component_status bt_private_component_source_add_output_port(
- struct bt_private_component *private_component,
- const char *name, void *user_data,
- struct bt_private_port **user_priv_port)
-{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- struct bt_port *port = NULL;
- struct bt_component *component =
- bt_component_borrow_from_private(private_component);
- struct bt_graph *graph;
-
- if (!component) {
- BT_LOGW_STR("Invalid parameter: component is NULL.");
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- BT_LOGW("Invalid parameter: component's class is not a source component class: "
- "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s",
- component, bt_component_get_name(component),
- bt_component_class_type_string(component->class->type));
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- graph = bt_component_borrow_graph(component);
-
- if (graph && bt_graph_is_canceled(graph)) {
- BT_LOGW("Cannot add output port to source component: graph is canceled: "
- "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
- component, bt_component_get_name(component),
- bt_component_borrow_graph(component));
- status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
- goto end;
- }
-
- /* bt_component_add_output_port() logs details and errors */
- port = bt_component_add_output_port(component, name, user_data);
- if (!port) {
- status = BT_COMPONENT_STATUS_NOMEM;
- goto end;
- }
-
- if (user_priv_port) {
- /* Move reference to user */
- *user_priv_port = bt_private_port_from_port(port);
- port = NULL;
- }
-
-end:
- bt_object_put_ref(port);
- return status;
-}
#define PRFIELD(_expr) prefix, (_expr)
+#define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL)
+
#define SET_TMP_PREFIX(_prefix2) \
do { \
strcpy(tmp_prefix, prefix); \
return;
}
- trace = (void *) bt_object_borrow_parent(&stream->base);
- if (!trace) {
- return;
- }
-
BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
SET_TMP_PREFIX("trace-");
format_trace(buf_ch, false, tmp_prefix, trace);
BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, "
"%scommon-context-field-addr=%p, "
- "%specific-scontext-field-addr=%p, "
+ "%sspecific-context-field-addr=%p, "
"%spayload-field-addr=%p, ",
PRFIELD(event->frozen),
PRFIELD(event->header_field ?
}
BUF_APPEND(", %sis-set=%d", PRFIELD(clock_value->is_set));
- BUF_APPEND(", %sclock-class-addr=%p",
- PRFIELD(clock_value->clock_class));
- SET_TMP_PREFIX("clock-class-");
- format_clock_class(buf_ch, false, tmp_prefix, clock_value->clock_class);
+
+ if (clock_value->clock_class) {
+ BUF_APPEND(", %sclock-class-addr=%p",
+ PRFIELD(clock_value->clock_class));
+ SET_TMP_PREFIX("clock-class-");
+ format_clock_class(buf_ch, false, tmp_prefix,
+ clock_value->clock_class);
+ }
}
static inline void format_value(char **buf_ch, bool extended,
{
struct bt_notification_event *notif_event = (void *) notif;
- SET_TMP_PREFIX("event-");
- format_event(buf_ch, true, tmp_prefix, notif_event->event);
+ if (notif_event->event) {
+ SET_TMP_PREFIX("event-");
+ format_event(buf_ch, true, tmp_prefix, notif_event->event);
+ }
+
break;
}
case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
struct bt_notification_stream_begin *notif_stream =
(void *) notif;
- SET_TMP_PREFIX("stream-");
- format_stream(buf_ch, true, tmp_prefix, notif_stream->stream);
+ if (notif_stream->stream) {
+ SET_TMP_PREFIX("stream-");
+ format_stream(buf_ch, true, tmp_prefix, notif_stream->stream);
+ }
+
break;
}
case BT_NOTIFICATION_TYPE_STREAM_END:
struct bt_notification_stream_end *notif_stream =
(void *) notif;
- SET_TMP_PREFIX("stream-");
- format_stream(buf_ch, true, tmp_prefix, notif_stream->stream);
+ if (notif_stream->stream) {
+ SET_TMP_PREFIX("stream-");
+ format_stream(buf_ch, true, tmp_prefix, notif_stream->stream);
+ }
+
break;
}
case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
struct bt_notification_packet_begin *notif_packet =
(void *) notif;
- SET_TMP_PREFIX("packet-");
- format_packet(buf_ch, true, tmp_prefix, notif_packet->packet);
+ if (notif_packet->packet) {
+ SET_TMP_PREFIX("packet-");
+ format_packet(buf_ch, true, tmp_prefix, notif_packet->packet);
+ }
+
break;
}
case BT_NOTIFICATION_TYPE_PACKET_END:
struct bt_notification_packet_end *notif_packet =
(void *) notif;
- SET_TMP_PREFIX("packet-");
- format_packet(buf_ch, true, tmp_prefix, notif_packet->packet);
+ if (notif_packet->packet) {
+ SET_TMP_PREFIX("packet-");
+ format_packet(buf_ch, true, tmp_prefix, notif_packet->packet);
+ }
+
break;
}
default:
BUF_APPEND(", %saddr=%p", PRFIELD(handle));
if (handle->path) {
- BUF_APPEND(", %spath=\"%s\"", PRFIELD(handle->path->str));
+ BUF_APPEND(", %spath=\"%s\"", PRFIELD_GSTRING(handle->path));
}
}
BUF_APPEND(", %stype=%s, %sname=\"%s\"",
PRFIELD(bt_component_class_type_string(comp_class->type)),
- PRFIELD(comp_class->name ? comp_class->name->str : NULL));
+ PRFIELD_GSTRING(comp_class->name));
if (comp_class->description) {
BUF_APPEND(", %spartial-descr=\"%.32s\"",
- PRFIELD(comp_class->description->str));
+ PRFIELD_GSTRING(comp_class->description));
}
if (!extended) {
{
char tmp_prefix[64];
- BUF_APPEND(", %sname=\"%s\"", PRFIELD(component->name->str));
- SET_TMP_PREFIX("class-");
- format_component_class(buf_ch, extended, tmp_prefix, component->class);
+ BUF_APPEND(", %sname=\"%s\"",
+ PRFIELD_GSTRING(component->name));
+
+ if (component->class) {
+ SET_TMP_PREFIX("class-");
+ format_component_class(buf_ch, extended, tmp_prefix,
+ component->class);
+ }
if (!extended) {
return;
BUF_APPEND(", %stype=%s, %sname=\"%s\"",
PRFIELD(bt_port_type_string(port->type)),
- PRFIELD(port->name->str));
+ PRFIELD_GSTRING(port->name));
if (!extended) {
return;
const char *type;
char tmp_prefix[64];
- if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION) {
- type = "BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION";
- } else if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT) {
- type = "BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT";
+ if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT) {
+ type = "BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT";
+ } else if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT) {
+ type = "BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT";
} else {
type = "(unknown)";
}
BUF_APPEND(", %stype=%s", PRFIELD(type));
switch (iterator->type) {
- case BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION:
+ case BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT:
{
- struct bt_notification_iterator_private_connection *
- iter_priv_conn = (void *) iterator;
+ struct bt_self_component_port_input_notification_iterator *
+ port_in_iter = (void *) iterator;
- if (iter_priv_conn->upstream_component) {
+ if (port_in_iter->upstream_component) {
SET_TMP_PREFIX("upstream-comp-");
format_component(buf_ch, false, tmp_prefix,
- iter_priv_conn->upstream_component);
+ port_in_iter->upstream_component);
}
- if (iter_priv_conn->upstream_port) {
+ if (port_in_iter->upstream_port) {
SET_TMP_PREFIX("upstream-port-");
format_port(buf_ch, false, tmp_prefix,
- iter_priv_conn->upstream_port);
+ port_in_iter->upstream_port);
}
- if (iter_priv_conn->connection) {
+ if (port_in_iter->connection) {
SET_TMP_PREFIX("upstream-conn-");
format_connection(buf_ch, false, tmp_prefix,
- iter_priv_conn->connection);
+ port_in_iter->connection);
}
break;
}
- case BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT:
+ case BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT:
{
- struct bt_notification_iterator_output_port *iter_output_port =
+ struct bt_port_output_notification_iterator *port_out_iter =
(void *) iterator;
- SET_TMP_PREFIX("graph-");
- format_graph(buf_ch, false, tmp_prefix,
- iter_output_port->graph);
- SET_TMP_PREFIX("colander-comp-");
- format_component(buf_ch, false, tmp_prefix,
- iter_output_port->colander);
+ if (port_out_iter->graph) {
+ SET_TMP_PREFIX("graph-");
+ format_graph(buf_ch, false, tmp_prefix,
+ port_out_iter->graph);
+ }
+
+ if (port_out_iter->colander) {
+ SET_TMP_PREFIX("colander-comp-");
+ format_component(buf_ch, false, tmp_prefix,
+ (void *) port_out_iter->colander);
+ }
+
break;
}
default:
if (plugin->info.path_set) {
BUF_APPEND(", %spath=\"%s\"",
- PRFIELD(plugin->info.path->str));
+ PRFIELD_GSTRING(plugin->info.path));
}
if (plugin->info.name_set) {
BUF_APPEND(", %sname=\"%s\"",
- PRFIELD(plugin->info.name->str));
+ PRFIELD_GSTRING(plugin->info.name));
}
if (!extended) {
if (plugin->info.author_set) {
BUF_APPEND(", %sauthor=\"%s\"",
- PRFIELD(plugin->info.author->str));
+ PRFIELD_GSTRING(plugin->info.author));
}
if (plugin->info.license_set) {
BUF_APPEND(", %slicense=\"%s\"",
- PRFIELD(plugin->info.license->str));
+ PRFIELD_GSTRING(plugin->info.license));
}
if (plugin->info.version_set) {
plugin->info.version.extra->str : "");
}
- BUF_APPEND(", %sis-frozen=%d, %scomp-class-count=%u",
- PRFIELD(plugin->frozen),
- PRFIELD(plugin->comp_classes->len));
+ BUF_APPEND(", %ssrc-comp-class-count=%u, %sflt-comp-class-count=%u, "
+ "%ssink-comp-class-count=%u",
+ PRFIELD(plugin->src_comp_classes->len),
+ PRFIELD(plugin->flt_comp_classes->len),
+ PRFIELD(plugin->sink_comp_classes->len));
if (plugin->spec_data) {
struct bt_plugin_so_spec_data *spec_data =
/*
- * ref.c: reference counting
- *
- * Babeltrace Library
- *
* Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
/*
- * plugin-so.c
- *
- * Babeltrace Plugin (shared object)
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
#include <babeltrace/plugin/plugin-dev.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/graph/component-class-internal.h>
+#include <babeltrace/graph/private-component-class.h>
+#include <babeltrace/graph/private-component-class-source.h>
+#include <babeltrace/graph/private-component-class-filter.h>
+#include <babeltrace/graph/private-component-class-sink.h>
#include <babeltrace/types.h>
#include <babeltrace/list-internal.h>
#include <babeltrace/assert-internal.h>
bt_list_del(&comp_class->node);
BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle);
}
+
BT_LOGD_STR("Released references from all component classes to shared library handles.");
}
const struct __bt_plugin_component_class_descriptor *descriptor;
const char *description;
const char *help;
- bt_component_class_init_method init_method;
- bt_component_class_finalize_method finalize_method;
- bt_component_class_query_method query_method;
- bt_component_class_accept_port_connection_method accept_port_connection_method;
- bt_component_class_port_connected_method port_connected_method;
- bt_component_class_port_disconnected_method port_disconnected_method;
- struct bt_component_class_notification_iterator_methods iterator_methods;
+
+ union {
+ struct {
+ bt_private_component_class_source_init_method init;
+ bt_private_component_class_source_finalize_method finalize;
+ bt_private_component_class_source_query_method query;
+ bt_private_component_class_source_accept_output_port_connection_method accept_output_port_connection;
+ bt_private_component_class_source_output_port_connected_method output_port_connected;
+ bt_private_component_class_source_output_port_disconnected_method output_port_disconnected;
+ bt_private_component_class_source_notification_iterator_init_method notif_iter_init;
+ bt_private_component_class_source_notification_iterator_finalize_method notif_iter_finalize;
+ } source;
+
+ struct {
+ bt_private_component_class_filter_init_method init;
+ bt_private_component_class_filter_finalize_method finalize;
+ bt_private_component_class_filter_query_method query;
+ bt_private_component_class_filter_accept_input_port_connection_method accept_input_port_connection;
+ bt_private_component_class_filter_accept_output_port_connection_method accept_output_port_connection;
+ bt_private_component_class_filter_input_port_connected_method input_port_connected;
+ bt_private_component_class_filter_output_port_connected_method output_port_connected;
+ bt_private_component_class_filter_input_port_disconnected_method input_port_disconnected;
+ bt_private_component_class_filter_output_port_disconnected_method output_port_disconnected;
+ bt_private_component_class_filter_notification_iterator_init_method notif_iter_init;
+ bt_private_component_class_filter_notification_iterator_finalize_method notif_iter_finalize;
+ } filter;
+
+ struct {
+ bt_private_component_class_sink_init_method init;
+ bt_private_component_class_sink_finalize_method finalize;
+ bt_private_component_class_sink_query_method query;
+ bt_private_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
+ bt_private_component_class_sink_input_port_connected_method input_port_connected;
+ bt_private_component_class_sink_input_port_disconnected_method input_port_disconnected;
+ } sink;
+ } methods;
};
enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
for (cur_cc_descr_attr_ptr = cc_descr_attrs_begin; cur_cc_descr_attr_ptr != cc_descr_attrs_end; cur_cc_descr_attr_ptr++) {
const struct __bt_plugin_component_class_descriptor_attribute *cur_cc_descr_attr =
*cur_cc_descr_attr_ptr;
+ enum bt_component_class_type cc_type;
if (cur_cc_descr_attr == NULL) {
continue;
continue;
}
+ cc_type = cur_cc_descr_attr->comp_class_descriptor->type;
+
/* Find the corresponding component class descriptor entry */
for (i = 0; i < comp_class_full_descriptors->len; i++) {
struct comp_class_full_descriptor *cc_full_descr =
&g_array_index(comp_class_full_descriptors,
struct comp_class_full_descriptor, i);
- if (cur_cc_descr_attr->comp_class_descriptor ==
+ if (cur_cc_descr_attr->comp_class_descriptor !=
cc_full_descr->descriptor) {
- switch (cur_cc_descr_attr->type) {
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION:
- cc_full_descr->description =
- cur_cc_descr_attr->value.description;
+ continue;
+ }
+
+ switch (cur_cc_descr_attr->type) {
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION:
+ cc_full_descr->description =
+ cur_cc_descr_attr->value.description;
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP:
+ cc_full_descr->help =
+ cur_cc_descr_attr->value.help;
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.init =
+ cur_cc_descr_attr->value.source_init_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP:
- cc_full_descr->help =
- cur_cc_descr_attr->value.help;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.init =
+ cur_cc_descr_attr->value.filter_init_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD:
- cc_full_descr->init_method =
- cur_cc_descr_attr->value.init_method;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ cc_full_descr->methods.sink.init =
+ cur_cc_descr_attr->value.sink_init_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD:
- cc_full_descr->finalize_method =
- cur_cc_descr_attr->value.finalize_method;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.finalize =
+ cur_cc_descr_attr->value.source_finalize_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD:
- cc_full_descr->query_method =
- cur_cc_descr_attr->value.query_method;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.finalize =
+ cur_cc_descr_attr->value.filter_finalize_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_PORT_CONNECTION_METHOD:
- cc_full_descr->accept_port_connection_method =
- cur_cc_descr_attr->value.accept_port_connection_method;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ cc_full_descr->methods.sink.finalize =
+ cur_cc_descr_attr->value.sink_finalize_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_CONNECTED_METHOD:
- cc_full_descr->port_connected_method =
- cur_cc_descr_attr->value.port_connected_method;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.query =
+ cur_cc_descr_attr->value.source_query_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_PORT_DISCONNECTED_METHOD:
- cc_full_descr->port_disconnected_method =
- cur_cc_descr_attr->value.port_disconnected_method;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.query =
+ cur_cc_descr_attr->value.filter_query_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD:
- cc_full_descr->iterator_methods.init =
- cur_cc_descr_attr->value.notif_iter_init_method;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ cc_full_descr->methods.sink.query =
+ cur_cc_descr_attr->value.sink_query_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD:
- cc_full_descr->iterator_methods.finalize =
- cur_cc_descr_attr->value.notif_iter_finalize_method;
+ default:
+ 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:
+ cc_full_descr->methods.filter.input_port_connected =
+ cur_cc_descr_attr->value.filter_input_port_connected_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ cc_full_descr->methods.sink.input_port_connected =
+ cur_cc_descr_attr->value.sink_input_port_connected_method;
break;
default:
- /*
- * WARN-level logging because
- * this should not happen with
- * the appropriate ABI version.
- * If we're here, we know that
- * for the reported version of
- * the ABI, this attribute is
- * unknown.
- */
- BT_LOGW("Ignoring unknown component class descriptor attribute: "
- "plugin-path=\"%s\", "
- "plugin-name=\"%s\", "
- "comp-class-name=\"%s\", "
- "comp-class-type=%s, "
- "attr-type-name=\"%s\", "
- "attr-type-id=%d",
- spec->shared_lib_handle->path ?
- spec->shared_lib_handle->path->str :
- NULL,
- descriptor->name,
- cur_cc_descr_attr->comp_class_descriptor->name,
- bt_component_class_type_string(
- cur_cc_descr_attr->comp_class_descriptor->type),
- cur_cc_descr_attr->type_name,
- cur_cc_descr_attr->type);
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.output_port_connected =
+ cur_cc_descr_attr->value.source_output_port_connected_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.output_port_connected =
+ cur_cc_descr_attr->value.filter_output_port_connected_method;
break;
+ default:
+ abort();
}
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_DISCONNECTED_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.input_port_disconnected =
+ cur_cc_descr_attr->value.filter_input_port_disconnected_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ cc_full_descr->methods.sink.input_port_disconnected =
+ cur_cc_descr_attr->value.sink_input_port_disconnected_method;
+ break;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.output_port_disconnected =
+ cur_cc_descr_attr->value.source_output_port_disconnected_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.output_port_disconnected =
+ cur_cc_descr_attr->value.filter_output_port_disconnected_method;
+ break;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.notif_iter_init =
+ cur_cc_descr_attr->value.source_notif_iter_init_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.notif_iter_init =
+ cur_cc_descr_attr->value.filter_notif_iter_init_method;
+ break;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.notif_iter_finalize =
+ cur_cc_descr_attr->value.source_notif_iter_finalize_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.notif_iter_finalize =
+ cur_cc_descr_attr->value.filter_notif_iter_finalize_method;
+ break;
+ default:
+ abort();
+ }
+ break;
+ default:
+ /*
+ * WARN-level logging because this
+ * should not happen with the
+ * appropriate ABI version. If we're
+ * here, we know that for the reported
+ * version of the ABI, this attribute is
+ * unknown.
+ */
+ BT_LOGW("Ignoring unknown component class descriptor attribute: "
+ "plugin-path=\"%s\", "
+ "plugin-name=\"%s\", "
+ "comp-class-name=\"%s\", "
+ "comp-class-type=%s, "
+ "attr-type-name=\"%s\", "
+ "attr-type-id=%d",
+ spec->shared_lib_handle->path ?
+ spec->shared_lib_handle->path->str :
+ NULL,
+ descriptor->name,
+ cur_cc_descr_attr->comp_class_descriptor->name,
+ bt_component_class_type_string(
+ cur_cc_descr_attr->comp_class_descriptor->type),
+ cur_cc_descr_attr->type_name,
+ cur_cc_descr_attr->type);
+ break;
}
}
}
struct comp_class_full_descriptor *cc_full_descr =
&g_array_index(comp_class_full_descriptors,
struct comp_class_full_descriptor, i);
- struct bt_component_class *comp_class;
+ struct bt_private_component_class *comp_class = NULL;
+ struct bt_private_component_class_source *src_comp_class = NULL;
+ struct bt_private_component_class_filter *flt_comp_class = NULL;
+ struct bt_private_component_class_sink *sink_comp_class = NULL;
BT_LOGD("Creating and setting properties of plugin's component class: "
"plugin-path=\"%s\", plugin-name=\"%s\", "
switch (cc_full_descr->descriptor->type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
- comp_class = bt_component_class_source_create(
+ src_comp_class = bt_private_component_class_source_create(
cc_full_descr->descriptor->name,
cc_full_descr->descriptor->methods.source.notif_iter_next);
+ comp_class = bt_private_component_class_source_borrow_private_component_class(
+ src_comp_class);
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
- comp_class = bt_component_class_filter_create(
+ flt_comp_class = bt_private_component_class_filter_create(
cc_full_descr->descriptor->name,
cc_full_descr->descriptor->methods.source.notif_iter_next);
+ comp_class = bt_private_component_class_filter_borrow_private_component_class(
+ flt_comp_class);
break;
case BT_COMPONENT_CLASS_TYPE_SINK:
- comp_class = bt_component_class_sink_create(
+ sink_comp_class = bt_private_component_class_sink_create(
cc_full_descr->descriptor->name,
cc_full_descr->descriptor->methods.sink.consume);
+ comp_class = bt_private_component_class_sink_borrow_private_component_class(
+ sink_comp_class);
break;
default:
/*
}
if (cc_full_descr->description) {
- ret = bt_component_class_set_description(comp_class,
- cc_full_descr->description);
+ ret = bt_private_component_class_set_description(
+ comp_class, cc_full_descr->description);
if (ret) {
BT_LOGE_STR("Cannot set component class's description.");
status = BT_PLUGIN_STATUS_ERROR;
}
if (cc_full_descr->help) {
- ret = bt_component_class_set_help(comp_class,
+ ret = bt_private_component_class_set_help(comp_class,
cc_full_descr->help);
if (ret) {
BT_LOGE_STR("Cannot set component class's help string.");
}
}
- if (cc_full_descr->init_method) {
- ret = bt_component_class_set_init_method(comp_class,
- cc_full_descr->init_method);
- if (ret) {
- BT_LOGE_STR("Cannot set component class's initialization method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
- goto end;
+ switch (cc_full_descr->descriptor->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ if (cc_full_descr->methods.source.init) {
+ ret = bt_private_component_class_source_set_init_method(
+ src_comp_class,
+ cc_full_descr->methods.source.init);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's initialization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
}
- }
- if (cc_full_descr->finalize_method) {
- ret = bt_component_class_set_finalize_method(comp_class,
- cc_full_descr->finalize_method);
- if (ret) {
- BT_LOGE_STR("Cannot set component class's finalization method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
- goto end;
+ if (cc_full_descr->methods.source.finalize) {
+ ret = bt_private_component_class_source_set_finalize_method(
+ src_comp_class,
+ cc_full_descr->methods.source.finalize);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's finalization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
}
- }
- if (cc_full_descr->query_method) {
- ret = bt_component_class_set_query_method(
- comp_class, cc_full_descr->query_method);
- if (ret) {
- BT_LOGE_STR("Cannot set component class's query method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
- goto end;
+ if (cc_full_descr->methods.source.query) {
+ ret = bt_private_component_class_source_set_query_method(
+ src_comp_class,
+ cc_full_descr->methods.source.query);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's query method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
}
- }
- if (cc_full_descr->accept_port_connection_method) {
- ret = bt_component_class_set_accept_port_connection_method(
- comp_class, cc_full_descr->accept_port_connection_method);
- if (ret) {
- BT_LOGE_STR("Cannot set component class's \"accept port connection\" method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
- goto end;
+ if (cc_full_descr->methods.source.accept_output_port_connection) {
+ ret = bt_private_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->port_connected_method) {
- ret = bt_component_class_set_port_connected_method(
- comp_class, cc_full_descr->port_connected_method);
- if (ret) {
- BT_LOGE_STR("Cannot set component class's \"port connected\" method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
- goto end;
+ if (cc_full_descr->methods.source.output_port_connected) {
+ ret = bt_private_component_class_source_set_output_port_connected_method(
+ src_comp_class,
+ cc_full_descr->methods.source.output_port_connected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's \"output port connected\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
}
- }
- if (cc_full_descr->port_disconnected_method) {
- ret = bt_component_class_set_port_disconnected_method(
- comp_class, cc_full_descr->port_disconnected_method);
- if (ret) {
- BT_LOGE_STR("Cannot set component class's \"port disconnected\" method.");
- status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
- goto end;
+ if (cc_full_descr->methods.source.output_port_disconnected) {
+ ret = bt_private_component_class_source_set_output_port_disconnected_method(
+ src_comp_class,
+ cc_full_descr->methods.source.output_port_disconnected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's \"output port disconnected\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
}
- }
- switch (cc_full_descr->descriptor->type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- if (cc_full_descr->iterator_methods.init) {
- ret = bt_component_class_source_set_notification_iterator_init_method(
- comp_class,
- cc_full_descr->iterator_methods.init);
+ if (cc_full_descr->methods.source.notif_iter_init) {
+ ret = bt_private_component_class_source_set_notification_iterator_init_method(
+ src_comp_class,
+ cc_full_descr->methods.source.notif_iter_init);
if (ret) {
- BT_LOGE_STR("Cannot set component class's notification iterator initialization method.");
+ BT_LOGE_STR("Cannot set source component class's notification iterator initialization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
goto end;
}
}
- if (cc_full_descr->iterator_methods.finalize) {
- ret = bt_component_class_source_set_notification_iterator_finalize_method(
- comp_class,
- cc_full_descr->iterator_methods.finalize);
+ if (cc_full_descr->methods.source.notif_iter_finalize) {
+ ret = bt_private_component_class_source_set_notification_iterator_finalize_method(
+ src_comp_class,
+ cc_full_descr->methods.source.notif_iter_finalize);
if (ret) {
BT_LOGE_STR("Cannot set source component class's notification iterator finalization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
goto end;
}
}
+
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
- if (cc_full_descr->iterator_methods.init) {
- ret = bt_component_class_filter_set_notification_iterator_init_method(
- comp_class,
- cc_full_descr->iterator_methods.init);
+ if (cc_full_descr->methods.filter.init) {
+ ret = bt_private_component_class_filter_set_init_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.init);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's initialization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.finalize) {
+ ret = bt_private_component_class_filter_set_finalize_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.finalize);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's finalization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.query) {
+ ret = bt_private_component_class_filter_set_query_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.query);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's query method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.accept_input_port_connection) {
+ ret = bt_private_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_private_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_private_component_class_filter_set_input_port_connected_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.input_port_connected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's \"input port connected\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.output_port_connected) {
+ ret = bt_private_component_class_filter_set_output_port_connected_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.output_port_connected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's \"output port connected\" 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_disconnected) {
+ ret = bt_private_component_class_filter_set_input_port_disconnected_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.input_port_disconnected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's \"input port disconnected\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.output_port_disconnected) {
+ ret = bt_private_component_class_filter_set_output_port_disconnected_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.output_port_disconnected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's \"output port disconnected\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.notif_iter_init) {
+ ret = bt_private_component_class_filter_set_notification_iterator_init_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.notif_iter_init);
if (ret) {
BT_LOGE_STR("Cannot set filter component class's notification iterator initialization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
goto end;
}
}
- if (cc_full_descr->iterator_methods.finalize) {
- ret = bt_component_class_filter_set_notification_iterator_finalize_method(
- comp_class,
- cc_full_descr->iterator_methods.finalize);
+ if (cc_full_descr->methods.filter.notif_iter_finalize) {
+ ret = bt_private_component_class_filter_set_notification_iterator_finalize_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.notif_iter_finalize);
if (ret) {
BT_LOGE_STR("Cannot set filter component class's notification iterator finalization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
goto end;
}
}
+
break;
case BT_COMPONENT_CLASS_TYPE_SINK:
+ if (cc_full_descr->methods.sink.init) {
+ ret = bt_private_component_class_sink_set_init_method(
+ sink_comp_class,
+ cc_full_descr->methods.sink.init);
+ if (ret) {
+ BT_LOGE_STR("Cannot set sink component class's initialization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.sink.finalize) {
+ ret = bt_private_component_class_sink_set_finalize_method(
+ sink_comp_class,
+ cc_full_descr->methods.sink.finalize);
+ if (ret) {
+ BT_LOGE_STR("Cannot set sink component class's finalization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.sink.query) {
+ ret = bt_private_component_class_sink_set_query_method(
+ sink_comp_class,
+ cc_full_descr->methods.sink.query);
+ if (ret) {
+ BT_LOGE_STR("Cannot set sink component class's query method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.sink.accept_input_port_connection) {
+ ret = bt_private_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_private_component_class_sink_set_input_port_connected_method(
+ sink_comp_class,
+ cc_full_descr->methods.sink.input_port_connected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set sink component class's \"input port connected\" 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_disconnected) {
+ ret = bt_private_component_class_sink_set_input_port_disconnected_method(
+ sink_comp_class,
+ cc_full_descr->methods.sink.input_port_disconnected);
+ if (ret) {
+ BT_LOGE_STR("Cannot set sink component class's \"input port disconnected\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
+ goto end;
+ }
+ }
+
break;
default:
abort();
*
* This will call back
* bt_plugin_so_on_add_component_class() so that we can
- * add a mapping in the component class list when
- * we know the component class is successfully added.
+ * add a mapping in the component class list when we
+ * know the component class is successfully added.
*/
status = bt_plugin_add_component_class(plugin,
- comp_class);
+ (void *) comp_class);
BT_OBJECT_PUT_REF_AND_RESET(comp_class);
if (status < 0) {
BT_LOGE("Cannot add component class to plugin.");
}
}
- /*
- * All the plugin's component classes should be added at this
- * point. We freeze the plugin so that it's not possible to add
- * component classes to this plugin object after this stage
- * (plugin object becomes immutable).
- */
- bt_plugin_freeze(plugin);
-
end:
g_array_free(comp_class_full_descriptors, TRUE);
return status;
/*
- * plugin.c
- *
- * Babeltrace Plugin (generic)
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <glib.h>
#include <unistd.h>
#include <stdlib.h>
}
#endif
-extern
-int64_t bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set)
+uint64_t bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set)
{
- int64_t count = -1;
-
- if (!plugin_set) {
- BT_LOGW_STR("Invalid parameter: plugin set is NULL.");
- goto end;
- }
-
- count = (int64_t) plugin_set->plugins->len;
-
-end:
- return count;
+ BT_ASSERT_PRE_NON_NULL(plugin_set, "Plugin set");
+ return (uint64_t) plugin_set->plugins->len;
}
-extern
-struct bt_plugin *bt_plugin_set_get_plugin(struct bt_plugin_set *plugin_set,
+struct bt_plugin *bt_plugin_set_borrow_plugin_by_index(
+ struct bt_plugin_set *plugin_set,
uint64_t index)
{
- struct bt_plugin *plugin = NULL;
-
- if (!plugin_set) {
- BT_LOGW_STR("Invalid parameter: plugin set is NULL.");
- goto end;
- }
-
- if (index >= plugin_set->plugins->len) {
- BT_LOGW("Invalid parameter: index is out of bounds: "
- "addr=%p, index=%" PRIu64 ", count=%u",
- plugin_set, index, plugin_set->plugins->len);
- goto end;
- }
-
- plugin = bt_object_get_ref(g_ptr_array_index(plugin_set->plugins, index));
-
-end:
- return plugin;
+ BT_ASSERT_PRE_NON_NULL(plugin_set, "Plugin set");
+ BT_ASSERT_PRE_VALID_INDEX(index, plugin_set->plugins->len);
+ return g_ptr_array_index(plugin_set->plugins, index);
}
struct bt_plugin_set *bt_plugin_create_all_from_static(void)
{
struct bt_plugin_set *plugin_set = NULL;
- if (!path) {
- BT_LOGW_STR("Invalid parameter: path is NULL.");
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(path, "Path");
BT_LOGD("Creating plugins from file: path=\"%s\"", path);
/* Try shared object plugins */
int ret;
size_t i, j;
- if (!plugin_name) {
- BT_LOGW_STR("Invalid parameter: plugin name is NULL.");
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(plugin_name, "Name");
BT_LOGD("Finding named plugin in standard directories and built-in plugins: "
"name=\"%s\"", plugin_name);
dirs = g_ptr_array_new_with_free_func((GDestroyNotify) destroy_gstring);
}
if (plugin) {
- BT_LOGD("Found plugin in standard directories and built-in plugins: "
- "addr=%p, name=\"%s\", path=\"%s\"",
- plugin, plugin_name, bt_plugin_get_path(plugin));
+ BT_LIB_LOGD("Found plugin in standard directories and built-in plugins: "
+ "%!+l", plugin);
} else {
BT_LOGD("No plugin found in standard directories and built-in plugins: "
"name=\"%s\"", plugin_name);
return plugin;
}
-struct bt_component_class *bt_plugin_find_component_class(
- const char *plugin_name, const char *comp_cls_name,
- enum bt_component_class_type comp_cls_type)
-{
- struct bt_plugin *plugin = NULL;
- struct bt_component_class *comp_cls = NULL;
-
- if (!plugin_name) {
- BT_LOGW_STR("Invalid parameter: plugin name is NULL.");
- goto end;
- }
-
- if (!comp_cls_name) {
- BT_LOGW_STR("Invalid parameter: component class name is NULL.");
- goto end;
- }
-
- BT_LOGD("Finding named plugin and component class in standard directories and built-in plugins: "
- "plugin-name=\"%s\", comp-class-name=\"%s\"",
- plugin_name, comp_cls_name);
- plugin = bt_plugin_find(plugin_name);
- if (!plugin) {
- BT_LOGD_STR("Plugin not found.");
- goto end;
- }
-
- comp_cls = bt_plugin_get_component_class_by_name_and_type(
- plugin, comp_cls_name, comp_cls_type);
- if (!comp_cls) {
- BT_LOGD("Component class not found in plugin: "
- "plugin-addr=%p, plugin-path=\"%s\"",
- plugin, bt_plugin_get_path(plugin));
- }
-
-end:
- bt_object_put_ref(plugin);
- return comp_cls;
-}
-
static struct {
pthread_mutex_t lock;
struct bt_plugin_set *plugin_set;
- bt_bool recurse;
+ bool recurse;
} append_all_from_dir_info = {
.lock = PTHREAD_MUTEX_INITIALIZER
};
struct bt_plugin *plugin =
g_ptr_array_index(plugins_from_file->plugins, j);
- BT_LOGD("Adding plugin to plugin set: "
- "plugin-path=\"%s\", plugin-addr=%p, plugin-name=\"%s\"",
- file, plugin, bt_plugin_get_name(plugin));
+ BT_LIB_LOGD("Adding plugin to plugin set: "
+ "plugin-path=\"%s\", %![plugin-]+l",
+ file, plugin);
bt_plugin_set_add_plugin(append_all_from_dir_info.plugin_set, plugin);
}
bt_bool recurse)
{
int nftw_flags = FTW_PHYS;
- size_t path_len;
enum bt_plugin_status ret = BT_PLUGIN_STATUS_OK;
- if (!path) {
- BT_LOGW_STR("Invalid parameter: path is NULL.");
- ret = BT_PLUGIN_STATUS_ERROR;
- goto end;
- }
-
- path_len = strlen(path);
- if (path_len >= PATH_MAX) {
- BT_LOGW("Invalid parameter: path length is too large: "
- "path-length=%zu", path_len);
- ret = BT_PLUGIN_STATUS_ERROR;
- goto end;
- }
-
+ BT_ASSERT(plugin_set);
+ BT_ASSERT(path);
+ BT_ASSERT(strlen(path) < PATH_MAX);
pthread_mutex_lock(&append_all_from_dir_info.lock);
-
append_all_from_dir_info.plugin_set = plugin_set;
append_all_from_dir_info.recurse = recurse;
ret = nftw(path, nftw_append_all_from_dir,
APPEND_ALL_FROM_DIR_NFDOPEN_MAX, nftw_flags);
-
pthread_mutex_unlock(&append_all_from_dir_info.lock);
-
if (ret != 0) {
- BT_LOGW("Cannot open directory: %s: path=\"%s\", errno=%d",
- strerror(errno), path, errno);
+ BT_LOGW_ERRNO("Cannot open directory", ": path=\"%s\"", path);
ret = BT_PLUGIN_STATUS_ERROR;
}
-end:
return ret;
}
const char *bt_plugin_get_name(struct bt_plugin *plugin)
{
- const char *val = NULL;
-
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto end;
- }
-
- if (plugin->info.name_set) {
- val = plugin->info.name->str;
- }
-
-end:
- return val;
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return plugin->info.name_set ? plugin->info.name->str : NULL;
}
const char *bt_plugin_get_author(struct bt_plugin *plugin)
{
- const char *val = NULL;
-
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto end;
- }
-
- if (plugin->info.author_set) {
- val = plugin->info.author->str;
- }
-
-end:
- return val;
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return plugin->info.author_set ? plugin->info.author->str : NULL;
}
const char *bt_plugin_get_license(struct bt_plugin *plugin)
{
- const char *val = NULL;
-
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto end;
- }
-
- if (plugin->info.license_set) {
- val = plugin->info.license->str;
- }
-
-end:
- return val;
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return plugin->info.license_set ? plugin->info.license->str : NULL;
}
const char *bt_plugin_get_path(struct bt_plugin *plugin)
{
- const char *val = NULL;
-
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto end;
- }
-
- if (plugin->info.path_set) {
- val = plugin->info.path->str;
- }
-
-end:
- return val;
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return plugin->info.path_set ? plugin->info.path->str : NULL;
}
const char *bt_plugin_get_description(struct bt_plugin *plugin)
{
- const char *val = NULL;
-
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto end;
- }
-
- if (plugin->info.description_set) {
- val = plugin->info.description->str;
- }
-
-end:
- return val;
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return plugin->info.description_set ?
+ plugin->info.description->str : NULL;
}
-enum bt_plugin_status bt_plugin_get_version(struct bt_plugin *plugin,
+enum bt_property_availability bt_plugin_get_version(struct bt_plugin *plugin,
unsigned int *major, unsigned int *minor, unsigned int *patch,
const char **extra)
{
- enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
+ enum bt_property_availability avail =
+ BT_PROPERTY_AVAILABILITY_AVAILABLE;
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- status = BT_PLUGIN_STATUS_ERROR;
- goto end;
- }
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
if (!plugin->info.version_set) {
- BT_LOGV("Plugin's version is not set: addr=%p", plugin);
- status = BT_PLUGIN_STATUS_ERROR;
+ BT_LIB_LOGV("Plugin's version is not set: %!+l", plugin);
+ avail = BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE;
goto end;
}
}
end:
- return status;
+ return avail;
}
-int64_t bt_plugin_get_component_class_count(struct bt_plugin *plugin)
+uint64_t bt_plugin_get_source_component_class_count(struct bt_plugin *plugin)
{
- return plugin ? plugin->comp_classes->len : (int64_t) -1;
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return (uint64_t) plugin->src_comp_classes->len;
}
-struct bt_component_class *bt_plugin_get_component_class_by_index(
- struct bt_plugin *plugin, uint64_t index)
+uint64_t bt_plugin_get_filter_component_class_count(struct bt_plugin *plugin)
{
- struct bt_component_class *comp_class = NULL;
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return (uint64_t) plugin->flt_comp_classes->len;
+}
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto error;
- }
+uint64_t bt_plugin_get_sink_component_class_count(struct bt_plugin *plugin)
+{
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ return (uint64_t) plugin->sink_comp_classes->len;
+}
- if (index >= plugin->comp_classes->len) {
- BT_LOGW("Invalid parameter: index is out of bounds: "
- "addr=%p, index=%" PRIu64 ", count=%u",
- plugin, index, plugin->comp_classes->len);
- goto error;
- }
+static inline
+struct bt_component_class *borrow_component_class_by_index(
+ struct bt_plugin *plugin, GPtrArray *comp_classes,
+ uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ BT_ASSERT_PRE_VALID_INDEX(index, comp_classes->len);
+ return g_ptr_array_index(comp_classes, index);
+}
- comp_class = g_ptr_array_index(plugin->comp_classes, index);
- bt_object_get_ref(comp_class);
- goto end;
-error:
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
+struct bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_index(
+ struct bt_plugin *plugin, uint64_t index)
+{
+ return (void *) borrow_component_class_by_index(plugin,
+ plugin->src_comp_classes, index);
+}
-end:
- return comp_class;
+struct bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_index(
+ struct bt_plugin *plugin, uint64_t index)
+{
+ return (void *) borrow_component_class_by_index(plugin,
+ plugin->flt_comp_classes, index);
+}
+
+struct bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_index(
+ struct bt_plugin *plugin, uint64_t index)
+{
+ return (void *) borrow_component_class_by_index(plugin,
+ plugin->sink_comp_classes, index);
}
-struct bt_component_class *bt_plugin_get_component_class_by_name_and_type(
- struct bt_plugin *plugin, const char *name,
- enum bt_component_class_type type)
+static inline
+struct bt_component_class *borrow_component_class_by_name(
+ struct bt_plugin *plugin, GPtrArray *comp_classes,
+ const char *name)
{
struct bt_component_class *comp_class = NULL;
size_t i;
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto error;
- }
-
- if (!name) {
- BT_LOGW_STR("Invalid parameter: name is NULL.");
- goto error;
- }
+ BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
- for (i = 0; i < plugin->comp_classes->len; i++) {
+ for (i = 0; i < comp_classes->len; i++) {
struct bt_component_class *comp_class_candidate =
- g_ptr_array_index(plugin->comp_classes, i);
+ g_ptr_array_index(comp_classes, i);
const char *comp_class_cand_name =
bt_component_class_get_name(comp_class_candidate);
- enum bt_component_class_type comp_class_cand_type =
- bt_component_class_get_type(comp_class_candidate);
BT_ASSERT(comp_class_cand_name);
- BT_ASSERT(comp_class_cand_type >= 0);
- if (strcmp(name, comp_class_cand_name) == 0 &&
- comp_class_cand_type == type) {
- comp_class = bt_object_get_ref(comp_class_candidate);
+ if (strcmp(name, comp_class_cand_name) == 0) {
+ comp_class = comp_class_candidate;
break;
}
}
- goto end;
-
-error:
- BT_OBJECT_PUT_REF_AND_RESET(comp_class);
-
-end:
return comp_class;
}
-enum bt_plugin_status bt_plugin_add_component_class(
- struct bt_plugin *plugin, struct bt_component_class *comp_class)
+struct bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_name(struct bt_plugin *plugin,
+ const char *name)
{
- enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
- struct bt_component_class *comp_class_dup = NULL;
- int comp_class_index = -1;
-
- if (!plugin) {
- BT_LOGW_STR("Invalid parameter: plugin is NULL.");
- goto error;
- }
-
- if (!comp_class) {
- BT_LOGW_STR("Invalid parameter: component class is NULL.");
- goto error;
- }
-
- if (plugin->frozen) {
- BT_LOGW("Invalid parameter: plugin is frozen: "
- "addr=%p, name=\"%s\"", plugin,
- bt_plugin_get_name(plugin));
- goto error;
- }
-
- /* Check for duplicate */
- comp_class_dup = bt_plugin_get_component_class_by_name_and_type(plugin,
- bt_component_class_get_name(comp_class),
- bt_component_class_get_type(comp_class));
- if (comp_class_dup) {
- BT_LOGW("Invalid parameter: a component class with this name and type already exists in the plugin: "
- "plugin-addr=%p, plugin-name=\"%s\", plugin-path=\"%s\", "
- "comp-class-name=\"%s\", comp-class-type=%s",
- plugin, bt_plugin_get_name(plugin),
- bt_plugin_get_path(plugin),
- bt_component_class_get_name(comp_class),
- bt_component_class_type_string(
- bt_component_class_get_type(comp_class)));
- goto error;
- }
-
- /* Add new component class */
- comp_class_index = plugin->comp_classes->len;
- g_ptr_array_add(plugin->comp_classes, bt_object_get_ref(comp_class));
-
- /* Special case for a shared object plugin */
- if (plugin->type == BT_PLUGIN_TYPE_SO) {
- bt_plugin_so_on_add_component_class(plugin, comp_class);
- }
-
- BT_LOGD("Added component class to plugin: "
- "plugin-addr=%p, plugin-name=\"%s\", plugin-path=\"%s\", "
- "comp-class-addr=%p, comp-class-name=\"%s\", comp-class-type=%s",
- plugin, bt_plugin_get_name(plugin),
- bt_plugin_get_path(plugin),
- comp_class,
- bt_component_class_get_name(comp_class),
- bt_component_class_type_string(
- bt_component_class_get_type(comp_class)));
- goto end;
-
-error:
- /* Remove entry from plugin's component classes (if added) */
- if (comp_class_index >= 0) {
- g_ptr_array_remove_index(plugin->comp_classes,
- comp_class_index);
- }
+ return (void *) borrow_component_class_by_name(plugin,
+ plugin->src_comp_classes, name);
+}
- status = BT_PLUGIN_STATUS_ERROR;
+struct bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_name(struct bt_plugin *plugin,
+ const char *name)
+{
+ return (void *) borrow_component_class_by_name(plugin,
+ plugin->flt_comp_classes, name);
+}
-end:
- bt_object_put_ref(comp_class_dup);
- return status;
+struct bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_name(struct bt_plugin *plugin,
+ const char *name)
+{
+ return (void *) borrow_component_class_by_name(plugin,
+ plugin->sink_comp_classes, name);
}
/*
- * prio_heap.c
- *
* Static-sized priority heap containing pointers. Based on CLRS,
* chapter 6.
*
/*
- * attributes.c
- *
- * Babeltrace trace IR - Attributes
- *
* Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
* Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
*
BT_HIDDEN
int64_t bt_attributes_get_count(struct bt_private_value *attr_obj)
{
- return bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
+ return bt_value_array_get_size(bt_private_value_borrow_value(attr_obj));
}
BT_HIDDEN
}
if (index >= bt_value_array_get_size(
- bt_value_borrow_from_private(attr_obj))) {
+ bt_private_value_borrow_value(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
index, bt_value_array_get_size(
- bt_value_borrow_from_private(attr_obj)));
+ bt_private_value_borrow_value(attr_obj)));
goto end;
}
}
ret = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj));
+ bt_private_value_borrow_value(attr_field_name_obj));
end:
return ret;
goto end;
}
- if (index >= bt_value_array_get_size(bt_value_borrow_from_private(attr_obj))) {
+ if (index >= bt_value_array_get_size(bt_private_value_borrow_value(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
index, bt_value_array_get_size(
- bt_value_borrow_from_private(attr_obj)));
+ bt_private_value_borrow_value(attr_obj)));
goto end;
}
struct bt_private_value *attr_field_name_obj = NULL;
attr_size = bt_value_array_get_size(
- bt_value_borrow_from_private(attr_obj));
+ bt_private_value_borrow_value(attr_obj));
if (attr_size < 0) {
BT_LOGE("Cannot get array value's size: value-addr=%p",
attr_obj);
}
field_name = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj));
+ bt_private_value_borrow_value(attr_field_name_obj));
if (!strcmp(field_name, name)) {
break;
if (attr_field_obj) {
ret = bt_private_value_array_set_element_by_index(
attr_field_obj, BT_ATTR_VALUE_INDEX,
- bt_value_borrow_from_private(value_obj));
+ bt_private_value_borrow_value(value_obj));
attr_field_obj = NULL;
goto end;
}
ret = bt_private_value_array_append_string_element(attr_field_obj,
name);
ret |= bt_private_value_array_append_element(attr_field_obj,
- bt_value_borrow_from_private(value_obj));
+ bt_private_value_borrow_value(value_obj));
if (ret) {
BT_LOGE("Cannot append elements to array value: addr=%p",
attr_field_obj);
}
ret = bt_private_value_array_append_element(attr_obj,
- bt_value_borrow_from_private(attr_field_obj));
+ bt_private_value_borrow_value(attr_field_obj));
if (ret) {
BT_LOGE("Cannot append element to array value: "
"array-value-addr=%p, element-value-addr=%p",
}
BT_LOGD("Freezing attributes object: value-addr=%p", attr_obj);
- count = bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
+ count = bt_value_array_get_size(bt_private_value_borrow_value(attr_obj));
BT_ASSERT(count >= 0);
/*
goto end;
}
- bt_value_freeze(bt_value_borrow_from_private(obj));
+ bt_value_freeze(bt_private_value_borrow_value(obj));
}
end:
return ret;
}
-
-struct bt_clock_class *bt_clock_class_borrow_from_private(
- struct bt_private_clock_class *priv_clock_class)
-{
- return (void *) priv_clock_class;
-}
BT_LIB_LOGD("Freezing event class: %!+E", event_class);
event_class->frozen = true;
}
-
-struct bt_event_class *bt_event_class_borrow_from_private(
- struct bt_private_event_class *priv_event_class)
-{
- return (void *) priv_event_class;
-}
event->header_field = field_wrapper;
return 0;
}
-
-struct bt_event *bt_event_borrow_from_private(
- struct bt_private_event *priv_event)
-{
- return (void *) priv_event;
-}
break;
}
}
-
-struct bt_field_class *bt_field_class_borrow_from_private(
- struct bt_private_field_class *priv_field_class)
-{
- return (void *) priv_field_class;
-}
/*
- * field-path.c
- *
- * Babeltrace trace IR - Field path
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
end:
return is_set;
}
-
-struct bt_field *bt_field_borrow_from_private(
- struct bt_private_field *priv_field)
-{
- return (void *) priv_field;
-}
bt_property_uint_set(&packet->packet_counter_snapshot, value);
return 0;
}
-
-struct bt_packet *bt_packet_borrow_from_private(
- struct bt_private_packet *priv_packet)
-{
- return (void *) priv_packet;
-}
/* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */
return BT_TRUE;
}
-
-struct bt_stream_class *bt_stream_class_borrow_from_private(
- struct bt_private_stream_class *priv_stream_class)
-{
- return (void *) priv_stream_class;
-}
BT_LIB_LOGD("Freezing stream: %!+s", stream);
stream->frozen = true;
}
-
-struct bt_stream *bt_stream_borrow_from_private(
- struct bt_private_stream *priv_stream)
-{
- return (void *) priv_stream;
-}
"%![trace-]+t, entry-name=\"%s\"", trace, name);
ret = bt_attributes_set_field_value(trace->environment, name,
value);
- bt_value_freeze(bt_value_borrow_from_private(value));
+ bt_value_freeze(bt_private_value_borrow_value(value));
if (ret) {
BT_LIB_LOGE("Cannot set trace's environment entry: "
"%![trace-]+t, entry-name=\"%s\"", trace, name);
BT_ASSERT_PRE_NON_NULL(value, "Value");
BT_ASSERT_PRE_VALID_INDEX(index,
bt_attributes_get_count(trace->environment));
- *value = bt_value_borrow_from_private(
+ *value = bt_private_value_borrow_value(
bt_attributes_borrow_field_value(trace->environment, index));
BT_ASSERT(*value);
*name = bt_attributes_get_field_name(trace->environment, index);
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- return bt_value_borrow_from_private(
+ return bt_private_value_borrow_value(
bt_attributes_borrow_field_value_by_name(trace->environment,
name));
}
/*
- * utils.c
- *
- * Babeltrace trace IR - Utilities
- *
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
/*
- * Values.c: value objects
- *
- * Babeltrace Library
- *
* Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
* Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
*
end:
return ret;
}
-
-struct bt_value *bt_value_borrow_from_private(
- struct bt_private_value *priv_value)
-{
- return (void *) priv_value;
-}
if (sc->default_clock_class) {
ret = bt_private_stream_class_set_default_clock_class(ir_sc,
- bt_clock_class_borrow_from_private(sc->default_clock_class));
+ bt_private_clock_class_borrow_clock_class(sc->default_clock_class));
BT_ASSERT(ret == 0);
}
"clock class: expected-cc-name=\"%s\", "
"other-cc-name=\"%s\"",
bt_clock_class_get_name(
- bt_clock_class_borrow_from_private(
+ bt_private_clock_class_borrow_clock_class(
*clock_class)),
bt_clock_class_get_name(
- bt_clock_class_borrow_from_private(
+ bt_private_clock_class_borrow_clock_class(
int_fc->mapped_clock_class)));
ret = -1;
goto end;
for (i = 0; i < tc->clock_classes->len; i++) {
struct bt_private_clock_class *cc = tc->clock_classes->pdata[i];
const char *cc_name = bt_clock_class_get_name(
- bt_clock_class_borrow_from_private(cc));
+ bt_private_clock_class_borrow_clock_class(cc));
BT_ASSERT(cc_name);
if (strcmp(cc_name, name) == 0) {
}
freq = bt_clock_class_get_frequency(
- bt_clock_class_borrow_from_private(clock));
- bt_clock_class_get_offset(bt_clock_class_borrow_from_private(clock),
+ bt_private_clock_class_borrow_clock_class(clock));
+ bt_clock_class_get_offset(bt_private_clock_class_borrow_clock_class(clock),
&cur_offset_s, &cur_offset_cycles);
/* Apply offsets */
}
clock_class_name = bt_clock_class_get_name(
- bt_clock_class_borrow_from_private(clock));
+ bt_private_clock_class_borrow_clock_class(clock));
BT_ASSERT(clock_class_name);
if (ctx->is_lttng && strcmp(clock_class_name, "monotonic") == 0) {
/*
* frequency (move to the part in seconds).
*/
freq = bt_clock_class_get_frequency(
- bt_clock_class_borrow_from_private(clock));
+ bt_private_clock_class_borrow_clock_class(clock));
calibrate_clock_class_offsets(&offset_seconds, &offset_cycles, freq);
BT_ASSERT(offset_cycles < bt_clock_class_get_frequency(
- bt_clock_class_borrow_from_private(clock)));
+ bt_private_clock_class_borrow_clock_class(clock)));
ret = bt_private_clock_class_set_offset(clock, offset_seconds, offset_cycles);
BT_ASSERT(ret == 0);
apply_clock_class_offset(ctx, clock);
struct stack *stack;
/* Current notification iterator to create notifications (weak) */
- struct bt_private_connection_private_notification_iterator *notif_iter;
+ struct bt_self_notification_iterator *notif_iter;
/*
* Current dynamic scope field pointer.
base_fc = bt_private_field_borrow_class(base_field);
BT_ASSERT(base_fc);
- switch (bt_field_class_get_type(bt_field_class_borrow_from_private(base_fc))) {
+ switch (bt_field_class_get_type(
+ bt_private_field_class_borrow_field_class(base_fc))) {
case BT_FIELD_CLASS_TYPE_STRUCTURE:
{
BT_ASSERT(index <
bt_field_class_structure_get_member_count(
- bt_field_class_borrow_from_private(
+ bt_private_field_class_borrow_field_class(
bt_private_field_borrow_class(
base_field))));
next_field =
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
BT_ASSERT(index < bt_field_array_get_length(
- bt_field_borrow_from_private(base_field)));
+ bt_private_field_borrow_field(base_field)));
next_field = bt_private_field_array_borrow_element_field_by_index(
base_field, index);
break;
BT_ASSERT(field);
BT_ASSERT(bt_private_field_borrow_class(field) == fc->ir_fc);
BT_ASSERT(bt_field_get_class_type(
- bt_field_borrow_from_private(field)) ==
+ bt_private_field_borrow_field(field)) ==
BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
- bt_field_get_class_type(bt_field_borrow_from_private(field)) ==
+ bt_field_get_class_type(bt_private_field_borrow_field(field)) ==
BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION);
bt_private_field_unsigned_integer_set_value(field, value);
stack_top(notit->stack)->index++;
string_field = stack_top(notit->stack)->base;
BT_ASSERT(bt_field_get_class_type(
- bt_field_borrow_from_private(string_field)) ==
+ bt_private_field_borrow_field(string_field)) ==
BT_FIELD_CLASS_TYPE_STRING);
/* Append character */
BT_ASSERT(field);
BT_ASSERT(bt_private_field_borrow_class(field) == fc->ir_fc);
BT_ASSERT(bt_field_get_class_type(
- bt_field_borrow_from_private(field)) ==
+ bt_private_field_borrow_field(field)) ==
BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
- bt_field_get_class_type(bt_field_borrow_from_private(field)) ==
+ bt_field_get_class_type(bt_private_field_borrow_field(field)) ==
BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION);
bt_private_field_signed_integer_set_value(field, value);
stack_top(notit->stack)->index++;
BT_ASSERT(field);
BT_ASSERT(bt_private_field_borrow_class(field) == fc->ir_fc);
BT_ASSERT(bt_field_get_class_type(
- bt_field_borrow_from_private(field)) ==
+ bt_private_field_borrow_field(field)) ==
BT_FIELD_CLASS_TYPE_REAL);
bt_private_field_real_set_value(field, value);
stack_top(notit->stack)->index++;
BT_ASSERT(field);
BT_ASSERT(bt_private_field_borrow_class(field) == fc->ir_fc);
BT_ASSERT(bt_field_get_class_type(
- bt_field_borrow_from_private(field)) ==
+ bt_private_field_borrow_field(field)) ==
BT_FIELD_CLASS_TYPE_STRING);
ret = bt_private_field_string_clear(field);
BT_ASSERT(ret == 0);
int ret;
BT_ASSERT(bt_field_get_class_type(
- bt_field_borrow_from_private(field)) ==
+ bt_private_field_borrow_field(field)) ==
BT_FIELD_CLASS_TYPE_STRING);
notit->done_filling_string = false;
ret = bt_private_field_string_clear(field);
if (array_fc->is_text) {
BT_ASSERT(bt_field_get_class_type(
- bt_field_borrow_from_private(
+ bt_private_field_borrow_field(
stack_top(notit->stack)->base)) ==
BT_FIELD_CLASS_TYPE_STRING);
bt_bfcr_set_unsigned_int_cb(notit->bfcr,
struct bt_private_event *event =
bt_private_notification_event_borrow_event(
notit->event_notif);
- struct bt_stream_class *sc = bt_stream_class_borrow_from_private(
+ struct bt_stream_class *sc = bt_private_stream_class_borrow_stream_class(
notit->meta.sc->ir_sc);
BT_ASSERT(event);
}
BT_ASSERT(notit->packet);
- sc = bt_stream_class_borrow_from_private(notit->meta.sc->ir_sc);
+ sc = bt_private_stream_class_borrow_stream_class(notit->meta.sc->ir_sc);
BT_ASSERT(sc);
if (bt_stream_class_packets_have_discarded_event_counter_snapshot(sc)) {
enum bt_notif_iter_status bt_notif_iter_get_next_notification(
struct bt_notif_iter *notit,
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *notif_iter,
struct bt_private_notification **notification)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
BT_HIDDEN
enum bt_notif_iter_status bt_notif_iter_get_next_notification(
struct bt_notif_iter *notit,
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *notif_iter,
struct bt_private_notification **notification);
/**
}
BT_HIDDEN
-void writer_component_finalize(struct bt_private_component *component)
+void writer_component_finalize(struct bt_self_component *component)
{
struct writer_component *writer_component = (struct writer_component *)
- bt_private_component_get_user_data(component);
+ bt_self_component_get_user_data(component);
destroy_writer_component_data(writer_component);
g_free(writer_component);
BT_HIDDEN
void writer_component_port_connected(
- struct bt_private_component *component,
+ struct bt_self_component *component,
struct bt_private_port *self_port,
struct bt_port *other_port)
{
struct writer_component *writer;
enum bt_connection_status conn_status;
- writer = bt_private_component_get_user_data(component);
+ writer = bt_self_component_get_user_data(component);
BT_ASSERT(writer);
BT_ASSERT(!writer->input_iterator);
connection = bt_private_port_get_connection(self_port);
}
BT_HIDDEN
-enum bt_component_status writer_run(struct bt_private_component *component)
+enum bt_component_status writer_run(struct bt_self_component *component)
{
enum bt_component_status ret;
struct bt_notification *notification = NULL;
struct bt_notification_iterator *it;
struct writer_component *writer_component =
- bt_private_component_get_user_data(component);
+ bt_self_component_get_user_data(component);
enum bt_notification_iterator_status it_ret;
if (unlikely(writer_component->error)) {
BT_HIDDEN
enum bt_component_status writer_component_init(
- struct bt_private_component *component, struct bt_value *params,
+ struct bt_self_component *component, struct bt_value *params,
UNUSED_VAR void *init_method_data)
{
enum bt_component_status ret;
goto end;
}
- ret = bt_private_component_sink_add_input_port(component,
+ ret = bt_self_component_sink_add_input_port(component,
"in", NULL, NULL);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
goto end;
}
- ret = bt_private_component_set_user_data(component, writer_component);
+ ret = bt_self_component_set_user_data(component, writer_component);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
BT_HIDDEN
enum bt_component_status writer_component_init(
- struct bt_private_component *component, struct bt_value *params,
+ struct bt_self_component *component, struct bt_value *params,
void *init_method_data);
BT_HIDDEN
-enum bt_component_status writer_run(struct bt_private_component *component);
+enum bt_component_status writer_run(struct bt_self_component *component);
BT_HIDDEN
void writer_component_port_connected(
- struct bt_private_component *component,
+ struct bt_self_component *component,
struct bt_private_port *self_port,
struct bt_port *other_port);
BT_HIDDEN
-void writer_component_finalize(struct bt_private_component *component);
+void writer_component_finalize(struct bt_self_component *component);
#endif /* BABELTRACE_PLUGIN_WRITER_H */
uint64_t cycles, int64_t *ns)
{
return bt_clock_class_cycles_to_ns_from_origin(
- bt_clock_class_borrow_from_private(clock_class), cycles, ns);
+ bt_private_clock_class_borrow_clock_class(clock_class), cycles, ns);
}
static
BT_HIDDEN
struct ctf_fs_ds_file *ctf_fs_ds_file_create(
struct ctf_fs_trace *ctf_fs_trace,
- struct bt_private_connection_private_notification_iterator *pc_notif_iter,
+ struct bt_self_notification_iterator *pc_notif_iter,
struct bt_notif_iter *notif_iter,
struct bt_private_stream *stream, const char *path)
{
struct ctf_fs_metadata *metadata;
/* Weak */
- struct bt_private_connection_private_notification_iterator *pc_notif_iter;
+ struct bt_self_notification_iterator *pc_notif_iter;
/* Owned by this */
struct ctf_fs_file *file;
BT_HIDDEN
struct ctf_fs_ds_file *ctf_fs_ds_file_create(
struct ctf_fs_trace *ctf_fs_trace,
- struct bt_private_connection_private_notification_iterator *pc_notif_iter,
+ struct bt_self_notification_iterator *pc_notif_iter,
struct bt_notif_iter *notif_iter,
struct bt_private_stream *stream, const char *path);
}
static
-enum bt_notification_iterator_status ctf_fs_iterator_next_one(
+enum bt_self_notification_iterator_status ctf_fs_iterator_next_one(
struct ctf_fs_notif_iter_data *notif_iter_data,
struct bt_notification **notif)
{
- enum bt_notification_iterator_status status;
+ enum bt_self_notification_iterator_status status;
struct bt_private_notification *priv_notif;
int ret;
BT_ASSERT(notif_iter_data->ds_file);
status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif);
- *notif = bt_notification_borrow_from_private(priv_notif);
+ *notif = bt_private_notification_borrow_notification(priv_notif);
- if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK &&
+ if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK &&
bt_notification_get_type(*notif) ==
BT_NOTIFICATION_TYPE_STREAM_BEGIN) {
if (notif_iter_data->skip_stream_begin_notifs) {
BT_OBJECT_PUT_REF_AND_RESET(*notif);
status = ctf_fs_ds_file_next(notif_iter_data->ds_file,
&priv_notif);
- *notif = bt_notification_borrow_from_private(priv_notif);
- BT_ASSERT(status != BT_NOTIFICATION_ITERATOR_STATUS_END);
+ *notif = bt_private_notification_borrow_notification(priv_notif);
+ BT_ASSERT(status != BT_SELF_NOTIFICATION_ITERATOR_STATUS_END);
goto end;
} else {
/*
}
}
- if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK &&
+ if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK &&
bt_notification_get_type(*notif) ==
BT_NOTIFICATION_TYPE_STREAM_END) {
notif_iter_data->ds_file_info_index++;
* The next time ctf_fs_iterator_next() is
* called for this notification iterator,
* ctf_fs_ds_file_next() will return
- * BT_NOTIFICATION_ITERATOR_STATUS_END().
+ * BT_SELF_NOTIFICATION_ITERATOR_STATUS_END().
*/
goto end;
}
*/
ret = notif_iter_data_set_current_ds_file(notif_iter_data);
if (ret) {
- status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
goto end;
}
status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif);
- *notif = bt_notification_borrow_from_private(priv_notif);
+ *notif = bt_private_notification_borrow_notification(priv_notif);
/*
* If we get a notification, we expect to get a
*/
BT_ASSERT(notif_iter_data->skip_stream_begin_notifs);
- if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) {
BT_ASSERT(bt_notification_get_type(*notif) ==
BT_NOTIFICATION_TYPE_STREAM_BEGIN);
BT_OBJECT_PUT_REF_AND_RESET(*notif);
status = ctf_fs_ds_file_next(notif_iter_data->ds_file,
&priv_notif);
- *notif = bt_notification_borrow_from_private(priv_notif);
- BT_ASSERT(status != BT_NOTIFICATION_ITERATOR_STATUS_END);
+ *notif = bt_private_notification_borrow_notification(priv_notif);
+ BT_ASSERT(status != BT_SELF_NOTIFICATION_ITERATOR_STATUS_END);
}
}
}
BT_HIDDEN
-enum bt_notification_iterator_status ctf_fs_iterator_next(
- struct bt_private_connection_private_notification_iterator *iterator,
+enum bt_self_notification_iterator_status ctf_fs_iterator_next(
+ struct bt_self_notification_iterator *iterator,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count)
{
- enum bt_notification_iterator_status status =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ enum bt_self_notification_iterator_status status =
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
struct ctf_fs_notif_iter_data *notif_iter_data =
- bt_private_connection_private_notification_iterator_get_user_data(iterator);
+ bt_self_notification_iterator_get_data(iterator);
uint64_t i = 0;
- while (i < capacity && status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ while (i < capacity && status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) {
status = ctf_fs_iterator_next_one(notif_iter_data, ¬ifs[i]);
- if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) {
i++;
}
}
if (i > 0) {
/*
* Even if ctf_fs_iterator_next_one() returned something
- * else than BT_NOTIFICATION_ITERATOR_STATUS_OK, we
+ * else than BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK, we
* accumulated notification objects in the output
* notification array, so we need to return
- * BT_NOTIFICATION_ITERATOR_STATUS_OK so that they are
+ * BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK so that they are
* transfered to downstream. This other status occurs
* again the next time muxer_notif_iter_do_next() is
* called, possibly without any accumulated
* notification, in which case we'll return it.
*/
*count = i;
- status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
}
return status;
}
-void ctf_fs_iterator_finalize(struct bt_private_connection_private_notification_iterator *it)
+void ctf_fs_iterator_finalize(struct bt_self_notification_iterator *it)
{
- void *notif_iter_data =
- bt_private_connection_private_notification_iterator_get_user_data(it);
-
- ctf_fs_notif_iter_data_destroy(notif_iter_data);
+ ctf_fs_notif_iter_data_destroy(
+ bt_self_notification_iterator_get_data(it));
}
-enum bt_notification_iterator_status ctf_fs_iterator_init(
- struct bt_private_connection_private_notification_iterator *it,
- struct bt_private_port *port)
+enum bt_self_notification_iterator_status ctf_fs_iterator_init(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_port)
{
struct ctf_fs_port_data *port_data;
struct ctf_fs_notif_iter_data *notif_iter_data = NULL;
- enum bt_notification_iterator_status ret =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ enum bt_self_notification_iterator_status ret =
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
int iret;
- port_data = bt_private_port_get_user_data(port);
- if (!port_data) {
- ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID;
- goto error;
- }
-
+ port_data = bt_self_component_port_get_data(
+ bt_self_component_port_output_borrow_self_component_port(
+ self_port));
+ BT_ASSERT(port_data);
notif_iter_data = g_new0(struct ctf_fs_notif_iter_data, 1);
if (!notif_iter_data) {
- ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+ ret = BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM;
goto error;
}
- notif_iter_data->pc_notif_iter = it;
+ notif_iter_data->pc_notif_iter = self_notif_iter;
notif_iter_data->notif_iter = bt_notif_iter_create(
port_data->ds_file_group->ctf_fs_trace->metadata->tc,
bt_common_get_page_size() * 8,
ctf_fs_ds_file_medops, NULL);
if (!notif_iter_data->notif_iter) {
BT_LOGE_STR("Cannot create a CTF notification iterator.");
- ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+ ret = BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM;
goto error;
}
notif_iter_data->ds_file_group = port_data->ds_file_group;
iret = notif_iter_data_set_current_ds_file(notif_iter_data);
if (iret) {
- ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ ret = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
goto error;
}
- ret = bt_private_connection_private_notification_iterator_set_user_data(it, notif_iter_data);
- if (ret != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ bt_self_notification_iterator_set_data(self_notif_iter,
+ notif_iter_data);
+ if (ret != BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) {
goto error;
}
goto end;
error:
- (void) bt_private_connection_private_notification_iterator_set_user_data(it, NULL);
+ bt_self_notification_iterator_set_data(self_notif_iter, NULL);
end:
ctf_fs_notif_iter_data_destroy(notif_iter_data);
ctf_fs_trace_destroy(trace);
}
-void ctf_fs_finalize(struct bt_private_component *component)
+void ctf_fs_finalize(struct bt_self_component_source *component)
{
- void *data = bt_private_component_get_user_data(component);
-
- ctf_fs_destroy(data);
+ ctf_fs_destroy(bt_self_component_get_data(
+ bt_self_component_source_borrow_self_component(component)));
}
static
port_data->ctf_fs = ctf_fs;
port_data->ds_file_group = ds_file_group;
- ret = bt_private_component_source_add_output_port(
- ctf_fs->priv_comp, port_name->str, port_data, NULL);
+ ret = bt_self_component_source_add_output_port(
+ ctf_fs->self_comp, port_name->str, port_data, NULL);
if (ret) {
goto error;
}
if (props.snapshots.beginning_clock != UINT64_C(-1)) {
BT_ASSERT(sc->default_clock_class);
ret = bt_clock_class_cycles_to_ns_from_origin(
- bt_clock_class_borrow_from_private(
+ bt_private_clock_class_borrow_clock_class(
sc->default_clock_class),
props.snapshots.beginning_clock, &begin_ns);
if (ret) {
}
static
-struct ctf_fs_component *ctf_fs_create(struct bt_private_component *priv_comp,
+struct ctf_fs_component *ctf_fs_create(
+ struct bt_self_component_source *self_comp,
struct bt_value *params)
{
struct ctf_fs_component *ctf_fs;
struct bt_value *value = NULL;
const char *path_param;
- enum bt_component_status ret;
ctf_fs = g_new0(struct ctf_fs_component, 1);
if (!ctf_fs) {
goto end;
}
- ret = bt_private_component_set_user_data(priv_comp, ctf_fs);
- BT_ASSERT(ret == BT_COMPONENT_STATUS_OK);
+ bt_self_component_set_data(
+ bt_self_component_source_borrow_self_component(self_comp),
+ ctf_fs);
/*
* We don't need to get a new reference here because as long as
* our private ctf_fs_component object exists, the containing
* private component should also exist.
*/
- ctf_fs->priv_comp = priv_comp;
+ ctf_fs->self_comp = self_comp;
value = bt_value_map_borrow_entry_value(params, "path");
if (value && !bt_value_is_string(value)) {
goto error;
error:
ctf_fs_destroy(ctf_fs);
ctf_fs = NULL;
- ret = bt_private_component_set_user_data(priv_comp, NULL);
- BT_ASSERT(ret == BT_COMPONENT_STATUS_OK);
+ bt_self_component_set_data(
+ bt_self_component_source_borrow_self_component(self_comp),
+ NULL);
end:
return ctf_fs;
}
BT_HIDDEN
-enum bt_component_status ctf_fs_init(struct bt_private_component *priv_comp,
+enum bt_self_component_status ctf_fs_init(
+ struct bt_self_component_source *self_comp,
struct bt_value *params, UNUSED_VAR void *init_method_data)
{
struct ctf_fs_component *ctf_fs;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
- ctf_fs = ctf_fs_create(priv_comp, params);
+ ctf_fs = ctf_fs_create(self_comp, params);
if (!ctf_fs) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
}
return ret;
}
BT_HIDDEN
-struct bt_component_class_query_method_return ctf_fs_query(
- struct bt_component_class *comp_class,
+enum bt_query_status ctf_fs_query(
+ struct bt_self_component_class_source *comp_class,
struct bt_query_executor *query_exec,
- const char *object, struct bt_value *params)
+ const char *object, struct bt_value *params,
+ struct bt_value **result)
{
- struct bt_component_class_query_method_return ret = {
- .result = NULL,
- .status = BT_QUERY_STATUS_OK,
- };
+ enum bt_query_status status = BT_QUERY_STATUS_OK;
if (!strcmp(object, "metadata-info")) {
- ret = metadata_info_query(comp_class, params);
+ status = metadata_info_query(comp_class, params, result);
} else if (!strcmp(object, "trace-info")) {
- ret = trace_info_query(comp_class, params);
+ status = trace_info_query(comp_class, params, result);
} else {
BT_LOGE("Unknown query object `%s`", object);
- ret.status = BT_QUERY_STATUS_INVALID_OBJECT;
+ status = BT_QUERY_STATUS_INVALID_OBJECT;
goto end;
}
end:
- return ret;
+ return status;
}
struct ctf_fs_component {
/* Weak, guaranteed to exist */
- struct bt_private_component *priv_comp;
+ struct bt_self_component_source *self_comp;
/* Array of struct ctf_fs_port_data *, owned by this */
GPtrArray *port_data;
struct ctf_fs_notif_iter_data {
/* Weak */
- struct bt_private_connection_private_notification_iterator *pc_notif_iter;
+ struct bt_self_notification_iterator *pc_notif_iter;
/* Weak, belongs to ctf_fs_trace */
struct ctf_fs_ds_file_group *ds_file_group;
};
BT_HIDDEN
-enum bt_component_status ctf_fs_init(struct bt_private_component *source,
+enum bt_self_component_status ctf_fs_init(
+ struct bt_self_component_source *source,
struct bt_value *params, void *init_method_data);
BT_HIDDEN
-void ctf_fs_finalize(struct bt_private_component *component);
+void ctf_fs_finalize(struct bt_self_component_source *component);
BT_HIDDEN
-struct bt_component_class_query_method_return ctf_fs_query(
- struct bt_component_class *comp_class,
+enum bt_query_status ctf_fs_query(
+ struct bt_self_component_class_source *comp_class,
struct bt_query_executor *query_exec,
- const char *object, struct bt_value *params);
+ const char *object, struct bt_value *params,
+ struct bt_value **result);
BT_HIDDEN
struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *name,
GList *ctf_fs_create_trace_names(GList *trace_paths, const char *base_path);
BT_HIDDEN
-enum bt_notification_iterator_status ctf_fs_iterator_init(
- struct bt_private_connection_private_notification_iterator *it,
- struct bt_private_port *port);
+enum bt_self_notification_iterator_status ctf_fs_iterator_init(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_port);
+
BT_HIDDEN
-void ctf_fs_iterator_finalize(struct bt_private_connection_private_notification_iterator *it);
+void ctf_fs_iterator_finalize(struct bt_self_notification_iterator *it);
BT_HIDDEN
-enum bt_notification_iterator_status ctf_fs_iterator_next(
- struct bt_private_connection_private_notification_iterator *iterator,
+enum bt_self_notification_iterator_status ctf_fs_iterator_next(
+ struct bt_self_notification_iterator *iterator,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count);
};
BT_HIDDEN
-struct bt_component_class_query_method_return metadata_info_query(
- struct bt_component_class *comp_class,
- struct bt_value *params)
+enum bt_query_status metadata_info_query(
+ struct bt_self_component_class_source *comp_class,
+ struct bt_value *params, struct bt_value **user_result)
{
- struct bt_component_class_query_method_return query_ret = {
- .result = NULL,
- .status = BT_QUERY_STATUS_OK,
- };
-
+ enum bt_query_status status = BT_QUERY_STATUS_OK;
struct bt_private_value *result = NULL;
struct bt_value *path_value = NULL;
char *metadata_text = NULL;
result = bt_private_value_map_create();
if (!result) {
- query_ret.status = BT_QUERY_STATUS_NOMEM;
+ status = BT_QUERY_STATUS_NOMEM;
goto error;
}
- query_ret.result = bt_value_borrow_from_private(result);
BT_ASSERT(params);
if (!bt_value_is_map(params)) {
BT_LOGE_STR("Query parameters is not a map value object.");
- query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
+ status = BT_QUERY_STATUS_INVALID_PARAMS;
goto error;
}
error:
BT_OBJECT_PUT_REF_AND_RESET(result);
- query_ret.result = NULL;
+ result = NULL;
- if (query_ret.status >= 0) {
- query_ret.status = BT_QUERY_STATUS_ERROR;
+ if (status >= 0) {
+ status = BT_QUERY_STATUS_ERROR;
}
end:
fclose(metadata_fp);
}
- return query_ret;
+ *user_result = bt_private_value_borrow_value(result);
+ return status;
}
static
}
status = bt_private_value_map_insert_entry(info, range_name,
- bt_value_borrow_from_private(range_map));
+ bt_private_value_borrow_value(range_map));
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
status = bt_private_value_map_insert_entry(group_info, "paths",
- bt_value_borrow_from_private(file_paths));
+ bt_private_value_borrow_value(file_paths));
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
ret = add_stream_ids(group_info,
- bt_stream_borrow_from_private(group->stream));
+ bt_private_stream_borrow_stream(group->stream));
if (ret) {
goto end;
}
trace_intersection.set = true;
status = bt_private_value_array_append_element(
file_groups,
- bt_value_borrow_from_private(group_info));
+ bt_private_value_borrow_value(group_info));
bt_object_put_ref(group_info);
if (status != BT_VALUE_STATUS_OK) {
goto end;
}
status = bt_private_value_map_insert_entry(trace_info, "streams",
- bt_value_borrow_from_private(file_groups));
+ bt_private_value_borrow_value(file_groups));
BT_OBJECT_PUT_REF_AND_RESET(file_groups);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
}
BT_HIDDEN
-struct bt_component_class_query_method_return trace_info_query(
- struct bt_component_class *comp_class,
- struct bt_value *params)
+enum bt_query_status trace_info_query(
+ struct bt_self_component_class_source *comp_class,
+ struct bt_value *params, struct bt_value **user_result)
{
- struct bt_component_class_query_method_return query_ret = {
- .result = NULL,
- .status = BT_QUERY_STATUS_OK,
- };
-
+ enum bt_query_status status = BT_QUERY_STATUS_OK;
struct bt_private_value *result = NULL;
struct bt_value *path_value = NULL;
int ret = 0;
if (!bt_value_is_map(params)) {
BT_LOGE("Query parameters is not a map value object.");
- query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
+ status = BT_QUERY_STATUS_INVALID_PARAMS;
goto error;
}
result = bt_private_value_array_create();
if (!result) {
- query_ret.status = BT_QUERY_STATUS_NOMEM;
+ status = BT_QUERY_STATUS_NOMEM;
goto error;
}
- query_ret.result = bt_value_borrow_from_private(result);
-
/* Iterates over both trace paths and names simultaneously. */
for (tp_node = trace_paths, tn_node = trace_names; tp_node;
tp_node = g_list_next(tp_node),
}
status = bt_private_value_array_append_element(result,
- bt_value_borrow_from_private(trace_info));
+ bt_private_value_borrow_value(trace_info));
bt_object_put_ref(trace_info);
if (status != BT_VALUE_STATUS_OK) {
goto error;
error:
BT_OBJECT_PUT_REF_AND_RESET(result);
- query_ret.result = NULL;
+ result = NULL;
- if (query_ret.status >= 0) {
- query_ret.status = BT_QUERY_STATUS_ERROR;
+ if (status >= 0) {
+ status = BT_QUERY_STATUS_ERROR;
}
end:
}
g_list_free(trace_names);
}
- /* "path" becomes invalid with the release of path_value. */
- return query_ret;
+
+ *user_result = bt_private_value_borrow_value(result);
+ return status;
}
#include <babeltrace/babeltrace.h>
BT_HIDDEN
-struct bt_component_class_query_method_return metadata_info_query(
- struct bt_component_class *comp_class,
- struct bt_value *params);
+enum bt_query_status metadata_info_query(
+ struct bt_self_component_class_source *comp_class,
+ struct bt_value *params, struct bt_value **result);
BT_HIDDEN
-struct bt_component_class_query_method_return trace_info_query(
- struct bt_component_class *comp_class,
- struct bt_value *params);
+enum bt_query_status trace_info_query(
+ struct bt_self_component_class_source *comp_class,
+ struct bt_value *params, struct bt_value **result);
#endif /* BABELTRACE_PLUGIN_CTF_FS_QUERY_H */
*/
struct lttng_live_component {
struct bt_object obj;
- struct bt_private_component *private_component; /* weak */
+ struct bt_self_component *private_component; /* weak */
struct bt_live_viewer_connection *viewer_connection;
/* List of struct lttng_live_session */
BT_LTTNG_LIVE_ITERATOR_STATUS_UNSUPPORTED = -4,
};
-enum bt_component_status lttng_live_component_init(struct bt_private_component *source,
+enum bt_component_status lttng_live_component_init(struct bt_self_component *source,
struct bt_value *params, void *init_method_data);
struct bt_component_class_query_method_return lttng_live_query(
struct bt_query_executor *query_exec,
const char *object, struct bt_value *params);
-void lttng_live_component_finalize(struct bt_private_component *component);
+void lttng_live_component_finalize(struct bt_self_component *component);
struct bt_notification_iterator_next_method_return lttng_live_iterator_next(
- struct bt_private_connection_private_notification_iterator *iterator);
+ struct bt_self_notification_iterator *iterator);
enum bt_component_status lttng_live_accept_port_connection(
- struct bt_private_component *private_component,
+ struct bt_self_component *private_component,
struct bt_private_port *self_private_port,
struct bt_port *other_port);
enum bt_notification_iterator_status lttng_live_iterator_init(
- struct bt_private_connection_private_notification_iterator *it,
+ struct bt_self_notification_iterator *it,
struct bt_private_port *port);
-void lttng_live_iterator_finalize(struct bt_private_connection_private_notification_iterator *it);
+void lttng_live_iterator_finalize(struct bt_self_notification_iterator *it);
int lttng_live_create_viewer_session(struct lttng_live_component *lttng_live);
int lttng_live_attach_session(struct lttng_live_session *session);
if (lttng_live_is_canceled(lttng_live)) {
return 0;
}
- status = bt_private_component_source_add_output_port(
+ status = bt_self_component_source_add_output_port(
lttng_live->private_component, name, stream_iter,
&private_port);
switch (status) {
if (lttng_live_is_canceled(lttng_live)) {
return 0;
}
- status = bt_private_component_source_add_output_port(lttng_live->private_component,
+ status = bt_self_component_source_add_output_port(lttng_live->private_component,
"no-stream", lttng_live->no_stream_iter,
<tng_live->no_stream_port);
switch (status) {
}
BT_HIDDEN
-void lttng_live_iterator_finalize(struct bt_private_connection_private_notification_iterator *it)
+void lttng_live_iterator_finalize(struct bt_self_notification_iterator *it)
{
struct lttng_live_stream_iterator_generic *s =
- bt_private_connection_private_notification_iterator_get_user_data(it);
+ bt_self_notification_iterator_get_user_data(it);
switch (s->type) {
case LIVE_STREAM_TYPE_NO_STREAM:
*/
static
struct bt_notification_iterator_next_method_return lttng_live_iterator_next_stream(
- struct bt_private_connection_private_notification_iterator *iterator,
+ struct bt_self_notification_iterator *iterator,
struct lttng_live_stream_iterator *stream_iter)
{
enum bt_lttng_live_iterator_status status;
static
struct bt_notification_iterator_next_method_return lttng_live_iterator_next_no_stream(
- struct bt_private_connection_private_notification_iterator *iterator,
+ struct bt_self_notification_iterator *iterator,
struct lttng_live_no_stream_iterator *no_stream_iter)
{
enum bt_lttng_live_iterator_status status;
BT_HIDDEN
struct bt_notification_iterator_next_method_return lttng_live_iterator_next(
- struct bt_private_connection_private_notification_iterator *iterator)
+ struct bt_self_notification_iterator *iterator)
{
struct lttng_live_stream_iterator_generic *s =
- bt_private_connection_private_notification_iterator_get_user_data(iterator);
+ bt_self_notification_iterator_get_user_data(iterator);
struct bt_notification_iterator_next_method_return next_return;
switch (s->type) {
BT_HIDDEN
enum bt_notification_iterator_status lttng_live_iterator_init(
- struct bt_private_connection_private_notification_iterator *it,
+ struct bt_self_notification_iterator *it,
struct bt_private_port *port)
{
enum bt_notification_iterator_status ret =
{
struct lttng_live_no_stream_iterator *no_stream_iter =
container_of(s, struct lttng_live_no_stream_iterator, p);
- ret = bt_private_connection_private_notification_iterator_set_user_data(it, no_stream_iter);
+ ret = bt_self_notification_iterator_set_user_data(it, no_stream_iter);
if (ret) {
goto error;
}
{
struct lttng_live_stream_iterator *stream_iter =
container_of(s, struct lttng_live_stream_iterator, p);
- ret = bt_private_connection_private_notification_iterator_set_user_data(it, stream_iter);
+ ret = bt_self_notification_iterator_set_user_data(it, stream_iter);
if (ret) {
goto error;
}
end:
return ret;
error:
- if (bt_private_connection_private_notification_iterator_set_user_data(it, NULL)
+ if (bt_self_notification_iterator_set_user_data(it, NULL)
!= BT_NOTIFICATION_ITERATOR_STATUS_OK) {
BT_LOGE("Error setting private data to NULL");
}
}
BT_HIDDEN
-void lttng_live_component_finalize(struct bt_private_component *component)
+void lttng_live_component_finalize(struct bt_self_component *component)
{
- void *data = bt_private_component_get_user_data(component);
+ void *data = bt_self_component_get_user_data(component);
if (!data) {
return;
static
struct lttng_live_component *lttng_live_component_create(struct bt_value *params,
- struct bt_private_component *private_component)
+ struct bt_self_component *private_component)
{
struct lttng_live_component *lttng_live;
struct bt_value *value = NULL;
BT_HIDDEN
enum bt_component_status lttng_live_component_init(
- struct bt_private_component *private_component,
+ struct bt_self_component *private_component,
struct bt_value *params, void *init_method_data)
{
struct lttng_live_component *lttng_live;
if (lttng_live_is_canceled(lttng_live)) {
goto end;
}
- ret = bt_private_component_source_add_output_port(
+ ret = bt_self_component_source_add_output_port(
lttng_live->private_component, "no-stream",
lttng_live->no_stream_iter,
<tng_live->no_stream_port);
bt_object_put_ref(lttng_live->no_stream_port); /* weak */
lttng_live->no_stream_iter->port = lttng_live->no_stream_port;
- ret = bt_private_component_set_user_data(private_component, lttng_live);
+ ret = bt_self_component_set_user_data(private_component, lttng_live);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
end:
return ret;
error:
- (void) bt_private_component_set_user_data(private_component, NULL);
+ (void) bt_self_component_set_user_data(private_component, NULL);
lttng_live_component_destroy_data(lttng_live);
return ret;
}
BT_HIDDEN
enum bt_component_status lttng_live_accept_port_connection(
- struct bt_private_component *private_component,
+ struct bt_self_component *private_component,
struct bt_private_port *self_private_port,
struct bt_port *other_port)
{
struct lttng_live_component *lttng_live =
- bt_private_component_get_user_data(private_component);
+ bt_self_component_get_user_data(private_component);
struct bt_component *other_component;
enum bt_component_status status = BT_COMPONENT_STATUS_OK;
struct bt_port *self_port = bt_port_from_private(self_private_port);
#include <babeltrace/babeltrace.h>
#include "fs-src/fs.h"
-#include "fs-sink/writer.h"
-#include "lttng-live/lttng-live-internal.h"
#ifndef BT_BUILT_IN_PLUGINS
BT_PLUGIN_MODULE();
}
static
-void destroy_debug_info_component(struct bt_private_component *component)
+void destroy_debug_info_component(struct bt_self_component *component)
{
- void *data = bt_private_component_get_user_data(component);
+ void *data = bt_self_component_get_user_data(component);
destroy_debug_info_data(data);
}
}
static
-void debug_info_iterator_destroy(struct bt_private_connection_private_notification_iterator *it)
+void debug_info_iterator_destroy(struct bt_self_notification_iterator *it)
{
struct debug_info_iterator *it_data;
- it_data = bt_private_connection_private_notification_iterator_get_user_data(it);
+ it_data = bt_self_notification_iterator_get_user_data(it);
BT_ASSERT(it_data);
if (it_data->input_iterator_group) {
static
struct bt_notification_iterator_next_method_return debug_info_iterator_next(
- struct bt_private_connection_private_notification_iterator *iterator)
+ struct bt_self_notification_iterator *iterator)
{
struct debug_info_iterator *debug_it = NULL;
- struct bt_private_component *component = NULL;
+ struct bt_self_component *component = NULL;
struct debug_info_component *debug_info = NULL;
struct bt_notification_iterator *source_it = NULL;
struct bt_notification *notification;
.notification = NULL,
};
- debug_it = bt_private_connection_private_notification_iterator_get_user_data(iterator);
+ debug_it = bt_self_notification_iterator_get_user_data(iterator);
BT_ASSERT(debug_it);
- component = bt_private_connection_private_notification_iterator_get_private_component(iterator);
+ component = bt_self_notification_iterator_get_private_component(iterator);
BT_ASSERT(component);
- debug_info = bt_private_component_get_user_data(component);
+ debug_info = bt_self_component_get_user_data(component);
BT_ASSERT(debug_info);
source_it = debug_it->input_iterator;
static
enum bt_notification_iterator_status debug_info_iterator_init(
- struct bt_private_connection_private_notification_iterator *iterator,
+ struct bt_self_notification_iterator *iterator,
struct bt_private_port *port)
{
enum bt_notification_iterator_status ret =
enum bt_notification_iterator_status it_ret;
enum bt_connection_status conn_status;
struct bt_private_connection *connection = NULL;
- struct bt_private_component *component =
- bt_private_connection_private_notification_iterator_get_private_component(iterator);
+ struct bt_self_component *component =
+ bt_self_notification_iterator_get_private_component(iterator);
struct debug_info_iterator *it_data = g_new0(struct debug_info_iterator, 1);
struct bt_private_port *input_port;
goto end;
}
- input_port = bt_private_component_filter_get_input_port_by_name(
+ input_port = bt_self_component_filter_get_input_port_by_name(
component, "in");
if (!input_port) {
ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
}
it_data->debug_info_component = (struct debug_info_component *)
- bt_private_component_get_user_data(component);
+ bt_self_component_get_user_data(component);
it_data->err = it_data->debug_info_component->err;
it_data->trace_map = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL, (GDestroyNotify) unref_trace);
- it_ret = bt_private_connection_private_notification_iterator_set_user_data(iterator, it_data);
+ it_ret = bt_self_notification_iterator_set_user_data(iterator, it_data);
if (it_ret) {
goto end;
}
}
enum bt_component_status debug_info_component_init(
- struct bt_private_component *component, struct bt_value *params,
+ struct bt_self_component *component, struct bt_value *params,
UNUSED_VAR void *init_method_data)
{
enum bt_component_status ret;
goto end;
}
- ret = bt_private_component_set_user_data(component, debug_info);
+ ret = bt_self_component_set_user_data(component, debug_info);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
- ret = bt_private_component_filter_add_input_port(
+ ret = bt_self_component_filter_add_input_port(
component, "in", NULL, NULL);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
- ret = bt_private_component_filter_add_output_port(
+ ret = bt_self_component_filter_add_output_port(
component, "out", NULL, NULL);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
/*
* Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
- * Copyright 2017 Philippe Proulx <jeremie.galarneau@efficios.com>
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
struct dmesg_notif_iter {
struct dmesg_component *dmesg_comp;
- struct bt_private_connection_private_notification_iterator *pc_notif_iter; /* Weak */
+ struct bt_self_notification_iterator *pc_notif_iter; /* Weak */
char *linebuf;
size_t linebuf_len;
FILE *fp;
ret = bt_private_stream_class_set_default_clock_class(
dmesg_comp->stream_class,
- bt_clock_class_borrow_from_private(
+ bt_private_clock_class_borrow_clock_class(
dmesg_comp->clock_class));
if (ret) {
BT_LOGE_STR("Cannot set stream class's default clock class.");
}
static
-enum bt_component_status create_port(struct bt_private_component *priv_comp)
+enum bt_self_component_status create_port(
+ struct bt_self_component_source *self_comp)
{
- return bt_private_component_source_add_output_port(priv_comp,
+ return bt_self_component_source_add_output_port(self_comp,
"out", NULL, NULL);
}
BT_HIDDEN
-enum bt_component_status dmesg_init(struct bt_private_component *priv_comp,
+enum bt_self_component_status dmesg_init(
+ struct bt_self_component_source *self_comp,
struct bt_value *params, void *init_method_data)
{
int ret = 0;
struct dmesg_component *dmesg_comp = g_new0(struct dmesg_component, 1);
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
if (!dmesg_comp) {
BT_LOGE_STR("Failed to allocate one dmesg component structure.");
ret = handle_params(dmesg_comp, params);
if (ret) {
- BT_LOGE("Invalid parameters: comp-addr=%p", priv_comp);
+ BT_LOGE("Invalid parameters: comp-addr=%p", self_comp);
goto error;
}
!g_file_test(dmesg_comp->params.path->str,
G_FILE_TEST_IS_REGULAR)) {
BT_LOGE("Input path is not a regular file: "
- "comp-addr=%p, path=\"%s\"", priv_comp,
+ "comp-addr=%p, path=\"%s\"", self_comp,
dmesg_comp->params.path->str);
goto error;
}
- status = create_port(priv_comp);
- if (status != BT_COMPONENT_STATUS_OK) {
+ status = create_port(self_comp);
+ if (status != BT_SELF_COMPONENT_STATUS_OK) {
goto error;
}
- (void) bt_private_component_set_user_data(priv_comp, dmesg_comp);
+ bt_self_component_set_data(
+ bt_self_component_source_borrow_self_component(self_comp),
+ dmesg_comp);
goto end;
error:
destroy_dmesg_component(dmesg_comp);
- (void) bt_private_component_set_user_data(priv_comp, NULL);
+ bt_self_component_set_data(
+ bt_self_component_source_borrow_self_component(self_comp),
+ NULL);
if (status >= 0) {
- status = BT_COMPONENT_STATUS_ERROR;
+ status = BT_SELF_COMPONENT_STATUS_ERROR;
}
end:
}
BT_HIDDEN
-void dmesg_finalize(struct bt_private_component *priv_comp)
+void dmesg_finalize(struct bt_self_component_source *self_comp)
{
- void *data = bt_private_component_get_user_data(priv_comp);
-
- destroy_dmesg_component(data);
+ destroy_dmesg_component(bt_self_component_get_data(
+ bt_self_component_source_borrow_self_component(self_comp)));
}
static
}
BT_HIDDEN
-enum bt_notification_iterator_status dmesg_notif_iter_init(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
- struct bt_private_port *priv_port)
+enum bt_self_notification_iterator_status dmesg_notif_iter_init(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_port)
{
- struct bt_private_component *priv_comp = NULL;
struct dmesg_component *dmesg_comp;
struct dmesg_notif_iter *dmesg_notif_iter =
g_new0(struct dmesg_notif_iter, 1);
- enum bt_notification_iterator_status status =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ enum bt_self_notification_iterator_status status =
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
if (!dmesg_notif_iter) {
BT_LOGE_STR("Failed to allocate on dmesg notification iterator structure.");
goto error;
}
- priv_comp = bt_private_connection_private_notification_iterator_get_private_component(
- priv_notif_iter);
- BT_ASSERT(priv_comp);
- dmesg_comp = bt_private_component_get_user_data(priv_comp);
+ dmesg_comp = bt_self_component_get_data(
+ bt_self_component_source_borrow_self_component(self_comp));
BT_ASSERT(dmesg_comp);
dmesg_notif_iter->dmesg_comp = dmesg_comp;
- dmesg_notif_iter->pc_notif_iter = priv_notif_iter;
+ dmesg_notif_iter->pc_notif_iter = self_notif_iter;
if (dmesg_comp->params.read_from_stdin) {
dmesg_notif_iter->fp = stdin;
}
}
- (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter,
+ bt_self_notification_iterator_set_data(self_notif_iter,
dmesg_notif_iter);
goto end;
error:
destroy_dmesg_notif_iter(dmesg_notif_iter);
- (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter,
- NULL);
+ bt_self_notification_iterator_set_data(self_notif_iter, NULL);
if (status >= 0) {
- status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
}
end:
- bt_object_put_ref(priv_comp);
return status;
}
BT_HIDDEN
void dmesg_notif_iter_finalize(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter)
+ struct bt_self_notification_iterator *priv_notif_iter)
{
- destroy_dmesg_notif_iter(bt_private_connection_private_notification_iterator_get_user_data(
+ destroy_dmesg_notif_iter(bt_self_notification_iterator_get_data(
priv_notif_iter));
}
static
-enum bt_notification_iterator_status dmesg_notif_iter_next_one(
+enum bt_self_notification_iterator_status dmesg_notif_iter_next_one(
struct dmesg_notif_iter *dmesg_notif_iter,
struct bt_private_notification **notif)
{
ssize_t len;
struct dmesg_component *dmesg_comp;
- enum bt_notification_iterator_status status =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ enum bt_self_notification_iterator_status status =
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
BT_ASSERT(dmesg_notif_iter);
dmesg_comp = dmesg_notif_iter->dmesg_comp;
BT_ASSERT(dmesg_comp);
if (dmesg_notif_iter->state == STATE_DONE) {
- status = BT_NOTIFICATION_ITERATOR_STATUS_END;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_END;
goto end;
}
&dmesg_notif_iter->linebuf_len, dmesg_notif_iter->fp);
if (len < 0) {
if (errno == EINVAL) {
- status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
} else if (errno == ENOMEM) {
status =
- BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM;
} else {
if (dmesg_notif_iter->state == STATE_EMIT_STREAM_BEGINNING) {
/* Stream did not even begin */
- status = BT_NOTIFICATION_ITERATOR_STATUS_END;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_END;
goto end;
} else {
/* End current packet now */
if (!*notif) {
BT_LOGE("Cannot create notification: dmesg-comp-addr=%p",
dmesg_comp);
- status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
}
end:
}
BT_HIDDEN
-enum bt_notification_iterator_status dmesg_notif_iter_next(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
+enum bt_self_notification_iterator_status dmesg_notif_iter_next(
+ struct bt_self_notification_iterator *self_notif_iter,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count)
{
struct dmesg_notif_iter *dmesg_notif_iter =
- bt_private_connection_private_notification_iterator_get_user_data(
- priv_notif_iter);
- enum bt_notification_iterator_status status =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ bt_self_notification_iterator_get_data(
+ self_notif_iter);
+ enum bt_self_notification_iterator_status status =
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
uint64_t i = 0;
- while (i < capacity && status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
- struct bt_private_notification *priv_notif;
+ while (i < capacity &&
+ status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) {
+ struct bt_private_notification *priv_notif = NULL;
status = dmesg_notif_iter_next_one(dmesg_notif_iter,
&priv_notif);
- notifs[i] = bt_notification_borrow_from_private(priv_notif);
- if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+ notifs[i] = bt_private_notification_borrow_notification(
+ priv_notif);
+ if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) {
i++;
}
}
/*
* Even if dmesg_notif_iter_next_one() returned
* something else than
- * BT_NOTIFICATION_ITERATOR_STATUS_OK, we accumulated
- * notification objects in the output notification
- * array, so we need to return
- * BT_NOTIFICATION_ITERATOR_STATUS_OK so that they are
- * transfered to downstream. This other status occurs
- * again the next time muxer_notif_iter_do_next() is
- * called, possibly without any accumulated
+ * BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK, we
+ * accumulated notification objects in the output
+ * notification array, so we need to return
+ * BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK so that they
+ * are transfered to downstream. This other status
+ * occurs again the next time muxer_notif_iter_do_next()
+ * is called, possibly without any accumulated
* notification, in which case we'll return it.
*/
*count = i;
- status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
}
return status;
#define BABELTRACE_PLUGIN_TEXT_DMESG_DMESG_H
/*
- * Copyright 2017 Philippe Proulx <jeremie.galarneau@efficios.com>
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#include <babeltrace/babeltrace.h>
BT_HIDDEN
-enum bt_component_status dmesg_init(struct bt_private_component *priv_comp,
+enum bt_self_component_status dmesg_init(
+ struct bt_self_component_source *self_comp,
struct bt_value *params, void *init_method_data);
BT_HIDDEN
-void dmesg_finalize(struct bt_private_component *priv_comp);
+void dmesg_finalize(struct bt_self_component_source *self_comp);
BT_HIDDEN
-enum bt_notification_iterator_status dmesg_notif_iter_init(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
- struct bt_private_port *priv_port);
+enum bt_self_notification_iterator_status dmesg_notif_iter_init(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_port);
BT_HIDDEN
void dmesg_notif_iter_finalize(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter);
+ struct bt_self_notification_iterator *self_notif_iter);
BT_HIDDEN
-enum bt_notification_iterator_status dmesg_notif_iter_next(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
+enum bt_self_notification_iterator_status dmesg_notif_iter_next(
+ struct bt_self_notification_iterator *self_notif_iter,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count);
BT_PLUGIN_SINK_COMPONENT_CLASS(pretty, pretty_consume);
BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(pretty, pretty_init);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(pretty, pretty_finalize);
-BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD(pretty,
+BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(pretty,
pretty_port_connected);
BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(pretty,
"Pretty-print notifications (`text` format of Babeltrace 1).");
/*
- * pretty.c
- *
- * Babeltrace CTF Text Output Plugin
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
static
void destroy_pretty_data(struct pretty_component *pretty)
{
- bt_object_put_ref(pretty->input_iterator);
+ bt_object_put_ref(pretty->iterator);
if (pretty->string) {
(void) g_string_free(pretty->string, TRUE);
}
BT_HIDDEN
-void pretty_finalize(struct bt_private_component *component)
+void pretty_finalize(struct bt_self_component_sink *comp)
{
- void *data = bt_private_component_get_user_data(component);
-
- destroy_pretty_data(data);
+ destroy_pretty_data(
+ bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp)));
}
static
-enum bt_component_status handle_notification(struct pretty_component *pretty,
+enum bt_self_component_status handle_notification(
+ struct pretty_component *pretty,
struct bt_notification *notification)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
BT_ASSERT(pretty);
switch (bt_notification_get_type(notification)) {
case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
- ret = pretty_print_packet(pretty, notification);
+ if (pretty_print_packet(pretty, notification)) {
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
+ }
break;
case BT_NOTIFICATION_TYPE_EVENT:
- ret = pretty_print_event(pretty, notification);
+ if (pretty_print_event(pretty, notification)) {
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
+ }
break;
case BT_NOTIFICATION_TYPE_INACTIVITY:
fprintf(stderr, "Inactivity notification\n");
}
BT_HIDDEN
-enum bt_component_status pretty_port_connected(
- struct bt_private_component *component,
- struct bt_private_port *self_port,
- struct bt_port *other_port)
+enum bt_self_component_status pretty_port_connected(
+ struct bt_self_component_sink *comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- enum bt_connection_status conn_status;
- struct bt_private_connection *connection;
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct pretty_component *pretty;
- pretty = bt_private_component_get_user_data(component);
+ pretty = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp));
BT_ASSERT(pretty);
- BT_ASSERT(!pretty->input_iterator);
- connection = bt_private_port_get_connection(self_port);
- BT_ASSERT(connection);
- conn_status = bt_private_connection_create_notification_iterator(
- connection, &pretty->input_iterator);
- if (conn_status != BT_CONNECTION_STATUS_OK) {
- status = BT_COMPONENT_STATUS_ERROR;
+ BT_ASSERT(!pretty->iterator);
+ pretty->iterator = bt_self_component_port_input_notification_iterator_create(
+ self_port);
+ if (!pretty->iterator) {
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
}
- bt_object_put_ref(connection);
return status;
}
BT_HIDDEN
-enum bt_component_status pretty_consume(struct bt_private_component *component)
+enum bt_self_component_status pretty_consume(
+ struct bt_self_component_sink *comp)
{
- enum bt_component_status ret;
+ enum bt_self_component_status ret;
bt_notification_array notifs;
- struct bt_notification_iterator *it;
- struct pretty_component *pretty =
- bt_private_component_get_user_data(component);
+ struct bt_self_component_port_input_notification_iterator *it;
+ struct pretty_component *pretty = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp));
enum bt_notification_iterator_status it_ret;
uint64_t count = 0;
uint64_t i = 0;
- it = pretty->input_iterator;
- it_ret = bt_private_connection_notification_iterator_next(it, ¬ifs,
- &count);
+ it = pretty->iterator;
+ it_ret = bt_self_component_port_input_notification_iterator_next(it,
+ ¬ifs, &count);
switch (it_ret) {
- case BT_NOTIFICATION_ITERATOR_STATUS_END:
- ret = BT_COMPONENT_STATUS_END;
- BT_OBJECT_PUT_REF_AND_RESET(pretty->input_iterator);
+ case BT_NOTIFICATION_ITERATOR_STATUS_OK:
+ break;
+ case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
+ ret = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
- ret = BT_COMPONENT_STATUS_AGAIN;
+ ret = BT_SELF_COMPONENT_STATUS_AGAIN;
+ goto end;
+ case BT_NOTIFICATION_ITERATOR_STATUS_END:
+ ret = BT_SELF_COMPONENT_STATUS_END;
+ BT_OBJECT_PUT_REF_AND_RESET(pretty->iterator);
goto end;
- case BT_NOTIFICATION_ITERATOR_STATUS_OK:
- break;
default:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
}
}
static
-enum bt_component_status add_params_to_map(
- struct bt_private_value *plugin_opt_map)
+int add_params_to_map(struct bt_private_value *plugin_opt_map)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
unsigned int i;
for (i = 0; i < BT_ARRAY_SIZE(plugin_options); i++) {
case BT_VALUE_STATUS_OK:
break;
default:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
}
struct pretty_component *pretty = data;
if (!bt_value_map_has_entry(
- bt_value_borrow_from_private(pretty->plugin_opt_map),
+ bt_private_value_borrow_value(pretty->plugin_opt_map),
key)) {
fprintf(pretty->err,
"[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
}
static
-enum bt_component_status apply_one_string(const char *key,
- struct bt_value *params,
- char **option)
+void apply_one_string(const char *key, struct bt_value *params, char **option)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_value *value = NULL;
const char *str;
*option = g_strdup(str);
end:
- return ret;
+ return;
}
static
-enum bt_component_status apply_one_bool(const char *key,
- struct bt_value *params,
- bool *option,
+void apply_one_bool(const char *key, struct bt_value *params, bool *option,
bool *found)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_value *value = NULL;
bt_bool bool_val;
}
end:
- return ret;
+ return;
}
static
}
static
-enum bt_component_status open_output_file(struct pretty_component *pretty)
+int open_output_file(struct pretty_component *pretty)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
if (!pretty->options.output_path) {
goto end;
goto end;
error:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
+
end:
return ret;
}
static
-enum bt_component_status apply_params(struct pretty_component *pretty,
- struct bt_value *params)
+int apply_params(struct pretty_component *pretty, struct bt_value *params)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
enum bt_value_status status;
bool value, found;
char *str = NULL;
pretty->plugin_opt_map = bt_private_value_map_create();
if (!pretty->plugin_opt_map) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
ret = add_params_to_map(pretty->plugin_opt_map);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret) {
goto end;
}
/* Report unknown parameters. */
case BT_VALUE_STATUS_OK:
break;
default:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
/* Known parameters. */
}
}
- ret = apply_one_string("path", params, &pretty->options.output_path);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_string("path", params, &pretty->options.output_path);
ret = open_output_file(pretty);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret) {
goto end;
}
value = false; /* Default. */
- ret = apply_one_bool("no-delta", params, &value, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("no-delta", params, &value, NULL);
pretty->options.print_delta_field = !value; /* Reverse logic. */
value = false; /* Default. */
- ret = apply_one_bool("clock-cycles", params, &value, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("clock-cycles", params, &value, NULL);
pretty->options.print_timestamp_cycles = value;
value = false; /* Default. */
- ret = apply_one_bool("clock-seconds", params, &value, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("clock-seconds", params, &value, NULL);
pretty->options.clock_seconds = value;
value = false; /* Default. */
- ret = apply_one_bool("clock-date", params, &value, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("clock-date", params, &value, NULL);
pretty->options.clock_date = value;
value = false; /* Default. */
- ret = apply_one_bool("clock-gmt", params, &value, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("clock-gmt", params, &value, NULL);
pretty->options.clock_gmt = value;
value = false; /* Default. */
- ret = apply_one_bool("verbose", params, &value, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("verbose", params, &value, NULL);
pretty->options.verbose = value;
/* Names. */
- ret = apply_one_string("name-default", params, &str);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_string("name-default", params, &str);
if (!str) {
pretty->options.name_default = PRETTY_DEFAULT_UNSET;
} else if (!strcmp(str, "show")) {
} else if (!strcmp(str, "hide")) {
pretty->options.name_default = PRETTY_DEFAULT_HIDE;
} else {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
g_free(str);
pretty->options.print_scope_field_names = false;
break;
default:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
value = false;
found = false;
- ret = apply_one_bool("name-payload", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("name-payload", params, &value, &found);
if (found) {
pretty->options.print_payload_field_names = value;
}
value = false;
found = false;
- ret = apply_one_bool("name-context", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("name-context", params, &value, &found);
if (found) {
pretty->options.print_context_field_names = value;
}
value = false;
found = false;
- ret = apply_one_bool("name-header", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("name-header", params, &value, &found);
if (found) {
pretty->options.print_header_field_names = value;
}
value = false;
found = false;
- ret = apply_one_bool("name-scope", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("name-scope", params, &value, &found);
if (found) {
pretty->options.print_scope_field_names = value;
}
/* Fields. */
- ret = apply_one_string("field-default", params, &str);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_string("field-default", params, &str);
if (!str) {
pretty->options.field_default = PRETTY_DEFAULT_UNSET;
} else if (!strcmp(str, "show")) {
} else if (!strcmp(str, "hide")) {
pretty->options.field_default = PRETTY_DEFAULT_HIDE;
} else {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
g_free(str);
pretty->options.print_callsite_field = false;
break;
default:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
value = false;
found = false;
- ret = apply_one_bool("field-trace", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-trace", params, &value, &found);
if (found) {
pretty->options.print_trace_field = value;
}
value = false;
found = false;
- ret = apply_one_bool("field-trace:hostname", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-trace:hostname", params, &value, &found);
if (found) {
pretty->options.print_trace_hostname_field = value;
}
value = false;
found = false;
- ret = apply_one_bool("field-trace:domain", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-trace:domain", params, &value, &found);
if (found) {
pretty->options.print_trace_domain_field = value;
}
value = false;
found = false;
- ret = apply_one_bool("field-trace:procname", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-trace:procname", params, &value, &found);
if (found) {
pretty->options.print_trace_procname_field = value;
}
value = false;
found = false;
- ret = apply_one_bool("field-trace:vpid", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-trace:vpid", params, &value, &found);
if (found) {
pretty->options.print_trace_vpid_field = value;
}
value = false;
found = false;
- ret = apply_one_bool("field-loglevel", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-loglevel", params, &value, &found);
if (found) {
pretty->options.print_loglevel_field = value;
}
value = false;
found = false;
- ret = apply_one_bool("field-emf", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-emf", params, &value, &found);
if (found) {
pretty->options.print_emf_field = value;
}
value = false;
found = false;
- ret = apply_one_bool("field-callsite", params, &value, &found);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
+ apply_one_bool("field-callsite", params, &value, &found);
if (found) {
pretty->options.print_callsite_field = value;
}
}
BT_HIDDEN
-enum bt_component_status pretty_init(
- struct bt_private_component *component,
+enum bt_self_component_status pretty_init(
+ struct bt_self_component_sink *comp,
struct bt_value *params,
UNUSED_VAR void *init_method_data)
{
- enum bt_component_status ret;
+ enum bt_self_component_status ret;
struct pretty_component *pretty = create_pretty();
if (!pretty) {
- ret = BT_COMPONENT_STATUS_NOMEM;
+ ret = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
- ret = bt_private_component_sink_add_input_port(component,
- "in", NULL, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ ret = bt_self_component_sink_add_input_port(comp, "in", NULL, NULL);
+ if (ret != BT_SELF_COMPONENT_STATUS_OK) {
goto end;
}
pretty->delta_real_timestamp = -1ULL;
pretty->last_real_timestamp = -1ULL;
- ret = apply_params(pretty, params);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (apply_params(pretty, params)) {
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
goto error;
}
set_use_colors(pretty);
- ret = bt_private_component_set_user_data(component, pretty);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
+ bt_self_component_set_data(
+ bt_self_component_sink_borrow_self_component(comp), pretty);
init_stream_packet_context_quarks();
end:
return ret;
+
error:
destroy_pretty_data(pretty);
return ret;
#define BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H
/*
- * BabelTrace - CTF Text Output Plug-in
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
struct pretty_component {
struct pretty_options options;
- struct bt_notification_iterator *input_iterator;
+ struct bt_self_component_port_input_notification_iterator *iterator;
FILE *out, *err;
int depth; /* nesting, used for tabulation alignment. */
bool start_line;
GQuark stream_packet_context_quarks[STREAM_PACKET_CONTEXT_QUARKS_LEN];
BT_HIDDEN
-enum bt_component_status pretty_init(
- struct bt_private_component *component,
+enum bt_self_component_status pretty_init(
+ struct bt_self_component_sink *component,
struct bt_value *params,
void *init_method_data);
BT_HIDDEN
-enum bt_component_status pretty_consume(struct bt_private_component *component);
+enum bt_self_component_status pretty_consume(
+ struct bt_self_component_sink *component);
BT_HIDDEN
-enum bt_component_status pretty_port_connected(
- struct bt_private_component *component,
- struct bt_private_port *self_port,
- struct bt_port *other_port);
+enum bt_self_component_status pretty_port_connected(
+ struct bt_self_component_sink *component,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
BT_HIDDEN
-void pretty_finalize(struct bt_private_component *component);
+void pretty_finalize(struct bt_self_component_sink *component);
BT_HIDDEN
-enum bt_component_status pretty_print_event(struct pretty_component *pretty,
+int pretty_print_event(struct pretty_component *pretty,
struct bt_notification *event_notif);
BT_HIDDEN
-enum bt_component_status pretty_print_packet(struct pretty_component *pretty,
+int pretty_print_packet(struct pretty_component *pretty,
struct bt_notification *packet_beginning_notif);
#endif /* BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H */
/*
- * print.c
- *
- * Babeltrace CTF Text Output Plugin Event Printing
- *
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
};
static
-enum bt_component_status print_field(struct pretty_component *pretty,
+int print_field(struct pretty_component *pretty,
struct bt_field *field, bool print_names,
GQuark *filters_fields, int filter_array_len);
}
static
-enum bt_component_status print_event_timestamp(struct pretty_component *pretty,
+int print_event_timestamp(struct pretty_component *pretty,
struct bt_event *event, bool *start_line)
{
bool print_names = pretty->options.print_header_field_names;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_stream *stream = NULL;
struct bt_stream_class *stream_class = NULL;
struct bt_trace *trace = NULL;
stream = bt_event_borrow_stream(event);
if (!stream) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
stream_class = bt_stream_borrow_class(stream);
if (!stream_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
trace = bt_stream_class_borrow_trace(stream_class);
if (!trace) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
}
static
-enum bt_component_status print_event_header(struct pretty_component *pretty,
+int print_event_header(struct pretty_component *pretty,
struct bt_event *event)
{
bool print_names = pretty->options.print_header_field_names;
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_event_class *event_class = NULL;
struct bt_stream_class *stream_class = NULL;
struct bt_trace *trace_class = NULL;
event_class = bt_event_borrow_class(event);
if (!event_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
stream_class = bt_event_class_borrow_stream_class(event_class);
if (!stream_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
trace_class = bt_stream_class_borrow_trace(stream_class);
if (!trace_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
ret = print_event_timestamp(pretty, event, &pretty->start_line);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret) {
goto end;
}
if (pretty->options.print_trace_field) {
}
static
-enum bt_component_status print_integer(struct pretty_component *pretty,
+int print_integer(struct pretty_component *pretty,
struct bt_field *field)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
enum bt_field_class_integer_preferred_display_base base;
struct bt_field_class *int_fc;
union {
break;
}
default:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
end:
}
static
-enum bt_component_status print_enum(struct pretty_component *pretty,
+int print_enum(struct pretty_component *pretty,
struct bt_field *field)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field_class *enumeration_field_class = NULL;
bt_field_class_enumeration_mapping_label_array label_array;
uint64_t label_count;
enumeration_field_class = bt_field_borrow_class(field);
if (!enumeration_field_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
}
if (ret) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
skip_loop:
g_string_append(pretty->string, " : container = ");
ret = print_integer(pretty, field);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
g_string_append(pretty->string, " )");
}
static
-enum bt_component_status print_struct_field(struct pretty_component *pretty,
+int print_struct_field(struct pretty_component *pretty,
struct bt_field *_struct,
struct bt_field_class *struct_class,
uint64_t i, bool print_names, uint64_t *nr_printed_fields,
GQuark *filter_fields, int filter_array_len)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
const char *field_name;
struct bt_field *field = NULL;
struct bt_field_class *field_class = NULL;;
field = bt_field_structure_borrow_member_field_by_index(_struct, i);
if (!field) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
if (filter_fields && !filter_field_name(pretty, field_name,
filter_fields, filter_array_len)) {
- ret = BT_COMPONENT_STATUS_OK;
+ ret = 0;
goto end;
}
}
static
-enum bt_component_status print_struct(struct pretty_component *pretty,
+int print_struct(struct pretty_component *pretty,
struct bt_field *_struct, bool print_names,
GQuark *filter_fields, int filter_array_len)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field_class *struct_class = NULL;
uint64_t nr_fields, i, nr_printed_fields;
struct_class = bt_field_borrow_class(_struct);
if (!struct_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
nr_fields = bt_field_class_structure_get_member_count(struct_class);
if (nr_fields < 0) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
g_string_append(pretty->string, "{");
ret = print_struct_field(pretty, _struct, struct_class, i,
print_names, &nr_printed_fields, filter_fields,
filter_array_len);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
}
}
static
-enum bt_component_status print_array_field(struct pretty_component *pretty,
+int print_array_field(struct pretty_component *pretty,
struct bt_field *array, uint64_t i, bool print_names)
{
struct bt_field *field = NULL;
}
static
-enum bt_component_status print_array(struct pretty_component *pretty,
+int print_array(struct pretty_component *pretty,
struct bt_field *array, bool print_names)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field_class *array_class = NULL;
uint64_t len;
uint64_t i;
array_class = bt_field_borrow_class(array);
if (!array_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
len = bt_field_array_get_length(array);
pretty->depth++;
for (i = 0; i < len; i++) {
ret = print_array_field(pretty, array, i, print_names);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
}
}
static
-enum bt_component_status print_sequence_field(struct pretty_component *pretty,
+int print_sequence_field(struct pretty_component *pretty,
struct bt_field *seq, uint64_t i, bool print_names)
{
struct bt_field *field = NULL;
}
static
-enum bt_component_status print_sequence(struct pretty_component *pretty,
+int print_sequence(struct pretty_component *pretty,
struct bt_field *seq, bool print_names)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
uint64_t len;
uint64_t i;
len = bt_field_array_get_length(seq);
if (len < 0) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
pretty->depth++;
for (i = 0; i < len; i++) {
ret = print_sequence_field(pretty, seq, i, print_names);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
}
}
static
-enum bt_component_status print_variant(struct pretty_component *pretty,
+int print_variant(struct pretty_component *pretty,
struct bt_field *variant, bool print_names)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field *field = NULL;
field = bt_field_variant_borrow_selected_option_field(variant);
// print_field_name_equal(pretty, tag_choice);
}
ret = print_field(pretty, field, print_names, NULL, 0);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
pretty->depth--;
}
static
-enum bt_component_status print_field(struct pretty_component *pretty,
+int print_field(struct pretty_component *pretty,
struct bt_field *field, bool print_names,
GQuark *filter_fields, int filter_array_len)
{
if (pretty->use_colors) {
g_string_append(pretty->string, COLOR_RST);
}
- return BT_COMPONENT_STATUS_OK;
+ return 0;
}
case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
str = bt_field_string_get_value(field);
if (!str) {
- return BT_COMPONENT_STATUS_ERROR;
+ return -1;
}
if (pretty->use_colors) {
if (pretty->use_colors) {
g_string_append(pretty->string, COLOR_RST);
}
- return BT_COMPONENT_STATUS_OK;
+ return 0;
}
case BT_FIELD_CLASS_TYPE_STRUCTURE:
return print_struct(pretty, field, print_names, filter_fields,
default:
// TODO: log instead
fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) class_id);
- return BT_COMPONENT_STATUS_ERROR;
+ return -1;
}
}
static
-enum bt_component_status print_stream_packet_context(struct pretty_component *pretty,
+int print_stream_packet_context(struct pretty_component *pretty,
struct bt_event *event)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_packet *packet = NULL;
struct bt_field *main_field = NULL;
packet = bt_event_borrow_packet(event);
if (!packet) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
main_field = bt_packet_borrow_context_field(packet);
}
static
-enum bt_component_status print_event_header_raw(struct pretty_component *pretty,
+int print_event_header_raw(struct pretty_component *pretty,
struct bt_event *event)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field *main_field = NULL;
main_field = bt_event_borrow_header_field(event);
}
static
-enum bt_component_status print_stream_event_context(struct pretty_component *pretty,
+int print_stream_event_context(struct pretty_component *pretty,
struct bt_event *event)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field *main_field = NULL;
main_field = bt_event_borrow_common_context_field(event);
}
static
-enum bt_component_status print_event_context(struct pretty_component *pretty,
+int print_event_context(struct pretty_component *pretty,
struct bt_event *event)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field *main_field = NULL;
main_field = bt_event_borrow_specific_context_field(event);
}
static
-enum bt_component_status print_event_payload(struct pretty_component *pretty,
+int print_event_payload(struct pretty_component *pretty,
struct bt_event *event)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_field *main_field = NULL;
main_field = bt_event_borrow_payload_field(event);
}
BT_HIDDEN
-enum bt_component_status pretty_print_event(struct pretty_component *pretty,
+int pretty_print_event(struct pretty_component *pretty,
struct bt_notification *event_notif)
{
- enum bt_component_status ret;
+ int ret;
struct bt_event *event =
bt_notification_event_borrow_event(event_notif);
pretty->start_line = true;
g_string_assign(pretty->string, "");
ret = print_event_header(pretty, event);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
ret = print_stream_packet_context(pretty, event);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
if (pretty->options.verbose) {
ret = print_event_header_raw(pretty, event);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
}
ret = print_stream_event_context(pretty, event);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
ret = print_event_context(pretty, event);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
ret = print_event_payload(pretty, event);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != 0) {
goto end;
}
g_string_append_c(pretty->string, '\n');
if (flush_buf(pretty->out, pretty)) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
goto end;
}
}
static
-enum bt_component_status print_discarded_elements_msg(
+int print_discarded_elements_msg(
struct pretty_component *pretty, struct bt_packet *packet,
uint64_t count, const char *elem_type)
{
#if 0
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ int ret = 0;
struct bt_stream *stream = NULL;
struct bt_stream_class *stream_class = NULL;
struct bt_trace *trace = NULL;
* with Babeltrace 1.
*/
if (flush_buf(stderr, pretty)) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = -1;
}
return ret;
}
BT_HIDDEN
-enum bt_component_status pretty_print_packet(struct pretty_component *pretty,
+int pretty_print_packet(struct pretty_component *pretty,
struct bt_notification *packet_beginning_notif)
{
#if 0
struct bt_packet *packet = bt_notification_packet_begin_borrow_packet(
packet_beginning_notif);
uint64_t count;
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ int status = 0;
if (bt_packet_get_discarded_event_count(packet, &count) ==
BT_PACKET_PROPERTY_AVAILABILITY_AVAILABLE &&
count > 0) {
status = print_discarded_elements_msg(pretty, packet,
count, "event");
- if (status != BT_COMPONENT_STATUS_OK) {
+ if (status != 0) {
goto end;
}
}
count > 0) {
status = print_discarded_elements_msg(pretty, packet,
count, "packet");
- if (status != BT_COMPONENT_STATUS_OK) {
+ if (status != 0) {
goto end;
}
}
g_free(counter);
}
-void counter_finalize(struct bt_private_component *component)
+BT_HIDDEN
+void counter_finalize(struct bt_self_component_sink *comp)
{
struct counter *counter;
- BT_ASSERT(component);
- counter = bt_private_component_get_user_data(component);
+ BT_ASSERT(comp);
+ counter = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp));
BT_ASSERT(counter);
try_print_last(counter);
bt_object_put_ref(counter->notif_iter);
g_free(counter);
}
-enum bt_component_status counter_init(struct bt_private_component *component,
+BT_HIDDEN
+enum bt_self_component_status counter_init(
+ struct bt_self_component_sink *component,
struct bt_value *params, UNUSED_VAR void *init_method_data)
{
- enum bt_component_status ret;
+ enum bt_self_component_status ret;
struct counter *counter = g_new0(struct counter, 1);
struct bt_value *step = NULL;
struct bt_value *hide_zero = NULL;
if (!counter) {
- ret = BT_COMPONENT_STATUS_NOMEM;
- goto end;
+ ret = BT_SELF_COMPONENT_STATUS_NOMEM;
+ goto error;
}
- ret = bt_private_component_sink_add_input_port(component,
+ ret = bt_self_component_sink_add_input_port(component,
"in", NULL, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
+ if (ret != BT_SELF_COMPONENT_STATUS_OK) {
+ goto error;
}
counter->last_printed_total = -1ULL;
counter->hide_zero = (bool) val;
}
- ret = bt_private_component_set_user_data(component, counter);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
+ bt_self_component_set_data(
+ bt_self_component_sink_borrow_self_component(component),
+ counter);
goto end;
error:
return ret;
}
-enum bt_component_status counter_port_connected(
- struct bt_private_component *component,
- struct bt_private_port *self_port,
- struct bt_port *other_port)
+BT_HIDDEN
+enum bt_self_component_status counter_port_connected(
+ struct bt_self_component_sink *comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct counter *counter;
- struct bt_notification_iterator *iterator;
- struct bt_private_connection *connection;
- enum bt_connection_status conn_status;
+ struct bt_self_component_port_input_notification_iterator *iterator;
- counter = bt_private_component_get_user_data(component);
+ counter = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp));
BT_ASSERT(counter);
- connection = bt_private_port_get_connection(self_port);
- BT_ASSERT(connection);
- conn_status = bt_private_connection_create_notification_iterator(
- connection, &iterator);
- if (conn_status != BT_CONNECTION_STATUS_OK) {
- status = BT_COMPONENT_STATUS_ERROR;
+ iterator = bt_self_component_port_input_notification_iterator_create(
+ self_port);
+ if (!iterator) {
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
BT_OBJECT_MOVE_REF(counter->notif_iter, iterator);
end:
- bt_object_put_ref(connection);
return status;
}
-enum bt_component_status counter_consume(struct bt_private_component *component)
+BT_HIDDEN
+enum bt_self_component_status counter_consume(
+ struct bt_self_component_sink *comp)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
struct counter *counter;
enum bt_notification_iterator_status it_ret;
uint64_t notif_count;
bt_notification_array notifs;
- counter = bt_private_component_get_user_data(component);
+ counter = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp));
BT_ASSERT(counter);
if (unlikely(!counter->notif_iter)) {
try_print_last(counter);
- ret = BT_COMPONENT_STATUS_END;
+ ret = BT_SELF_COMPONENT_STATUS_END;
goto end;
}
/* Consume notifications */
- it_ret = bt_private_connection_notification_iterator_next(
+ it_ret = bt_self_component_port_input_notification_iterator_next(
counter->notif_iter, ¬ifs, ¬if_count);
if (it_ret < 0) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
}
switch (it_ret) {
- case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
- ret = BT_COMPONENT_STATUS_AGAIN;
- goto end;
- case BT_NOTIFICATION_ITERATOR_STATUS_END:
- try_print_last(counter);
- ret = BT_COMPONENT_STATUS_END;
- goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_OK:
{
uint64_t i;
bt_object_put_ref(notif);
}
+
+ ret = BT_SELF_COMPONENT_STATUS_OK;
+ break;
}
+ case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
+ ret = BT_SELF_COMPONENT_STATUS_AGAIN;
+ goto end;
+ case BT_NOTIFICATION_ITERATOR_STATUS_END:
+ try_print_last(counter);
+ ret = BT_SELF_COMPONENT_STATUS_END;
+ goto end;
+ case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
+ ret = BT_SELF_COMPONENT_STATUS_NOMEM;
+ goto end;
default:
break;
}
#include <stdint.h>
struct counter {
- struct bt_notification_iterator *notif_iter;
+ struct bt_self_component_port_input_notification_iterator *notif_iter;
struct {
uint64_t event;
uint64_t stream_begin;
bool hide_zero;
};
-enum bt_component_status counter_init(struct bt_private_component *component,
+BT_HIDDEN
+enum bt_self_component_status counter_init(
+ struct bt_self_component_sink *component,
struct bt_value *params, void *init_method_data);
-void counter_finalize(struct bt_private_component *component);
-enum bt_component_status counter_port_connected(
- struct bt_private_component *component,
- struct bt_private_port *self_port,
- struct bt_port *other_port);
-enum bt_component_status counter_consume(struct bt_private_component *component);
+
+BT_HIDDEN
+void counter_finalize(struct bt_self_component_sink *component);
+
+BT_HIDDEN
+enum bt_self_component_status counter_port_connected(
+ struct bt_self_component_sink *component,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
+
+BT_HIDDEN
+enum bt_self_component_status counter_consume(struct bt_self_component_sink *component);
#endif /* BABELTRACE_PLUGINS_UTILS_COUNTER_H */
{
bt_object_put_ref(dummy->notif_iter);
g_free(dummy);
+
}
-void dummy_finalize(struct bt_private_component *component)
+BT_HIDDEN
+void dummy_finalize(struct bt_self_component_sink *comp)
{
struct dummy *dummy;
- BT_ASSERT(component);
- dummy = bt_private_component_get_user_data(component);
+ BT_ASSERT(comp);
+ dummy = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp));
BT_ASSERT(dummy);
destroy_private_dummy_data(dummy);
}
-enum bt_component_status dummy_init(struct bt_private_component *component,
+BT_HIDDEN
+enum bt_self_component_status dummy_init(
+ struct bt_self_component_sink *component,
struct bt_value *params, UNUSED_VAR void *init_method_data)
{
- enum bt_component_status ret;
+ enum bt_self_component_status ret;
struct dummy *dummy = g_new0(struct dummy, 1);
if (!dummy) {
- ret = BT_COMPONENT_STATUS_NOMEM;
+ ret = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
- ret = bt_private_component_sink_add_input_port(component,
+ ret = bt_self_component_sink_add_input_port(component,
"in", NULL, NULL);
- if (ret != BT_COMPONENT_STATUS_OK) {
- goto end;
- }
-
- ret = bt_private_component_set_user_data(component, dummy);
- if (ret != BT_COMPONENT_STATUS_OK) {
+ if (ret != BT_SELF_COMPONENT_STATUS_OK) {
goto error;
}
+ bt_self_component_set_data(
+ bt_self_component_sink_borrow_self_component(component), dummy);
goto end;
error:
return ret;
}
-enum bt_component_status dummy_port_connected(
- struct bt_private_component *component,
- struct bt_private_port *self_port,
- struct bt_port *other_port)
+BT_HIDDEN
+enum bt_self_component_status dummy_port_connected(
+ struct bt_self_component_sink *comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct dummy *dummy;
- struct bt_notification_iterator *iterator;
- struct bt_private_connection *connection;
- enum bt_connection_status conn_status;
+ struct bt_self_component_port_input_notification_iterator *iterator;
- dummy = bt_private_component_get_user_data(component);
+ dummy = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(comp));
BT_ASSERT(dummy);
- connection = bt_private_port_get_connection(self_port);
- BT_ASSERT(connection);
- conn_status = bt_private_connection_create_notification_iterator(
- connection, &iterator);
- if (conn_status != BT_CONNECTION_STATUS_OK) {
- status = BT_COMPONENT_STATUS_ERROR;
+ iterator = bt_self_component_port_input_notification_iterator_create(
+ self_port);
+ if (!iterator) {
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
BT_OBJECT_MOVE_REF(dummy->notif_iter, iterator);
end:
- bt_object_put_ref(connection);
return status;
}
-enum bt_component_status dummy_consume(struct bt_private_component *component)
+BT_HIDDEN
+enum bt_self_component_status dummy_consume(
+ struct bt_self_component_sink *component)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
bt_notification_array notifs;
uint64_t count;
struct dummy *dummy;
enum bt_notification_iterator_status it_ret;
uint64_t i;
- dummy = bt_private_component_get_user_data(component);
+ dummy = bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(component));
BT_ASSERT(dummy);
if (unlikely(!dummy->notif_iter)) {
- ret = BT_COMPONENT_STATUS_END;
+ ret = BT_SELF_COMPONENT_STATUS_END;
goto end;
}
/* Consume one notification */
- it_ret = bt_private_connection_notification_iterator_next(
+ it_ret = bt_self_component_port_input_notification_iterator_next(
dummy->notif_iter, ¬ifs, &count);
switch (it_ret) {
case BT_NOTIFICATION_ITERATOR_STATUS_OK:
- ret = BT_COMPONENT_STATUS_OK;
+ ret = BT_SELF_COMPONENT_STATUS_OK;
for (i = 0; i < count; i++) {
bt_object_put_ref(notifs[i]);
break;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
- ret = BT_COMPONENT_STATUS_AGAIN;
+ ret = BT_SELF_COMPONENT_STATUS_AGAIN;
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_END:
- ret = BT_COMPONENT_STATUS_END;
+ ret = BT_SELF_COMPONENT_STATUS_END;
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
+ goto end;
+ case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
+ ret = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
default:
break;
#include <glib.h>
#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
#include <stdbool.h>
struct dummy {
- struct bt_notification_iterator *notif_iter;
+ struct bt_self_component_port_input_notification_iterator *notif_iter;
};
-enum bt_component_status dummy_init(struct bt_private_component *component,
+BT_HIDDEN
+enum bt_self_component_status dummy_init(
+ struct bt_self_component_sink *component,
struct bt_value *params, void *init_method_data);
-void dummy_finalize(struct bt_private_component *component);
-enum bt_component_status dummy_port_connected(
- struct bt_private_component *component,
- struct bt_private_port *self_port,
- struct bt_port *other_port);
-enum bt_component_status dummy_consume(struct bt_private_component *component);
+
+BT_HIDDEN
+void dummy_finalize(struct bt_self_component_sink *component);
+
+BT_HIDDEN
+enum bt_self_component_status dummy_port_connected(
+ struct bt_self_component_sink *comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
+
+BT_HIDDEN
+enum bt_self_component_status dummy_consume(
+ struct bt_self_component_sink *component);
#endif /* BABELTRACE_PLUGINS_UTILS_DUMMY_H */
struct muxer_comp {
/*
* Array of struct
- * bt_private_connection_private_notification_iterator *
+ * bt_self_notification_iterator *
* (weak refs)
*/
GPtrArray *muxer_notif_iters;
/* Weak ref */
- struct bt_private_component *priv_comp;
+ struct bt_self_component_filter *self_comp;
+
unsigned int next_port_num;
size_t available_input_ports;
bool initializing_muxer_notif_iter;
struct muxer_upstream_notif_iter {
/* Owned by this, NULL if ended */
- struct bt_notification_iterator *notif_iter;
+ struct bt_self_component_port_input_notification_iterator *notif_iter;
/* Contains `struct bt_notification *`, owned by this */
GQueue *notifs;
* muxer_upstream_notif_iters above by
* muxer_notif_iter_handle_newly_connected_ports().
*/
- GList *newly_connected_priv_ports;
+ GList *newly_connected_self_ports;
/* Last time returned in a notification */
int64_t last_returned_ts_ns;
static
struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter(
struct muxer_notif_iter *muxer_notif_iter,
- struct bt_notification_iterator *notif_iter,
- struct bt_private_port *priv_port)
+ struct bt_self_component_port_input_notification_iterator *self_notif_iter)
{
struct muxer_upstream_notif_iter *muxer_upstream_notif_iter =
g_new0(struct muxer_upstream_notif_iter, 1);
goto end;
}
- muxer_upstream_notif_iter->notif_iter = bt_object_get_ref(notif_iter);
+ muxer_upstream_notif_iter->notif_iter = bt_object_get_ref(self_notif_iter);
muxer_upstream_notif_iter->notifs = g_queue_new();
if (!muxer_upstream_notif_iter->notifs) {
BT_LOGE_STR("Failed to allocate a GQueue.");
-
goto end;
}
BT_LOGD("Added muxer's upstream notification iterator wrapper: "
"addr=%p, muxer-notif-iter-addr=%p, notif-iter-addr=%p",
muxer_upstream_notif_iter, muxer_notif_iter,
- notif_iter);
+ self_notif_iter);
end:
return muxer_upstream_notif_iter;
}
static
-enum bt_component_status ensure_available_input_port(
- struct bt_private_component *priv_comp)
+enum bt_self_component_status ensure_available_input_port(
+ struct bt_self_component_filter *self_comp)
{
- struct muxer_comp *muxer_comp =
- bt_private_component_get_user_data(priv_comp);
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ struct muxer_comp *muxer_comp = bt_self_component_get_data(
+ bt_self_component_filter_borrow_self_component(self_comp));
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
GString *port_name = NULL;
BT_ASSERT(muxer_comp);
port_name = g_string_new("in");
if (!port_name) {
BT_LOGE_STR("Failed to allocate a GString.");
- status = BT_COMPONENT_STATUS_NOMEM;
+ status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
g_string_append_printf(port_name, "%u", muxer_comp->next_port_num);
- status = bt_private_component_filter_add_input_port(
- priv_comp, port_name->str, NULL, NULL);
- if (status != BT_COMPONENT_STATUS_OK) {
+ status = bt_self_component_filter_add_input_port(
+ self_comp, port_name->str, NULL, NULL);
+ if (status != BT_SELF_COMPONENT_STATUS_OK) {
BT_LOGE("Cannot add input port to muxer component: "
"port-name=\"%s\", comp-addr=%p, status=%s",
- port_name->str, priv_comp,
- bt_component_status_string(status));
+ port_name->str, self_comp,
+ bt_self_component_status_string(status));
goto end;
}
muxer_comp->next_port_num++;
BT_LOGD("Added one input port to muxer component: "
"port-name=\"%s\", comp-addr=%p",
- port_name->str, priv_comp);
+ port_name->str, self_comp);
end:
if (port_name) {
g_string_free(port_name, TRUE);
}
static
-enum bt_component_status create_output_port(
- struct bt_private_component *priv_comp)
+enum bt_self_component_status create_output_port(
+ struct bt_self_component_filter *self_comp)
{
- return bt_private_component_filter_add_output_port(
- priv_comp, "out", NULL, NULL);
+ return bt_self_component_filter_add_output_port(
+ self_comp, "out", NULL, NULL);
}
static
}
ret = bt_value_map_extend(&real_params,
- bt_value_borrow_from_private(default_params), params);
+ bt_private_value_borrow_value(default_params), params);
if (ret) {
BT_LOGE("Cannot extend default parameters map value: "
"muxer-comp-addr=%p, def-params-addr=%p, "
}
assume_absolute_clock_classes = bt_value_map_borrow_entry_value(
- bt_value_borrow_from_private(real_params),
+ bt_private_value_borrow_value(real_params),
ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
if (assume_absolute_clock_classes &&
!bt_value_is_bool(assume_absolute_clock_classes)) {
}
BT_HIDDEN
-enum bt_component_status muxer_init(
- struct bt_private_component *priv_comp,
+enum bt_self_component_status muxer_init(
+ struct bt_self_component_filter *self_comp,
struct bt_value *params, void *init_data)
{
int ret;
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct muxer_comp *muxer_comp = g_new0(struct muxer_comp, 1);
BT_LOGD("Initializing muxer component: "
- "comp-addr=%p, params-addr=%p", priv_comp, params);
+ "comp-addr=%p, params-addr=%p", self_comp, params);
if (!muxer_comp) {
BT_LOGE_STR("Failed to allocate one muxer component.");
goto error;
}
- muxer_comp->priv_comp = priv_comp;
- ret = bt_private_component_set_user_data(priv_comp, muxer_comp);
- BT_ASSERT(ret == 0);
- status = ensure_available_input_port(priv_comp);
- if (status != BT_COMPONENT_STATUS_OK) {
+ muxer_comp->self_comp = self_comp;
+ bt_self_component_set_data(
+ bt_self_component_filter_borrow_self_component(self_comp),
+ muxer_comp);
+ status = ensure_available_input_port(self_comp);
+ if (status != BT_SELF_COMPONENT_STATUS_OK) {
BT_LOGE("Cannot ensure that at least one muxer component's input port is available: "
"muxer-comp-addr=%p, status=%s",
muxer_comp,
- bt_component_status_string(status));
+ bt_self_component_status_string(status));
goto error;
}
- status = create_output_port(priv_comp);
+ status = create_output_port(self_comp);
if (status) {
BT_LOGE("Cannot create muxer component's output port: "
"muxer-comp-addr=%p, status=%s",
muxer_comp,
- bt_component_status_string(status));
+ bt_self_component_status_string(status));
goto error;
}
BT_LOGD("Initialized muxer component: "
"comp-addr=%p, params-addr=%p, muxer-comp-addr=%p",
- priv_comp, params, muxer_comp);
+ self_comp, params, muxer_comp);
goto end;
error:
destroy_muxer_comp(muxer_comp);
- ret = bt_private_component_set_user_data(priv_comp, NULL);
- BT_ASSERT(ret == 0);
+ bt_self_component_set_data(
+ bt_self_component_filter_borrow_self_component(self_comp),
+ NULL);
- if (status == BT_COMPONENT_STATUS_OK) {
- status = BT_COMPONENT_STATUS_ERROR;
+ if (status == BT_SELF_COMPONENT_STATUS_OK) {
+ status = BT_SELF_COMPONENT_STATUS_ERROR;
}
end:
}
BT_HIDDEN
-void muxer_finalize(struct bt_private_component *priv_comp)
+void muxer_finalize(struct bt_self_component_filter *self_comp)
{
- struct muxer_comp *muxer_comp =
- bt_private_component_get_user_data(priv_comp);
+ struct muxer_comp *muxer_comp = bt_self_component_get_data(
+ bt_self_component_filter_borrow_self_component(self_comp));
BT_LOGD("Finalizing muxer component: comp-addr=%p",
- priv_comp);
+ self_comp);
destroy_muxer_comp(muxer_comp);
}
static
-struct bt_notification_iterator *create_notif_iter_on_input_port(
- struct bt_private_port *priv_port, int *ret)
+struct bt_self_component_port_input_notification_iterator *
+create_notif_iter_on_input_port(
+ struct bt_self_component_port_input *self_port, int *ret)
{
- struct bt_port *port = bt_port_borrow_from_private(priv_port);
- struct bt_notification_iterator *notif_iter = NULL;
- struct bt_private_connection *priv_conn = NULL;
- enum bt_connection_status conn_status;
+ struct bt_port *port = bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ self_port));
+ struct bt_self_component_port_input_notification_iterator *notif_iter =
+ NULL;
BT_ASSERT(ret);
*ret = 0;
BT_ASSERT(port);
BT_ASSERT(bt_port_is_connected(port));
- priv_conn = bt_private_port_get_connection(priv_port);
- BT_ASSERT(priv_conn);
// TODO: Advance the iterator to >= the time of the latest
// returned notification by the muxer notification
// iterator which creates it.
- conn_status = bt_private_connection_create_notification_iterator(
- priv_conn, ¬if_iter);
- if (conn_status != BT_CONNECTION_STATUS_OK) {
- BT_LOGE("Cannot create upstream notification iterator on input port's connection: "
- "port-addr=%p, port-name=\"%s\", conn-addr=%p, "
- "status=%s",
- port, bt_port_get_name(port), priv_conn,
- bt_connection_status_string(conn_status));
+ notif_iter = bt_self_component_port_input_notification_iterator_create(
+ self_port);
+ if (!notif_iter) {
+ BT_LOGE("Cannot create upstream notification iterator on input port: "
+ "port-addr=%p, port-name=\"%s\"",
+ port, bt_port_get_name(port));
*ret = -1;
goto end;
}
- BT_LOGD("Created upstream notification iterator on input port's connection: "
- "port-addr=%p, port-name=\"%s\", conn-addr=%p, "
- "notif-iter-addr=%p",
- port, bt_port_get_name(port), priv_conn, notif_iter);
+ BT_LOGD("Created upstream notification iterator on input port: "
+ "port-addr=%p, port-name=\"%s\", notif-iter-addr=%p",
+ port, bt_port_get_name(port), notif_iter);
end:
- bt_object_put_ref(priv_conn);
return notif_iter;
}
"muxer-upstream-notif-iter-wrap-addr=%p, notif-iter-addr=%p",
muxer_upstream_notif_iter,
muxer_upstream_notif_iter->notif_iter);
- status = bt_private_connection_notification_iterator_next(
+ status = bt_self_component_port_input_notification_iterator_next(
muxer_upstream_notif_iter->notif_iter, ¬ifs, &count);
BT_LOGV("Upstream notification iterator's \"next\" method returned: "
"status=%s", bt_notification_iterator_status_string(status));
* muxer_port_connected().
*/
while (true) {
- GList *node = muxer_notif_iter->newly_connected_priv_ports;
- struct bt_private_port *priv_port;
+ GList *node = muxer_notif_iter->newly_connected_self_ports;
+ struct bt_self_component_port_input *self_port;
struct bt_port *port;
- struct bt_notification_iterator *upstream_notif_iter = NULL;
+ struct bt_self_component_port_input_notification_iterator *
+ upstream_notif_iter = NULL;
struct muxer_upstream_notif_iter *muxer_upstream_notif_iter;
if (!node) {
break;
}
- priv_port = node->data;
- port = bt_port_borrow_from_private(priv_port);
+ self_port = node->data;
+ port = bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ (self_port)));
BT_ASSERT(port);
if (!bt_port_is_connected(port)) {
goto remove_node;
}
- upstream_notif_iter = create_notif_iter_on_input_port(priv_port,
- &ret);
+ upstream_notif_iter = create_notif_iter_on_input_port(
+ self_port, &ret);
if (ret) {
/* create_notif_iter_on_input_port() logs errors */
BT_ASSERT(!upstream_notif_iter);
muxer_upstream_notif_iter =
muxer_notif_iter_add_upstream_notif_iter(
- muxer_notif_iter, upstream_notif_iter,
- priv_port);
+ muxer_notif_iter, upstream_notif_iter);
BT_OBJECT_PUT_REF_AND_RESET(upstream_notif_iter);
if (!muxer_upstream_notif_iter) {
/*
remove_node:
bt_object_put_ref(upstream_notif_iter);
- muxer_notif_iter->newly_connected_priv_ports =
+ muxer_notif_iter->newly_connected_self_ports =
g_list_delete_link(
- muxer_notif_iter->newly_connected_priv_ports,
+ muxer_notif_iter->newly_connected_self_ports,
node);
}
* connected new ports. If no ports were connected
* during this operation, exit the loop.
*/
- if (!muxer_notif_iter->newly_connected_priv_ports) {
+ if (!muxer_notif_iter->newly_connected_self_ports) {
BT_LOGV("Not breaking this loop: muxer's notification iterator still has newly connected input ports to handle: "
"muxer-comp-addr=%p", muxer_comp);
break;
}
}
- BT_ASSERT(!muxer_notif_iter->newly_connected_priv_ports);
+ BT_ASSERT(!muxer_notif_iter->newly_connected_self_ports);
/*
* At this point we know that all the existing upstream
muxer_notif_iter->muxer_upstream_notif_iters, TRUE);
}
- g_list_free(muxer_notif_iter->newly_connected_priv_ports);
+ g_list_free(muxer_notif_iter->newly_connected_self_ports);
g_free(muxer_notif_iter);
}
int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
struct muxer_notif_iter *muxer_notif_iter)
{
- struct bt_component *comp;
int64_t count;
int64_t i;
int ret = 0;
* iterator's list of newly connected ports. They will be
* handled by muxer_notif_iter_handle_newly_connected_ports().
*/
- comp = bt_component_borrow_from_private(muxer_comp->priv_comp);
- BT_ASSERT(comp);
- count = bt_component_filter_get_input_port_count(comp);
+ count = bt_component_filter_get_input_port_count(
+ bt_self_component_filter_borrow_component_filter(
+ muxer_comp->self_comp));
if (count < 0) {
BT_LOGD("No input port to initialize for muxer component's notification iterator: "
"muxer-comp-addr=%p, muxer-notif-iter-addr=%p",
}
for (i = 0; i < count; i++) {
- struct bt_private_port *priv_port =
- bt_private_component_filter_get_input_port_by_index(
- muxer_comp->priv_comp, i);
+ struct bt_self_component_port_input *self_port =
+ bt_self_component_filter_borrow_input_port_by_index(
+ muxer_comp->self_comp, i);
struct bt_port *port;
- BT_ASSERT(priv_port);
- port = bt_port_borrow_from_private(priv_port);
+ BT_ASSERT(self_port);
+ port = bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ self_port));
BT_ASSERT(port);
if (!bt_port_is_connected(port)) {
BT_LOGD("Skipping input port: not connected: "
"muxer-comp-addr=%p, port-addr=%p, port-name\"%s\"",
muxer_comp, port, bt_port_get_name(port));
- bt_object_put_ref(priv_port);
continue;
}
- bt_object_put_ref(priv_port);
- muxer_notif_iter->newly_connected_priv_ports =
+ muxer_notif_iter->newly_connected_self_ports =
g_list_append(
- muxer_notif_iter->newly_connected_priv_ports,
- priv_port);
- if (!muxer_notif_iter->newly_connected_priv_ports) {
+ muxer_notif_iter->newly_connected_self_ports,
+ self_port);
+ if (!muxer_notif_iter->newly_connected_self_ports) {
BT_LOGE("Cannot append port to muxer's notification iterator list of newly connected input ports: "
"port-addr=%p, port-name=\"%s\", "
"muxer-notif-iter-addr=%p", port,
}
BT_HIDDEN
-enum bt_notification_iterator_status muxer_notif_iter_init(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
- struct bt_private_port *output_priv_port)
+enum bt_self_notification_iterator_status muxer_notif_iter_init(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_filter *self_comp,
+ struct bt_self_component_port_output *port)
{
struct muxer_comp *muxer_comp = NULL;
struct muxer_notif_iter *muxer_notif_iter = NULL;
- struct bt_private_component *priv_comp = NULL;
- enum bt_notification_iterator_status status =
+ enum bt_self_notification_iterator_status status =
BT_NOTIFICATION_ITERATOR_STATUS_OK;
int ret;
- priv_comp = bt_private_connection_private_notification_iterator_get_private_component(
- priv_notif_iter);
- BT_ASSERT(priv_comp);
- muxer_comp = bt_private_component_get_user_data(priv_comp);
+ muxer_comp = bt_self_component_get_data(
+ bt_self_component_filter_borrow_self_component(self_comp));
BT_ASSERT(muxer_comp);
BT_LOGD("Initializing muxer component's notification iterator: "
"comp-addr=%p, muxer-comp-addr=%p, notif-iter-addr=%p",
- priv_comp, muxer_comp, priv_notif_iter);
+ self_comp, muxer_comp, self_notif_iter);
if (muxer_comp->initializing_muxer_notif_iter) {
/*
*/
BT_LOGE("Recursive initialization of muxer component's notification iterator: "
"comp-addr=%p, muxer-comp-addr=%p, notif-iter-addr=%p",
- priv_comp, muxer_comp, priv_notif_iter);
+ self_comp, muxer_comp, self_notif_iter);
goto error;
}
BT_LOGE("Cannot initialize newly connected input ports for muxer component's notification iterator: "
"comp-addr=%p, muxer-comp-addr=%p, "
"muxer-notif-iter-addr=%p, notif-iter-addr=%p, ret=%d",
- priv_comp, muxer_comp, muxer_notif_iter,
- priv_notif_iter, ret);
+ self_comp, muxer_comp, muxer_notif_iter,
+ self_notif_iter, ret);
goto error;
}
- ret = bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter,
+ bt_self_notification_iterator_set_data(self_notif_iter,
muxer_notif_iter);
- BT_ASSERT(ret == 0);
BT_LOGD("Initialized muxer component's notification iterator: "
"comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, "
"notif-iter-addr=%p",
- priv_comp, muxer_comp, muxer_notif_iter, priv_notif_iter);
+ self_comp, muxer_comp, muxer_notif_iter, self_notif_iter);
goto end;
error:
}
destroy_muxer_notif_iter(muxer_notif_iter);
- ret = bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter,
+ bt_self_notification_iterator_set_data(self_notif_iter,
NULL);
- BT_ASSERT(ret == 0);
status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
end:
muxer_comp->initializing_muxer_notif_iter = false;
- bt_object_put_ref(priv_comp);
return status;
}
BT_HIDDEN
void muxer_notif_iter_finalize(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter)
+ struct bt_self_notification_iterator *self_notif_iter)
{
struct muxer_notif_iter *muxer_notif_iter =
- bt_private_connection_private_notification_iterator_get_user_data(priv_notif_iter);
- struct bt_private_component *priv_comp = NULL;
+ bt_self_notification_iterator_get_data(self_notif_iter);
+ struct bt_self_component *self_comp = NULL;
struct muxer_comp *muxer_comp = NULL;
- priv_comp = bt_private_connection_private_notification_iterator_get_private_component(
- priv_notif_iter);
- BT_ASSERT(priv_comp);
- muxer_comp = bt_private_component_get_user_data(priv_comp);
+ self_comp = bt_self_notification_iterator_borrow_component(
+ self_notif_iter);
+ BT_ASSERT(self_comp);
+ muxer_comp = bt_self_component_get_data(self_comp);
BT_LOGD("Finalizing muxer component's notification iterator: "
"comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, "
"notif-iter-addr=%p",
- priv_comp, muxer_comp, muxer_notif_iter, priv_notif_iter);
+ self_comp, muxer_comp, muxer_notif_iter, self_notif_iter);
if (muxer_comp) {
(void) g_ptr_array_remove_fast(muxer_comp->muxer_notif_iters,
muxer_notif_iter);
destroy_muxer_notif_iter(muxer_notif_iter);
}
-
- bt_object_put_ref(priv_comp);
}
BT_HIDDEN
enum bt_notification_iterator_status muxer_notif_iter_next(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
+ struct bt_self_notification_iterator *self_notif_iter,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count)
{
enum bt_notification_iterator_status status;
struct muxer_notif_iter *muxer_notif_iter =
- bt_private_connection_private_notification_iterator_get_user_data(priv_notif_iter);
- struct bt_private_component *priv_comp = NULL;
+ bt_self_notification_iterator_get_data(self_notif_iter);
+ struct bt_self_component *self_comp = NULL;
struct muxer_comp *muxer_comp = NULL;
BT_ASSERT(muxer_notif_iter);
- priv_comp = bt_private_connection_private_notification_iterator_get_private_component(
- priv_notif_iter);
- BT_ASSERT(priv_comp);
- muxer_comp = bt_private_component_get_user_data(priv_comp);
+ self_comp = bt_self_notification_iterator_borrow_component(
+ self_notif_iter);
+ BT_ASSERT(self_comp);
+ muxer_comp = bt_self_component_get_data(self_comp);
BT_ASSERT(muxer_comp);
BT_LOGV("Muxer component's notification iterator's \"next\" method called: "
"comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, "
"notif-iter-addr=%p",
- priv_comp, muxer_comp, muxer_notif_iter, priv_notif_iter);
+ self_comp, muxer_comp, muxer_notif_iter, self_notif_iter);
status = muxer_notif_iter_do_next(muxer_comp, muxer_notif_iter,
notifs, capacity, count);
BT_LOGE("Cannot get next notification: "
"comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, "
"notif-iter-addr=%p, status=%s",
- priv_comp, muxer_comp, muxer_notif_iter, priv_notif_iter,
+ self_comp, muxer_comp, muxer_notif_iter, self_notif_iter,
bt_notification_iterator_status_string(status));
} else {
BT_LOGV("Returning from muxer component's notification iterator's \"next\" method: "
bt_notification_iterator_status_string(status));
}
- bt_object_put_ref(priv_comp);
return status;
}
BT_HIDDEN
-enum bt_component_status muxer_port_connected(
- struct bt_private_component *priv_comp,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port)
+enum bt_self_component_status muxer_input_port_connected(
+ struct bt_self_component_filter *self_comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port)
{
- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- struct bt_port *self_port =
- bt_port_borrow_from_private(self_private_port);
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+ struct bt_port *port = bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ self_port));
struct muxer_comp *muxer_comp =
- bt_private_component_get_user_data(priv_comp);
+ bt_self_component_get_data(
+ bt_self_component_filter_borrow_self_component(
+ self_comp));
size_t i;
int ret;
- BT_ASSERT(self_port);
+ BT_ASSERT(port);
BT_ASSERT(muxer_comp);
BT_LOGD("Port connected: "
"comp-addr=%p, muxer-comp-addr=%p, "
"port-addr=%p, port-name=\"%s\", "
"other-port-addr=%p, other-port-name=\"%s\"",
- priv_comp, muxer_comp, self_port, bt_port_get_name(self_port),
- other_port, bt_port_get_name(other_port));
-
- if (bt_port_get_type(self_port) == BT_PORT_TYPE_OUTPUT) {
- goto end;
- }
+ self_comp, muxer_comp, self_port, bt_port_get_name(port),
+ other_port,
+ bt_port_get_name(bt_port_output_borrow_port(other_port)));
for (i = 0; i < muxer_comp->muxer_notif_iters->len; i++) {
struct muxer_notif_iter *muxer_notif_iter =
* muxer_notif_iter_handle_newly_connected_ports()
* removes the nodes from the beginning.
*/
- muxer_notif_iter->newly_connected_priv_ports =
+ muxer_notif_iter->newly_connected_self_ports =
g_list_append(
- muxer_notif_iter->newly_connected_priv_ports,
- self_private_port);
- if (!muxer_notif_iter->newly_connected_priv_ports) {
+ muxer_notif_iter->newly_connected_self_ports,
+ self_port);
+ if (!muxer_notif_iter->newly_connected_self_ports) {
BT_LOGE("Cannot append port to muxer's notification iterator list of newly connected input ports: "
"port-addr=%p, port-name=\"%s\", "
"muxer-notif-iter-addr=%p", self_port,
- bt_port_get_name(self_port), muxer_notif_iter);
- status = BT_COMPONENT_STATUS_ERROR;
+ bt_port_get_name(port), muxer_notif_iter);
+ status = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
}
BT_LOGD("Appended port to muxer's notification iterator list of newly connected input ports: "
"port-addr=%p, port-name=\"%s\", "
"muxer-notif-iter-addr=%p", self_port,
- bt_port_get_name(self_port), muxer_notif_iter);
+ bt_port_get_name(port), muxer_notif_iter);
}
/* One less available input port */
muxer_comp->available_input_ports--;
- ret = ensure_available_input_port(priv_comp);
+ ret = ensure_available_input_port(self_comp);
if (ret) {
/*
* Only way to report an error later since this
*/
BT_LOGE("Cannot ensure that at least one muxer component's input port is available: "
"muxer-comp-addr=%p, status=%s",
- muxer_comp, bt_component_status_string(ret));
- status = BT_COMPONENT_STATUS_ERROR;
+ muxer_comp, bt_self_component_status_string(ret));
+ status = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
}
}
BT_HIDDEN
-void muxer_port_disconnected(struct bt_private_component *priv_comp,
- struct bt_private_port *priv_port)
+void muxer_input_port_disconnected(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_input *self_port)
{
- struct bt_port *port = bt_port_borrow_from_private(priv_port);
struct muxer_comp *muxer_comp =
- bt_private_component_get_user_data(priv_comp);
+ bt_self_component_get_data(
+ bt_self_component_filter_borrow_self_component(
+ self_component));
+ struct bt_port *port =
+ bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ self_port));
BT_ASSERT(port);
BT_ASSERT(muxer_comp);
- BT_LOGD("Port disconnected: "
- "comp-addr=%p, muxer-comp-addr=%p, port-addr=%p, "
- "port-name=\"%s\"", priv_comp, muxer_comp,
- port, bt_port_get_name(port));
- /*
- * There's nothing special to do when a port is disconnected
- * because this component deals with upstream notification
- * iterators which were already created thanks to connected
- * ports. The fact that the port is disconnected does not cancel
- * the upstream notification iterators created using its
- * connection: they still exist, even if the connection is dead.
- * The only way to remove an upstream notification iterator is
- * for its "next" operation to return
- * BT_NOTIFICATION_ITERATOR_STATUS_END.
- */
- if (bt_port_get_type(port) == BT_PORT_TYPE_INPUT) {
- /* One more available input port */
- muxer_comp->available_input_ports++;
- BT_LOGD("Leaving disconnected input port available for future connections: "
- "comp-addr=%p, muxer-comp-addr=%p, port-addr=%p, "
- "port-name=\"%s\", avail-input-port-count=%zu",
- priv_comp, muxer_comp, port, bt_port_get_name(port),
- muxer_comp->available_input_ports);
- }
+ /* One more available input port */
+ muxer_comp->available_input_ports++;
+ BT_LOGD("Leaving disconnected input port available for future connections: "
+ "comp-addr=%p, muxer-comp-addr=%p, port-addr=%p, "
+ "port-name=\"%s\", avail-input-port-count=%zu",
+ self_component, muxer_comp, port, bt_port_get_name(port),
+ muxer_comp->available_input_ports);
}
*/
#include <stdint.h>
+#include <babeltrace/babeltrace.h>
#include <babeltrace/babeltrace-internal.h>
BT_HIDDEN
-enum bt_component_status muxer_init(
- struct bt_private_component *priv_comp,
+enum bt_self_component_status muxer_init(
+ struct bt_self_component_filter *self_comp,
struct bt_value *params, void *init_data);
BT_HIDDEN
-void muxer_finalize(
- struct bt_private_component *priv_comp);
+void muxer_finalize(struct bt_self_component_filter *self_comp);
BT_HIDDEN
-enum bt_notification_iterator_status muxer_notif_iter_init(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
- struct bt_private_port *priv_port);
+enum bt_self_notification_iterator_status muxer_notif_iter_init(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_filter *self_comp,
+ struct bt_self_component_port_output *self_port);
BT_HIDDEN
void muxer_notif_iter_finalize(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter);
+ struct bt_self_notification_iterator *self_notif_iter);
BT_HIDDEN
-enum bt_notification_iterator_status muxer_notif_iter_next(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
+enum bt_self_notification_iterator_status muxer_notif_iter_next(
+ struct bt_self_notification_iterator *self_notif_iter,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count);
BT_HIDDEN
-enum bt_component_status muxer_port_connected(
- struct bt_private_component *priv_comp,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port);
+enum bt_self_component_status muxer_input_port_connected(
+ struct bt_self_component_filter *comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port);
BT_HIDDEN
-void muxer_port_disconnected(
- struct bt_private_component *priv_comp,
- struct bt_private_port *priv_port);
+void muxer_input_port_disconnected(
+ struct bt_self_component_filter *self_component,
+ struct bt_self_component_port_input *self_port);
#endif /* BABELTRACE_PLUGINS_UTILS_MUXER_H */
#include <babeltrace/babeltrace.h>
#include "dummy/dummy.h"
#include "counter/counter.h"
-#include "trimmer/trimmer.h"
-#include "trimmer/iterator.h"
#include "muxer/muxer.h"
#ifndef BT_BUILT_IN_PLUGINS
BT_PLUGIN_SINK_COMPONENT_CLASS(dummy, dummy_consume);
BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(dummy, dummy_init);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dummy, dummy_finalize);
-BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD(dummy,
+BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(dummy,
dummy_port_connected);
BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(dummy,
"Consume notifications and discard them.");
BT_PLUGIN_SINK_COMPONENT_CLASS(counter, counter_consume);
BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(counter, counter_init);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(counter, counter_finalize);
-BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD(counter,
+BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(counter,
counter_port_connected);
BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(counter,
"Count notifications and print the results.");
"Sort notifications from multiple input ports to a single output port by time.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(muxer, muxer_init);
BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(muxer, muxer_finalize);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_DISCONNECTED_METHOD(muxer,
- muxer_port_disconnected);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_PORT_CONNECTED_METHOD(muxer,
- muxer_port_connected);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD(muxer,
+ muxer_input_port_disconnected);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(muxer,
+ muxer_input_port_connected);
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(muxer,
muxer_notif_iter_init);
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(muxer,
}
BT_HIDDEN
-void trimmer_iterator_finalize(struct bt_private_connection_private_notification_iterator *it)
+void trimmer_iterator_finalize(struct bt_self_notification_iterator *it)
{
struct trimmer_iterator *trim_it;
- trim_it = bt_private_connection_private_notification_iterator_get_user_data(it);
+ trim_it = bt_self_notification_iterator_get_user_data(it);
BT_ASSERT(trim_it);
bt_object_put_ref(trim_it->input_iterator);
BT_HIDDEN
enum bt_notification_iterator_status trimmer_iterator_init(
- struct bt_private_connection_private_notification_iterator *iterator,
+ struct bt_self_notification_iterator *iterator,
struct bt_private_port *port)
{
enum bt_notification_iterator_status ret =
enum bt_connection_status conn_status;
struct bt_private_port *input_port = NULL;
struct bt_private_connection *connection = NULL;
- struct bt_private_component *component =
- bt_private_connection_private_notification_iterator_get_private_component(iterator);
+ struct bt_self_component *component =
+ bt_self_notification_iterator_get_private_component(iterator);
struct trimmer_iterator *it_data = g_new0(struct trimmer_iterator, 1);
if (!it_data) {
}
/* Create a new iterator on the upstream component. */
- input_port = bt_private_component_filter_get_input_port_by_name(
+ input_port = bt_self_component_filter_get_input_port_by_name(
component, "in");
BT_ASSERT(input_port);
connection = bt_private_port_get_connection(input_port);
it_data->packet_map = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL, NULL);
- it_ret = bt_private_connection_private_notification_iterator_set_user_data(iterator,
+ it_ret = bt_self_notification_iterator_set_user_data(iterator,
it_data);
if (it_ret) {
goto end;
BT_HIDDEN
struct bt_notification_iterator_next_method_return trimmer_iterator_next(
- struct bt_private_connection_private_notification_iterator *iterator)
+ struct bt_self_notification_iterator *iterator)
{
struct trimmer_iterator *trim_it = NULL;
- struct bt_private_component *component = NULL;
+ struct bt_self_component *component = NULL;
struct trimmer *trimmer = NULL;
struct bt_notification_iterator *source_it = NULL;
struct bt_notification_iterator_next_method_return ret = {
};
bool notification_in_range = false;
- trim_it = bt_private_connection_private_notification_iterator_get_user_data(iterator);
+ trim_it = bt_self_notification_iterator_get_user_data(iterator);
BT_ASSERT(trim_it);
- component = bt_private_connection_private_notification_iterator_get_private_component(
+ component = bt_self_notification_iterator_get_private_component(
iterator);
BT_ASSERT(component);
- trimmer = bt_private_component_get_user_data(component);
+ trimmer = bt_self_component_get_user_data(component);
BT_ASSERT(trimmer);
source_it = trim_it->input_iterator;
BT_HIDDEN
enum bt_notification_iterator_status trimmer_iterator_init(
- struct bt_private_connection_private_notification_iterator *iterator,
+ struct bt_self_notification_iterator *iterator,
struct bt_private_port *port);
BT_HIDDEN
-void trimmer_iterator_finalize(struct bt_private_connection_private_notification_iterator *it);
+void trimmer_iterator_finalize(struct bt_self_notification_iterator *it);
BT_HIDDEN
struct bt_notification_iterator_next_method_return trimmer_iterator_next(
- struct bt_private_connection_private_notification_iterator *iterator);
+ struct bt_self_notification_iterator *iterator);
#endif /* BABELTRACE_PLUGIN_TRIMMER_ITERATOR_H */
return g_new0(struct trimmer, 1);
}
-void finalize_trimmer(struct bt_private_component *component)
+void finalize_trimmer(struct bt_self_component *component)
{
- void *data = bt_private_component_get_user_data(component);
+ void *data = bt_self_component_get_user_data(component);
destroy_trimmer_data(data);
}
}
enum bt_component_status trimmer_component_init(
- struct bt_private_component *component, struct bt_value *params,
+ struct bt_self_component *component, struct bt_value *params,
UNUSED_VAR void *init_method_data)
{
enum bt_component_status ret;
}
/* Create input and output ports */
- ret = bt_private_component_filter_add_input_port(
+ ret = bt_self_component_filter_add_input_port(
component, "in", NULL, NULL);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
- ret = bt_private_component_filter_add_output_port(
+ ret = bt_self_component_filter_add_output_port(
component, "out", NULL, NULL);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
- ret = bt_private_component_set_user_data(component, trimmer);
+ ret = bt_self_component_set_user_data(component, trimmer);
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
};
enum bt_component_status trimmer_component_init(
- struct bt_private_component *component,
+ struct bt_self_component *component,
struct bt_value *params, void *init_method_data);
-void finalize_trimmer(struct bt_private_component *component);
+void finalize_trimmer(struct bt_self_component *component);
#endif /* BABELTRACE_PLUGINS_UTILS_TRIMMER_H */
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-internal.h>
-static enum bt_component_status sink_consume(
- struct bt_private_component *private_component)
+static enum bt_self_component_status sink_consume(
+ struct bt_self_component_sink *self_comp)
{
- return BT_COMPONENT_STATUS_OK;
+ return BT_SELF_COMPONENT_STATUS_OK;
}
-static enum bt_notification_iterator_status dummy_iterator_init_method(
- struct bt_private_connection_private_notification_iterator *private_iterator,
- struct bt_private_port *private_port)
+static enum bt_self_notification_iterator_status src_dummy_iterator_init_method(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_port)
{
- return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
+}
+
+static enum bt_self_notification_iterator_status flt_dummy_iterator_init_method(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_filter *self_comp,
+ struct bt_self_component_port_output *self_port)
+{
+ return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
}
static void dummy_iterator_finalize_method(
- struct bt_private_connection_private_notification_iterator *private_iterator)
+ struct bt_self_notification_iterator *self_notif_iter)
{
}
-static enum bt_notification_iterator_status dummy_iterator_next_method(
- struct bt_private_connection_private_notification_iterator *private_iterator,
+static enum bt_self_notification_iterator_status dummy_iterator_next_method(
+ struct bt_self_notification_iterator *self_notif_iter,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count)
{
- return BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
}
-static struct bt_component_class_query_method_return query_method(
- struct bt_component_class *component_class,
+static enum bt_query_status flt_query_method(
+ struct bt_self_component_class_filter *component_class,
struct bt_query_executor *query_exec,
- const char *object, struct bt_value *params)
+ const char *object, struct bt_value *params,
+ struct bt_value **result)
{
- struct bt_private_value *results = bt_private_value_array_create();
- struct bt_component_class_query_method_return ret = {
- .status = BT_QUERY_STATUS_OK,
- .result = bt_value_borrow_from_private(results),
- };
+ struct bt_private_value *res = bt_private_value_array_create();
+ *result = bt_private_value_borrow_value(res);
int iret;
- BT_ASSERT(ret.result);
- iret = bt_private_value_array_append_string_element(results, object);
+ BT_ASSERT(*result);
+ iret = bt_private_value_array_append_string_element(res, object);
BT_ASSERT(iret == 0);
- iret = bt_private_value_array_append_element(results, params);
+ iret = bt_private_value_array_append_element(res, params);
BT_ASSERT(iret == 0);
- return ret;
+ return BT_QUERY_STATUS_OK;
}
BT_PLUGIN_MODULE();
BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source,
- dummy_iterator_init_method);
+ src_dummy_iterator_init_method);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(source,
dummy_iterator_finalize_method);
BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter,
- dummy_iterator_init_method);
+ flt_dummy_iterator_init_method);
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(filter,
dummy_iterator_finalize_method);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, query_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method);
static enum test current_test;
static GArray *test_events;
static struct bt_private_graph *graph;
-static struct bt_private_connection_private_notification_iterator *cur_notif_iter;
static struct bt_private_stream_class *src_stream_class;
static struct bt_private_event_class *src_event_class;
static struct bt_private_stream *src_stream1;
};
struct sink_user_data {
- struct bt_notification_iterator *notif_iter;
+ void *notif_iter;
};
/*
BT_ASSERT(src_event_class);
src_stream1 = bt_private_stream_create(src_stream_class);
BT_ASSERT(src_stream1);
- pub_src_stream1 = bt_stream_borrow_from_private(src_stream1);
+ pub_src_stream1 = bt_private_stream_borrow_stream(src_stream1);
src_stream2 = bt_private_stream_create(src_stream_class);
BT_ASSERT(src_stream2);
- pub_src_stream2 = bt_stream_borrow_from_private(src_stream2);
+ pub_src_stream2 = bt_private_stream_borrow_stream(src_stream2);
src_stream1_packet1 = bt_private_packet_create(src_stream1);
BT_ASSERT(src_stream1_packet1);
- pub_src_stream1_packet1 = bt_packet_borrow_from_private(
+ pub_src_stream1_packet1 = bt_private_packet_borrow_packet(
src_stream1_packet1);
src_stream1_packet2 = bt_private_packet_create(src_stream1);
BT_ASSERT(src_stream1_packet2);
- pub_src_stream1_packet2 = bt_packet_borrow_from_private(
+ pub_src_stream1_packet2 = bt_private_packet_borrow_packet(
src_stream1_packet2);
src_stream2_packet1 = bt_private_packet_create(src_stream2);
BT_ASSERT(src_stream2_packet1);
- pub_src_stream2_packet1 = bt_packet_borrow_from_private(
+ pub_src_stream2_packet1 = bt_private_packet_borrow_packet(
src_stream2_packet1);
src_stream2_packet2 = bt_private_packet_create(src_stream2);
BT_ASSERT(src_stream2_packet2);
- pub_src_stream2_packet2 = bt_packet_borrow_from_private(
+ pub_src_stream2_packet2 = bt_private_packet_borrow_packet(
src_stream2_packet2);
if (debug) {
}
static
-void src_iter_finalize(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator)
+void src_iter_finalize(struct bt_self_notification_iterator *self_notif_iter)
{
struct src_iter_user_data *user_data =
- bt_private_connection_private_notification_iterator_get_user_data(
- private_notification_iterator);
+ bt_self_notification_iterator_get_data(
+ self_notif_iter);
if (user_data) {
g_free(user_data);
}
static
-enum bt_notification_iterator_status src_iter_init(
- struct bt_private_connection_private_notification_iterator *priv_notif_iter,
- struct bt_private_port *private_port)
+enum bt_self_notification_iterator_status src_iter_init(
+ struct bt_self_notification_iterator *self_notif_iter,
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_port)
{
struct src_iter_user_data *user_data =
g_new0(struct src_iter_user_data, 1);
- int ret;
BT_ASSERT(user_data);
- ret = bt_private_connection_private_notification_iterator_set_user_data(
- priv_notif_iter, user_data);
- BT_ASSERT(ret == 0);
+ bt_self_notification_iterator_set_data(self_notif_iter, user_data);
switch (current_test) {
case TEST_NO_AUTO_NOTIFS:
abort();
}
- return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
}
static
-void src_iter_next_seq_one(struct src_iter_user_data *user_data,
+void src_iter_next_seq_one(struct bt_self_notification_iterator* notif_iter,
+ struct src_iter_user_data *user_data,
struct bt_notification **notif)
{
struct bt_private_packet *event_packet = NULL;
switch (user_data->seq[user_data->at]) {
case SEQ_STREAM1_BEGIN:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_stream_begin_create(
- cur_notif_iter, src_stream1));
+ notif_iter, src_stream1));
break;
case SEQ_STREAM2_BEGIN:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_stream_begin_create(
- cur_notif_iter, src_stream2));
+ notif_iter, src_stream2));
break;
case SEQ_STREAM1_END:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_stream_end_create(
- cur_notif_iter, src_stream1));
+ notif_iter, src_stream1));
break;
case SEQ_STREAM2_END:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_stream_end_create(
- cur_notif_iter, src_stream2));
+ notif_iter, src_stream2));
break;
case SEQ_STREAM1_PACKET1_BEGIN:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_begin_create(
- cur_notif_iter, src_stream1_packet1));
+ notif_iter, src_stream1_packet1));
break;
case SEQ_STREAM1_PACKET2_BEGIN:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_begin_create(
- cur_notif_iter, src_stream1_packet2));
+ notif_iter, src_stream1_packet2));
break;
case SEQ_STREAM2_PACKET1_BEGIN:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_begin_create(
- cur_notif_iter, src_stream2_packet1));
+ notif_iter, src_stream2_packet1));
break;
case SEQ_STREAM2_PACKET2_BEGIN:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_begin_create(
- cur_notif_iter, src_stream2_packet2));
+ notif_iter, src_stream2_packet2));
break;
case SEQ_STREAM1_PACKET1_END:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_end_create(
- cur_notif_iter, src_stream1_packet1));
+ notif_iter, src_stream1_packet1));
break;
case SEQ_STREAM1_PACKET2_END:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_end_create(
- cur_notif_iter, src_stream1_packet2));
+ notif_iter, src_stream1_packet2));
break;
case SEQ_STREAM2_PACKET1_END:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_end_create(
- cur_notif_iter, src_stream2_packet1));
+ notif_iter, src_stream2_packet1));
break;
case SEQ_STREAM2_PACKET2_END:
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_packet_end_create(
- cur_notif_iter, src_stream2_packet2));
+ notif_iter, src_stream2_packet2));
break;
case SEQ_EVENT_STREAM1_PACKET1:
event_packet = src_stream1_packet1;
}
if (event_packet) {
- *notif = bt_notification_borrow_from_private(
+ *notif = bt_private_notification_borrow_notification(
bt_private_notification_event_create(
- cur_notif_iter, src_event_class, event_packet));
+ notif_iter, src_event_class, event_packet));
}
BT_ASSERT(*notif);
}
static
-enum bt_notification_iterator_status src_iter_next_seq(
+enum bt_self_notification_iterator_status src_iter_next_seq(
+ struct bt_self_notification_iterator *notif_iter,
struct src_iter_user_data *user_data,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count)
{
- enum bt_notification_iterator_status status =
- BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ enum bt_self_notification_iterator_status status =
+ BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
uint64_t i = 0;
BT_ASSERT(user_data->seq);
if (user_data->seq[user_data->at] == SEQ_END) {
- status = BT_NOTIFICATION_ITERATOR_STATUS_END;
+ status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_END;
goto end;
}
while (i < capacity && user_data->seq[user_data->at] != SEQ_END) {
- src_iter_next_seq_one(user_data, ¬ifs[i]);
+ src_iter_next_seq_one(notif_iter, user_data, ¬ifs[i]);
i++;
}
}
static
-enum bt_notification_iterator_status src_iter_next(
- struct bt_private_connection_private_notification_iterator *priv_iterator,
+enum bt_self_notification_iterator_status src_iter_next(
+ struct bt_self_notification_iterator *self_notif_iter,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count)
{
struct src_iter_user_data *user_data =
- bt_private_connection_private_notification_iterator_get_user_data(priv_iterator);
+ bt_self_notification_iterator_get_data(self_notif_iter);
BT_ASSERT(user_data);
- cur_notif_iter = priv_iterator;
- return src_iter_next_seq(user_data, notifs, capacity, count);
+ return src_iter_next_seq(self_notif_iter, user_data, notifs,
+ capacity, count);
}
static
-enum bt_component_status src_init(
- struct bt_private_component *private_component,
+enum bt_self_component_status src_init(
+ struct bt_self_component_source *self_comp,
struct bt_value *params, void *init_method_data)
{
int ret;
- ret = bt_private_component_source_add_output_port(
- private_component, "out", NULL, NULL);
+ ret = bt_self_component_source_add_output_port(
+ self_comp, "out", NULL, NULL);
BT_ASSERT(ret == 0);
- return BT_COMPONENT_STATUS_OK;
+ return BT_SELF_COMPONENT_STATUS_OK;
}
static
-void src_finalize(struct bt_private_component *private_component)
+void src_finalize(struct bt_self_component_source *self_comp)
{
}
static
enum bt_notification_iterator_status common_consume(
- struct bt_notification_iterator *notif_iter,
- bool is_output_port_notif_iter)
+ void *notif_iter, bool is_output_port_notif_iter)
{
enum bt_notification_iterator_status ret;
bt_notification_array notifications = NULL;
BT_ASSERT(notif_iter);
if (is_output_port_notif_iter) {
- ret = bt_output_port_notification_iterator_next(notif_iter,
+ ret = bt_port_output_notification_iterator_next(notif_iter,
¬ifications, &count);
} else {
- ret = bt_private_connection_notification_iterator_next(
+ ret = bt_self_component_port_input_notification_iterator_next(
notif_iter, ¬ifications, &count);
}
}
static
-enum bt_component_status sink_consume(
- struct bt_private_component *priv_component)
+enum bt_self_component_status sink_consume(
+ struct bt_self_component_sink *self_comp)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
struct sink_user_data *user_data =
- bt_private_component_get_user_data(priv_component);
+ bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(
+ self_comp));
enum bt_notification_iterator_status it_ret;
BT_ASSERT(user_data && user_data->notif_iter);
it_ret = common_consume(user_data->notif_iter, false);
if (it_ret < 0) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ ret = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
}
switch (it_ret) {
case BT_NOTIFICATION_ITERATOR_STATUS_END:
- ret = BT_COMPONENT_STATUS_END;
+ ret = BT_SELF_COMPONENT_STATUS_END;
BT_OBJECT_PUT_REF_AND_RESET(user_data->notif_iter);
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
}
static
-enum bt_component_status sink_port_connected(
- struct bt_private_component *private_component,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port)
+enum bt_self_component_status sink_port_connected(
+ struct bt_self_component_sink *self_comp,
+ struct bt_self_component_port_input *self_port,
+ struct bt_port_output *other_port)
{
- struct bt_private_connection *priv_conn =
- bt_private_port_get_connection(self_private_port);
- struct sink_user_data *user_data = bt_private_component_get_user_data(
- private_component);
- enum bt_connection_status conn_status;
+ struct sink_user_data *user_data =
+ bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(
+ self_comp));
BT_ASSERT(user_data);
- BT_ASSERT(priv_conn);
- conn_status = bt_private_connection_create_notification_iterator(
- priv_conn, &user_data->notif_iter);
- BT_ASSERT(conn_status == 0);
- bt_object_put_ref(priv_conn);
- return BT_COMPONENT_STATUS_OK;
+ user_data->notif_iter =
+ bt_self_component_port_input_notification_iterator_create(
+ self_port);
+ return BT_SELF_COMPONENT_STATUS_OK;
}
static
-enum bt_component_status sink_init(
- struct bt_private_component *private_component,
+enum bt_self_component_status sink_init(
+ struct bt_self_component_sink *self_comp,
struct bt_value *params, void *init_method_data)
{
struct sink_user_data *user_data = g_new0(struct sink_user_data, 1);
int ret;
BT_ASSERT(user_data);
- ret = bt_private_component_set_user_data(private_component,
+ bt_self_component_set_data(
+ bt_self_component_sink_borrow_self_component(self_comp),
user_data);
+ ret = bt_self_component_sink_add_input_port(
+ self_comp, "in", NULL, NULL);
BT_ASSERT(ret == 0);
- ret = bt_private_component_sink_add_input_port(
- private_component, "in", NULL, NULL);
- BT_ASSERT(ret == 0);
- return BT_COMPONENT_STATUS_OK;
+ return BT_SELF_COMPONENT_STATUS_OK;
}
static
-void sink_finalize(struct bt_private_component *private_component)
+void sink_finalize(struct bt_self_component_sink *self_comp)
{
- struct sink_user_data *user_data = bt_private_component_get_user_data(
- private_component);
+ struct sink_user_data *user_data =
+ bt_self_component_get_data(
+ bt_self_component_sink_borrow_self_component(
+ self_comp));
if (user_data) {
bt_object_put_ref(user_data->notif_iter);
}
static
-void create_source_sink(struct bt_private_graph *graph, struct bt_component **source,
- struct bt_component **sink)
+void create_source_sink(struct bt_private_graph *graph,
+ struct bt_component_source **source,
+ struct bt_component_sink **sink)
{
- struct bt_component_class *src_comp_class;
- struct bt_component_class *sink_comp_class;
+ struct bt_private_component_class_source *src_comp_class;
+ struct bt_private_component_class_sink *sink_comp_class;
int ret;
/* Create source component */
if (source) {
- src_comp_class = bt_component_class_source_create("src",
+ src_comp_class = bt_private_component_class_source_create("src",
src_iter_next);
BT_ASSERT(src_comp_class);
- ret = bt_component_class_set_init_method(src_comp_class,
- src_init);
+ ret = bt_private_component_class_source_set_init_method(
+ src_comp_class, src_init);
BT_ASSERT(ret == 0);
- ret = bt_component_class_set_finalize_method(src_comp_class,
- src_finalize);
+ ret = bt_private_component_class_source_set_finalize_method(
+ src_comp_class, src_finalize);
BT_ASSERT(ret == 0);
- ret = bt_component_class_source_set_notification_iterator_init_method(
+ ret = bt_private_component_class_source_set_notification_iterator_init_method(
src_comp_class, src_iter_init);
BT_ASSERT(ret == 0);
- ret = bt_component_class_source_set_notification_iterator_finalize_method(
+ ret = bt_private_component_class_source_set_notification_iterator_finalize_method(
src_comp_class, src_iter_finalize);
BT_ASSERT(ret == 0);
- ret = bt_private_graph_add_component(graph, src_comp_class, "source",
- NULL, source);
+ ret = bt_private_graph_add_source_component(graph,
+ bt_private_component_class_source_borrow_component_class_source(
+ src_comp_class), "source", NULL, source);
BT_ASSERT(ret == 0);
bt_object_put_ref(src_comp_class);
}
/* Create sink component */
if (sink) {
- sink_comp_class = bt_component_class_sink_create("sink",
+ sink_comp_class = bt_private_component_class_sink_create("sink",
sink_consume);
BT_ASSERT(sink_comp_class);
- ret = bt_component_class_set_init_method(sink_comp_class,
- sink_init);
+ ret = bt_private_component_class_sink_set_init_method(
+ sink_comp_class, sink_init);
BT_ASSERT(ret == 0);
- ret = bt_component_class_set_finalize_method(sink_comp_class,
- sink_finalize);
- ret = bt_component_class_set_port_connected_method(
+ ret = bt_private_component_class_sink_set_finalize_method(
+ sink_comp_class, sink_finalize);
+ ret = bt_private_component_class_sink_set_input_port_connected_method(
sink_comp_class, sink_port_connected);
BT_ASSERT(ret == 0);
- ret = bt_private_graph_add_component(graph, sink_comp_class, "sink",
- NULL, sink);
+ ret = bt_private_graph_add_sink_component(graph,
+ bt_private_component_class_sink_borrow_component_class_sink(
+ sink_comp_class),
+ "sink", NULL, sink);
BT_ASSERT(ret == 0);
bt_object_put_ref(sink_comp_class);
}
void do_std_test(enum test test, const char *name,
const struct test_event *expected_test_events)
{
- struct bt_component *src_comp;
- struct bt_component *sink_comp;
- struct bt_port *upstream_port;
- struct bt_port *downstream_port;
+ struct bt_component_source *src_comp;
+ struct bt_component_sink *sink_comp;
+ struct bt_port_output *upstream_port;
+ struct bt_port_input *downstream_port;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
clear_test_events();
create_source_sink(graph, &src_comp, &sink_comp);
/* Connect source to sink */
- upstream_port = bt_component_source_get_output_port_by_name(src_comp, "out");
+ upstream_port = bt_component_source_borrow_output_port_by_name(
+ src_comp, "out");
BT_ASSERT(upstream_port);
- downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in");
+ downstream_port = bt_component_sink_borrow_input_port_by_name(
+ sink_comp, "in");
BT_ASSERT(downstream_port);
graph_status = bt_private_graph_connect_ports(graph, upstream_port,
downstream_port, NULL);
- bt_object_put_ref(upstream_port);
- bt_object_put_ref(downstream_port);
/* Run the graph until the end */
while (graph_status == BT_GRAPH_STATUS_OK ||
graph_status = bt_private_graph_run(graph);
}
- ok(graph_status == BT_GRAPH_STATUS_END, "graph finishes without any error");
+ ok(graph_status == BT_GRAPH_STATUS_END,
+ "graph finishes without any error");
/* Compare the resulting test events */
if (expected_test_events) {
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
- struct bt_component *src_comp;
- struct bt_notification_iterator *notif_iter;
+ struct bt_component_source *src_comp;
+ struct bt_port_output_notification_iterator *notif_iter;
enum bt_notification_iterator_status iter_status =
BT_NOTIFICATION_ITERATOR_STATUS_OK;
- struct bt_port *upstream_port;
+ struct bt_port_output *upstream_port;
clear_test_events();
current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR;
create_source_sink(graph, &src_comp, NULL);
/* Create notification iterator on source's output port */
- upstream_port = bt_component_source_get_output_port_by_name(src_comp, "out");
- notif_iter = bt_output_port_notification_iterator_create(upstream_port,
- NULL);
+ upstream_port = bt_component_source_borrow_output_port_by_name(
+ src_comp, "out");
+ notif_iter = bt_port_output_notification_iterator_create(graph,
+ upstream_port, NULL);
ok(notif_iter, "bt_private_output_port_notification_iterator_create() succeeds");
- bt_object_put_ref(upstream_port);
/* Consume the notification iterator */
while (iter_status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
struct bt_value *obj;
priv_obj = bt_private_value_bool_create();
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_bool(obj),
"bt_private_value_bool_create() returns a boolean value object");
value = BT_FALSE;
priv_obj = bt_private_value_bool_create_init(BT_TRUE);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_bool(obj),
"bt_private_value_bool_create_init() returns a boolean value object");
value = bt_value_bool_get(obj);
struct bt_value *obj;
priv_obj = bt_private_value_integer_create();
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_integer(obj),
"bt_private_value_integer_create() returns an integer value object");
pass("putting an existing integer value object does not cause a crash")
priv_obj = bt_private_value_integer_create_init(321456987);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_integer(obj),
"bt_private_value_integer_create_init() returns an integer value object");
value = bt_value_integer_get(obj);
struct bt_value *obj;
priv_obj = bt_private_value_real_create();
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_real(obj),
"bt_private_value_real_create() returns a real number value object");
pass("putting an existing real number value object does not cause a crash")
priv_obj = bt_private_value_real_create_init(33.1649758);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_real(obj),
"bt_private_value_real_create_init() returns a real number value object");
value = bt_value_real_get(obj);
struct bt_value *obj;
priv_obj = bt_private_value_string_create();
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_string(obj),
"bt_private_value_string_create() returns a string value object");
pass("putting an existing string value object does not cause a crash")
priv_obj = bt_private_value_string_create_init("initial value");
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ok(obj && bt_value_is_string(obj),
"bt_private_value_string_create_init() returns a string value object");
value = bt_value_string_get(obj);
struct bt_value *array_obj;
priv_array_obj = bt_private_value_array_create();
- array_obj = bt_value_borrow_from_private(priv_array_obj);
+ array_obj = bt_private_value_borrow_value(priv_array_obj);
ok(array_obj && bt_value_is_array(array_obj),
"bt_private_value_array_create() returns an array value object");
ok(bt_value_array_is_empty(array_obj),
"initial array value object size is 0");
priv_obj = bt_private_value_integer_create_init(345);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ret = bt_private_value_array_append_element(priv_array_obj, obj);
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
priv_obj = bt_private_value_real_create_init(-17.45);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ret |= bt_private_value_array_append_element(priv_array_obj, obj);
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
priv_obj = bt_private_value_bool_create_init(BT_TRUE);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ret |= bt_private_value_array_append_element(priv_array_obj, obj);
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
ret |= bt_private_value_array_append_element(priv_array_obj,
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (null)");
priv_obj = bt_private_value_integer_create_init(1001);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
BT_ASSERT(obj);
ok(!bt_private_value_array_set_element_by_index(priv_array_obj, 2, obj),
"bt_value_array_set_element_by_index() succeeds");
struct map_foreach_checklist checklist;
priv_map_obj = bt_private_value_map_create();
- map_obj = bt_value_borrow_from_private(priv_map_obj);
+ map_obj = bt_private_value_borrow_value(priv_map_obj);
ok(map_obj && bt_value_is_map(map_obj),
"bt_private_value_map_create() returns a map value object");
ok(bt_value_map_get_size(map_obj) == 0,
"initial map value object size is 0");
priv_obj = bt_private_value_integer_create_init(19457);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ret = bt_private_value_map_insert_entry(priv_map_obj, "int", obj);
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
priv_obj = bt_private_value_real_create_init(5.444);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ret |= bt_private_value_map_insert_entry(priv_map_obj, "real", obj);
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
priv_obj = bt_private_value_bool_create();
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ret |= bt_private_value_map_insert_entry(priv_map_obj, "bt_bool", obj);
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
ret |= bt_private_value_map_insert_entry(priv_map_obj, "null",
"inserting an element into a map value object increment its size");
priv_obj = bt_private_value_bool_create_init(BT_TRUE);
- obj = bt_value_borrow_from_private(priv_obj);
+ obj = bt_private_value_borrow_value(priv_obj);
ret = bt_private_value_map_insert_entry(priv_map_obj, "bt_bool", obj);
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
ok(!ret, "bt_private_value_map_insert_entry() accepts an existing key");
BT_ASSERT(bool1 && bool2 && bool3);
ok(!bt_value_compare(bt_value_null,
- bt_value_borrow_from_private(bool1)),
+ bt_private_value_borrow_value(bool1)),
"cannot compare null value object and bt_bool value object");
- ok(!bt_value_compare(bt_value_borrow_from_private(bool1),
- bt_value_borrow_from_private(bool2)),
+ ok(!bt_value_compare(bt_private_value_borrow_value(bool1),
+ bt_private_value_borrow_value(bool2)),
"boolean value objects are not equivalent (BT_FALSE and BT_TRUE)");
- ok(bt_value_compare(bt_value_borrow_from_private(bool1),
- bt_value_borrow_from_private(bool3)),
+ ok(bt_value_compare(bt_private_value_borrow_value(bool1),
+ bt_private_value_borrow_value(bool3)),
"boolean value objects are equivalent (BT_FALSE and BT_FALSE)");
BT_OBJECT_PUT_REF_AND_RESET(bool1);
BT_ASSERT(int1 && int2 && int3);
ok(!bt_value_compare(bt_value_null,
- bt_value_borrow_from_private(int1)),
+ bt_private_value_borrow_value(int1)),
"cannot compare null value object and integer value object");
- ok(!bt_value_compare(bt_value_borrow_from_private(int1),
- bt_value_borrow_from_private(int2)),
+ ok(!bt_value_compare(bt_private_value_borrow_value(int1),
+ bt_private_value_borrow_value(int2)),
"integer value objects are not equivalent (10 and -23)");
- ok(bt_value_compare(bt_value_borrow_from_private(int1),
- bt_value_borrow_from_private(int3)),
+ ok(bt_value_compare(bt_private_value_borrow_value(int1),
+ bt_private_value_borrow_value(int3)),
"integer value objects are equivalent (10 and 10)");
BT_OBJECT_PUT_REF_AND_RESET(int1);
BT_ASSERT(real1 && real2 && real3);
ok(!bt_value_compare(bt_value_null,
- bt_value_borrow_from_private(real1)),
+ bt_private_value_borrow_value(real1)),
"cannot compare null value object and real number value object");
- ok(!bt_value_compare(bt_value_borrow_from_private(real1),
- bt_value_borrow_from_private(real2)),
+ ok(!bt_value_compare(bt_private_value_borrow_value(real1),
+ bt_private_value_borrow_value(real2)),
"real number value objects are not equivalent (17.38 and -14.23)");
- ok(bt_value_compare(bt_value_borrow_from_private(real1),
- bt_value_borrow_from_private(real3)),
+ ok(bt_value_compare(bt_private_value_borrow_value(real1),
+ bt_private_value_borrow_value(real3)),
"real number value objects are equivalent (17.38 and 17.38)");
BT_OBJECT_PUT_REF_AND_RESET(real1);
BT_ASSERT(string1 && string2 && string3);
ok(!bt_value_compare(bt_value_null,
- bt_value_borrow_from_private(string1)),
+ bt_private_value_borrow_value(string1)),
"cannot compare null value object and string value object");
- ok(!bt_value_compare(bt_value_borrow_from_private(string1),
- bt_value_borrow_from_private(string2)),
+ ok(!bt_value_compare(bt_private_value_borrow_value(string1),
+ bt_private_value_borrow_value(string2)),
"string value objects are not equivalent (\"hello\" and \"bt_value\")");
- ok(bt_value_compare(bt_value_borrow_from_private(string1),
- bt_value_borrow_from_private(string3)),
+ ok(bt_value_compare(bt_private_value_borrow_value(string1),
+ bt_private_value_borrow_value(string3)),
"string value objects are equivalent (\"hello\" and \"hello\")");
BT_OBJECT_PUT_REF_AND_RESET(string1);
BT_ASSERT(array1 && array2 && array3);
- ok(bt_value_compare(bt_value_borrow_from_private(array1),
- bt_value_borrow_from_private(array2)),
+ ok(bt_value_compare(bt_private_value_borrow_value(array1),
+ bt_private_value_borrow_value(array2)),
"empty array value objects are equivalent");
status = bt_private_value_array_append_integer_element(array1, 23);
status = bt_private_value_array_append_bool_element(array3, BT_FALSE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
BT_ASSERT(bt_value_array_get_size(
- bt_value_borrow_from_private(array1)) == 3);
+ bt_private_value_borrow_value(array1)) == 3);
BT_ASSERT(bt_value_array_get_size(
- bt_value_borrow_from_private(array2)) == 3);
+ bt_private_value_borrow_value(array2)) == 3);
BT_ASSERT(bt_value_array_get_size(
- bt_value_borrow_from_private(array3)) == 3);
+ bt_private_value_borrow_value(array3)) == 3);
ok(!bt_value_compare(bt_value_null,
- bt_value_borrow_from_private(array1)),
+ bt_private_value_borrow_value(array1)),
"cannot compare null value object and array value object");
- ok(!bt_value_compare(bt_value_borrow_from_private(array1),
- bt_value_borrow_from_private(array2)),
+ ok(!bt_value_compare(bt_private_value_borrow_value(array1),
+ bt_private_value_borrow_value(array2)),
"array value objects are not equivalent ([23, 14.2, BT_FALSE] and [14.2, 23, BT_FALSE])");
- ok(bt_value_compare(bt_value_borrow_from_private(array1),
- bt_value_borrow_from_private(array3)),
+ ok(bt_value_compare(bt_private_value_borrow_value(array1),
+ bt_private_value_borrow_value(array3)),
"array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])");
BT_OBJECT_PUT_REF_AND_RESET(array1);
BT_ASSERT(map1 && map2 && map3);
- ok(bt_value_compare(bt_value_borrow_from_private(map1),
- bt_value_borrow_from_private(map2)),
+ ok(bt_value_compare(bt_private_value_borrow_value(map1),
+ bt_private_value_borrow_value(map2)),
"empty map value objects are equivalent");
status = bt_private_value_map_insert_real_entry(map3, "two", 14.2);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
BT_ASSERT(bt_value_map_get_size(
- bt_value_borrow_from_private(map1)) == 3);
+ bt_private_value_borrow_value(map1)) == 3);
BT_ASSERT(bt_value_map_get_size(
- bt_value_borrow_from_private(map2)) == 3);
+ bt_private_value_borrow_value(map2)) == 3);
BT_ASSERT(bt_value_map_get_size(
- bt_value_borrow_from_private(map3)) == 3);
+ bt_private_value_borrow_value(map3)) == 3);
ok(!bt_value_compare(bt_value_null,
- bt_value_borrow_from_private(map1)),
+ bt_private_value_borrow_value(map1)),
"cannot compare null value object and map value object");
- ok(!bt_value_compare(bt_value_borrow_from_private(map1),
- bt_value_borrow_from_private(map2)),
+ ok(!bt_value_compare(bt_private_value_borrow_value(map1),
+ bt_private_value_borrow_value(map2)),
"map value objects are not equivalent");
- ok(bt_value_compare(bt_value_borrow_from_private(map1),
- bt_value_borrow_from_private(map3)),
+ ok(bt_value_compare(bt_private_value_borrow_value(map1),
+ bt_private_value_borrow_value(map3)),
"map value objects are equivalent");
BT_OBJECT_PUT_REF_AND_RESET(map1);
array_obj && map_obj);
status = bt_private_value_array_append_element(array_obj,
- bt_value_borrow_from_private(bool_obj));
+ bt_private_value_borrow_value(bool_obj));
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_private_value_array_append_element(array_obj,
- bt_value_borrow_from_private(integer_obj));
+ bt_private_value_borrow_value(integer_obj));
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_private_value_array_append_element(array_obj,
- bt_value_borrow_from_private(real_obj));
+ bt_private_value_borrow_value(real_obj));
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_private_value_array_append_element(array_obj,
bt_value_null);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_private_value_map_insert_entry(map_obj, "array",
- bt_value_borrow_from_private(array_obj));
+ bt_private_value_borrow_value(array_obj));
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_private_value_map_insert_entry(map_obj, "string",
- bt_value_borrow_from_private(string_obj));
+ bt_private_value_borrow_value(string_obj));
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_value_copy(&map_copy_obj,
- bt_value_borrow_from_private(map_obj));
+ bt_private_value_borrow_value(map_obj));
ok(status == BT_VALUE_STATUS_OK && map_copy_obj,
"bt_value_copy() succeeds");
"bt_value_copy() returns a different pointer (real)");
null_copy_obj = bt_private_value_array_borrow_element_by_index(
array_copy_obj, 3);
- ok(bt_value_borrow_from_private(null_copy_obj) == bt_value_null,
+ ok(bt_private_value_borrow_value(null_copy_obj) == bt_value_null,
"bt_value_copy() returns the same pointer (null)");
- ok(bt_value_compare(bt_value_borrow_from_private(map_obj),
- bt_value_borrow_from_private(map_copy_obj)),
+ ok(bt_value_compare(bt_private_value_borrow_value(map_obj),
+ bt_private_value_borrow_value(map_copy_obj)),
"source and destination value objects have the same content");
BT_OBJECT_PUT_REF_AND_RESET(map_copy_obj);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_value_map_extend(
&extended_map,
- bt_value_borrow_from_private(base_map),
- bt_value_borrow_from_private(extension_map));
+ bt_private_value_borrow_value(base_map),
+ bt_private_value_borrow_value(extension_map));
ok(status == BT_VALUE_STATUS_OK &&
extended_map, "bt_value_map_extend() succeeds");
ok(bt_value_map_get_size(
- bt_value_borrow_from_private(extended_map)) == 5,
+ bt_private_value_borrow_value(extended_map)) == 5,
"bt_value_map_extend() returns a map object with the correct size");
- ok(compare_map_elements(bt_value_borrow_from_private(base_map),
- bt_value_borrow_from_private(extended_map), "file"),
+ ok(compare_map_elements(bt_private_value_borrow_value(base_map),
+ bt_private_value_borrow_value(extended_map), "file"),
"bt_value_map_extend() picks the appropriate element (file)");
- ok(compare_map_elements(bt_value_borrow_from_private(extension_map),
- bt_value_borrow_from_private(extended_map), "edit"),
+ ok(compare_map_elements(bt_private_value_borrow_value(extension_map),
+ bt_private_value_borrow_value(extended_map), "edit"),
"bt_value_map_extend() picks the appropriate element (edit)");
- ok(compare_map_elements(bt_value_borrow_from_private(base_map),
- bt_value_borrow_from_private(extended_map), "selection"),
+ ok(compare_map_elements(bt_private_value_borrow_value(base_map),
+ bt_private_value_borrow_value(extended_map), "selection"),
"bt_value_map_extend() picks the appropriate element (selection)");
- ok(compare_map_elements(bt_value_borrow_from_private(extension_map),
- bt_value_borrow_from_private(extended_map), "find"),
+ ok(compare_map_elements(bt_private_value_borrow_value(extension_map),
+ bt_private_value_borrow_value(extended_map), "find"),
"bt_value_map_extend() picks the appropriate element (find)");
- ok(compare_map_elements(bt_value_borrow_from_private(extension_map),
- bt_value_borrow_from_private(extended_map), "project"),
+ ok(compare_map_elements(bt_private_value_borrow_value(extension_map),
+ bt_private_value_borrow_value(extended_map), "project"),
"bt_value_map_extend() picks the appropriate element (project)");
BT_OBJECT_PUT_REF_AND_RESET(array);
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/object.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/graph/component.h>
-#include <babeltrace/graph/component-source.h>
-#include <babeltrace/graph/component-sink.h>
-#include <babeltrace/graph/private-graph.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/connection.h>
-#include <babeltrace/graph/port.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-component-source.h>
-#include <babeltrace/graph/private-component-sink.h>
-#include <babeltrace/graph/private-port.h>
-#include <babeltrace/graph/private-connection.h>
+#include <babeltrace/babeltrace.h>
+#include <babeltrace/assert-internal.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
-#include <babeltrace/assert-internal.h>
#include <glib.h>
#include "tap/tap.h"
#define NR_TESTS 99
enum event_type {
- COMP_ACCEPT_PORT_CONNECTION,
- COMP_PORT_CONNECTED,
- COMP_PORT_DISCONNECTED,
- GRAPH_PORT_ADDED,
- GRAPH_PORT_REMOVED,
- GRAPH_PORTS_CONNECTED,
- GRAPH_PORTS_DISCONNECTED,
+ SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION,
+ SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION,
+ SRC_COMP_OUTPUT_PORT_CONNECTED,
+ SINK_COMP_INPUT_PORT_CONNECTED,
+ SRC_COMP_OUTPUT_PORT_DISCONNECTED,
+ SINK_COMP_INPUT_PORT_DISCONNECTED,
+ GRAPH_SRC_OUTPUT_PORT_ADDED,
+ GRAPH_SINK_INPUT_PORT_ADDED,
+ GRAPH_SRC_OUTPUT_PORT_REMOVED,
+ GRAPH_SINK_INPUT_PORT_REMOVED,
+ GRAPH_SRC_SINK_PORTS_CONNECTED,
+ GRAPH_SRC_SINK_PORTS_DISCONNECTED,
};
enum test {
struct bt_component *comp;
struct bt_port *self_port;
struct bt_port *other_port;
- } comp_accept_port_connection;
+ } src_comp_accept_output_port_connection;
+
+ struct {
+ struct bt_component *comp;
+ struct bt_port *self_port;
+ struct bt_port *other_port;
+ } sink_comp_accept_input_port_connection;
+
+ struct {
+ struct bt_component *comp;
+ struct bt_port *self_port;
+ struct bt_port *other_port;
+ } src_comp_output_port_connected;
struct {
struct bt_component *comp;
struct bt_port *self_port;
struct bt_port *other_port;
- } comp_port_connected;
+ } sink_comp_input_port_connected;
+
+ struct {
+ struct bt_component *comp;
+ struct bt_port *self_port;
+ } src_comp_output_port_disconnected;
+
+ struct {
+ struct bt_component *comp;
+ struct bt_port *self_port;
+ } sink_comp_input_port_disconnected;
struct {
struct bt_component *comp;
struct bt_port *port;
- } comp_port_disconnected;
+ } graph_src_output_port_added;
struct {
struct bt_component *comp;
struct bt_port *port;
- } graph_port_added;
+ } graph_sink_input_port_added;
struct {
struct bt_component *comp;
struct bt_port *port;
- } graph_port_removed;
+ } graph_src_output_port_removed;
+
+ struct {
+ struct bt_component *comp;
+ struct bt_port *port;
+ } graph_sink_input_port_removed;
struct {
struct bt_component *upstream_comp;
struct bt_component *downstream_comp;
struct bt_port *upstream_port;
struct bt_port *downstream_port;
- struct bt_connection *conn;
- } graph_ports_connected;
+ } graph_src_sink_ports_connected;
struct {
struct bt_component *upstream_comp;
struct bt_component *downstream_comp;
struct bt_port *upstream_port;
struct bt_port *downstream_port;
- } graph_ports_disconnected;
+ } graph_src_sink_ports_disconnected;
} data;
};
static GArray *events;
-static struct bt_component_class *src_comp_class;
-static struct bt_component_class *sink_comp_class;
+static struct bt_private_component_class_source *src_comp_class;
+static struct bt_private_component_class_sink *sink_comp_class;
static enum test current_test;
static
}
switch (ev_a->type) {
- case COMP_ACCEPT_PORT_CONNECTION:
- if (ev_a->data.comp_accept_port_connection.comp !=
- ev_b->data.comp_accept_port_connection.comp) {
+ 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.comp_accept_port_connection.self_port !=
- ev_b->data.comp_accept_port_connection.self_port) {
+ 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.comp_accept_port_connection.other_port !=
- ev_b->data.comp_accept_port_connection.other_port) {
+ 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 COMP_PORT_CONNECTED:
- if (ev_a->data.comp_port_connected.comp !=
- ev_b->data.comp_port_connected.comp) {
+ 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.comp_port_connected.self_port !=
- ev_b->data.comp_port_connected.self_port) {
+ 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.comp_port_connected.other_port !=
- ev_b->data.comp_port_connected.other_port) {
+ 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 COMP_PORT_DISCONNECTED:
- if (ev_a->data.comp_port_disconnected.comp !=
- ev_b->data.comp_port_disconnected.comp) {
+ 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 false;
+ }
+
+ if (ev_a->data.src_comp_output_port_connected.self_port !=
+ ev_b->data.src_comp_output_port_connected.self_port) {
return false;
}
- if (ev_a->data.comp_port_disconnected.port !=
- ev_b->data.comp_port_disconnected.port) {
+ if (ev_a->data.src_comp_output_port_connected.other_port !=
+ ev_b->data.src_comp_output_port_connected.other_port) {
return false;
}
break;
- case GRAPH_PORT_ADDED:
- if (ev_a->data.graph_port_added.comp !=
- ev_b->data.graph_port_added.comp) {
+ case SINK_COMP_INPUT_PORT_CONNECTED:
+ if (ev_a->data.sink_comp_input_port_connected.comp !=
+ ev_b->data.sink_comp_input_port_connected.comp) {
return false;
}
- if (ev_a->data.graph_port_added.port !=
- ev_b->data.graph_port_added.port) {
+ if (ev_a->data.sink_comp_input_port_connected.self_port !=
+ ev_b->data.sink_comp_input_port_connected.self_port) {
+ return false;
+ }
+
+ if (ev_a->data.sink_comp_input_port_connected.other_port !=
+ ev_b->data.sink_comp_input_port_connected.other_port) {
return false;
}
break;
- case GRAPH_PORT_REMOVED:
- if (ev_a->data.graph_port_removed.comp !=
- ev_b->data.graph_port_removed.comp) {
+ case SRC_COMP_OUTPUT_PORT_DISCONNECTED:
+ if (ev_a->data.src_comp_output_port_disconnected.comp !=
+ ev_b->data.src_comp_output_port_disconnected.comp) {
return false;
}
- if (ev_a->data.graph_port_removed.port !=
- ev_b->data.graph_port_removed.port) {
+ if (ev_a->data.src_comp_output_port_disconnected.self_port !=
+ ev_b->data.src_comp_output_port_disconnected.self_port) {
return false;
}
break;
- case GRAPH_PORTS_CONNECTED:
- if (ev_a->data.graph_ports_connected.upstream_comp !=
- ev_b->data.graph_ports_connected.upstream_comp) {
+ case SINK_COMP_INPUT_PORT_DISCONNECTED:
+ if (ev_a->data.sink_comp_input_port_disconnected.comp !=
+ ev_b->data.sink_comp_input_port_disconnected.comp) {
return false;
}
- if (ev_a->data.graph_ports_connected.downstream_comp !=
- ev_b->data.graph_ports_connected.downstream_comp) {
+ if (ev_a->data.sink_comp_input_port_disconnected.self_port !=
+ ev_b->data.sink_comp_input_port_disconnected.self_port) {
+ return false;
+ }
+ break;
+ case GRAPH_SRC_OUTPUT_PORT_ADDED:
+ if (ev_a->data.graph_src_output_port_added.comp !=
+ ev_b->data.graph_src_output_port_added.comp) {
return false;
}
- if (ev_a->data.graph_ports_connected.upstream_port !=
- ev_b->data.graph_ports_connected.upstream_port) {
+ if (ev_a->data.graph_src_output_port_added.port !=
+ ev_b->data.graph_src_output_port_added.port) {
+ return false;
+ }
+ break;
+ case GRAPH_SINK_INPUT_PORT_ADDED:
+ if (ev_a->data.graph_sink_input_port_added.comp !=
+ ev_b->data.graph_sink_input_port_added.comp) {
+ return false;
+ }
+
+ if (ev_a->data.graph_sink_input_port_added.port !=
+ ev_b->data.graph_sink_input_port_added.port) {
+ return false;
+ }
+ break;
+ case GRAPH_SRC_OUTPUT_PORT_REMOVED:
+ if (ev_a->data.graph_src_output_port_removed.comp !=
+ ev_b->data.graph_src_output_port_removed.comp) {
+ return false;
+ }
+
+ if (ev_a->data.graph_src_output_port_removed.port !=
+ ev_b->data.graph_src_output_port_removed.port) {
+ return false;
+ }
+ break;
+ case GRAPH_SINK_INPUT_PORT_REMOVED:
+ if (ev_a->data.graph_sink_input_port_removed.comp !=
+ ev_b->data.graph_sink_input_port_removed.comp) {
+ return false;
+ }
+
+ if (ev_a->data.graph_sink_input_port_removed.port !=
+ ev_b->data.graph_sink_input_port_removed.port) {
+ return false;
+ }
+ break;
+ case GRAPH_SRC_SINK_PORTS_CONNECTED:
+ if (ev_a->data.graph_src_sink_ports_connected.upstream_comp !=
+ ev_b->data.graph_src_sink_ports_connected.upstream_comp) {
+ return false;
+ }
+
+ if (ev_a->data.graph_src_sink_ports_connected.downstream_comp !=
+ ev_b->data.graph_src_sink_ports_connected.downstream_comp) {
return false;
}
- if (ev_a->data.graph_ports_connected.downstream_port !=
- ev_b->data.graph_ports_connected.downstream_port) {
+ if (ev_a->data.graph_src_sink_ports_connected.upstream_port !=
+ ev_b->data.graph_src_sink_ports_connected.upstream_port) {
return false;
}
- if (ev_a->data.graph_ports_connected.conn !=
- ev_b->data.graph_ports_connected.conn) {
+ if (ev_a->data.graph_src_sink_ports_connected.downstream_port !=
+ ev_b->data.graph_src_sink_ports_connected.downstream_port) {
return false;
}
break;
- case GRAPH_PORTS_DISCONNECTED:
- if (ev_a->data.graph_ports_disconnected.upstream_comp !=
- ev_b->data.graph_ports_disconnected.upstream_comp) {
+ case GRAPH_SRC_SINK_PORTS_DISCONNECTED:
+ if (ev_a->data.graph_src_sink_ports_disconnected.upstream_comp !=
+ ev_b->data.graph_src_sink_ports_disconnected.upstream_comp) {
return false;
}
- if (ev_a->data.graph_ports_disconnected.downstream_comp !=
- ev_b->data.graph_ports_disconnected.downstream_comp) {
+ if (ev_a->data.graph_src_sink_ports_disconnected.downstream_comp !=
+ ev_b->data.graph_src_sink_ports_disconnected.downstream_comp) {
return false;
}
- if (ev_a->data.graph_ports_disconnected.upstream_port !=
- ev_b->data.graph_ports_disconnected.upstream_port) {
+ if (ev_a->data.graph_src_sink_ports_disconnected.upstream_port !=
+ ev_b->data.graph_src_sink_ports_disconnected.upstream_port) {
return false;
}
- if (ev_a->data.graph_ports_disconnected.downstream_port !=
- ev_b->data.graph_ports_disconnected.downstream_port) {
+ if (ev_a->data.graph_src_sink_ports_disconnected.downstream_port !=
+ ev_b->data.graph_src_sink_ports_disconnected.downstream_port) {
return false;
}
break;
}
static
-enum bt_notification_iterator_status src_iter_next(
- struct bt_private_connection_private_notification_iterator *priv_iterator,
+enum bt_self_notification_iterator_status src_iter_next(
+ struct bt_self_notification_iterator *self_iterator,
bt_notification_array notifs, uint64_t capacity,
uint64_t *count)
{
- return BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
+ return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
}
static
-enum bt_component_status accept_port_connection(
- struct bt_private_component *private_component,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port)
+enum bt_self_component_status src_accept_output_port_connection(
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_comp_port,
+ struct bt_port_input *other_port)
{
struct event event = {
- .type = COMP_ACCEPT_PORT_CONNECTION,
- .data.comp_accept_port_connection = {
- .comp = bt_component_borrow_from_private(private_component),
- .self_port = bt_port_borrow_from_private(self_private_port),
- .other_port = other_port,
+ .type = SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION,
+ .data.src_comp_accept_output_port_connection = {
+ .comp = bt_self_component_borrow_component(
+ bt_self_component_source_borrow_self_component(
+ self_comp)),
+ .self_port = bt_self_component_port_borrow_port(
+ bt_self_component_port_output_borrow_self_component_port(
+ self_comp_port)),
+ .other_port = bt_port_input_borrow_port(other_port),
},
};
append_event(&event);
- return BT_COMPONENT_STATUS_OK;
+ return BT_SELF_COMPONENT_STATUS_OK;
}
static
-enum bt_component_status src_port_connected(
- struct bt_private_component *private_component,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port)
+enum bt_self_component_status sink_accept_input_port_connection(
+ struct bt_self_component_sink *self_comp,
+ struct bt_self_component_port_input *self_comp_port,
+ struct bt_port_output *other_port)
{
- int ret;
+ struct event event = {
+ .type = SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION,
+ .data.sink_comp_accept_input_port_connection = {
+ .comp = bt_self_component_borrow_component(
+ bt_self_component_sink_borrow_self_component(
+ self_comp)),
+ .self_port = bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ self_comp_port)),
+ .other_port = bt_port_output_borrow_port(other_port),
+ },
+ };
+ append_event(&event);
+ return BT_SELF_COMPONENT_STATUS_OK;
+}
+
+static
+enum bt_self_component_status src_output_port_connected(
+ struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_comp_port,
+ struct bt_port_input *other_port)
+{
+ int ret;
struct event event = {
- .type = COMP_PORT_CONNECTED,
- .data.comp_port_connected = {
- .comp = bt_component_borrow_from_private(private_component),
- .self_port = bt_port_borrow_from_private(self_private_port),
- .other_port = other_port,
+ .type = SRC_COMP_OUTPUT_PORT_CONNECTED,
+ .data.src_comp_output_port_connected = {
+ .comp = bt_self_component_borrow_component(
+ bt_self_component_source_borrow_self_component(
+ self_comp)),
+ .self_port = bt_self_component_port_borrow_port(
+ bt_self_component_port_output_borrow_self_component_port(
+ self_comp_port)),
+ .other_port = bt_port_input_borrow_port(other_port),
},
};
switch (current_test) {
case TEST_SRC_ADDS_PORT_IN_PORT_CONNECTED:
- ret = bt_private_component_source_add_output_port(
- private_component, "hello", NULL, NULL);
+ ret = bt_self_component_source_add_output_port(
+ self_comp, "hello", NULL, NULL);
BT_ASSERT(ret == 0);
break;
case TEST_SRC_PORT_CONNECTED_ERROR:
- return BT_COMPONENT_STATUS_ERROR;
+ return BT_SELF_COMPONENT_STATUS_ERROR;
default:
break;
}
- return BT_COMPONENT_STATUS_OK;
+ return BT_SELF_COMPONENT_STATUS_OK;
}
static
-void src_port_disconnected(struct bt_private_component *private_component,
- struct bt_private_port *private_port)
+enum bt_self_component_status sink_input_port_connected(
+ struct bt_self_component_sink *self_comp,
+ struct bt_self_component_port_input *self_comp_port,
+ struct bt_port_output *other_port)
+{
+ struct event event = {
+ .type = SINK_COMP_INPUT_PORT_CONNECTED,
+ .data.sink_comp_input_port_connected = {
+ .comp = bt_self_component_borrow_component(
+ bt_self_component_sink_borrow_self_component(
+ self_comp)),
+ .self_port = bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ self_comp_port)),
+ .other_port = bt_port_output_borrow_port(other_port),
+ },
+ };
+
+ append_event(&event);
+
+ if (current_test == TEST_SINK_PORT_CONNECTED_ERROR) {
+ return BT_SELF_COMPONENT_STATUS_ERROR;
+ } else {
+ return BT_SELF_COMPONENT_STATUS_OK;
+ }
+}
+
+static
+void src_output_port_disconnected(struct bt_self_component_source *self_comp,
+ struct bt_self_component_port_output *self_comp_port)
{
int ret;
struct event event = {
- .type = COMP_PORT_DISCONNECTED,
- .data.comp_port_disconnected = {
- .comp = bt_component_borrow_from_private(private_component),
- .port = bt_port_borrow_from_private(private_port),
+ .type = SRC_COMP_OUTPUT_PORT_DISCONNECTED,
+ .data.src_comp_output_port_disconnected = {
+ .comp = bt_self_component_borrow_component(
+ bt_self_component_source_borrow_self_component(
+ self_comp)),
+ .self_port = bt_self_component_port_borrow_port(
+ bt_self_component_port_output_borrow_self_component_port(
+ self_comp_port)),
},
};
switch (current_test) {
case TEST_SINK_REMOVES_PORT_IN_CONSUME_THEN_SRC_REMOVES_DISCONNECTED_PORT:
- ret = bt_private_port_remove_from_component(private_port);
+ ret = bt_self_component_port_remove_from_component(
+ bt_self_component_port_output_borrow_self_component_port(
+ self_comp_port));
BT_ASSERT(ret == 0);
default:
break;
}
static
-enum bt_component_status src_init(struct bt_private_component *priv_comp,
+void sink_input_port_disconnected(struct bt_self_component_sink *self_comp,
+ struct bt_self_component_port_input *self_comp_port)
+{
+ struct event event = {
+ .type = SINK_COMP_INPUT_PORT_DISCONNECTED,
+ .data.sink_comp_input_port_disconnected = {
+ .comp = bt_self_component_borrow_component(
+ bt_self_component_sink_borrow_self_component(
+ self_comp)),
+ .self_port = bt_self_component_port_borrow_port(
+ bt_self_component_port_input_borrow_self_component_port(
+ self_comp_port)),
+ },
+ };
+
+ append_event(&event);
+}
+
+static
+enum bt_self_component_status src_init(
+ struct bt_self_component_source *self_comp,
struct bt_value *params, void *init_method_data)
{
int ret;
- ret = bt_private_component_source_add_output_port(
- priv_comp, "out", NULL, NULL);
+ ret = bt_self_component_source_add_output_port(
+ self_comp, "out", NULL, NULL);
BT_ASSERT(ret == 0);
- return BT_COMPONENT_STATUS_OK;
+ return BT_SELF_COMPONENT_STATUS_OK;
}
static
-enum bt_component_status sink_consume(
- struct bt_private_component *priv_component)
+enum bt_self_component_status sink_init(
+ struct bt_self_component_sink *self_comp,
+ struct bt_value *params, void *init_method_data)
{
- struct bt_private_port *def_port;
+ int ret;
+
+ ret = bt_self_component_sink_add_input_port(self_comp,
+ "in", NULL, NULL);
+ BT_ASSERT(ret == 0);
+ return BT_SELF_COMPONENT_STATUS_OK;
+}
+
+static
+enum bt_self_component_status sink_consume(
+ struct bt_self_component_sink *self_comp)
+{
+ struct bt_self_component_port_input *def_port;
int ret;
switch (current_test) {
case TEST_SINK_REMOVES_PORT_IN_CONSUME:
case TEST_SINK_REMOVES_PORT_IN_CONSUME_THEN_SRC_REMOVES_DISCONNECTED_PORT:
- def_port = bt_private_component_sink_get_input_port_by_name(
- priv_component, "in");
+ def_port = bt_self_component_sink_borrow_input_port_by_name(
+ self_comp, "in");
BT_ASSERT(def_port);
- ret = bt_private_port_remove_from_component(def_port);
+ ret = bt_self_component_port_remove_from_component(
+ bt_self_component_port_input_borrow_self_component_port(
+ def_port));
BT_ASSERT(ret == 0);
- bt_object_put_ref(def_port);
break;
default:
break;
}
- return BT_COMPONENT_STATUS_OK;
+ return BT_SELF_COMPONENT_STATUS_OK;
}
static
-enum bt_component_status sink_port_connected(
- struct bt_private_component *private_component,
- struct bt_private_port *self_private_port,
- struct bt_port *other_port)
+void graph_src_output_port_added(struct bt_component_source *comp,
+ struct bt_port_output *port, void *data)
{
struct event event = {
- .type = COMP_PORT_CONNECTED,
- .data.comp_port_connected = {
- .comp = bt_component_borrow_from_private(private_component),
- .self_port = bt_port_borrow_from_private(self_private_port),
- .other_port = other_port,
+ .type = GRAPH_SRC_OUTPUT_PORT_ADDED,
+ .data.graph_src_output_port_added = {
+ .comp = bt_component_source_borrow_component(comp),
+ .port = bt_port_output_borrow_port(port),
},
};
append_event(&event);
-
- if (current_test == TEST_SINK_PORT_CONNECTED_ERROR) {
- return BT_COMPONENT_STATUS_ERROR;
- } else {
- return BT_COMPONENT_STATUS_OK;
- }
}
static
-void sink_port_disconnected(struct bt_private_component *private_component,
- struct bt_private_port *private_port)
+void graph_sink_input_port_added(struct bt_component_sink *comp,
+ struct bt_port_input *port, void *data)
{
struct event event = {
- .type = COMP_PORT_DISCONNECTED,
- .data.comp_port_disconnected = {
- .comp = bt_component_borrow_from_private(private_component),
- .port = bt_port_borrow_from_private(private_port),
+ .type = GRAPH_SINK_INPUT_PORT_ADDED,
+ .data.graph_sink_input_port_added = {
+ .comp = bt_component_sink_borrow_component(comp),
+ .port = bt_port_input_borrow_port(port),
},
};
}
static
-enum bt_component_status sink_init(struct bt_private_component *priv_comp,
- struct bt_value *params, void *init_method_data)
-{
- int ret;
-
- ret = bt_private_component_sink_add_input_port(priv_comp,
- "in", NULL, NULL);
- BT_ASSERT(ret == 0);
- return BT_COMPONENT_STATUS_OK;
-}
-
-static
-void graph_port_added(struct bt_port *port,
- void *data)
+void graph_src_output_port_removed(struct bt_component_source *comp,
+ struct bt_port_output *port, void *data)
{
- struct bt_component *comp = bt_port_get_component(port);
-
- BT_ASSERT(comp);
- bt_object_put_ref(comp);
-
struct event event = {
- .type = GRAPH_PORT_ADDED,
- .data.graph_port_added = {
- .comp = comp,
- .port = port,
+ .type = GRAPH_SRC_OUTPUT_PORT_REMOVED,
+ .data.graph_src_output_port_removed = {
+ .comp = bt_component_source_borrow_component(comp),
+ .port = bt_port_output_borrow_port(port),
},
};
}
static
-void graph_port_removed(struct bt_component *component,
- struct bt_port *port, void *data)
+void graph_sink_input_port_removed(struct bt_component_sink *comp,
+ struct bt_port_input *port, void *data)
{
struct event event = {
- .type = GRAPH_PORT_REMOVED,
- .data.graph_port_removed = {
- .comp = component,
- .port = port,
+ .type = GRAPH_SINK_INPUT_PORT_REMOVED,
+ .data.graph_sink_input_port_removed = {
+ .comp = bt_component_sink_borrow_component(comp),
+ .port = bt_port_input_borrow_port(port),
},
};
}
static
-void graph_ports_connected(struct bt_port *upstream_port,
- struct bt_port *downstream_port, void *data)
+void graph_src_sink_ports_connected(struct bt_component_source *upstream_comp,
+ struct bt_component_sink *downstream_comp,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port, void *data)
{
- struct bt_component *upstream_comp =
- bt_port_get_component(upstream_port);
- struct bt_component *downstream_comp =
- bt_port_get_component(downstream_port);
- struct bt_connection *conn = bt_port_get_connection(upstream_port);
-
- BT_ASSERT(upstream_comp);
- BT_ASSERT(downstream_comp);
- BT_ASSERT(conn);
- bt_object_put_ref(upstream_comp);
- bt_object_put_ref(downstream_comp);
- bt_object_put_ref(conn);
-
struct event event = {
- .type = GRAPH_PORTS_CONNECTED,
- .data.graph_ports_connected = {
- .upstream_comp = upstream_comp,
- .downstream_comp = downstream_comp,
- .upstream_port = upstream_port,
- .downstream_port = downstream_port,
- .conn = conn,
+ .type = GRAPH_SRC_SINK_PORTS_CONNECTED,
+ .data.graph_src_sink_ports_connected = {
+ .upstream_comp =
+ bt_component_source_borrow_component(upstream_comp),
+ .downstream_comp =
+ bt_component_sink_borrow_component(downstream_comp),
+ .upstream_port =
+ bt_port_output_borrow_port(upstream_port),
+ .downstream_port =
+ bt_port_input_borrow_port(downstream_port),
},
};
}
static
-void graph_ports_disconnected(
- struct bt_component *upstream_comp,
- struct bt_component *downstream_comp,
- struct bt_port *upstream_port, struct bt_port *downstream_port,
- void *data)
+void graph_src_sink_ports_disconnected(struct bt_component_source *upstream_comp,
+ struct bt_component_sink *downstream_comp,
+ struct bt_port_output *upstream_port,
+ struct bt_port_input *downstream_port, void *data)
{
struct event event = {
- .type = GRAPH_PORTS_DISCONNECTED,
- .data.graph_ports_disconnected = {
- .upstream_comp = upstream_comp,
- .downstream_comp = downstream_comp,
- .upstream_port = upstream_port,
- .downstream_port = downstream_port,
+ .type = GRAPH_SRC_SINK_PORTS_DISCONNECTED,
+ .data.graph_src_sink_ports_disconnected = {
+ .upstream_comp =
+ bt_component_source_borrow_component(upstream_comp),
+ .downstream_comp =
+ bt_component_sink_borrow_component(downstream_comp),
+ .upstream_port =
+ bt_port_output_borrow_port(upstream_port),
+ .downstream_port =
+ bt_port_input_borrow_port(downstream_port),
},
};
{
int ret;
- src_comp_class = bt_component_class_source_create("src", src_iter_next);
+ src_comp_class = bt_private_component_class_source_create(
+ "src", src_iter_next);
BT_ASSERT(src_comp_class);
- ret = bt_component_class_set_init_method(src_comp_class, src_init);
+ ret = bt_private_component_class_source_set_init_method(
+ src_comp_class, src_init);
BT_ASSERT(ret == 0);
- ret = bt_component_class_set_accept_port_connection_method(
- src_comp_class, accept_port_connection);
+ ret = bt_private_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_set_port_connected_method(src_comp_class,
- src_port_connected);
+ ret = bt_private_component_class_source_set_output_port_connected_method(
+ src_comp_class, src_output_port_connected);
BT_ASSERT(ret == 0);
- ret = bt_component_class_set_port_disconnected_method(
- src_comp_class, src_port_disconnected);
+ ret = bt_private_component_class_source_set_output_port_disconnected_method(
+ src_comp_class, src_output_port_disconnected);
BT_ASSERT(ret == 0);
- sink_comp_class = bt_component_class_sink_create("sink", sink_consume);
+ sink_comp_class = bt_private_component_class_sink_create("sink",
+ sink_consume);
BT_ASSERT(sink_comp_class);
- ret = bt_component_class_set_init_method(sink_comp_class, sink_init);
+ ret = bt_private_component_class_sink_set_init_method(sink_comp_class,
+ sink_init);
BT_ASSERT(ret == 0);
- ret = bt_component_class_set_accept_port_connection_method(
- sink_comp_class, accept_port_connection);
+ ret = bt_private_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_set_port_connected_method(sink_comp_class,
- sink_port_connected);
+ ret = bt_private_component_class_sink_set_input_port_connected_method(
+ sink_comp_class, sink_input_port_connected);
BT_ASSERT(ret == 0);
- ret = bt_component_class_set_port_disconnected_method(sink_comp_class,
- sink_port_disconnected);
+ ret = bt_private_component_class_sink_set_input_port_disconnected_method(
+ sink_comp_class, sink_input_port_disconnected);
BT_ASSERT(ret == 0);
- bt_component_class_freeze(src_comp_class);
- bt_component_class_freeze(sink_comp_class);
events = g_array_new(FALSE, TRUE, sizeof(struct event));
BT_ASSERT(events);
}
}
static
-struct bt_component *create_src(struct bt_private_graph *graph)
+struct bt_component_source *create_src(struct bt_private_graph *graph)
{
- struct bt_component *comp;
+ struct bt_component_source *comp;
int ret;
- ret = bt_private_graph_add_component(graph, src_comp_class, "src-comp", NULL,
- &comp);
+ ret = bt_private_graph_add_source_component(graph,
+ bt_private_component_class_source_borrow_component_class_source(
+ src_comp_class),
+ "src-comp", NULL, &comp);
BT_ASSERT(ret == 0);
return comp;
}
static
-struct bt_component *create_sink(struct bt_private_graph *graph)
+struct bt_component_sink *create_sink(struct bt_private_graph *graph)
{
- struct bt_component *comp;
+ struct bt_component_sink *comp;
int ret;
- ret = bt_private_graph_add_component(graph, sink_comp_class, "sink-comp",
- NULL, &comp);
+ ret = bt_private_graph_add_sink_component(graph,
+ bt_private_component_class_sink_borrow_component_class_sink(
+ sink_comp_class),
+ "sink-comp", NULL, &comp);
BT_ASSERT(ret == 0);
return comp;
}
int ret;
BT_ASSERT(graph);
- ret = bt_private_graph_add_port_added_listener(graph, graph_port_added, NULL,
- NULL);
+ ret = bt_private_graph_add_source_component_output_port_added_listener(
+ graph, graph_src_output_port_added, NULL, NULL, NULL);
+ BT_ASSERT(ret >= 0);
+ ret = bt_private_graph_add_sink_component_input_port_added_listener(
+ graph, graph_sink_input_port_added, NULL, NULL, NULL);
BT_ASSERT(ret >= 0);
- ret = bt_private_graph_add_port_removed_listener(graph, graph_port_removed,
- NULL, NULL);
+ ret = bt_private_graph_add_source_component_output_port_removed_listener(
+ graph, graph_src_output_port_removed, NULL, NULL, NULL);
BT_ASSERT(ret >= 0);
- ret = bt_private_graph_add_ports_connected_listener(graph,
- graph_ports_connected, NULL, NULL);
+ ret = bt_private_graph_add_sink_component_input_port_removed_listener(
+ graph, graph_sink_input_port_removed, NULL, NULL, NULL);
BT_ASSERT(ret >= 0);
- ret = bt_private_graph_add_ports_disconnected_listener(graph,
- graph_ports_disconnected, NULL, NULL);
+ ret = bt_private_graph_add_source_sink_component_ports_connected_listener(
+ graph, graph_src_sink_ports_connected, NULL, NULL, NULL);
+ BT_ASSERT(ret >= 0);
+ ret = bt_private_graph_add_source_sink_component_ports_disconnected_listener(
+ graph, graph_src_sink_ports_disconnected, NULL, NULL, NULL);
BT_ASSERT(ret >= 0);
return graph;
}
}
static
-void test_sink_removes_port_in_port_connected_then_src_removes_disconnected_port(void)
+void test_sink_removes_port_in_consume_then_src_removes_disconnected_port(void)
{
int ret;
- struct bt_component *src;
- struct bt_component *sink;
+ struct bt_component_source *src;
+ struct bt_component_sink *sink;
+ struct bt_component *gsrc;
+ struct bt_component *gsink;
struct bt_private_graph *graph;
- struct bt_port *src_def_port;
- struct bt_port *sink_def_port;
- struct bt_connection *conn;
+ struct bt_port_output *src_def_port;
+ struct bt_port_input *sink_def_port;
+ struct bt_port *gsrc_def_port;
+ struct bt_port *gsink_def_port;
struct event event;
enum 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;
+ size_t graph_ports_connected_pos;
size_t src_port_disconnected_pos;
size_t sink_port_disconnected_pos;
size_t graph_ports_disconnected_pos;
BT_ASSERT(graph);
src = create_src(graph);
sink = create_sink(graph);
- src_def_port = bt_component_source_get_output_port_by_name(src, "out");
+ src_def_port = bt_component_source_borrow_output_port_by_name(src, "out");
BT_ASSERT(src_def_port);
- sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
+ sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
- &conn);
+ status = bt_private_graph_connect_ports(graph, src_def_port,
+ sink_def_port, NULL);
BT_ASSERT(status == 0);
- BT_ASSERT(conn);
+ gsrc = bt_component_source_borrow_component(src);
+ gsink = bt_component_sink_borrow_component(sink);
+ gsrc_def_port = bt_port_output_borrow_port(src_def_port);
+ gsink_def_port = bt_port_input_borrow_port(sink_def_port);
/* We're supposed to have 7 events so far */
ok(events->len == 7, "we have the expected number of events (before consume)");
/* Source's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = src;
- event.data.graph_port_added.port = src_def_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
+ event.data.graph_src_output_port_added.comp = gsrc;
+ event.data.graph_src_output_port_added.port = gsrc_def_port;
ok(has_event(&event), "got the expected graph's port added event (for source, initial)");
/* Sink's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = sink;
- event.data.graph_port_added.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_ADDED;
+ event.data.graph_sink_input_port_added.comp = gsink;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = src;
- event.data.comp_accept_port_connection.self_port = src_def_port;
- event.data.comp_accept_port_connection.other_port = sink_def_port;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = sink;
- event.data.comp_accept_port_connection.self_port = sink_def_port;
- event.data.comp_accept_port_connection.other_port = src_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = src;
- event.data.comp_port_connected.self_port = src_def_port;
- event.data.comp_port_connected.other_port = sink_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = sink;
- event.data.comp_port_connected.self_port = sink_def_port;
- event.data.comp_port_connected.other_port = src_def_port;
+ event.type = SINK_COMP_INPUT_PORT_CONNECTED;
+ event.data.sink_comp_input_port_connected.comp = gsink;
+ 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);
/* Graph's ports connected */
- event.type = GRAPH_PORTS_CONNECTED;
- event.data.graph_ports_connected.upstream_comp = src;
- event.data.graph_ports_connected.downstream_comp = sink;
- event.data.graph_ports_connected.upstream_port = src_def_port;
- event.data.graph_ports_connected.downstream_port = sink_def_port;
- event.data.graph_ports_connected.conn = conn;
+ event.type = GRAPH_SRC_SINK_PORTS_CONNECTED;
+ event.data.graph_src_sink_ports_connected.upstream_comp = gsrc;
+ event.data.graph_src_sink_ports_connected.downstream_comp = gsink;
+ event.data.graph_src_sink_ports_connected.upstream_port = gsrc_def_port;
+ event.data.graph_src_sink_ports_connected.downstream_port = gsink_def_port;
ok(has_event(&event), "got the expected graph's ports connected event");
- graph_ports_connected = event_pos(&event);
+ graph_ports_connected_pos = event_pos(&event);
/* Order of events */
- ok(src_port_connected_pos < graph_ports_connected,
+ ok(src_port_connected_pos < graph_ports_connected_pos,
"event order is good (1)");
- ok(sink_port_connected_pos < graph_ports_connected,
+ 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(events->len == 5, "we have the expected number of events (after consume)");
/* Source's port disconnected */
- event.type = COMP_PORT_DISCONNECTED;
- event.data.comp_port_disconnected.comp = src;
- event.data.comp_port_disconnected.port = src_def_port;
+ event.type = SRC_COMP_OUTPUT_PORT_DISCONNECTED;
+ event.data.src_comp_output_port_disconnected.comp = gsrc;
+ event.data.src_comp_output_port_disconnected.self_port = gsrc_def_port;
ok(has_event(&event), "got the expected source's port disconnected event");
src_port_disconnected_pos = event_pos(&event);
/* Sink's port disconnected */
- event.type = COMP_PORT_DISCONNECTED;
- event.data.comp_port_disconnected.comp = sink;
- event.data.comp_port_disconnected.port = sink_def_port;
+ event.type = SINK_COMP_INPUT_PORT_DISCONNECTED;
+ event.data.sink_comp_input_port_disconnected.comp = gsink;
+ event.data.sink_comp_input_port_disconnected.self_port = gsink_def_port;
ok(has_event(&event), "got the expected sink's port disconnected event");
sink_port_disconnected_pos = event_pos(&event);
/* Graph's ports disconnected */
- event.type = GRAPH_PORTS_DISCONNECTED;
- event.data.graph_ports_disconnected.upstream_comp = src;
- event.data.graph_ports_disconnected.downstream_comp = sink;
- event.data.graph_ports_disconnected.upstream_port = src_def_port;
- event.data.graph_ports_disconnected.downstream_port = sink_def_port;
+ event.type = GRAPH_SRC_SINK_PORTS_DISCONNECTED;
+ event.data.graph_src_sink_ports_disconnected.upstream_comp = gsrc;
+ event.data.graph_src_sink_ports_disconnected.downstream_comp = gsink;
+ event.data.graph_src_sink_ports_disconnected.upstream_port = gsrc_def_port;
+ event.data.graph_src_sink_ports_disconnected.downstream_port = gsink_def_port;
ok(has_event(&event), "got the expected graph's ports disconnected event");
graph_ports_disconnected_pos = event_pos(&event);
/* Graph's port removed (sink) */
- event.type = GRAPH_PORT_REMOVED;
- event.data.graph_port_removed.comp = sink;
- event.data.graph_port_removed.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_REMOVED;
+ event.data.graph_sink_input_port_removed.comp = gsink;
+ event.data.graph_sink_input_port_removed.port = gsink_def_port;
ok(has_event(&event), "got the expected graph's port removed event (for sink)");
graph_port_removed_sink_pos = event_pos(&event);
/* Graph's port removed (source) */
- event.type = GRAPH_PORT_REMOVED;
- event.data.graph_port_removed.comp = src;
- event.data.graph_port_removed.port = src_def_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_REMOVED;
+ event.data.graph_src_output_port_removed.comp = gsrc;
+ event.data.graph_src_output_port_removed.port = gsrc_def_port;
ok(has_event(&event), "got the expected graph's port removed event (for source)");
graph_port_removed_src_pos = event_pos(&event);
bt_object_put_ref(graph);
bt_object_put_ref(sink);
bt_object_put_ref(src);
- bt_object_put_ref(conn);
- bt_object_put_ref(src_def_port);
- bt_object_put_ref(sink_def_port);
}
static
-void test_sink_removes_port_in_port_connected(void)
+void test_sink_removes_port_in_consume(void)
{
int ret;
- struct bt_component *src;
- struct bt_component *sink;
+ struct bt_component_source *src;
+ struct bt_component_sink *sink;
+ struct bt_component *gsrc;
+ struct bt_component *gsink;
struct bt_private_graph *graph;
- struct bt_port *src_def_port;
- struct bt_port *sink_def_port;
- struct bt_connection *conn;
+ struct bt_port_output *src_def_port;
+ struct bt_port_input *sink_def_port;
+ struct bt_port *gsrc_def_port;
+ struct bt_port *gsink_def_port;
struct event event;
enum bt_graph_status status;
size_t src_accept_port_connection_pos;
BT_ASSERT(graph);
src = create_src(graph);
sink = create_sink(graph);
- src_def_port = bt_component_source_get_output_port_by_name(src, "out");
+ src_def_port = bt_component_source_borrow_output_port_by_name(src, "out");
BT_ASSERT(src_def_port);
- sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
+ sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
- &conn);
+ status = bt_private_graph_connect_ports(graph, src_def_port,
+ sink_def_port, NULL);
BT_ASSERT(status == 0);
+ gsrc = bt_component_source_borrow_component(src);
+ gsink = bt_component_sink_borrow_component(sink);
+ gsrc_def_port = bt_port_output_borrow_port(src_def_port);
+ gsink_def_port = bt_port_input_borrow_port(sink_def_port);
/* We're supposed to have 7 events so far */
ok(events->len == 7, "we have the expected number of events (before consume)");
/* Source's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = src;
- event.data.graph_port_added.port = src_def_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
+ event.data.graph_src_output_port_added.comp = gsrc;
+ event.data.graph_src_output_port_added.port = gsrc_def_port;
ok(has_event(&event), "got the expected graph's port added event (for source, initial)");
/* Sink's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = sink;
- event.data.graph_port_added.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_ADDED;
+ event.data.graph_sink_input_port_added.comp = gsink;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = src;
- event.data.comp_accept_port_connection.self_port = src_def_port;
- event.data.comp_accept_port_connection.other_port = sink_def_port;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = sink;
- event.data.comp_accept_port_connection.self_port = sink_def_port;
- event.data.comp_accept_port_connection.other_port = src_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = src;
- event.data.comp_port_connected.self_port = src_def_port;
- event.data.comp_port_connected.other_port = sink_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = sink;
- event.data.comp_port_connected.self_port = sink_def_port;
- event.data.comp_port_connected.other_port = src_def_port;
+ event.type = SINK_COMP_INPUT_PORT_CONNECTED;
+ event.data.sink_comp_input_port_connected.comp = gsink;
+ 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);
/* Graph's ports connected */
- event.type = GRAPH_PORTS_CONNECTED;
- event.data.graph_ports_connected.upstream_comp = src;
- event.data.graph_ports_connected.downstream_comp = sink;
- event.data.graph_ports_connected.upstream_port = src_def_port;
- event.data.graph_ports_connected.downstream_port = sink_def_port;
- event.data.graph_ports_connected.conn = conn;
+ event.type = GRAPH_SRC_SINK_PORTS_CONNECTED;
+ event.data.graph_src_sink_ports_connected.upstream_comp = gsrc;
+ event.data.graph_src_sink_ports_connected.downstream_comp = gsink;
+ event.data.graph_src_sink_ports_connected.upstream_port = gsrc_def_port;
+ event.data.graph_src_sink_ports_connected.downstream_port = gsink_def_port;
ok(has_event(&event), "got the expected graph's ports connected event");
graph_ports_connected_pos = event_pos(&event);
ok(events->len == 4, "we have the expected number of events (after consume)");
/* Source's port disconnected */
- event.type = COMP_PORT_DISCONNECTED;
- event.data.comp_port_disconnected.comp = src;
- event.data.comp_port_disconnected.port = src_def_port;
+ event.type = SRC_COMP_OUTPUT_PORT_DISCONNECTED;
+ event.data.src_comp_output_port_disconnected.comp = gsrc;
+ event.data.src_comp_output_port_disconnected.self_port = gsrc_def_port;
ok(has_event(&event), "got the expected source's port disconnected event");
src_port_disconnected_pos = event_pos(&event);
/* Sink's port disconnected */
- event.type = COMP_PORT_DISCONNECTED;
- event.data.comp_port_disconnected.comp = sink;
- event.data.comp_port_disconnected.port = sink_def_port;
+ event.type = SINK_COMP_INPUT_PORT_DISCONNECTED;
+ event.data.sink_comp_input_port_disconnected.comp = gsink;
+ event.data.sink_comp_input_port_disconnected.self_port = gsink_def_port;
ok(has_event(&event), "got the expected sink's port disconnected event");
sink_port_disconnected_pos = event_pos(&event);
/* Graph's ports disconnected */
- event.type = GRAPH_PORTS_DISCONNECTED;
- event.data.graph_ports_disconnected.upstream_comp = src;
- event.data.graph_ports_disconnected.downstream_comp = sink;
- event.data.graph_ports_disconnected.upstream_port = src_def_port;
- event.data.graph_ports_disconnected.downstream_port = sink_def_port;
+ event.type = GRAPH_SRC_SINK_PORTS_DISCONNECTED;
+ event.data.graph_src_sink_ports_disconnected.upstream_comp = gsrc;
+ event.data.graph_src_sink_ports_disconnected.downstream_comp = gsink;
+ event.data.graph_src_sink_ports_disconnected.upstream_port = gsrc_def_port;
+ event.data.graph_src_sink_ports_disconnected.downstream_port = gsink_def_port;
ok(has_event(&event), "got the expected graph's ports disconnected event");
graph_ports_disconnected_pos = event_pos(&event);
/* Graph's port removed (sink) */
- event.type = GRAPH_PORT_REMOVED;
- event.data.graph_port_removed.comp = sink;
- event.data.graph_port_removed.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_REMOVED;
+ event.data.graph_sink_input_port_removed.comp = gsink;
+ event.data.graph_sink_input_port_removed.port = gsink_def_port;
ok(has_event(&event), "got the expected graph's port removed event (for sink)");
graph_port_removed_sink_pos = event_pos(&event);
ok(graph_ports_disconnected_pos < graph_port_removed_sink_pos,
"event order is good (11)");
- bt_object_put_ref(graph);
bt_object_put_ref(sink);
bt_object_put_ref(src);
- bt_object_put_ref(conn);
- bt_object_put_ref(src_def_port);
- bt_object_put_ref(sink_def_port);
+ bt_object_put_ref(graph);
}
static
void test_src_adds_port_in_port_connected(void)
{
- struct bt_component *src;
- struct bt_component *sink;
+ struct bt_component_source *src;
+ struct bt_component_sink *sink;
+ struct bt_component *gsrc;
+ struct bt_component *gsink;
struct bt_private_graph *graph;
- struct bt_port *src_def_port;
- struct bt_port *sink_def_port;
- struct bt_port *src_hello_port;
- struct bt_connection *conn;
+ struct bt_port_output *src_def_port;
+ struct bt_port_output *src_hello_port;
+ struct bt_port_input *sink_def_port;
+ struct bt_port *gsrc_def_port;
+ struct bt_port *gsrc_hello_port;
+ struct bt_port *gsink_def_port;
struct event event;
enum bt_graph_status status;
size_t src_accept_port_connection_pos;
BT_ASSERT(graph);
src = create_src(graph);
sink = create_sink(graph);
- src_def_port = bt_component_source_get_output_port_by_name(src, "out");
+ src_def_port = bt_component_source_borrow_output_port_by_name(src, "out");
BT_ASSERT(src_def_port);
- sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
+ sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
- &conn);
+ status = bt_private_graph_connect_ports(graph, src_def_port,
+ sink_def_port, NULL);
BT_ASSERT(status == 0);
- src_hello_port = bt_component_source_get_output_port_by_name(src,
+ src_hello_port = bt_component_source_borrow_output_port_by_name(src,
"hello");
BT_ASSERT(src_hello_port);
+ gsrc = bt_component_source_borrow_component(src);
+ gsink = bt_component_sink_borrow_component(sink);
+ gsrc_def_port = bt_port_output_borrow_port(src_def_port);
+ gsrc_hello_port = bt_port_output_borrow_port(src_hello_port);
+ gsink_def_port = bt_port_input_borrow_port(sink_def_port);
/* We're supposed to have 8 events */
ok(events->len == 8, "we have the expected number of events");
/* Source's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = src;
- event.data.graph_port_added.port = src_def_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
+ event.data.graph_src_output_port_added.comp = gsrc;
+ event.data.graph_src_output_port_added.port = gsrc_def_port;
ok(has_event(&event), "got the expected graph's port added event (for source, initial)");
/* Sink's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = sink;
- event.data.graph_port_added.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_ADDED;
+ event.data.graph_sink_input_port_added.comp = gsink;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = src;
- event.data.comp_accept_port_connection.self_port = src_def_port;
- event.data.comp_accept_port_connection.other_port = sink_def_port;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = sink;
- event.data.comp_accept_port_connection.self_port = sink_def_port;
- event.data.comp_accept_port_connection.other_port = src_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = src;
- event.data.comp_port_connected.self_port = src_def_port;
- event.data.comp_port_connected.other_port = sink_def_port;
+ 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);
/* Graph's port added (source) */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = src;
- event.data.graph_port_added.port = src_hello_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
+ event.data.graph_src_output_port_added.comp = gsrc;
+ event.data.graph_src_output_port_added.port = gsrc_hello_port;
ok(has_event(&event), "got the expected graph's port added event (for source)");
graph_port_added_src_pos = event_pos(&event);
/* Sink's port connected */
- event.type = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = sink;
- event.data.comp_port_connected.self_port = sink_def_port;
- event.data.comp_port_connected.other_port = src_def_port;
+ event.type = SINK_COMP_INPUT_PORT_CONNECTED;
+ event.data.sink_comp_input_port_connected.comp = gsink;
+ 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);
/* Graph's ports connected */
- event.type = GRAPH_PORTS_CONNECTED;
- event.data.graph_ports_connected.upstream_comp = src;
- event.data.graph_ports_connected.downstream_comp = sink;
- event.data.graph_ports_connected.upstream_port = src_def_port;
- event.data.graph_ports_connected.downstream_port = sink_def_port;
- event.data.graph_ports_connected.conn = conn;
- ok(has_event(&event), "got the expected graph's port connected event (for source)");
+ event.type = GRAPH_SRC_SINK_PORTS_CONNECTED;
+ event.data.graph_src_sink_ports_connected.upstream_comp = gsrc;
+ event.data.graph_src_sink_ports_connected.downstream_comp = gsink;
+ event.data.graph_src_sink_ports_connected.upstream_port = gsrc_def_port;
+ event.data.graph_src_sink_ports_connected.downstream_port = gsink_def_port;
+ ok(has_event(&event), "got the expected graph's ports connected event");
graph_ports_connected_pos = event_pos(&event);
/* Order of events */
ok(graph_port_added_src_pos < graph_ports_connected_pos,
"event order is good (6)");
- bt_object_put_ref(graph);
- bt_object_put_ref(sink);
bt_object_put_ref(src);
- bt_object_put_ref(conn);
- bt_object_put_ref(src_def_port);
- bt_object_put_ref(sink_def_port);
- bt_object_put_ref(src_hello_port);
+ bt_object_put_ref(sink);
+ bt_object_put_ref(graph);
}
static
void test_simple(void)
{
- struct bt_component *src;
- struct bt_component *sink;
+ struct bt_component_source *src;
+ struct bt_component_sink *sink;
+ struct bt_component *gsrc;
+ struct bt_component *gsink;
struct bt_private_graph *graph;
- struct bt_port *src_def_port;
- struct bt_port *sink_def_port;
- struct bt_connection *conn;
+ struct bt_port_output *src_def_port;
+ struct bt_port_input *sink_def_port;
+ struct bt_port *gsrc_def_port;
+ struct bt_port *gsink_def_port;
struct event event;
enum bt_graph_status status;
size_t src_accept_port_connection_pos;
BT_ASSERT(graph);
src = create_src(graph);
sink = create_sink(graph);
- src_def_port = bt_component_source_get_output_port_by_name(src, "out");
+ src_def_port = bt_component_source_borrow_output_port_by_name(src, "out");
BT_ASSERT(src_def_port);
- sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
+ sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
- &conn);
+ status = bt_private_graph_connect_ports(graph, src_def_port,
+ sink_def_port, NULL);
BT_ASSERT(status == 0);
+ gsrc = bt_component_source_borrow_component(src);
+ gsink = bt_component_sink_borrow_component(sink);
+ gsrc_def_port = bt_port_output_borrow_port(src_def_port);
+ gsink_def_port = bt_port_input_borrow_port(sink_def_port);
/* We're supposed to have 7 events */
ok(events->len == 7, "we have the expected number of events");
/* Source's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = src;
- event.data.graph_port_added.port = src_def_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
+ event.data.graph_src_output_port_added.comp = gsrc;
+ event.data.graph_src_output_port_added.port = gsrc_def_port;
ok(has_event(&event), "got the expected graph's port added event (for source, initial)");
/* Sink's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = sink;
- event.data.graph_port_added.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_ADDED;
+ event.data.graph_sink_input_port_added.comp = gsink;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = src;
- event.data.comp_accept_port_connection.self_port = src_def_port;
- event.data.comp_accept_port_connection.other_port = sink_def_port;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = sink;
- event.data.comp_accept_port_connection.self_port = sink_def_port;
- event.data.comp_accept_port_connection.other_port = src_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = src;
- event.data.comp_port_connected.self_port = src_def_port;
- event.data.comp_port_connected.other_port = sink_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = sink;
- event.data.comp_port_connected.self_port = sink_def_port;
- event.data.comp_port_connected.other_port = src_def_port;
+ event.type = SINK_COMP_INPUT_PORT_CONNECTED;
+ event.data.sink_comp_input_port_connected.comp = gsink;
+ 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);
- /* Graph's port connected */
- event.type = GRAPH_PORTS_CONNECTED;
- event.data.graph_ports_connected.upstream_comp = src;
- event.data.graph_ports_connected.downstream_comp = sink;
- event.data.graph_ports_connected.upstream_port = src_def_port;
- event.data.graph_ports_connected.downstream_port = sink_def_port;
- event.data.graph_ports_connected.conn = conn;
+ /* Graph's ports connected */
+ event.type = GRAPH_SRC_SINK_PORTS_CONNECTED;
+ event.data.graph_src_sink_ports_connected.upstream_comp = gsrc;
+ event.data.graph_src_sink_ports_connected.downstream_comp = gsink;
+ event.data.graph_src_sink_ports_connected.upstream_port = gsrc_def_port;
+ event.data.graph_src_sink_ports_connected.downstream_port = gsink_def_port;
ok(has_event(&event), "got the expected graph's ports connected event");
graph_ports_connected_pos = event_pos(&event);
ok(sink_accept_port_connection_pos < sink_port_connected_pos,
"event order is good (4)");
- bt_object_put_ref(graph);
bt_object_put_ref(sink);
+ bt_object_put_ref(graph);
bt_object_put_ref(src);
- bt_object_put_ref(conn);
- bt_object_put_ref(src_def_port);
- bt_object_put_ref(sink_def_port);
}
static
void test_src_port_connected_error(void)
{
- struct bt_component *src;
- struct bt_component *sink;
+ struct bt_component_source *src;
+ struct bt_component_sink *sink;
+ struct bt_component *gsrc;
+ struct bt_component *gsink;
struct bt_private_graph *graph;
- struct bt_port *src_def_port;
- struct bt_port *sink_def_port;
+ struct bt_port_output *src_def_port;
+ struct bt_port_input *sink_def_port;
+ struct bt_port *gsrc_def_port;
+ struct bt_port *gsink_def_port;
struct bt_connection *conn = NULL;
struct event event;
enum bt_graph_status status;
BT_ASSERT(graph);
src = create_src(graph);
sink = create_sink(graph);
- src_def_port = bt_component_source_get_output_port_by_name(src, "out");
+ src_def_port = bt_component_source_borrow_output_port_by_name(src, "out");
BT_ASSERT(src_def_port);
- sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
+ sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
- &conn);
+ status = bt_private_graph_connect_ports(graph, src_def_port,
+ sink_def_port, &conn);
ok(status != BT_GRAPH_STATUS_OK,
"bt_private_graph_connect_ports() returns an error");
- ok(!conn, "returned connection is NULL");
+ ok(!conn, "returned connection is still NULL");
+ gsrc = bt_component_source_borrow_component(src);
+ gsink = bt_component_sink_borrow_component(sink);
+ gsrc_def_port = bt_port_output_borrow_port(src_def_port);
+ gsink_def_port = bt_port_input_borrow_port(sink_def_port);
/* 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_PORT_ADDED;
- event.data.graph_port_added.comp = src;
- event.data.graph_port_added.port = src_def_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
+ event.data.graph_src_output_port_added.comp = gsrc;
+ event.data.graph_src_output_port_added.port = gsrc_def_port;
ok(has_event(&event), "got the expected graph's port added event (for source, initial)");
/* Sink's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = sink;
- event.data.graph_port_added.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_ADDED;
+ event.data.graph_sink_input_port_added.comp = gsink;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = src;
- event.data.comp_accept_port_connection.self_port = src_def_port;
- event.data.comp_accept_port_connection.other_port = sink_def_port;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = sink;
- event.data.comp_accept_port_connection.self_port = sink_def_port;
- event.data.comp_accept_port_connection.other_port = src_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = src;
- event.data.comp_port_connected.self_port = src_def_port;
- event.data.comp_port_connected.other_port = sink_def_port;
+ 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);
bt_object_put_ref(sink);
bt_object_put_ref(src);
bt_object_put_ref(conn);
- bt_object_put_ref(src_def_port);
- bt_object_put_ref(sink_def_port);
}
static
void test_sink_port_connected_error(void)
{
- struct bt_component *src;
- struct bt_component *sink;
+ struct bt_component_source *src;
+ struct bt_component_sink *sink;
+ struct bt_component *gsrc;
+ struct bt_component *gsink;
struct bt_private_graph *graph;
- struct bt_port *src_def_port;
- struct bt_port *sink_def_port;
+ struct bt_port_output *src_def_port;
+ struct bt_port_input *sink_def_port;
+ struct bt_port *gsrc_def_port;
+ struct bt_port *gsink_def_port;
struct bt_connection *conn = NULL;
struct event event;
enum bt_graph_status status;
BT_ASSERT(graph);
src = create_src(graph);
sink = create_sink(graph);
- src_def_port = bt_component_source_get_output_port_by_name(src, "out");
+ src_def_port = bt_component_source_borrow_output_port_by_name(src, "out");
BT_ASSERT(src_def_port);
- sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
+ sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
- &conn);
+ status = bt_private_graph_connect_ports(graph, src_def_port,
+ sink_def_port, &conn);
ok(status != BT_GRAPH_STATUS_OK,
"bt_private_graph_connect_ports() returns an error");
- ok(!conn, "returned connection is NULL");
+ ok(!conn, "returned connection is still NULL");
+ gsrc = bt_component_source_borrow_component(src);
+ gsink = bt_component_sink_borrow_component(sink);
+ gsrc_def_port = bt_port_output_borrow_port(src_def_port);
+ gsink_def_port = bt_port_input_borrow_port(sink_def_port);
/* We're supposed to have 5 events */
ok(events->len == 7, "we have the expected number of events");
/* Source's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = src;
- event.data.graph_port_added.port = src_def_port;
+ event.type = GRAPH_SRC_OUTPUT_PORT_ADDED;
+ event.data.graph_src_output_port_added.comp = gsrc;
+ event.data.graph_src_output_port_added.port = gsrc_def_port;
ok(has_event(&event), "got the expected graph's port added event (for source, initial)");
/* Sink's port added */
- event.type = GRAPH_PORT_ADDED;
- event.data.graph_port_added.comp = sink;
- event.data.graph_port_added.port = sink_def_port;
+ event.type = GRAPH_SINK_INPUT_PORT_ADDED;
+ event.data.graph_sink_input_port_added.comp = gsink;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = src;
- event.data.comp_accept_port_connection.self_port = src_def_port;
- event.data.comp_accept_port_connection.other_port = sink_def_port;
+ 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 = COMP_ACCEPT_PORT_CONNECTION;
- event.data.comp_accept_port_connection.comp = sink;
- event.data.comp_accept_port_connection.self_port = sink_def_port;
- event.data.comp_accept_port_connection.other_port = src_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = src;
- event.data.comp_port_connected.self_port = src_def_port;
- event.data.comp_port_connected.other_port = sink_def_port;
+ 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 = COMP_PORT_CONNECTED;
- event.data.comp_port_connected.comp = sink;
- event.data.comp_port_connected.self_port = sink_def_port;
- event.data.comp_port_connected.other_port = src_def_port;
+ event.type = SINK_COMP_INPUT_PORT_CONNECTED;
+ event.data.sink_comp_input_port_connected.comp = gsink;
+ 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);
/* Source's port disconnected */
- event.type = COMP_PORT_DISCONNECTED;
- event.data.comp_port_disconnected.comp = src;
- event.data.comp_port_disconnected.port = src_def_port;
+ event.type = SRC_COMP_OUTPUT_PORT_DISCONNECTED;
+ event.data.src_comp_output_port_disconnected.comp = gsrc;
+ event.data.src_comp_output_port_disconnected.self_port = gsrc_def_port;
ok(has_event(&event), "got the expected source's port disconnected event");
src_port_disconnected_pos = event_pos(&event);
ok(sink_port_connected_pos < src_port_disconnected_pos,
"event order is good (3)");
+ bt_object_put_ref(conn);
bt_object_put_ref(graph);
bt_object_put_ref(sink);
bt_object_put_ref(src);
- bt_object_put_ref(conn);
- bt_object_put_ref(src_def_port);
- bt_object_put_ref(sink_def_port);
}
static
test_src_port_connected_error();
test_sink_port_connected_error();
test_src_adds_port_in_port_connected();
- test_sink_removes_port_in_port_connected();
- test_sink_removes_port_in_port_connected_then_src_removes_disconnected_port();
+ test_sink_removes_port_in_consume();
+ test_sink_removes_port_in_consume_then_src_removes_disconnected_port();
fini_test();
return exit_status();
}
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/plugin/plugin.h>
-#include <babeltrace/object.h>
-#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
-#include <babeltrace/graph/component.h>
-#include <babeltrace/graph/private-graph.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/query-executor.h>
+#include <babeltrace/babeltrace.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "tap/tap.h"
#include "common.h"
-#define NR_TESTS 58
+#define NR_TESTS 35
#define NON_EXISTING_PATH "/this/hopefully/does/not/exist/5bc75f8d-0dba-4043-a509-d7984b97e42b.so"
/* Those symbols are written to by some test plugins */
return ret;
}
-static void test_invalid(const char *plugin_dir)
-{
- struct bt_plugin_set *plugin_set;
-
- diag("invalid plugin test below");
-
- plugin_set = bt_plugin_create_all_from_file(NON_EXISTING_PATH);
- ok(!plugin_set, "bt_plugin_create_all_from_file() fails with a non-existing file");
-
- plugin_set = bt_plugin_create_all_from_file(plugin_dir);
- ok(!plugin_set, "bt_plugin_create_all_from_file() fails with a directory");
-
- ok(!bt_plugin_create_all_from_file(NULL),
- "bt_plugin_create_all_from_file() handles NULL correctly");
- ok(!bt_plugin_create_all_from_dir(NULL, BT_FALSE),
- "bt_plugin_create_all_from_dir() handles NULL correctly");
- ok(!bt_plugin_get_name(NULL),
- "bt_plugin_get_name() handles NULL correctly");
- ok(!bt_plugin_get_description(NULL),
- "bt_plugin_get_description() handles NULL correctly");
- ok(bt_plugin_get_version(NULL, NULL, NULL, NULL, NULL) !=
- BT_PLUGIN_STATUS_OK,
- "bt_plugin_get_version() handles NULL correctly");
- ok(!bt_plugin_get_author(NULL),
- "bt_plugin_get_author() handles NULL correctly");
- ok(!bt_plugin_get_license(NULL),
- "bt_plugin_get_license() handles NULL correctly");
- ok(!bt_plugin_get_path(NULL),
- "bt_plugin_get_path() handles NULL correctly");
- ok(bt_plugin_get_component_class_count(NULL) < 0,
- "bt_plugin_get_component_class_count() handles NULL correctly");
- ok(!bt_plugin_get_component_class_by_index(NULL, 0),
- "bt_plugin_get_component_class_by_index() handles NULL correctly");
- ok(!bt_plugin_get_component_class_by_name_and_type(NULL, NULL, 0),
- "bt_plugin_get_component_class_by_name_and_type() handles NULL correctly");
-}
-
static void test_minimal(const char *plugin_dir)
{
struct bt_plugin_set *plugin_set;
"plugin's initialization function is called during bt_plugin_create_all_from_file()");
ok(bt_plugin_set_get_plugin_count(plugin_set) == 1,
"bt_plugin_create_all_from_file() returns the expected number of plugins");
- plugin = bt_plugin_set_get_plugin(plugin_set, 0);
+ plugin = bt_plugin_set_borrow_plugin_by_index(plugin_set, 0);
ok(strcmp(bt_plugin_get_name(plugin), "test_minimal") == 0,
"bt_plugin_get_name() returns the expected name");
ok(strcmp(bt_plugin_get_description(plugin),
"Minimal Babeltrace plugin with no component classes") == 0,
"bt_plugin_get_description() returns the expected description");
- ok(bt_plugin_get_version(plugin, NULL, NULL, NULL, NULL) !=
- BT_PLUGIN_STATUS_OK,
+ ok(bt_plugin_get_version(plugin, NULL, NULL, NULL, NULL) ==
+ BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE,
"bt_plugin_get_version() fails when there's no version");
ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0,
"bt_plugin_get_author() returns the expected author");
"bt_plugin_get_license() returns the expected license");
ok(strcmp(bt_plugin_get_path(plugin), minimal_path) == 0,
"bt_plugin_get_path() returns the expected path");
- ok(bt_plugin_get_component_class_count(plugin) == 0,
- "bt_plugin_get_component_class_count() returns the expected value");
- bt_object_put_ref(plugin);
+ ok(bt_plugin_get_source_component_class_count(plugin) == 0,
+ "bt_plugin_get_source_component_class_count() returns the expected value");
+ ok(bt_plugin_get_filter_component_class_count(plugin) == 0,
+ "bt_plugin_get_filter_component_class_count() returns the expected value");
+ ok(bt_plugin_get_sink_component_class_count(plugin) == 0,
+ "bt_plugin_get_sink_component_class_count() returns the expected value");
bt_object_put_ref(plugin_set);
ok(check_env_var("BT_TEST_PLUGIN_EXIT_CALLED") == 1,
"plugin's exit function is called when the plugin is destroyed");
{
struct bt_plugin_set *plugin_set;
struct bt_plugin *plugin;
- struct bt_component_class *sink_comp_class;
- struct bt_component_class *source_comp_class;
- struct bt_component_class *filter_comp_class;
- struct bt_component *sink_component;
+ struct bt_component_class_sink *sink_comp_class;
+ struct bt_component_class_source *source_comp_class;
+ struct bt_component_class_filter *filter_comp_class;
+ struct bt_component_sink *sink_component;
char *sfs_path = get_test_plugin_path(plugin_dir, "sfs");
unsigned int major, minor, patch;
const char *extra;
struct bt_private_graph *graph;
const char *object_str;
enum bt_graph_status graph_ret;
- struct bt_query_executor *query_exec = bt_query_executor_create();
+ struct bt_private_query_executor *query_exec =
+ bt_private_query_executor_create();
int ret;
BT_ASSERT(query_exec);
plugin_set = bt_plugin_create_all_from_file(sfs_path);
BT_ASSERT(plugin_set && bt_plugin_set_get_plugin_count(plugin_set) == 1);
- plugin = bt_plugin_set_get_plugin(plugin_set, 0);
+ plugin = bt_plugin_set_borrow_plugin_by_index(plugin_set, 0);
ok(bt_plugin_get_version(plugin, &major, &minor, &patch, &extra) ==
- BT_PLUGIN_STATUS_OK,
+ BT_PROPERTY_AVAILABILITY_AVAILABLE,
"bt_plugin_get_version() succeeds when there's a version");
ok(major == 1,
"bt_plugin_get_version() returns the expected major version");
"bt_plugin_get_version() returns the expected patch version");
ok(strcmp(extra, "yes") == 0,
"bt_plugin_get_version() returns the expected extra version");
- ok(bt_plugin_get_component_class_count(plugin) == 3,
- "bt_plugin_get_component_class_count() returns the expected value");
-
- source_comp_class = bt_plugin_get_component_class_by_name_and_type(
- plugin, "source", BT_COMPONENT_CLASS_TYPE_SOURCE);
+ ok(bt_plugin_get_source_component_class_count(plugin) == 1,
+ "bt_plugin_get_source_component_class_count() returns the expected value");
+ ok(bt_plugin_get_filter_component_class_count(plugin) == 1,
+ "bt_plugin_get_filter_component_class_count() returns the expected value");
+ ok(bt_plugin_get_sink_component_class_count(plugin) == 1,
+ "bt_plugin_get_sink_component_class_count() returns the expected value");
+
+ source_comp_class = bt_plugin_borrow_source_component_class_by_name(
+ plugin, "source");
ok(source_comp_class,
- "bt_plugin_get_component_class_by_name_and_type() finds a source component class");
+ "bt_plugin_borrow_source_component_class_by_name() finds a source component class");
- sink_comp_class = bt_plugin_get_component_class_by_name_and_type(
- plugin, "sink", BT_COMPONENT_CLASS_TYPE_SINK);
+ sink_comp_class = bt_plugin_borrow_sink_component_class_by_name(
+ plugin, "sink");
ok(sink_comp_class,
- "bt_plugin_get_component_class_by_name_and_type() finds a sink component class");
- ok(strcmp(bt_component_class_get_help(sink_comp_class),
+ "bt_plugin_borrow_sink_component_class_by_name() finds a sink component class");
+ ok(strcmp(bt_component_class_get_help(
+ bt_component_class_sink_borrow_component_class(sink_comp_class)),
"Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
"Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
"venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
"ground round brisket salami cupim pork bresaola turkey bacon boudin.\n") == 0,
"bt_component_class_get_help() returns the expected help text");
- filter_comp_class = bt_plugin_get_component_class_by_name_and_type(
- plugin, "filter", BT_COMPONENT_CLASS_TYPE_FILTER);
+ filter_comp_class = bt_plugin_borrow_filter_component_class_by_name(
+ plugin, "filter");
ok(filter_comp_class,
- "bt_plugin_get_component_class_by_name_and_type() finds a filter component class");
- ok(!bt_plugin_get_component_class_by_name_and_type(plugin, "filter",
- BT_COMPONENT_CLASS_TYPE_SOURCE),
- "bt_plugin_get_component_class_by_name_and_type() does not find a component class given the wrong type");
+ "bt_plugin_borrow_filter_component_class_by_name() finds a filter component class");
params = bt_private_value_integer_create_init(23);
BT_ASSERT(params);
- ret = bt_query_executor_query(NULL, filter_comp_class, "object",
- bt_value_borrow_from_private(params), &results);
- ok (ret, "bt_query_executor_query() handles NULL (query executor)");
- ret = bt_query_executor_query(query_exec, NULL, "object",
- bt_value_borrow_from_private(params), &results);
- ok (ret, "bt_query_executor_query() handles NULL (component class)");
- ret = bt_query_executor_query(query_exec, filter_comp_class, NULL,
- bt_value_borrow_from_private(params), &results);
- ok (ret, "bt_query_executor_query() handles NULL (object)");
- ret = bt_query_executor_query(query_exec, filter_comp_class,
- "get-something", bt_value_borrow_from_private(params),
+ ret = bt_private_query_executor_query(query_exec,
+ bt_component_class_filter_borrow_component_class(filter_comp_class),
+ "get-something", bt_private_value_borrow_value(params),
&results);
- ok(ret == 0 && results, "bt_query_executor_query() succeeds");
+ ok(ret == 0 && results, "bt_private_query_executor_query() succeeds");
BT_ASSERT(bt_value_is_array(results) && bt_value_array_get_size(results) == 2);
object = bt_value_array_borrow_element_by_index(results, 0);
BT_ASSERT(object && bt_value_is_string(object));
ok(strcmp(object_str, "get-something") == 0,
"bt_component_class_query() receives the expected object name");
res_params = bt_value_array_borrow_element_by_index(results, 1);
- ok(res_params == bt_value_borrow_from_private(params),
+ ok(res_params == bt_private_value_borrow_value(params),
"bt_component_class_query() receives the expected parameters");
- diag("> putting the plugin object here");
- BT_OBJECT_PUT_REF_AND_RESET(plugin);
- graph = bt_private_graph_create();
- BT_ASSERT(graph);
- graph_ret = bt_private_graph_add_component(graph, sink_comp_class, "the-sink",
- NULL, &sink_component);
- ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
- "bt_private_graph_add_component() still works after the plugin object is destroyed");
- BT_OBJECT_PUT_REF_AND_RESET(sink_component);
- BT_OBJECT_PUT_REF_AND_RESET(source_comp_class);
- bt_object_put_ref(graph);
+ bt_object_get_ref(sink_comp_class);
+ diag("> putting the plugin set object here");
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
graph = bt_private_graph_create();
BT_ASSERT(graph);
- graph_ret = bt_private_graph_add_component(graph, sink_comp_class, "the-sink",
+ graph_ret = bt_private_graph_add_sink_component(graph, sink_comp_class, "the-sink",
NULL, &sink_component);
ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
- "bt_private_graph_add_component() still works after the source component class object is destroyed");
+ "bt_private_graph_add_sink_component() still works after the plugin object is destroyed");
BT_OBJECT_PUT_REF_AND_RESET(sink_component);
- BT_OBJECT_PUT_REF_AND_RESET(filter_comp_class);
bt_object_put_ref(graph);
- graph = bt_private_graph_create();
- BT_ASSERT(graph);
- graph_ret = bt_private_graph_add_component(graph, sink_comp_class, "the-sink",
- NULL, &sink_component);
- ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
- "bt_private_graph_add_component() still works after the filter component class object is destroyed");
- BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
- BT_OBJECT_PUT_REF_AND_RESET(sink_component);
free(sfs_path);
- bt_object_put_ref(graph);
- bt_object_put_ref(plugin_set);
+ bt_object_put_ref(sink_comp_class);
bt_object_put_ref(results);
bt_object_put_ref(params);
bt_object_put_ref(query_exec);
{
int ret;
struct bt_plugin *plugin;
- struct bt_component_class *comp_cls_sink;
- struct bt_component_class *comp_cls_source;
char *plugin_path;
- ok(!bt_plugin_find(NULL),
- "bt_plugin_find() handles NULL");
ok(!bt_plugin_find(NON_EXISTING_PATH),
"bt_plugin_find() returns NULL with an unknown plugin name");
ret = asprintf(&plugin_path, "%s" G_SEARCHPATH_SEPARATOR_S
ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0,
"bt_plugin_find() finds the correct plugin for a given name");
BT_OBJECT_PUT_REF_AND_RESET(plugin);
- comp_cls_sink = bt_plugin_find_component_class(NULL, "sink",
- BT_COMPONENT_CLASS_TYPE_SINK);
- ok(!comp_cls_sink, "bt_plugin_find_component_class() handles NULL (plugin name)");
- comp_cls_sink = bt_plugin_find_component_class("test_sfs", NULL,
- BT_COMPONENT_CLASS_TYPE_SINK);
- ok(!comp_cls_sink, "bt_plugin_find_component_class() handles NULL (component class name)");
- comp_cls_sink = bt_plugin_find_component_class("test_sfs", "sink2",
- BT_COMPONENT_CLASS_TYPE_SINK);
- ok(!comp_cls_sink, "bt_plugin_find_component_class() fails with an unknown component class name");
- comp_cls_sink = bt_plugin_find_component_class("test_sfs", "sink",
- BT_COMPONENT_CLASS_TYPE_SINK);
- ok(comp_cls_sink, "bt_plugin_find_component_class() succeeds with valid parameters");
- ok(strcmp(bt_component_class_get_name(comp_cls_sink), "sink") == 0,
- "bt_plugin_find_component_class() returns the appropriate component class (sink)");
- comp_cls_source = bt_plugin_find_component_class("test_sfs", "source",
- BT_COMPONENT_CLASS_TYPE_SOURCE);
- ok(comp_cls_sink, "bt_plugin_find_component_class() succeeds with another component class name (same plugin)");
- ok(strcmp(bt_component_class_get_name(comp_cls_source), "source") == 0,
- "bt_plugin_find_component_class() returns the appropriate component class (source)");
- BT_OBJECT_PUT_REF_AND_RESET(comp_cls_sink);
- BT_OBJECT_PUT_REF_AND_RESET(comp_cls_source);
free(plugin_path);
}
plugin_dir = argv[1];
plan_tests(NR_TESTS);
- test_invalid(plugin_dir);
test_minimal(plugin_dir);
test_sfs(plugin_dir);
test_create_all_from_dir(plugin_dir);