From 0d72b8c329ad51d14ab4e83330b38c2c8da69dd4 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 4 Dec 2018 17:07:29 -0500 Subject: [PATCH] lib: make graph API const-correct Signed-off-by: Philippe Proulx --- cli/babeltrace.c | 196 ++++---- include/Makefile.am | 42 +- include/babeltrace/babeltrace.h | 40 +- .../babeltrace/ctf-writer/fields-internal.h | 1 - .../babeltrace/ctf-writer/stream-internal.h | 1 - .../babeltrace/graph/component-class-const.h | 81 ++++ .../graph/component-class-filter-const.h | 45 ++ .../babeltrace/graph/component-class-filter.h | 139 +++++- .../graph/component-class-internal.h | 67 +-- .../component-class-sink-colander-internal.h | 6 +- .../graph/component-class-sink-const.h | 45 ++ .../babeltrace/graph/component-class-sink.h | 82 +++- .../graph/component-class-source-const.h | 45 ++ .../babeltrace/graph/component-class-source.h | 110 ++++- include/babeltrace/graph/component-class.h | 52 +-- .../graph/{component.h => component-const.h} | 27 +- ...nent-filter.h => component-filter-const.h} | 36 +- .../graph/component-filter-internal.h | 3 +- include/babeltrace/graph/component-internal.h | 6 +- ...omponent-sink.h => component-sink-const.h} | 24 +- .../graph/component-sink-internal.h | 4 +- ...nent-source.h => component-source-const.h} | 22 +- .../graph/component-source-internal.h | 2 +- .../{connection.h => connection-const.h} | 16 +- .../babeltrace/graph/connection-internal.h | 2 +- .../{notification.h => const-notification.h} | 8 +- include/babeltrace/graph/graph-const.h | 54 +++ include/babeltrace/graph/graph-internal.h | 2 +- include/babeltrace/graph/graph.h | 254 +++++++++- include/babeltrace/graph/notification-const.h | 61 +++ ...ification.h => notification-event-const.h} | 18 +- include/babeltrace/graph/notification-event.h | 12 +- ...vity.h => notification-inactivity-const.h} | 23 +- .../graph/notification-inactivity-internal.h | 2 +- .../graph/notification-inactivity.h | 14 +- .../babeltrace/graph/notification-internal.h | 2 +- .../graph/notification-iterator-internal.h | 4 +- ...on-event.h => notification-packet-const.h} | 23 +- .../babeltrace/graph/notification-packet.h | 15 +- ...n-packet.h => notification-stream-const.h} | 35 +- .../babeltrace/graph/notification-stream.h | 27 +- .../babeltrace/graph/{port.h => port-const.h} | 22 +- .../{port-input.h => port-input-const.h} | 11 +- include/babeltrace/graph/port-internal.h | 11 +- .../{port-output.h => port-output-const.h} | 11 +- .../graph/port-output-notification-iterator.h | 15 +- .../graph/private-component-class-filter.h | 192 -------- .../graph/private-component-class-sink.h | 136 ------ .../graph/private-component-class-source.h | 160 ------- .../graph/private-component-class.h | 65 --- include/babeltrace/graph/private-graph.h | 287 ------------ .../graph/private-notification-stream.h | 66 --- .../babeltrace/graph/private-query-executor.h | 63 --- .../babeltrace/graph/query-executor-const.h | 54 +++ .../graph/query-executor-internal.h | 2 +- include/babeltrace/graph/query-executor.h | 28 +- .../graph/self-component-class-filter.h | 4 +- .../graph/self-component-class-sink.h | 4 +- .../graph/self-component-class-source.h | 4 +- .../babeltrace/graph/self-component-filter.h | 7 +- ...mponent-port-input-notification-iterator.h | 6 +- .../graph/self-component-port-input.h | 6 +- .../graph/self-component-port-output.h | 4 +- .../babeltrace/graph/self-component-port.h | 6 +- .../babeltrace/graph/self-component-sink.h | 4 +- .../babeltrace/graph/self-component-source.h | 4 +- include/babeltrace/graph/self-component.h | 6 +- .../graph/self-notification-iterator.h | 2 +- include/babeltrace/plugin/plugin-const.h | 24 +- include/babeltrace/plugin/plugin-dev.h | 179 +++---- lib/babeltrace.c | 2 +- lib/graph/component-class-sink-colander.c | 21 +- lib/graph/component-class.c | 254 ++++------ lib/graph/component-filter.c | 29 +- lib/graph/component-sink.c | 17 +- lib/graph/component-source.c | 16 +- lib/graph/component.c | 31 +- lib/graph/connection.c | 17 +- lib/graph/graph.c | 263 +++++------ lib/graph/iterator.c | 104 +++-- lib/graph/notification/event.c | 17 +- lib/graph/notification/inactivity.c | 16 +- lib/graph/notification/notification.c | 4 +- lib/graph/notification/packet.c | 27 +- lib/graph/notification/stream.c | 38 +- lib/graph/port.c | 20 +- lib/graph/query-executor.c | 26 +- lib/plugin/plugin-so.c | 132 +++--- lib/plugin/plugin.c | 27 +- lib/trace-ir/event-header-field.c | 3 +- lib/trace-ir/packet-context-field.c | 3 +- lib/trace-ir/packet-header-field.c | 3 +- plugins/ctf/common/notif-iter/notif-iter.c | 36 +- plugins/ctf/common/notif-iter/notif-iter.h | 2 +- plugins/ctf/fs-sink/writer.c | 6 +- plugins/ctf/fs-sink/writer.h | 2 +- plugins/ctf/fs-src/data-stream-file.c | 2 +- plugins/ctf/fs-src/data-stream-file.h | 2 +- plugins/ctf/fs-src/fs.c | 16 +- plugins/ctf/fs-src/fs.h | 4 +- plugins/ctf/lttng-live/lttng-live-internal.h | 8 +- plugins/ctf/lttng-live/lttng-live.c | 26 +- plugins/lttng-utils/debug-info.h | 2 +- plugins/lttng-utils/plugin.c | 8 +- plugins/text/dmesg/dmesg.c | 33 +- plugins/text/dmesg/dmesg.h | 2 +- plugins/text/pretty/pretty.c | 6 +- plugins/text/pretty/pretty.h | 6 +- plugins/text/pretty/print.c | 6 +- plugins/utils/counter/counter.c | 6 +- plugins/utils/counter/counter.h | 2 +- plugins/utils/dummy/dummy.c | 4 +- plugins/utils/dummy/dummy.h | 2 +- plugins/utils/muxer/muxer.c | 36 +- plugins/utils/muxer/muxer.h | 4 +- plugins/utils/trimmer/iterator.c | 20 +- plugins/utils/trimmer/iterator.h | 2 +- tests/lib/test-plugin-plugins/sfs.c | 4 +- tests/lib/test_bt_notification_iterator.c | 161 +++---- tests/lib/test_graph_topo.c | 442 +++++++++--------- tests/lib/test_plugin.c | 38 +- 121 files changed, 2447 insertions(+), 2542 deletions(-) create mode 100644 include/babeltrace/graph/component-class-const.h create mode 100644 include/babeltrace/graph/component-class-filter-const.h create mode 100644 include/babeltrace/graph/component-class-sink-const.h create mode 100644 include/babeltrace/graph/component-class-source-const.h rename include/babeltrace/graph/{component.h => component-const.h} (73%) rename include/babeltrace/graph/{component-filter.h => component-filter-const.h} (60%) rename include/babeltrace/graph/{component-sink.h => component-sink-const.h} (69%) rename include/babeltrace/graph/{component-source.h => component-source-const.h} (70%) rename include/babeltrace/graph/{connection.h => connection-const.h} (75%) rename include/babeltrace/graph/{notification.h => const-notification.h} (90%) create mode 100644 include/babeltrace/graph/graph-const.h create mode 100644 include/babeltrace/graph/notification-const.h rename include/babeltrace/graph/{private-notification.h => notification-event-const.h} (75%) rename include/babeltrace/graph/{private-notification-inactivity.h => notification-inactivity-const.h} (66%) rename include/babeltrace/graph/{private-notification-event.h => notification-packet-const.h} (68%) rename include/babeltrace/graph/{private-notification-packet.h => notification-stream-const.h} (61%) rename include/babeltrace/graph/{port.h => port-const.h} (72%) rename include/babeltrace/graph/{port-input.h => port-input-const.h} (83%) rename include/babeltrace/graph/{port-output.h => port-output-const.h} (83%) delete mode 100644 include/babeltrace/graph/private-component-class-filter.h delete mode 100644 include/babeltrace/graph/private-component-class-sink.h delete mode 100644 include/babeltrace/graph/private-component-class-source.h delete mode 100644 include/babeltrace/graph/private-component-class.h delete mode 100644 include/babeltrace/graph/private-graph.h delete mode 100644 include/babeltrace/graph/private-notification-stream.h delete mode 100644 include/babeltrace/graph/private-query-executor.h create mode 100644 include/babeltrace/graph/query-executor-const.h diff --git a/cli/babeltrace.c b/cli/babeltrace.c index a8b5b372..537ab44d 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -69,8 +69,8 @@ static const char* log_level_env_var_names[] = { }; /* Application's processing graph (weak) */ -static struct bt_private_graph *the_graph; -static struct bt_private_query_executor *the_query_executor; +static struct bt_graph *the_graph; +static struct bt_query_executor *the_query_executor; static bool canceled = false; GPtrArray *loaded_plugins; @@ -82,7 +82,7 @@ GPtrArray *loaded_plugins; static BOOL WINAPI signal_handler(DWORD signal) { if (the_graph) { - bt_private_graph_cancel(the_graph); + bt_graph_cancel(the_graph); } canceled = true; @@ -108,11 +108,11 @@ void signal_handler(int signum) } if (the_graph) { - bt_private_graph_cancel(the_graph); + bt_graph_cancel(the_graph); } if (the_query_executor) { - bt_private_query_executor_cancel(the_query_executor); + bt_query_executor_cancel(the_query_executor); } canceled = true; @@ -153,7 +153,7 @@ int create_the_query_executor(void) { int ret = 0; - the_query_executor = bt_private_query_executor_create(); + the_query_executor = bt_query_executor_create(); if (!the_query_executor) { BT_LOGE_STR("Cannot create a query executor."); ret = -1; @@ -169,7 +169,7 @@ void destroy_the_query_executor(void) } static -int query(struct bt_component_class *comp_cls, const char *obj, +int query(const struct bt_component_class *comp_cls, const char *obj, const struct bt_value *params, const struct bt_value **user_result, const char **fail_reason) { @@ -196,7 +196,7 @@ int query(struct bt_component_class *comp_cls, const char *obj, } while (true) { - status = bt_private_query_executor_query(the_query_executor, + status = bt_query_executor_query(the_query_executor, comp_cls, obj, params, &result); switch (status) { case BT_QUERY_EXECUTOR_STATUS_OK: @@ -210,8 +210,7 @@ int query(struct bt_component_class *comp_cls, const char *obj, "time-us=%" PRIu64, sleep_time_us); if (usleep(sleep_time_us)) { - if (bt_query_executor_is_canceled( - bt_private_query_executor_as_query_executor(the_query_executor))) { + if (bt_query_executor_is_canceled(the_query_executor)) { BT_LOGI("Query was canceled by user: " "comp-cls-addr=%p, comp-cls-name=\"%s\", " "query-obj=\"%s\"", comp_cls, @@ -292,15 +291,15 @@ const struct bt_plugin *find_plugin(const char *name) return plugin; } -typedef void *(*plugin_borrow_comp_cls_func_t)(const struct bt_plugin *, - const char *); +typedef const void *(*plugin_borrow_comp_cls_func_t)( + const struct bt_plugin *, const char *); static -void *find_component_class_from_plugin(const char *plugin_name, +const void *find_component_class_from_plugin(const char *plugin_name, const char *comp_class_name, plugin_borrow_comp_cls_func_t plugin_borrow_comp_cls_func) { - void *comp_class = NULL; + const void *comp_class = NULL; const struct bt_plugin *plugin; BT_LOGD("Finding component class: plugin-name=\"%s\", " @@ -329,57 +328,51 @@ end: } static -struct bt_component_class_source *find_source_component_class( +const 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, + return (const 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_const); } static -struct bt_component_class_filter *find_filter_component_class( +const 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, + return (const 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_const); } static -struct bt_component_class_sink *find_sink_component_class( +const 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, + return (const 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_const); } static -struct bt_component_class *find_component_class(const char *plugin_name, +const 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; + const struct bt_component_class *comp_cls = NULL; switch (comp_class_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: - comp_cls = bt_component_class_source_as_component_class( - find_source_component_class(plugin_name, - comp_class_name)); + comp_cls = bt_component_class_source_as_component_class_const(find_source_component_class(plugin_name, comp_class_name)); break; case BT_COMPONENT_CLASS_TYPE_FILTER: - comp_cls = bt_component_class_filter_as_component_class( - find_filter_component_class(plugin_name, - comp_class_name)); + comp_cls = bt_component_class_filter_as_component_class_const(find_filter_component_class(plugin_name, comp_class_name)); break; case BT_COMPONENT_CLASS_TYPE_SINK: - comp_cls = bt_component_class_sink_as_component_class( - find_sink_component_class(plugin_name, - comp_class_name)); + comp_cls = bt_component_class_sink_as_component_class_const(find_sink_component_class(plugin_name, comp_class_name)); break; default: abort(); @@ -940,7 +933,7 @@ static int cmd_query(struct bt_config *cfg) { int ret = 0; - struct bt_component_class *comp_cls = NULL; + const struct bt_component_class *comp_cls = NULL; const struct bt_value *results = NULL; const char *fail_reason = NULL; @@ -1009,7 +1002,7 @@ end: static void print_component_class_help(const char *plugin_name, - struct bt_component_class *comp_cls) + const struct bt_component_class *comp_cls) { const char *comp_class_name = bt_component_class_get_name(comp_cls); @@ -1036,7 +1029,7 @@ int cmd_help(struct bt_config *cfg) { int ret = 0; const struct bt_plugin *plugin = NULL; - struct bt_component_class *needed_comp_cls = NULL; + const struct bt_component_class *needed_comp_cls = NULL; plugin = find_plugin(cfg->cmd_data.help.cfg_component->plugin_name->str); if (!plugin) { @@ -1106,7 +1099,7 @@ end: typedef void *(* plugin_borrow_comp_cls_by_index_func_t)(const struct bt_plugin *, uint64_t); -typedef struct bt_component_class *(* spec_comp_cls_borrow_comp_cls_func_t)( +typedef const struct bt_component_class *(* spec_comp_cls_borrow_comp_cls_func_t)( void *); void cmd_list_plugins_print_component_classes(const struct bt_plugin *plugin, @@ -1128,7 +1121,7 @@ void cmd_list_plugins_print_component_classes(const struct bt_plugin *plugin, } for (i = 0; i < count; i++) { - struct bt_component_class *comp_class = + const 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 = @@ -1219,7 +1212,7 @@ static int cmd_print_lttng_live_sessions(struct bt_config *cfg) { int ret = 0; - struct bt_component_class *comp_cls = NULL; + const struct bt_component_class *comp_cls = NULL; const struct bt_value *results = NULL; struct bt_value *params = NULL; const struct bt_value *map = NULL; @@ -1371,7 +1364,7 @@ static int cmd_print_ctf_metadata(struct bt_config *cfg) { int ret = 0; - struct bt_component_class *comp_cls = NULL; + const struct bt_component_class *comp_cls = NULL; const struct bt_value *results = NULL; struct bt_value *params = NULL; const struct bt_value *metadata_text_value = NULL; @@ -1537,7 +1530,7 @@ struct cmd_run_ctx { GHashTable *sink_components; /* Owned by this */ - struct bt_private_graph *graph; + struct bt_graph *graph; /* Weak */ struct bt_config *cfg; @@ -1600,15 +1593,15 @@ char *s_from_ns(int64_t ns) static int cmd_run_ctx_connect_upstream_port_to_downstream_component( struct cmd_run_ctx *ctx, - struct bt_component *upstream_comp, - struct bt_port_output *out_upstream_port, + const struct bt_component *upstream_comp, + const 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_as_port(out_upstream_port); + typedef const struct bt_port_input *(*borrow_input_port_by_index_func_t)( + const void *, uint64_t); + const struct bt_port *upstream_port = + bt_port_output_as_port_const(out_upstream_port); int ret = 0; GQuark downstreamp_comp_name_quark; @@ -1622,10 +1615,10 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( struct bt_value *trimmer_params = NULL; char *intersection_begin = NULL; char *intersection_end = 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; + const struct bt_component_filter *trimmer = NULL; + const struct bt_component_class_filter *trimmer_class = NULL; + const struct bt_port_input *trimmer_input = NULL; + const struct bt_port_output *trimmer_output = NULL; if (ctx->intersections && bt_component_get_class_type(upstream_comp) == @@ -1693,7 +1686,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( 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; + bt_component_filter_borrow_input_port_by_index_const; if (!downstream_comp) { downstream_comp = g_hash_table_lookup(ctx->sink_components, @@ -1701,7 +1694,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( 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; + bt_component_sink_borrow_input_port_by_index_const; } if (!downstream_comp) { @@ -1717,10 +1710,10 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( BT_ASSERT(downstream_port_count >= 0); for (i = 0; i < downstream_port_count; i++) { - struct bt_port_input *in_downstream_port = + const struct bt_port_input *in_downstream_port = port_by_index_fn(downstream_comp, i); - struct bt_port *downstream_port = - bt_port_input_as_port(in_downstream_port); + const struct bt_port *downstream_port = + bt_port_input_as_port_const(in_downstream_port); const char *upstream_port_name; const char *downstream_port_name; @@ -1774,10 +1767,9 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( ret = 0; ctx->connect_ports = false; - graph_status = bt_private_graph_add_filter_component( + graph_status = bt_graph_add_filter_component( ctx->graph, trimmer_class, trimmer_name, - trimmer_params, - &trimmer); + trimmer_params, &trimmer); free(trimmer_name); if (graph_status != BT_GRAPH_STATUS_OK) { goto error; @@ -1785,13 +1777,13 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( BT_ASSERT(trimmer); trimmer_input = - bt_component_filter_borrow_input_port_by_index( + bt_component_filter_borrow_input_port_by_index_const( trimmer, 0); if (!trimmer_input) { goto error; } trimmer_output = - bt_component_filter_borrow_output_port_by_index( + bt_component_filter_borrow_output_port_by_index_const( trimmer, 0); if (!trimmer_output) { goto error; @@ -1803,14 +1795,14 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( */ in_downstream_port = trimmer_input; downstream_port = - bt_port_input_as_port(in_downstream_port); + bt_port_input_as_port_const(in_downstream_port); downstream_port_name = bt_port_get_name( downstream_port); BT_ASSERT(downstream_port_name); } /* We have a winner! */ - status = bt_private_graph_connect_ports(ctx->graph, + status = bt_graph_connect_ports(ctx->graph, out_upstream_port, in_downstream_port, NULL); downstream_port = NULL; switch (status) { @@ -1878,7 +1870,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( */ ret = cmd_run_ctx_connect_upstream_port_to_downstream_component( ctx, - bt_component_filter_as_component(trimmer), + bt_component_filter_as_component_const(trimmer), trimmer_output, cfg_conn); if (ret) { goto error; @@ -1918,21 +1910,21 @@ end: static int cmd_run_ctx_connect_upstream_port(struct cmd_run_ctx *ctx, - struct bt_port_output *upstream_port) + const struct bt_port_output *upstream_port) { int ret = 0; const char *upstream_port_name; const char *upstream_comp_name; - struct bt_component *upstream_comp = NULL; + const struct bt_component *upstream_comp = NULL; size_t i; BT_ASSERT(ctx); BT_ASSERT(upstream_port); upstream_port_name = bt_port_get_name( - bt_port_output_as_port(upstream_port)); + bt_port_output_as_port_const(upstream_port)); BT_ASSERT(upstream_port_name); - upstream_comp = bt_port_borrow_component( - bt_port_output_as_port(upstream_port)); + upstream_comp = bt_port_borrow_component_const( + bt_port_output_as_port_const(upstream_port)); if (!upstream_comp) { BT_LOGW("Upstream port to connect is not part of a component: " "port-addr=%p, port-name=\"%s\"", @@ -1997,12 +1989,12 @@ end: static void graph_output_port_added_listener(struct cmd_run_ctx *ctx, - struct bt_port_output *out_port) + const struct bt_port_output *out_port) { - struct bt_component *comp; - struct bt_port *port = bt_port_output_as_port(out_port); + const struct bt_component *comp; + const struct bt_port *port = bt_port_output_as_port_const(out_port); - comp = bt_port_borrow_component(port); + comp = bt_port_borrow_component_const(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) : "", @@ -2034,16 +2026,16 @@ end: static void graph_source_output_port_added_listener( - struct bt_component_source *component, - struct bt_port_output *port, void *data) + const struct bt_component_source *component, + const struct bt_port_output *port, void *data) { graph_output_port_added_listener(data, port); } static void graph_filter_output_port_added_listener( - struct bt_component_filter *component, - struct bt_port_output *port, void *data) + const struct bt_component_filter *component, + const struct bt_port_output *port, void *data) { graph_output_port_added_listener(data, port); } @@ -2115,13 +2107,13 @@ int cmd_run_ctx_init(struct cmd_run_ctx *ctx, struct bt_config *cfg) } } - ctx->graph = bt_private_graph_create(); + ctx->graph = bt_graph_create(); if (!ctx->graph) { goto error; } the_graph = ctx->graph; - status = bt_private_graph_add_source_component_output_port_added_listener( + status = bt_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) { @@ -2129,7 +2121,7 @@ int cmd_run_ctx_init(struct cmd_run_ctx *ctx, struct bt_config *cfg) goto error; } - status = bt_private_graph_add_filter_component_output_port_added_listener( + status = bt_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) { @@ -2150,7 +2142,7 @@ end: static int set_stream_intersections(struct cmd_run_ctx *ctx, struct bt_config_component *cfg_comp, - struct bt_component_class_source *src_comp_cls) + const struct bt_component_class_source *src_comp_cls) { int ret = 0; uint64_t trace_idx; @@ -2171,8 +2163,8 @@ int set_stream_intersections(struct cmd_run_ctx *ctx, 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_as_component_class(src_comp_cls); + const struct bt_component_class *comp_cls = + bt_component_class_source_as_component_class_const(src_comp_cls); component_path_value = bt_value_map_borrow_entry_value(cfg_comp->params, "path"); @@ -2390,8 +2382,8 @@ int cmd_run_ctx_create_components_from_config_components( struct cmd_run_ctx *ctx, GPtrArray *cfg_components) { size_t i; - void *comp_cls = NULL; - void *comp = NULL; + const void *comp_cls = NULL; + const void *comp = NULL; int ret = 0; for (i = 0; i < cfg_components->len; i++) { @@ -2439,19 +2431,19 @@ int cmd_run_ctx_create_components_from_config_components( switch (cfg_comp->type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: - ret = bt_private_graph_add_source_component(ctx->graph, + ret = bt_graph_add_source_component(ctx->graph, comp_cls, cfg_comp->instance_name->str, cfg_comp->params, (void *) &comp); break; case BT_COMPONENT_CLASS_TYPE_FILTER: - ret = bt_private_graph_add_filter_component(ctx->graph, + ret = bt_graph_add_filter_component(ctx->graph, comp_cls, cfg_comp->instance_name->str, cfg_comp->params, (void *) &comp); break; case BT_COMPONENT_CLASS_TYPE_SINK: - ret = bt_private_graph_add_sink_component(ctx->graph, + ret = bt_graph_add_sink_component(ctx->graph, comp_cls, cfg_comp->instance_name->str, cfg_comp->params, (void *) &comp); @@ -2491,15 +2483,15 @@ int cmd_run_ctx_create_components_from_config_components( switch (cfg_comp->type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: g_hash_table_insert(ctx->src_components, - GUINT_TO_POINTER(quark), comp); + GUINT_TO_POINTER(quark), (void *) comp); break; case BT_COMPONENT_CLASS_TYPE_FILTER: g_hash_table_insert(ctx->flt_components, - GUINT_TO_POINTER(quark), comp); + GUINT_TO_POINTER(quark), (void *) comp); break; case BT_COMPONENT_CLASS_TYPE_SINK: g_hash_table_insert(ctx->sink_components, - GUINT_TO_POINTER(quark), comp); + GUINT_TO_POINTER(quark), (void *) comp); break; default: abort(); @@ -2558,9 +2550,9 @@ end: 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); +typedef uint64_t (*output_port_count_func_t)(const void *); +typedef const struct bt_port_output *(*borrow_output_port_by_index_func_t)( + const void *, uint64_t); static int cmd_run_ctx_connect_comp_ports(struct cmd_run_ctx *ctx, @@ -2575,7 +2567,7 @@ int cmd_run_ctx_connect_comp_ports(struct cmd_run_ctx *ctx, BT_ASSERT(count >= 0); for (i = 0; i < count; i++) { - struct bt_port_output *upstream_port = port_by_index_fn(comp, i); + const 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); @@ -2603,7 +2595,7 @@ int cmd_run_ctx_connect_ports(struct cmd_run_ctx *ctx) (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); + bt_component_source_borrow_output_port_by_index_const); if (ret) { goto end; } @@ -2616,7 +2608,7 @@ int cmd_run_ctx_connect_ports(struct cmd_run_ctx *ctx) (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); + bt_component_filter_borrow_output_port_by_index_const); if (ret) { goto end; } @@ -2701,7 +2693,7 @@ int cmd_run(struct bt_config *cfg) /* Run the graph */ while (true) { - enum bt_graph_status graph_status = bt_private_graph_run(ctx.graph); + enum bt_graph_status graph_status = bt_graph_run(ctx.graph); /* * Reset console in case something messed with console @@ -2710,7 +2702,7 @@ int cmd_run(struct bt_config *cfg) printf("%s", bt_common_color_reset()); fflush(stdout); fprintf(stderr, "%s", bt_common_color_reset()); - BT_LOGV("bt_private_graph_run() returned: status=%s", + BT_LOGV("bt_graph_run() returned: status=%s", bt_graph_status_str(graph_status)); switch (graph_status) { @@ -2720,8 +2712,7 @@ int cmd_run(struct bt_config *cfg) BT_LOGI_STR("Graph was canceled by user."); goto error; case BT_GRAPH_STATUS_AGAIN: - if (bt_graph_is_canceled( - bt_private_graph_as_graph(ctx.graph))) { + if (bt_graph_is_canceled(ctx.graph)) { BT_LOGI_STR("Graph was canceled by user."); goto error; } @@ -2732,8 +2723,7 @@ int cmd_run(struct bt_config *cfg) cfg->cmd_data.run.retry_duration_us); if (usleep(cfg->cmd_data.run.retry_duration_us)) { - if (bt_graph_is_canceled( - bt_private_graph_as_graph(ctx.graph))) { + if (bt_graph_is_canceled(ctx.graph)) { BT_LOGI_STR("Graph was canceled by user."); goto error; } diff --git a/include/Makefile.am b/include/Makefile.am index 7a716590..d3eb841d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -152,37 +152,35 @@ babeltraceplugininclude_HEADERS = \ # Graph, component, and notification API babeltracegraphincludedir = "$(includedir)/babeltrace/graph" babeltracegraphinclude_HEADERS = \ + babeltrace/graph/component-class-const.h \ + babeltrace/graph/component-class-filter-const.h \ babeltrace/graph/component-class-filter.h \ - babeltrace/graph/component-class.h \ + babeltrace/graph/component-class-sink-const.h \ babeltrace/graph/component-class-sink.h \ + babeltrace/graph/component-class-source-const.h \ babeltrace/graph/component-class-source.h \ - babeltrace/graph/component-filter.h \ - babeltrace/graph/component.h \ - babeltrace/graph/component-sink.h \ - babeltrace/graph/component-source.h \ - babeltrace/graph/connection.h \ + babeltrace/graph/component-class.h \ + babeltrace/graph/component-const.h \ + babeltrace/graph/component-filter-const.h \ + babeltrace/graph/component-sink-const.h \ + babeltrace/graph/component-source-const.h \ + babeltrace/graph/connection-const.h \ + babeltrace/graph/graph-const.h \ babeltrace/graph/graph.h \ + babeltrace/graph/notification-const.h \ + babeltrace/graph/notification-event-const.h \ babeltrace/graph/notification-event.h \ + babeltrace/graph/notification-inactivity-const.h \ babeltrace/graph/notification-inactivity.h \ - babeltrace/graph/notification-iterator.h \ + babeltrace/graph/notification-packet-const.h \ babeltrace/graph/notification-packet.h \ + babeltrace/graph/notification-stream-const.h \ babeltrace/graph/notification-stream.h \ - babeltrace/graph/notification.h \ - babeltrace/graph/port-input.h \ + babeltrace/graph/port-const.h \ + babeltrace/graph/port-input-const.h \ + babeltrace/graph/port-output-const.h \ babeltrace/graph/port-output-notification-iterator.h \ - babeltrace/graph/port-output.h \ - babeltrace/graph/port.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-query-executor.h \ + babeltrace/graph/query-executor-const.h \ babeltrace/graph/query-executor.h \ babeltrace/graph/self-component-class-filter.h \ babeltrace/graph/self-component-class-sink.h \ diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h index 1a2f5831..dc77567f 100644 --- a/include/babeltrace/babeltrace.h +++ b/include/babeltrace/babeltrace.h @@ -94,37 +94,35 @@ #include /* Graph, component, and notification API */ +#include +#include #include +#include #include +#include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include +#include #include -#include +#include #include +#include #include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include diff --git a/include/babeltrace/ctf-writer/fields-internal.h b/include/babeltrace/ctf-writer/fields-internal.h index 97e14484..b4c1f224 100644 --- a/include/babeltrace/ctf-writer/fields-internal.h +++ b/include/babeltrace/ctf-writer/fields-internal.h @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/include/babeltrace/ctf-writer/stream-internal.h b/include/babeltrace/ctf-writer/stream-internal.h index 1b74770c..79859478 100644 --- a/include/babeltrace/ctf-writer/stream-internal.h +++ b/include/babeltrace/ctf-writer/stream-internal.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/include/babeltrace/graph/component-class-const.h b/include/babeltrace/graph/component-class-const.h new file mode 100644 index 00000000..9cad4c8e --- /dev/null +++ b/include/babeltrace/graph/component-class-const.h @@ -0,0 +1,81 @@ +#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H + +/* + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * 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 bt_bool */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_component_class; + +enum bt_component_class_type { + BT_COMPONENT_CLASS_TYPE_SOURCE = 0, + BT_COMPONENT_CLASS_TYPE_FILTER = 1, + BT_COMPONENT_CLASS_TYPE_SINK = 2, +}; + +extern const char *bt_component_class_get_name( + const struct bt_component_class *component_class); + +extern const char *bt_component_class_get_description( + const struct bt_component_class *component_class); + +extern const char *bt_component_class_get_help( + const struct bt_component_class *component_class); + +extern enum bt_component_class_type bt_component_class_get_type( + const struct bt_component_class *component_class); + +static inline +bt_bool bt_component_class_is_source( + const struct bt_component_class *component_class) +{ + return bt_component_class_get_type(component_class) == + BT_COMPONENT_CLASS_TYPE_SOURCE; +} + +static inline +bt_bool bt_component_class_is_filter( + const struct bt_component_class *component_class) +{ + return bt_component_class_get_type(component_class) == + BT_COMPONENT_CLASS_TYPE_FILTER; +} + +static inline +bt_bool bt_component_class_is_sink( + const struct bt_component_class *component_class) +{ + return bt_component_class_get_type(component_class) == + BT_COMPONENT_CLASS_TYPE_SINK; +} + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H */ diff --git a/include/babeltrace/graph/component-class-filter-const.h b/include/babeltrace/graph/component-class-filter-const.h new file mode 100644 index 00000000..0c12457a --- /dev/null +++ b/include/babeltrace/graph/component-class-filter-const.h @@ -0,0 +1,45 @@ +#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H + +/* + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * 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; +struct bt_component_class_filter; + +static inline +const struct bt_component_class * +bt_component_class_filter_as_component_class_const( + const struct bt_component_class_filter *comp_cls_filter) +{ + return (const void *) comp_cls_filter; +} + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H */ diff --git a/include/babeltrace/graph/component-class-filter.h b/include/babeltrace/graph/component-class-filter.h index 83365be3..2dec11ca 100644 --- a/include/babeltrace/graph/component-class-filter.h +++ b/include/babeltrace/graph/component-class-filter.h @@ -23,21 +23,156 @@ * SOFTWARE. */ +#include + +/* For enum bt_notification_array_const */ +#include + +/* For enum bt_self_component_status */ +#include + +/* For enum bt_self_notification_iterator_status */ +#include + +/* For enum bt_query_status */ +#include + #ifdef __cplusplus extern "C" { #endif struct bt_component_class; struct bt_component_class_filter; +struct bt_port_input; +struct bt_port_output; +struct bt_query_executor; +struct bt_self_component_class_filter; +struct bt_self_component_filter; +struct bt_self_component_port_input; +struct bt_self_component_port_output; +struct bt_value; + +typedef enum bt_self_component_status +(*bt_component_class_filter_init_method)( + struct bt_self_component_filter *self_component, + const struct bt_value *params, void *init_method_data); + +typedef void (*bt_component_class_filter_finalize_method)( + struct bt_self_component_filter *self_component); + +typedef enum bt_self_notification_iterator_status +(*bt_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_component_class_filter_notification_iterator_finalize_method)( + struct bt_self_notification_iterator *notification_iterator); + +typedef enum bt_self_notification_iterator_status +(*bt_component_class_filter_notification_iterator_next_method)( + struct bt_self_notification_iterator *notification_iterator, + bt_notification_array_const notifs, uint64_t capacity, + uint64_t *count); + +typedef enum bt_query_status +(*bt_component_class_filter_query_method)( + struct bt_self_component_class_filter *comp_class, + const struct bt_query_executor *query_executor, + const char *object, const struct bt_value *params, + const struct bt_value **result); + +typedef enum bt_self_component_status +(*bt_component_class_filter_accept_input_port_connection_method)( + struct bt_self_component_filter *self_component, + struct bt_self_component_port_input *self_port, + const struct bt_port_output *other_port); + +typedef enum bt_self_component_status +(*bt_component_class_filter_accept_output_port_connection_method)( + struct bt_self_component_filter *self_component, + struct bt_self_component_port_output *self_port, + const struct bt_port_input *other_port); + +typedef enum bt_self_component_status +(*bt_component_class_filter_input_port_connected_method)( + struct bt_self_component_filter *self_component, + struct bt_self_component_port_input *self_port, + const struct bt_port_output *other_port); + +typedef enum bt_self_component_status +(*bt_component_class_filter_output_port_connected_method)( + struct bt_self_component_filter *self_component, + struct bt_self_component_port_output *self_port, + const struct bt_port_input *other_port); + +typedef void +(*bt_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_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_component_class * -bt_component_class_filter_as_component_class( +struct bt_component_class *bt_component_class_filter_as_component_class( struct bt_component_class_filter *comp_cls_filter) { return (void *) comp_cls_filter; } +extern +struct bt_component_class_filter *bt_component_class_filter_create( + const char *name, + bt_component_class_filter_notification_iterator_next_method method); + +extern int bt_component_class_filter_set_init_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_init_method method); + +extern int bt_component_class_filter_set_finalize_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_finalize_method method); + +extern int bt_component_class_filter_set_accept_input_port_connection_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_accept_input_port_connection_method method); + +extern int bt_component_class_filter_set_accept_output_port_connection_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_accept_output_port_connection_method method); + +extern int bt_component_class_filter_set_input_port_connected_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_input_port_connected_method method); + +extern int bt_component_class_filter_set_output_port_connected_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_output_port_connected_method method); + +extern int bt_component_class_filter_set_input_port_disconnected_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_input_port_disconnected_method method); + +extern int bt_component_class_filter_set_output_port_disconnected_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_output_port_disconnected_method method); + +extern int bt_component_class_filter_set_query_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_query_method method); + +extern int bt_component_class_filter_set_notification_iterator_init_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_notification_iterator_init_method method); + +extern int bt_component_class_filter_set_notification_iterator_finalize_method( + struct bt_component_class_filter *comp_class, + bt_component_class_filter_notification_iterator_finalize_method method); + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-class-internal.h b/include/babeltrace/graph/component-class-internal.h index e5185739..d347d2c2 100644 --- a/include/babeltrace/graph/component-class-internal.h +++ b/include/babeltrace/graph/component-class-internal.h @@ -26,11 +26,11 @@ * SOFTWARE. */ -#include +#include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -65,46 +65,46 @@ struct bt_component_class { struct bt_component_class_source { struct bt_component_class parent; struct { - 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; + bt_component_class_source_init_method init; + bt_component_class_source_finalize_method finalize; + bt_component_class_source_notification_iterator_init_method notif_iter_init; + bt_component_class_source_notification_iterator_finalize_method notif_iter_finalize; + bt_component_class_source_notification_iterator_next_method notif_iter_next; + bt_component_class_source_query_method query; + bt_component_class_source_accept_output_port_connection_method accept_output_port_connection; + bt_component_class_source_output_port_connected_method output_port_connected; + bt_component_class_source_output_port_disconnected_method output_port_disconnected; } methods; }; struct bt_component_class_sink { struct bt_component_class parent; 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; - bt_private_component_class_sink_consume_method consume; + bt_component_class_sink_init_method init; + bt_component_class_sink_finalize_method finalize; + bt_component_class_sink_query_method query; + bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection; + bt_component_class_sink_input_port_connected_method input_port_connected; + bt_component_class_sink_input_port_disconnected_method input_port_disconnected; + bt_component_class_sink_consume_method consume; } methods; }; struct bt_component_class_filter { struct bt_component_class parent; struct { - 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; + bt_component_class_filter_init_method init; + bt_component_class_filter_finalize_method finalize; + bt_component_class_filter_notification_iterator_init_method notif_iter_init; + bt_component_class_filter_notification_iterator_finalize_method notif_iter_finalize; + bt_component_class_filter_notification_iterator_next_method notif_iter_next; + bt_component_class_filter_query_method query; + bt_component_class_filter_accept_input_port_connection_method accept_input_port_connection; + bt_component_class_filter_accept_output_port_connection_method accept_output_port_connection; + bt_component_class_filter_input_port_connected_method input_port_connected; + bt_component_class_filter_output_port_connected_method output_port_connected; + bt_component_class_filter_input_port_disconnected_method input_port_disconnected; + bt_component_class_filter_output_port_disconnected_method output_port_disconnected; } methods; }; @@ -113,7 +113,8 @@ 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); +void _bt_component_class_freeze( + const struct bt_component_class *component_class); #ifdef BT_DEV_MODE # define bt_component_class_freeze _bt_component_class_freeze diff --git a/include/babeltrace/graph/component-class-sink-colander-internal.h b/include/babeltrace/graph/component-class-sink-colander-internal.h index 0e86ff4b..b794f74e 100644 --- a/include/babeltrace/graph/component-class-sink-colander-internal.h +++ b/include/babeltrace/graph/component-class-sink-colander-internal.h @@ -25,16 +25,14 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif -struct bt_component_class; -struct bt_notification; - struct bt_component_class_sink_colander_data { - bt_notification_array notifs; + bt_notification_array_const notifs; uint64_t *count_addr; }; diff --git a/include/babeltrace/graph/component-class-sink-const.h b/include/babeltrace/graph/component-class-sink-const.h new file mode 100644 index 00000000..d862221a --- /dev/null +++ b/include/babeltrace/graph/component-class-sink-const.h @@ -0,0 +1,45 @@ +#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H + +/* + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * 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; +struct bt_component_class_sink; + +static inline +const struct bt_component_class * +bt_component_class_sink_as_component_class_const( + const struct bt_component_class_sink *comp_cls_sink) +{ + return (const void *) comp_cls_sink; +} + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H */ diff --git a/include/babeltrace/graph/component-class-sink.h b/include/babeltrace/graph/component-class-sink.h index db28fe83..6164c0cc 100644 --- a/include/babeltrace/graph/component-class-sink.h +++ b/include/babeltrace/graph/component-class-sink.h @@ -23,21 +23,99 @@ * SOFTWARE. */ +#include + +/* For enum bt_self_component_status */ +#include + +/* For enum bt_query_status */ +#include + #ifdef __cplusplus extern "C" { #endif struct bt_component_class; struct bt_component_class_sink; +struct bt_port_output; +struct bt_query_executor; +struct bt_self_component_class_sink; +struct bt_self_component_port_input; +struct bt_self_component_sink; +struct bt_value; + +typedef enum bt_self_component_status +(*bt_component_class_sink_init_method)( + struct bt_self_component_sink *self_component, + const struct bt_value *params, void *init_method_data); + +typedef void (*bt_component_class_sink_finalize_method)( + struct bt_self_component_sink *self_component); + +typedef enum bt_query_status +(*bt_component_class_sink_query_method)( + struct bt_self_component_class_sink *comp_class, + const struct bt_query_executor *query_executor, + const char *object, const struct bt_value *params, + const struct bt_value **result); + +typedef enum bt_self_component_status +(*bt_component_class_sink_accept_input_port_connection_method)( + struct bt_self_component_sink *self_component, + struct bt_self_component_port_input *self_port, + const struct bt_port_output *other_port); + +typedef enum bt_self_component_status +(*bt_component_class_sink_input_port_connected_method)( + struct bt_self_component_sink *self_component, + struct bt_self_component_port_input *self_port, + const struct bt_port_output *other_port); + +typedef void +(*bt_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_component_class_sink_consume_method)( + struct bt_self_component_sink *self_component); static inline -struct bt_component_class * -bt_component_class_sink_as_component_class( +struct bt_component_class *bt_component_class_sink_as_component_class( struct bt_component_class_sink *comp_cls_sink) { return (void *) comp_cls_sink; } +extern +struct bt_component_class_sink *bt_component_class_sink_create( + const char *name, + bt_component_class_sink_consume_method method); + +extern int bt_component_class_sink_set_init_method( + struct bt_component_class_sink *comp_class, + bt_component_class_sink_init_method method); + +extern int bt_component_class_sink_set_finalize_method( + struct bt_component_class_sink *comp_class, + bt_component_class_sink_finalize_method method); + +extern int bt_component_class_sink_set_accept_input_port_connection_method( + struct bt_component_class_sink *comp_class, + bt_component_class_sink_accept_input_port_connection_method method); + +extern int bt_component_class_sink_set_input_port_connected_method( + struct bt_component_class_sink *comp_class, + bt_component_class_sink_input_port_connected_method method); + +extern int bt_component_class_sink_set_input_port_disconnected_method( + struct bt_component_class_sink *comp_class, + bt_component_class_sink_input_port_disconnected_method method); + +extern int bt_component_class_sink_set_query_method( + struct bt_component_class_sink *comp_class, + bt_component_class_sink_query_method method); + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-class-source-const.h b/include/babeltrace/graph/component-class-source-const.h new file mode 100644 index 00000000..6491239c --- /dev/null +++ b/include/babeltrace/graph/component-class-source-const.h @@ -0,0 +1,45 @@ +#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H + +/* + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * 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; +struct bt_component_class_source; + +static inline +const struct bt_component_class * +bt_component_class_source_as_component_class_const( + const struct bt_component_class_source *comp_cls_source) +{ + return (const void *) comp_cls_source; +} + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H */ diff --git a/include/babeltrace/graph/component-class-source.h b/include/babeltrace/graph/component-class-source.h index 8e24e9c0..418b9c53 100644 --- a/include/babeltrace/graph/component-class-source.h +++ b/include/babeltrace/graph/component-class-source.h @@ -23,21 +23,125 @@ * SOFTWARE. */ +#include + +/* For enum bt_notification_array_const */ +#include + +/* For enum bt_self_component_status */ +#include + +/* For enum bt_self_notification_iterator_status */ +#include + +/* For enum bt_query_status */ +#include + #ifdef __cplusplus extern "C" { #endif -struct bt_component_class; +struct bt_self_component_class_source; +struct bt_component_class_source; +struct bt_self_component_source; struct bt_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_component_class_source_init_method)( + struct bt_self_component_source *self_component, + const struct bt_value *params, void *init_method_data); + +typedef void (*bt_component_class_source_finalize_method)( + struct bt_self_component_source *self_component); + +typedef enum bt_self_notification_iterator_status +(*bt_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_component_class_source_notification_iterator_finalize_method)( + struct bt_self_notification_iterator *notification_iterator); + +typedef enum bt_self_notification_iterator_status +(*bt_component_class_source_notification_iterator_next_method)( + struct bt_self_notification_iterator *notification_iterator, + bt_notification_array_const notifs, uint64_t capacity, + uint64_t *count); + +typedef enum bt_query_status +(*bt_component_class_source_query_method)( + struct bt_self_component_class_source *comp_class, + const struct bt_query_executor *query_executor, + const char *object, const struct bt_value *params, + const struct bt_value **result); + +typedef enum bt_self_component_status +(*bt_component_class_source_accept_output_port_connection_method)( + struct bt_self_component_source *self_component, + struct bt_self_component_port_output *self_port, + const struct bt_port_input *other_port); + +typedef enum bt_self_component_status +(*bt_component_class_source_output_port_connected_method)( + struct bt_self_component_source *self_component, + struct bt_self_component_port_output *self_port, + const struct bt_port_input *other_port); + +typedef void +(*bt_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_component_class * -bt_component_class_source_as_component_class( +struct bt_component_class *bt_component_class_source_as_component_class( struct bt_component_class_source *comp_cls_source) { return (void *) comp_cls_source; } +extern +struct bt_component_class_source *bt_component_class_source_create( + const char *name, + bt_component_class_source_notification_iterator_next_method method); + +extern int bt_component_class_source_set_init_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_init_method method); + +extern int bt_component_class_source_set_finalize_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_finalize_method method); + +extern int bt_component_class_source_set_accept_output_port_connection_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_accept_output_port_connection_method method); + +extern int bt_component_class_source_set_output_port_connected_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_output_port_connected_method method); + +extern int bt_component_class_source_set_output_port_disconnected_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_output_port_disconnected_method method); + +extern int bt_component_class_source_set_query_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_query_method method); + +extern int bt_component_class_source_set_notification_iterator_init_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_notification_iterator_init_method method); + +extern int bt_component_class_source_set_notification_iterator_finalize_method( + struct bt_component_class_source *comp_class, + bt_component_class_source_notification_iterator_finalize_method method); + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-class.h b/include/babeltrace/graph/component-class.h index 46cb59d2..454abba8 100644 --- a/include/babeltrace/graph/component-class.h +++ b/include/babeltrace/graph/component-class.h @@ -23,8 +23,8 @@ * SOFTWARE. */ -/* For bt_bool */ -#include +/* For enum bt_query_executor_status */ +#include #ifdef __cplusplus extern "C" { @@ -32,44 +32,22 @@ extern "C" { struct bt_component_class; -enum bt_component_class_type { - BT_COMPONENT_CLASS_TYPE_SOURCE = 0, - BT_COMPONENT_CLASS_TYPE_FILTER = 1, - BT_COMPONENT_CLASS_TYPE_SINK = 2, +enum bt_query_status { + BT_QUERY_STATUS_OK = BT_QUERY_EXECUTOR_STATUS_OK, + BT_QUERY_STATUS_AGAIN = BT_QUERY_EXECUTOR_STATUS_AGAIN, + BT_QUERY_STATUS_ERROR = BT_QUERY_EXECUTOR_STATUS_ERROR, + BT_QUERY_STATUS_NOMEM = BT_QUERY_EXECUTOR_STATUS_NOMEM, + BT_QUERY_STATUS_INVALID_OBJECT = BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT, + BT_QUERY_STATUS_INVALID_PARAMS = BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS, }; -extern const char *bt_component_class_get_name( - struct bt_component_class *component_class); +extern int bt_component_class_set_description( + struct bt_component_class *component_class, + const char *description); -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); - -extern enum bt_component_class_type bt_component_class_get_type( - struct bt_component_class *component_class); - -static inline -bt_bool bt_component_class_is_source(struct bt_component_class *component_class) -{ - return bt_component_class_get_type(component_class) == - BT_COMPONENT_CLASS_TYPE_SOURCE; -} - -static inline -bt_bool bt_component_class_is_filter(struct bt_component_class *component_class) -{ - return bt_component_class_get_type(component_class) == - BT_COMPONENT_CLASS_TYPE_FILTER; -} - -static inline -bt_bool bt_component_class_is_sink(struct bt_component_class *component_class) -{ - return bt_component_class_get_type(component_class) == - BT_COMPONENT_CLASS_TYPE_SINK; -} +extern int bt_component_class_set_help( + struct bt_component_class *component_class, + const char *help); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/component.h b/include/babeltrace/graph/component-const.h similarity index 73% rename from include/babeltrace/graph/component.h rename to include/babeltrace/graph/component-const.h index 7edbc0c3..3f6182e6 100644 --- a/include/babeltrace/graph/component.h +++ b/include/babeltrace/graph/component-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_COMPONENT_H -#define BABELTRACE_GRAPH_COMPONENT_H +#ifndef BABELTRACE_GRAPH_COMPONENT_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_CONST_H /* * Copyright 2015 Jérémie Galarneau @@ -25,8 +25,8 @@ * SOFTWARE. */ -/* For BT_COMPONENT_CLASS_TYPE_* */ -#include +/* For enum bt_component_class_type */ +#include /* For bt_bool */ #include @@ -47,7 +47,7 @@ struct bt_port; * @param component Component instance of which to get the name * @returns Returns a pointer to the component's name */ -extern const char *bt_component_get_name(struct bt_component *component); +extern const char *bt_component_get_name(const struct bt_component *component); /** * Get component's class. @@ -55,37 +55,38 @@ extern const char *bt_component_get_name(struct bt_component *component); * @param component Component instance of which to get the class * @returns The component's class */ -extern struct bt_component_class *bt_component_get_class( - struct bt_component *component); +extern const struct bt_component_class *bt_component_borrow_class_const( + const struct bt_component *component); extern enum bt_component_class_type bt_component_get_class_type( - struct bt_component *component); + const struct bt_component *component); static inline -bt_bool bt_component_is_source(struct bt_component *component) +bt_bool bt_component_is_source(const struct bt_component *component) { return bt_component_get_class_type(component) == BT_COMPONENT_CLASS_TYPE_SOURCE; } static inline -bt_bool bt_component_is_filter(struct bt_component *component) +bt_bool bt_component_is_filter(const struct bt_component *component) { return bt_component_get_class_type(component) == BT_COMPONENT_CLASS_TYPE_FILTER; } static inline -bt_bool bt_component_is_sink(struct bt_component *component) +bt_bool bt_component_is_sink(const struct bt_component *component) { return bt_component_get_class_type(component) == BT_COMPONENT_CLASS_TYPE_SINK; } -extern bt_bool bt_component_graph_is_canceled(struct bt_component *component); +extern bt_bool bt_component_graph_is_canceled( + const struct bt_component *component); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_COMPONENT_H */ +#endif /* BABELTRACE_GRAPH_COMPONENT_CONST_H */ diff --git a/include/babeltrace/graph/component-filter.h b/include/babeltrace/graph/component-filter-const.h similarity index 60% rename from include/babeltrace/graph/component-filter.h rename to include/babeltrace/graph/component-filter-const.h index 89238f28..015ae22b 100644 --- a/include/babeltrace/graph/component-filter.h +++ b/include/babeltrace/graph/component-filter-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_COMPONENT_FILTER_H -#define BABELTRACE_GRAPH_COMPONENT_FILTER_H +#ifndef BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H /* * Copyright 2016 Jérémie Galarneau @@ -37,32 +37,36 @@ struct bt_port_input; struct bt_port_output; static inline -struct bt_component *bt_component_filter_as_component( - struct bt_component_filter *component) +const struct bt_component *bt_component_filter_as_component_const( + const struct bt_component_filter *component) { - return (void *) component; + return (const void *) component; } extern uint64_t bt_component_filter_get_input_port_count( - struct bt_component_filter *component); + const 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 const struct bt_port_input * +bt_component_filter_borrow_input_port_by_name_const( + const 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 const struct bt_port_input * +bt_component_filter_borrow_input_port_by_index_const( + const struct bt_component_filter *component, uint64_t index); extern uint64_t bt_component_filter_get_output_port_count( - struct bt_component_filter *component); + const 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 const struct bt_port_output * +bt_component_filter_borrow_output_port_by_name_const( + const struct bt_component_filter *component, const char *name); -extern struct bt_port_output *bt_component_filter_borrow_output_port_by_index( - struct bt_component_filter *component, uint64_t index); +extern const struct bt_port_output * +bt_component_filter_borrow_output_port_by_index_const( + const struct bt_component_filter *component, uint64_t index); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_COMPONENT_FILTER_H */ +#endif /* BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H */ diff --git a/include/babeltrace/graph/component-filter-internal.h b/include/babeltrace/graph/component-filter-internal.h index a31a881d..79a7b000 100644 --- a/include/babeltrace/graph/component-filter-internal.h +++ b/include/babeltrace/graph/component-filter-internal.h @@ -26,6 +26,7 @@ */ #include +#include #include #include @@ -35,7 +36,7 @@ struct bt_component_filter { BT_HIDDEN struct bt_component *bt_component_filter_create( - struct bt_component_class *class); + const struct bt_component_class *class); BT_HIDDEN void bt_component_filter_destroy(struct bt_component *component); diff --git a/include/babeltrace/graph/component-internal.h b/include/babeltrace/graph/component-internal.h index d186425e..4ba2fe54 100644 --- a/include/babeltrace/graph/component-internal.h +++ b/include/babeltrace/graph/component-internal.h @@ -26,7 +26,7 @@ */ #include -#include +#include #include #include #include @@ -99,10 +99,10 @@ void bt_component_set_graph(struct bt_component *component, struct bt_graph *graph); BT_HIDDEN -uint64_t bt_component_get_input_port_count(struct bt_component *comp); +uint64_t bt_component_get_input_port_count(const struct bt_component *comp); BT_HIDDEN -uint64_t bt_component_get_output_port_count(struct bt_component *comp); +uint64_t bt_component_get_output_port_count(const struct bt_component *comp); BT_HIDDEN struct bt_port_input *bt_component_borrow_input_port_by_index( diff --git a/include/babeltrace/graph/component-sink.h b/include/babeltrace/graph/component-sink-const.h similarity index 69% rename from include/babeltrace/graph/component-sink.h rename to include/babeltrace/graph/component-sink-const.h index 12fe73d4..af69be8c 100644 --- a/include/babeltrace/graph/component-sink.h +++ b/include/babeltrace/graph/component-sink-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_COMPONENT_SINK_H -#define BABELTRACE_GRAPH_COMPONENT_SINK_H +#ifndef BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H /* * Copyright 2017 Jérémie Galarneau @@ -36,23 +36,25 @@ struct bt_component_sink; struct bt_port_input; static inline -struct bt_component *bt_component_sink_as_component( - struct bt_component_sink *component) +const struct bt_component *bt_component_sink_as_component_const( + const struct bt_component_sink *component) { - return (void *) component; + return (const void *) component; } extern uint64_t bt_component_sink_get_input_port_count( - struct bt_component_sink *component); + const 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 const struct bt_port_input * +bt_component_sink_borrow_input_port_by_name_const( + const struct bt_component_sink *component, const char *name); -extern struct bt_port_input *bt_component_sink_borrow_input_port_by_index( - struct bt_component_sink *component, uint64_t index); +extern const struct bt_port_input * +bt_component_sink_borrow_input_port_by_index_const( + const struct bt_component_sink *component, uint64_t index); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_COMPONENT_SINK_H */ +#endif /* BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H */ diff --git a/include/babeltrace/graph/component-sink-internal.h b/include/babeltrace/graph/component-sink-internal.h index 7b67e2fd..a5880fef 100644 --- a/include/babeltrace/graph/component-sink-internal.h +++ b/include/babeltrace/graph/component-sink-internal.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -37,7 +37,7 @@ struct bt_component_sink { BT_HIDDEN struct bt_component *bt_component_sink_create( - struct bt_component_class *class); + const struct bt_component_class *class); BT_HIDDEN void bt_component_sink_destroy(struct bt_component *component); diff --git a/include/babeltrace/graph/component-source.h b/include/babeltrace/graph/component-source-const.h similarity index 70% rename from include/babeltrace/graph/component-source.h rename to include/babeltrace/graph/component-source-const.h index cfdd41fe..06e014f5 100644 --- a/include/babeltrace/graph/component-source.h +++ b/include/babeltrace/graph/component-source-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_COMPONENT_SOURCE_H -#define BABELTRACE_GRAPH_COMPONENT_SOURCE_H +#ifndef BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H +#define BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H /* * Copyright 2016 Jérémie Galarneau @@ -36,23 +36,25 @@ struct bt_component_source; struct bt_port_output; static inline -struct bt_component *bt_component_source_as_component( - struct bt_component_source *component) +const struct bt_component *bt_component_source_as_component_const( + const struct bt_component_source *component) { return (void *) component; } extern uint64_t bt_component_source_get_output_port_count( - struct bt_component_source *component); + const 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 const struct bt_port_output * +bt_component_source_borrow_output_port_by_name_const( + const struct bt_component_source *component, const char *name); -extern struct bt_port_output *bt_component_source_borrow_output_port_by_index( - struct bt_component_source *component, uint64_t index); +extern const struct bt_port_output * +bt_component_source_borrow_output_port_by_index_const( + const struct bt_component_source *component, uint64_t index); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_COMPONENT_SOURCE_H */ +#endif /* BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H */ diff --git a/include/babeltrace/graph/component-source-internal.h b/include/babeltrace/graph/component-source-internal.h index 08c08296..21e4da2c 100644 --- a/include/babeltrace/graph/component-source-internal.h +++ b/include/babeltrace/graph/component-source-internal.h @@ -35,7 +35,7 @@ struct bt_component_source { BT_HIDDEN struct bt_component *bt_component_source_create( - struct bt_component_class *class); + const struct bt_component_class *class); BT_HIDDEN void bt_component_source_destroy(struct bt_component *component); diff --git a/include/babeltrace/graph/connection.h b/include/babeltrace/graph/connection-const.h similarity index 75% rename from include/babeltrace/graph/connection.h rename to include/babeltrace/graph/connection-const.h index c49de371..1d93c645 100644 --- a/include/babeltrace/graph/connection.h +++ b/include/babeltrace/graph/connection-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_CONNECTION_H -#define BABELTRACE_GRAPH_CONNECTION_H +#ifndef BABELTRACE_GRAPH_CONNECTION_CONST_H +#define BABELTRACE_GRAPH_CONNECTION_CONST_H /* * Copyright 2017 Jérémie Galarneau @@ -36,16 +36,16 @@ struct bt_port_input; struct bt_port_output; struct bt_connection; -extern struct bt_port_input *bt_connection_borrow_downstream_port( - struct bt_connection *connection); +extern const struct bt_port_input *bt_connection_borrow_downstream_port_const( + const struct bt_connection *connection); -extern struct bt_port_output *bt_connection_borrow_upstream_port( - struct bt_connection *connection); +extern const struct bt_port_output *bt_connection_borrow_upstream_port_const( + const struct bt_connection *connection); -extern bt_bool bt_connection_is_ended(struct bt_connection *connection); +extern bt_bool bt_connection_is_ended(const struct bt_connection *connection); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_CONNECTION_H */ +#endif /* BABELTRACE_GRAPH_CONNECTION_CONST_H */ diff --git a/include/babeltrace/graph/connection-internal.h b/include/babeltrace/graph/connection-internal.h index 98222c04..784ca643 100644 --- a/include/babeltrace/graph/connection-internal.h +++ b/include/babeltrace/graph/connection-internal.h @@ -25,7 +25,7 @@ * SOFTWARE. */ -#include +#include #include #include #include diff --git a/include/babeltrace/graph/notification.h b/include/babeltrace/graph/const-notification.h similarity index 90% rename from include/babeltrace/graph/notification.h rename to include/babeltrace/graph/const-notification.h index 658fe0e8..44c50d3c 100644 --- a/include/babeltrace/graph/notification.h +++ b/include/babeltrace/graph/const-notification.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_H -#define BABELTRACE_GRAPH_NOTIFICATION_H +#ifndef BABELTRACE_GRAPH_NOTIFICATION_CONST_H +#define BABELTRACE_GRAPH_NOTIFICATION_CONST_H /* * Copyright 2015 Jérémie Galarneau @@ -52,10 +52,10 @@ enum bt_notification_type { * @returns One of #bt_notification_type */ extern enum bt_notification_type bt_notification_get_type( - struct bt_notification *notification); + const struct bt_notification *notification); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_H */ +#endif /* BABELTRACE_GRAPH_NOTIFICATION_CONST_H */ diff --git a/include/babeltrace/graph/graph-const.h b/include/babeltrace/graph/graph-const.h new file mode 100644 index 00000000..e2f24e05 --- /dev/null +++ b/include/babeltrace/graph/graph-const.h @@ -0,0 +1,54 @@ +#ifndef BABELTRACE_GRAPH_GRAPH_CONST_H +#define BABELTRACE_GRAPH_GRAPH_CONST_H + +/* + * Copyright 2017 Jérémie Galarneau + * + * Author: Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * 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 bt_bool */ +#include + +#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, + BT_GRAPH_STATUS_CANCELED = 125, + BT_GRAPH_STATUS_ERROR = -1, + BT_GRAPH_STATUS_NO_SINK = -6, + BT_GRAPH_STATUS_NOMEM = -12, +}; + +extern bt_bool bt_graph_is_canceled(const struct bt_graph *graph); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_GRAPH_CONST_H */ diff --git a/include/babeltrace/graph/graph-internal.h b/include/babeltrace/graph/graph-internal.h index 80a661b4..cb2da872 100644 --- a/include/babeltrace/graph/graph-internal.h +++ b/include/babeltrace/graph/graph-internal.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/babeltrace/graph/graph.h b/include/babeltrace/graph/graph.h index 440fe58b..57a394fd 100644 --- a/include/babeltrace/graph/graph.h +++ b/include/babeltrace/graph/graph.h @@ -28,24 +28,254 @@ /* For bt_bool */ #include +/* For enum bt_graph_status */ +#include + #ifdef __cplusplus extern "C" { #endif +struct bt_component; +struct bt_component_class; +struct bt_component_class_filter; +struct bt_component_class_sink; +struct bt_component_class_source; +struct bt_component_filter; +struct bt_component_sink; +struct bt_component_source; +struct bt_connection; struct bt_graph; +struct bt_port_input; +struct bt_port_output; +struct bt_value; + +typedef void (*bt_graph_filter_component_input_port_added_listener_func)( + const struct bt_component_filter *component, + const struct bt_port_input *port, void *data); + +typedef void (*bt_graph_sink_component_input_port_added_listener_func)( + const struct bt_component_sink *component, + const struct bt_port_input *port, void *data); + +typedef void (*bt_graph_source_component_output_port_added_listener_func)( + const struct bt_component_source *component, + const struct bt_port_output *port, void *data); + +typedef void (*bt_graph_filter_component_output_port_added_listener_func)( + const struct bt_component_filter *component, + const struct bt_port_output *port, void *data); + +typedef void (*bt_graph_filter_component_input_port_removed_listener_func)( + const struct bt_component_filter *component, + const struct bt_port_input *port, void *data); + +typedef void (*bt_graph_sink_component_input_port_removed_listener_func)( + const struct bt_component_sink *component, + const struct bt_port_input *port, void *data); + +typedef void (*bt_graph_source_component_output_port_removed_listener_func)( + const struct bt_component_source *component, + const struct bt_port_output *port, void *data); + +typedef void (*bt_graph_filter_component_output_port_removed_listener_func)( + const struct bt_component_filter *component, + const struct bt_port_output *port, void *data); + +typedef void (*bt_graph_source_filter_component_ports_connected_listener_func)( + const struct bt_component_source *source_component, + const struct bt_component_filter *filter_component, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, void *data); + +typedef void (*bt_graph_source_sink_component_ports_connected_listener_func)( + const struct bt_component_source *source_component, + const struct bt_component_sink *sink_component, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, void *data); + +typedef void (*bt_graph_filter_sink_component_ports_connected_listener_func)( + const struct bt_component_filter *filter_component, + const struct bt_component_sink *sink_component, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, void *data); + +typedef void (*bt_graph_source_filter_component_ports_disconnected_listener_func)( + const struct bt_component_source *source_component, + const struct bt_component_filter *filter_component, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, + void *data); + +typedef void (*bt_graph_source_sink_component_ports_disconnected_listener_func)( + const struct bt_component_source *source_component, + const struct bt_component_sink *sink_component, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, + void *data); + +typedef void (*bt_graph_filter_sink_component_ports_disconnected_listener_func)( + const struct bt_component_filter *filter_component, + const struct bt_component_sink *sink_component, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, + void *data); + +typedef void (* bt_graph_listener_removed_func)(void *data); + +extern struct bt_graph *bt_graph_create(void); + +extern enum bt_graph_status bt_graph_add_source_component( + struct bt_graph *graph, + const struct bt_component_class_source *component_class, + const char *name, const struct bt_value *params, + const struct bt_component_source **component); + +extern enum bt_graph_status +bt_graph_add_source_component_with_init_method_data( + struct bt_graph *graph, + const struct bt_component_class_source *component_class, + const char *name, const struct bt_value *params, + void *init_method_data, + const struct bt_component_source **component); + +extern enum bt_graph_status bt_graph_add_filter_component( + struct bt_graph *graph, + const struct bt_component_class_filter *component_class, + const char *name, const struct bt_value *params, + const struct bt_component_filter **component); + +extern enum bt_graph_status +bt_graph_add_filter_component_with_init_method_data( + struct bt_graph *graph, + const struct bt_component_class_filter *component_class, + const char *name, const struct bt_value *params, + void *init_method_data, + const struct bt_component_filter **component); + +extern enum bt_graph_status bt_graph_add_sink_component( + struct bt_graph *graph, + const struct bt_component_class_sink *component_class, + const char *name, const struct bt_value *params, + const struct bt_component_sink **component); + +extern enum bt_graph_status +bt_graph_add_sink_component_with_init_method_data( + struct bt_graph *graph, + const struct bt_component_class_sink *component_class, + const char *name, const struct bt_value *params, + void *init_method_data, + const struct bt_component_sink **component); + +extern enum bt_graph_status bt_graph_connect_ports( + struct bt_graph *graph, + const struct bt_port_output *upstream, + const struct bt_port_input *downstream, + const struct bt_connection **connection); + +extern enum bt_graph_status bt_graph_run(struct bt_graph *graph); + +extern enum bt_graph_status bt_graph_consume( + struct bt_graph *graph); + +extern enum bt_graph_status +bt_graph_add_filter_component_input_port_added_listener( + struct bt_graph *graph, + bt_graph_filter_component_input_port_added_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_sink_component_input_port_added_listener( + struct bt_graph *graph, + bt_graph_sink_component_input_port_added_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_source_component_output_port_added_listener( + struct bt_graph *graph, + bt_graph_source_component_output_port_added_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_filter_component_output_port_added_listener( + struct bt_graph *graph, + bt_graph_filter_component_output_port_added_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_filter_component_input_port_removed_listener( + struct bt_graph *graph, + bt_graph_filter_component_input_port_removed_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_sink_component_input_port_removed_listener( + struct bt_graph *graph, + bt_graph_sink_component_input_port_removed_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_source_component_output_port_removed_listener( + struct bt_graph *graph, + bt_graph_source_component_output_port_removed_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_filter_component_output_port_removed_listener( + struct bt_graph *graph, + bt_graph_filter_component_output_port_removed_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_source_filter_component_ports_connected_listener( + struct bt_graph *graph, + bt_graph_source_filter_component_ports_connected_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_source_sink_component_ports_connected_listener( + struct bt_graph *graph, + bt_graph_source_sink_component_ports_connected_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_filter_sink_component_ports_connected_listener( + struct bt_graph *graph, + bt_graph_filter_sink_component_ports_connected_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_source_filter_component_ports_disconnected_listener( + struct bt_graph *graph, + bt_graph_source_filter_component_ports_disconnected_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_source_sink_component_ports_disconnected_listener( + struct bt_graph *graph, + bt_graph_source_sink_component_ports_disconnected_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); + +extern enum bt_graph_status +bt_graph_add_filter_sink_component_ports_disconnected_listener( + struct bt_graph *graph, + bt_graph_filter_sink_component_ports_disconnected_listener_func listener, + bt_graph_listener_removed_func listener_removed, void *data, + int *listener_id); -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, - BT_GRAPH_STATUS_CANCELED = 125, - BT_GRAPH_STATUS_ERROR = -1, - BT_GRAPH_STATUS_NO_SINK = -6, - BT_GRAPH_STATUS_NOMEM = -12, -}; - -extern bt_bool bt_graph_is_canceled(struct bt_graph *graph); +extern enum bt_graph_status bt_graph_cancel(struct bt_graph *graph); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/notification-const.h b/include/babeltrace/graph/notification-const.h new file mode 100644 index 00000000..4ab0bb91 --- /dev/null +++ b/include/babeltrace/graph/notification-const.h @@ -0,0 +1,61 @@ +#ifndef BABELTRACE_GRAPH_NOTIFICATION_CONST_H +#define BABELTRACE_GRAPH_NOTIFICATION_CONST_H + +/* + * Copyright 2015 Jérémie Galarneau + * + * Author: Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * 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_notification; + +typedef const struct bt_notification **bt_notification_array_const; + +/** + * Notification types. Unhandled notification types should be ignored. + */ +enum bt_notification_type { + BT_NOTIFICATION_TYPE_EVENT = 0, + BT_NOTIFICATION_TYPE_INACTIVITY = 1, + BT_NOTIFICATION_TYPE_STREAM_BEGIN = 2, + BT_NOTIFICATION_TYPE_STREAM_END = 3, + BT_NOTIFICATION_TYPE_PACKET_BEGIN = 4, + BT_NOTIFICATION_TYPE_PACKET_END = 5, +}; + +/** + * Get a notification's type. + * + * @param notification Notification instance + * @returns One of #bt_notification_type + */ +extern enum bt_notification_type bt_notification_get_type( + const struct bt_notification *notification); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_NOTIFICATION_CONST_H */ diff --git a/include/babeltrace/graph/private-notification.h b/include/babeltrace/graph/notification-event-const.h similarity index 75% rename from include/babeltrace/graph/private-notification.h rename to include/babeltrace/graph/notification-event-const.h index 3833d632..30edaf8f 100644 --- a/include/babeltrace/graph/private-notification.h +++ b/include/babeltrace/graph/notification-event-const.h @@ -1,8 +1,8 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_H -#define BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_H +#ifndef BABELTRACE_GRAPH_NOTIFICATION_EVENT_CONST_H +#define BABELTRACE_GRAPH_NOTIFICATION_EVENT_CONST_H /* - * Copyright 2015 Jérémie Galarneau + * Copyright 2016 Jérémie Galarneau * * Author: Jérémie Galarneau * @@ -30,17 +30,13 @@ extern "C" { #endif struct bt_notification; -struct bt_private_notification; +struct bt_event; -static inline -struct bt_notification *bt_private_notification_as_notification( - struct bt_private_notification *notification) -{ - return (void *) notification; -} +extern const struct bt_event *bt_notification_event_borrow_event_const( + const struct bt_notification *notification); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_H */ +#endif /* BABELTRACE_GRAPH_NOTIFICATION_EVENT_CONST_H */ diff --git a/include/babeltrace/graph/notification-event.h b/include/babeltrace/graph/notification-event.h index 3bcc6c88..7fb9c090 100644 --- a/include/babeltrace/graph/notification-event.h +++ b/include/babeltrace/graph/notification-event.h @@ -29,10 +29,18 @@ extern "C" { #endif -struct bt_notification; +struct bt_self_notification_iterator; struct bt_event; +struct bt_packet; +struct bt_event_class; -extern const struct bt_event *bt_notification_event_borrow_event( +extern +struct bt_notification *bt_notification_event_create( + struct bt_self_notification_iterator *notification_iterator, + struct bt_event_class *event_class, + struct bt_packet *packet); + +extern struct bt_event *bt_notification_event_borrow_event( struct bt_notification *notification); #ifdef __cplusplus diff --git a/include/babeltrace/graph/private-notification-inactivity.h b/include/babeltrace/graph/notification-inactivity-const.h similarity index 66% rename from include/babeltrace/graph/private-notification-inactivity.h rename to include/babeltrace/graph/notification-inactivity-const.h index 5649ffc1..11af899d 100644 --- a/include/babeltrace/graph/private-notification-inactivity.h +++ b/include/babeltrace/graph/notification-inactivity-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_INACTIVITY_H -#define BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_INACTIVITY_H +#ifndef BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_CONST_H +#define BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_CONST_H /* * Copyright 2017 Philippe Proulx @@ -23,26 +23,19 @@ * SOFTWARE. */ -#include - #ifdef __cplusplus extern "C" { #endif -struct bt_private_notification; -struct bt_self_notification_iterator; -struct bt_clock_class; - -extern -struct bt_private_notification *bt_private_notification_inactivity_create( - struct bt_self_notification_iterator *notification_iterator, - struct bt_clock_class *default_clock_class); +struct bt_notification; +struct bt_clock_value; -extern void bt_private_notification_inactivity_set_default_clock_value( - struct bt_private_notification *notif, uint64_t raw_value); +extern const struct bt_clock_value * +bt_notification_inactivity_borrow_default_clock_value_const( + const struct bt_notification *notif); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_INACTIVITY_H */ +#endif /* BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_CONST_H */ diff --git a/include/babeltrace/graph/notification-inactivity-internal.h b/include/babeltrace/graph/notification-inactivity-internal.h index 9a74e8fd..15bfbf25 100644 --- a/include/babeltrace/graph/notification-inactivity-internal.h +++ b/include/babeltrace/graph/notification-inactivity-internal.h @@ -25,7 +25,7 @@ #include #include -#include +#include struct bt_notification_inactivity { struct bt_notification parent; diff --git a/include/babeltrace/graph/notification-inactivity.h b/include/babeltrace/graph/notification-inactivity.h index 947634cf..c0c49382 100644 --- a/include/babeltrace/graph/notification-inactivity.h +++ b/include/babeltrace/graph/notification-inactivity.h @@ -23,15 +23,23 @@ * SOFTWARE. */ +#include + #ifdef __cplusplus extern "C" { #endif struct bt_notification; -struct bt_clock_value; +struct bt_self_notification_iterator; +struct bt_clock_class; + +extern +struct bt_notification *bt_notification_inactivity_create( + struct bt_self_notification_iterator *notification_iterator, + struct bt_clock_class *default_clock_class); -extern struct bt_clock_value *bt_notification_inactivity_borrow_default_clock_value( - struct bt_notification *notif); +extern void bt_notification_inactivity_set_default_clock_value( + struct bt_notification *notif, uint64_t raw_value); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/notification-internal.h b/include/babeltrace/graph/notification-internal.h index f776f5ec..4ef04290 100644 --- a/include/babeltrace/graph/notification-internal.h +++ b/include/babeltrace/graph/notification-internal.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/babeltrace/graph/notification-iterator-internal.h b/include/babeltrace/graph/notification-iterator-internal.h index 28c3f8f4..5222b4ff 100644 --- a/include/babeltrace/graph/notification-iterator-internal.h +++ b/include/babeltrace/graph/notification-iterator-internal.h @@ -26,8 +26,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/include/babeltrace/graph/private-notification-event.h b/include/babeltrace/graph/notification-packet-const.h similarity index 68% rename from include/babeltrace/graph/private-notification-event.h rename to include/babeltrace/graph/notification-packet-const.h index 6051286b..aa75c2f2 100644 --- a/include/babeltrace/graph/private-notification-event.h +++ b/include/babeltrace/graph/notification-packet-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_EVENT_H -#define BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_EVENT_H +#ifndef BABELTRACE_GRAPH_NOTIFICATION_PACKET_CONST_H +#define BABELTRACE_GRAPH_NOTIFICATION_PACKET_CONST_H /* * Copyright 2016 Jérémie Galarneau @@ -29,24 +29,17 @@ extern "C" { #endif -struct bt_private_notification; -struct bt_self_notification_iterator; -struct bt_event; +struct bt_notification; struct bt_packet; -struct bt_event_class; -extern -struct bt_private_notification *bt_private_notification_event_create( - struct bt_self_notification_iterator *notification_iterator, - struct bt_event_class *event_class, - struct bt_packet *packet); +extern const struct bt_packet *bt_notification_packet_begin_borrow_packet_const( + const struct bt_notification *notification); -extern struct bt_event * -bt_private_notification_event_borrow_event( - struct bt_private_notification *notification); +extern const struct bt_packet *bt_notification_packet_end_borrow_packet_const( + const struct bt_notification *notification); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_EVENT_H */ +#endif /* BABELTRACE_GRAPH_NOTIFICATION_PACKET_CONST_H */ diff --git a/include/babeltrace/graph/notification-packet.h b/include/babeltrace/graph/notification-packet.h index a6d6c7fa..b56e9e7a 100644 --- a/include/babeltrace/graph/notification-packet.h +++ b/include/babeltrace/graph/notification-packet.h @@ -30,12 +30,23 @@ extern "C" { #endif struct bt_notification; +struct bt_self_notification_iterator; struct bt_packet; -extern const struct bt_packet *bt_notification_packet_begin_borrow_packet( +extern +struct bt_notification *bt_notification_packet_begin_create( + struct bt_self_notification_iterator *notification_iterator, + struct bt_packet *packet); + +extern +struct bt_notification *bt_notification_packet_end_create( + struct bt_self_notification_iterator *notification_iterator, + struct bt_packet *packet); + +extern struct bt_packet *bt_notification_packet_begin_borrow_packet( struct bt_notification *notification); -extern const struct bt_packet *bt_notification_packet_end_borrow_packet( +extern struct bt_packet *bt_notification_packet_end_borrow_packet( struct bt_notification *notification); #ifdef __cplusplus diff --git a/include/babeltrace/graph/private-notification-packet.h b/include/babeltrace/graph/notification-stream-const.h similarity index 61% rename from include/babeltrace/graph/private-notification-packet.h rename to include/babeltrace/graph/notification-stream-const.h index e895255e..f0fd960c 100644 --- a/include/babeltrace/graph/private-notification-packet.h +++ b/include/babeltrace/graph/notification-stream-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_PACKET_H -#define BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_PACKET_H +#ifndef BABELTRACE_GRAPH_NOTIFICATION_STREAM_CONST_H +#define BABELTRACE_GRAPH_NOTIFICATION_STREAM_CONST_H /* * Copyright 2016 Jérémie Galarneau @@ -29,30 +29,27 @@ extern "C" { #endif -struct bt_private_notification; +struct bt_notification; struct bt_self_notification_iterator; -struct bt_packet; +struct bt_clock_value; +struct bt_stream; -extern -struct bt_private_notification *bt_private_notification_packet_begin_create( - struct bt_self_notification_iterator *notification_iterator, - struct bt_packet *packet); +extern const struct bt_stream *bt_notification_stream_begin_borrow_stream_const( + const struct bt_notification *notification); -extern -struct bt_private_notification *bt_private_notification_packet_end_create( - struct bt_self_notification_iterator *notification_iterator, - struct bt_packet *packet); +extern const struct bt_clock_value * +bt_notification_stream_begin_borrow_default_clock_value_const( + const struct bt_notification *notif); -extern struct bt_packet * -bt_private_notification_packet_begin_borrow_packet( - struct bt_private_notification *notification); +extern const struct bt_stream *bt_notification_stream_end_borrow_stream_const( + const struct bt_notification *notification); -extern struct bt_packet * -bt_private_notification_packet_end_borrow_packet( - struct bt_private_notification *notification); +extern const struct bt_clock_value * +bt_notification_stream_end_borrow_default_clock_value_const( + const struct bt_notification *notif); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_PACKET_H */ +#endif /* BABELTRACE_GRAPH_NOTIFICATION_STREAM_CONST_H */ diff --git a/include/babeltrace/graph/notification-stream.h b/include/babeltrace/graph/notification-stream.h index 2dea094c..2f98f82f 100644 --- a/include/babeltrace/graph/notification-stream.h +++ b/include/babeltrace/graph/notification-stream.h @@ -25,28 +25,37 @@ * SOFTWARE. */ +#include + #ifdef __cplusplus extern "C" { #endif struct bt_notification; struct bt_self_notification_iterator; -struct bt_clock_value; struct bt_stream; -extern const struct bt_stream *bt_notification_stream_begin_borrow_stream( +extern +struct bt_notification *bt_notification_stream_begin_create( + struct bt_self_notification_iterator *notification_iterator, + struct bt_stream *stream); + +extern +struct bt_notification *bt_notification_stream_end_create( + struct bt_self_notification_iterator *notification_iterator, + struct bt_stream *stream); + +extern struct bt_stream *bt_notification_stream_begin_borrow_stream( struct bt_notification *notification); -extern const struct bt_clock_value * -bt_notification_stream_begin_borrow_default_clock_value( - struct bt_notification *notif); +extern void bt_notification_stream_begin_set_default_clock_value( + struct bt_notification *notif, uint64_t value_cycles); -extern const struct bt_stream *bt_notification_stream_end_borrow_stream( +extern struct bt_stream *bt_notification_stream_end_borrow_stream( struct bt_notification *notification); -extern const struct bt_clock_value * -bt_notification_stream_end_borrow_default_clock_value( - struct bt_notification *notif); +extern void bt_notification_stream_end_set_default_clock_value( + struct bt_notification *notif, uint64_t value_cycles); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/port.h b/include/babeltrace/graph/port-const.h similarity index 72% rename from include/babeltrace/graph/port.h rename to include/babeltrace/graph/port-const.h index c70ca5e0..eb3e9329 100644 --- a/include/babeltrace/graph/port.h +++ b/include/babeltrace/graph/port-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_PORT_H -#define BABELTRACE_GRAPH_PORT_H +#ifndef BABELTRACE_GRAPH_PORT_CONST_H +#define BABELTRACE_GRAPH_PORT_CONST_H /* * Copyright 2017 Jérémie Galarneau @@ -43,24 +43,26 @@ enum bt_port_type { BT_PORT_TYPE_OUTPUT = 1, }; -extern const char *bt_port_get_name(struct bt_port *port); +extern const char *bt_port_get_name(const struct bt_port *port); -extern enum bt_port_type bt_port_get_type(struct bt_port *port); +extern enum bt_port_type bt_port_get_type(const struct bt_port *port); -extern struct bt_connection *bt_port_borrow_connection(struct bt_port *port); +extern const struct bt_connection *bt_port_borrow_connection_const( + const struct bt_port *port); -extern struct bt_component *bt_port_borrow_component(struct bt_port *port); +extern const struct bt_component *bt_port_borrow_component_const( + const struct bt_port *port); -extern bt_bool bt_port_is_connected(struct bt_port *port); +extern bt_bool bt_port_is_connected(const struct bt_port *port); static inline -bt_bool bt_port_is_input(struct bt_port *port) +bt_bool bt_port_is_input(const struct bt_port *port) { return bt_port_get_type(port) == BT_PORT_TYPE_INPUT; } static inline -bt_bool bt_port_is_output(struct bt_port *port) +bt_bool bt_port_is_output(const struct bt_port *port) { return bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT; } @@ -69,4 +71,4 @@ bt_bool bt_port_is_output(struct bt_port *port) } #endif -#endif /* BABELTRACE_GRAPH_PORT_H */ +#endif /* BABELTRACE_GRAPH_PORT_CONST_H */ diff --git a/include/babeltrace/graph/port-input.h b/include/babeltrace/graph/port-input-const.h similarity index 83% rename from include/babeltrace/graph/port-input.h rename to include/babeltrace/graph/port-input-const.h index 9e55f828..85a201d9 100644 --- a/include/babeltrace/graph/port-input.h +++ b/include/babeltrace/graph/port-input-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_PORT_INPUT_H -#define BABELTRACE_GRAPH_PORT_INPUT_H +#ifndef BABELTRACE_GRAPH_PORT_INPUT_CONST_H +#define BABELTRACE_GRAPH_PORT_INPUT_CONST_H /* * Copyright 2017 Jérémie Galarneau @@ -35,13 +35,14 @@ struct bt_port; struct bt_port_input; static inline -struct bt_port *bt_port_input_as_port(struct bt_port_input *port_input) +const struct bt_port *bt_port_input_as_port_const( + const struct bt_port_input *port_input) { - return (void *) port_input; + return (const void *) port_input; } #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_PORT_INPUT_H */ +#endif /* BABELTRACE_GRAPH_PORT_INPUT_CONST_H */ diff --git a/include/babeltrace/graph/port-internal.h b/include/babeltrace/graph/port-internal.h index 2a681dda..d7a48e73 100644 --- a/include/babeltrace/graph/port-internal.h +++ b/include/babeltrace/graph/port-internal.h @@ -25,7 +25,7 @@ * SOFTWARE. */ -#include +#include struct bt_port { struct bt_object base; @@ -35,6 +35,8 @@ struct bt_port { void *user_data; }; +struct bt_component; + BT_HIDDEN struct bt_port *bt_port_create(struct bt_component *parent_component, enum bt_port_type type, const char *name, void *user_data); @@ -43,6 +45,13 @@ BT_HIDDEN void bt_port_set_connection(struct bt_port *port, struct bt_connection *connection); +static inline +struct bt_component *bt_port_borrow_component_inline(const struct bt_port *port) +{ + BT_ASSERT(port); + return (void *) bt_object_borrow_parent(&port->base); +} + static inline const char *bt_port_type_string(enum bt_port_type port_type) { diff --git a/include/babeltrace/graph/port-output.h b/include/babeltrace/graph/port-output-const.h similarity index 83% rename from include/babeltrace/graph/port-output.h rename to include/babeltrace/graph/port-output-const.h index 986abb94..4d44914e 100644 --- a/include/babeltrace/graph/port-output.h +++ b/include/babeltrace/graph/port-output-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_H -#define BABELTRACE_GRAPH_PORT_OUTPUT_H +#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H +#define BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H /* * Copyright 2017 Jérémie Galarneau @@ -35,13 +35,14 @@ struct bt_port; struct bt_port_output; static inline -struct bt_port *bt_port_output_as_port(struct bt_port_output *port_output) +const struct bt_port *bt_port_output_as_port_const( + const struct bt_port_output *port_output) { - return (void *) port_output; + return (const void *) port_output; } #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_H */ +#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H */ diff --git a/include/babeltrace/graph/port-output-notification-iterator.h b/include/babeltrace/graph/port-output-notification-iterator.h index ddfb3f91..edf0da0a 100644 --- a/include/babeltrace/graph/port-output-notification-iterator.h +++ b/include/babeltrace/graph/port-output-notification-iterator.h @@ -28,8 +28,8 @@ /* For enum bt_notification_iterator_status */ #include -/* For bt_notification_array */ -#include +/* For bt_notification_array_const */ +#include #ifdef __cplusplus extern "C" { @@ -39,7 +39,7 @@ struct bt_port; struct bt_notification; struct bt_notification_iterator; struct bt_port_output_notification_iterator; -struct bt_private_graph; +struct bt_graph; struct bt_port_output; static inline @@ -50,14 +50,15 @@ bt_port_output_notification_iterator_as_notification_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); +extern struct bt_port_output_notification_iterator * +bt_port_output_notification_iterator_create( + struct bt_graph *graph, + const struct bt_port_output *output_port); 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); + bt_notification_array_const *notifs, uint64_t *count); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/private-component-class-filter.h b/include/babeltrace/graph/private-component-class-filter.h deleted file mode 100644 index 01e6cc8f..00000000 --- a/include/babeltrace/graph/private-component-class-filter.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_FILTER_H -#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_FILTER_H - -/* - * Copyright 2016 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * 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 - -/* For enum bt_notification_array */ -#include - -/* For enum bt_self_component_status */ -#include - - -/* For enum bt_self_notification_iterator_status */ -#include - -/* For enum bt_query_status */ -#include - -#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, - const 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, const struct bt_value *params, - const 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_as_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_as_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 */ diff --git a/include/babeltrace/graph/private-component-class-sink.h b/include/babeltrace/graph/private-component-class-sink.h deleted file mode 100644 index 02bc66c8..00000000 --- a/include/babeltrace/graph/private-component-class-sink.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SINK_H -#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SINK_H - -/* - * Copyright 2016 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * 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 - -/* For enum bt_notification_array */ -#include - -/* For enum bt_self_component_status */ -#include - -/* For enum bt_query_status */ -#include - -#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, - const 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, const struct bt_value *params, - const 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_as_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_as_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 */ diff --git a/include/babeltrace/graph/private-component-class-source.h b/include/babeltrace/graph/private-component-class-source.h deleted file mode 100644 index 8fdaa3f2..00000000 --- a/include/babeltrace/graph/private-component-class-source.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SOURCE_H -#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_SOURCE_H - -/* - * Copyright 2016 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * 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 - -/* For enum bt_notification_array */ -#include - -/* For enum bt_self_component_status */ -#include - -/* For enum bt_self_notification_iterator_status */ -#include - -/* For enum bt_query_status */ -#include - -#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, - const 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, const struct bt_value *params, - const 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_as_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_as_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 */ diff --git a/include/babeltrace/graph/private-component-class.h b/include/babeltrace/graph/private-component-class.h deleted file mode 100644 index 804f21e8..00000000 --- a/include/babeltrace/graph/private-component-class.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_H -#define BABELTRACE_GRAPH_PRIVATE_COMPONENT_CLASS_H - -/* - * Copyright 2016 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * 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_executor_status */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct bt_component_class; -struct bt_private_component_class; - -enum bt_query_status { - BT_QUERY_STATUS_OK = BT_QUERY_EXECUTOR_STATUS_OK, - BT_QUERY_STATUS_AGAIN = BT_QUERY_EXECUTOR_STATUS_AGAIN, - BT_QUERY_STATUS_ERROR = BT_QUERY_EXECUTOR_STATUS_ERROR, - BT_QUERY_STATUS_NOMEM = BT_QUERY_EXECUTOR_STATUS_NOMEM, - BT_QUERY_STATUS_INVALID_OBJECT = BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT, - BT_QUERY_STATUS_INVALID_PARAMS = BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS, -}; - -static inline -struct bt_component_class * -bt_private_component_class_as_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 */ diff --git a/include/babeltrace/graph/private-graph.h b/include/babeltrace/graph/private-graph.h deleted file mode 100644 index 8d2866e1..00000000 --- a/include/babeltrace/graph/private-graph.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_GRAPH_H -#define BABELTRACE_GRAPH_PRIVATE_GRAPH_H - -/* - * Copyright 2017 Jérémie Galarneau - * - * Author: Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * 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 bt_bool */ -#include - -/* For enum bt_graph_status */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct bt_graph; -struct bt_private_graph; -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_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_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_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_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); - -static inline -struct bt_graph *bt_private_graph_as_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_source_component( - struct bt_private_graph *graph, - struct bt_component_class_source *component_class, - const char *name, const struct bt_value *params, - struct bt_component_source **component); - -extern enum bt_graph_status -bt_private_graph_add_source_component_with_init_method_data( - struct bt_private_graph *graph, - struct bt_component_class_source *component_class, - const char *name, const struct bt_value *params, - 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, const 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, const 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, const 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, const struct bt_value *params, - void *init_method_data, struct bt_component_sink **component); - -extern enum bt_graph_status bt_private_graph_connect_ports( - struct bt_private_graph *graph, - struct bt_port_output *upstream, - struct bt_port_input *downstream, - struct bt_connection **connection); - -extern enum bt_graph_status bt_private_graph_run( - struct bt_private_graph *graph); - -extern enum bt_graph_status bt_private_graph_consume( - struct bt_private_graph *graph); - -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_sink_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_source_component_output_port_added_listener( - struct bt_private_graph *graph, - bt_private_graph_source_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_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_filter_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_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_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); - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_PRIVATE_GRAPH_H */ diff --git a/include/babeltrace/graph/private-notification-stream.h b/include/babeltrace/graph/private-notification-stream.h deleted file mode 100644 index 4274bbd1..00000000 --- a/include/babeltrace/graph/private-notification-stream.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_STREAM_H -#define BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_STREAM_H - -/* - * Copyright 2016 Jérémie Galarneau - * - * Author: Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * 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 - -#ifdef __cplusplus -extern "C" { -#endif - -struct bt_private_notification; -struct bt_self_notification_iterator; -struct bt_stream; - -extern -struct bt_private_notification *bt_private_notification_stream_begin_create( - struct bt_self_notification_iterator *notification_iterator, - struct bt_stream *stream); - -extern -struct bt_private_notification *bt_private_notification_stream_end_create( - struct bt_self_notification_iterator *notification_iterator, - struct bt_stream *stream); - -extern struct bt_stream * -bt_private_notification_stream_begin_borrow_stream( - struct bt_private_notification *notification); - -extern void bt_private_notification_stream_begin_set_default_clock_value( - struct bt_private_notification *notif, uint64_t value_cycles); - -extern struct bt_stream * -bt_private_notification_stream_end_borrow_stream( - struct bt_private_notification *notification); - -extern void bt_private_notification_stream_end_set_default_clock_value( - struct bt_private_notification *notif, uint64_t value_cycles); - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_PRIVATE_NOTIFICATION_STREAM_H */ diff --git a/include/babeltrace/graph/private-query-executor.h b/include/babeltrace/graph/private-query-executor.h deleted file mode 100644 index a5730200..00000000 --- a/include/babeltrace/graph/private-query-executor.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef BABELTRACE_GRAPH_PRIVATE_QUERY_EXECUTOR_H -#define BABELTRACE_GRAPH_PRIVATE_QUERY_EXECUTOR_H - -/* - * Copyright 2017 Philippe Proulx - * - * 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_executor_status */ -#include - -#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_as_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_executor_status bt_private_query_executor_query( - struct bt_private_query_executor *query_executor, - struct bt_component_class *component_class, - const char *object, const struct bt_value *params, - const struct bt_value **result); - -extern -enum bt_query_executor_status bt_private_query_executor_cancel( - struct bt_private_query_executor *query_executor); - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_PRIVATE_QUERY_EXECUTOR_H */ diff --git a/include/babeltrace/graph/query-executor-const.h b/include/babeltrace/graph/query-executor-const.h new file mode 100644 index 00000000..c5cfd937 --- /dev/null +++ b/include/babeltrace/graph/query-executor-const.h @@ -0,0 +1,54 @@ +#ifndef BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H +#define BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H + +/* + * Copyright 2017 Philippe Proulx + * + * 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 bt_bool */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_query_executor; + +enum bt_query_executor_status { + BT_QUERY_EXECUTOR_STATUS_OK = 0, + BT_QUERY_EXECUTOR_STATUS_AGAIN = 11, + BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED = 95, + BT_QUERY_EXECUTOR_STATUS_CANCELED = 125, + BT_QUERY_EXECUTOR_STATUS_ERROR = -1, + BT_QUERY_EXECUTOR_STATUS_NOMEM = -12, + BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT = -23, + BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS = -24, +}; + +extern +bt_bool bt_query_executor_is_canceled( + const struct bt_query_executor *query_executor); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H */ diff --git a/include/babeltrace/graph/query-executor-internal.h b/include/babeltrace/graph/query-executor-internal.h index 23bc2f40..98a46bed 100644 --- a/include/babeltrace/graph/query-executor-internal.h +++ b/include/babeltrace/graph/query-executor-internal.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include struct bt_query_executor { struct bt_object base; diff --git a/include/babeltrace/graph/query-executor.h b/include/babeltrace/graph/query-executor.h index abdb16ce..a3a376a9 100644 --- a/include/babeltrace/graph/query-executor.h +++ b/include/babeltrace/graph/query-executor.h @@ -23,28 +23,30 @@ * SOFTWARE. */ -/* For bt_bool */ -#include +/* For enum bt_query_executor_status */ +#include #ifdef __cplusplus extern "C" { #endif struct bt_query_executor; +struct bt_component_class; +struct bt_value; -enum bt_query_executor_status { - BT_QUERY_EXECUTOR_STATUS_OK = 0, - BT_QUERY_EXECUTOR_STATUS_AGAIN = 11, - BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED = 95, - BT_QUERY_EXECUTOR_STATUS_CANCELED = 125, - BT_QUERY_EXECUTOR_STATUS_ERROR = -1, - BT_QUERY_EXECUTOR_STATUS_NOMEM = -12, - BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT = -23, - BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS = -24, -}; +extern +struct bt_query_executor *bt_query_executor_create(void); + +extern +enum bt_query_executor_status bt_query_executor_query( + struct bt_query_executor *query_executor, + const struct bt_component_class *component_class, + const char *object, const struct bt_value *params, + const struct bt_value **result); extern -bt_bool bt_query_executor_is_canceled(struct bt_query_executor *query_executor); +enum bt_query_executor_status bt_query_executor_cancel( + struct bt_query_executor *query_executor); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/self-component-class-filter.h b/include/babeltrace/graph/self-component-class-filter.h index 8a029a8d..7d97cdbb 100644 --- a/include/babeltrace/graph/self-component-class-filter.h +++ b/include/babeltrace/graph/self-component-class-filter.h @@ -31,11 +31,11 @@ struct bt_component_class_filter; struct bt_self_component_class_filter; static inline -struct bt_component_class_filter * +const struct bt_component_class_filter * bt_self_component_class_filter_as_component_class_filter( struct bt_self_component_class_filter *self_comp_cls_filter) { - return (void *) self_comp_cls_filter; + return (const void *) self_comp_cls_filter; } #ifdef __cplusplus diff --git a/include/babeltrace/graph/self-component-class-sink.h b/include/babeltrace/graph/self-component-class-sink.h index 01dacaa3..46cb7bce 100644 --- a/include/babeltrace/graph/self-component-class-sink.h +++ b/include/babeltrace/graph/self-component-class-sink.h @@ -31,11 +31,11 @@ struct bt_component_class_sink; struct bt_self_component_class_sink; static inline -struct bt_component_class_sink * +const struct bt_component_class_sink * bt_self_component_class_sink_as_component_class_sink( struct bt_self_component_class_sink *self_comp_cls_sink) { - return (void *) self_comp_cls_sink; + return (const void *) self_comp_cls_sink; } #ifdef __cplusplus diff --git a/include/babeltrace/graph/self-component-class-source.h b/include/babeltrace/graph/self-component-class-source.h index 0cdbc866..13dbf7e8 100644 --- a/include/babeltrace/graph/self-component-class-source.h +++ b/include/babeltrace/graph/self-component-class-source.h @@ -31,11 +31,11 @@ struct bt_component_class_source; struct bt_self_component_class_source; static inline -struct bt_component_class_source * +const struct bt_component_class_source * bt_self_component_class_source_as_component_class_source( struct bt_self_component_class_source *self_comp_cls_source) { - return (void *) self_comp_cls_source; + return (const void *) self_comp_cls_source; } #ifdef __cplusplus diff --git a/include/babeltrace/graph/self-component-filter.h b/include/babeltrace/graph/self-component-filter.h index 4aef3ccc..12a6fa8d 100644 --- a/include/babeltrace/graph/self-component-filter.h +++ b/include/babeltrace/graph/self-component-filter.h @@ -46,16 +46,13 @@ struct bt_self_component *bt_self_component_filter_as_self_component( } static inline -struct bt_component_filter * +const struct bt_component_filter * bt_self_component_filter_as_component_filter( struct bt_self_component_filter *self_comp_filter) { - return (void *) self_comp_filter; + return (const 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); diff --git a/include/babeltrace/graph/self-component-port-input-notification-iterator.h b/include/babeltrace/graph/self-component-port-input-notification-iterator.h index fd7e02fc..15ef6c52 100644 --- a/include/babeltrace/graph/self-component-port-input-notification-iterator.h +++ b/include/babeltrace/graph/self-component-port-input-notification-iterator.h @@ -28,8 +28,8 @@ /* For enum bt_notification_iterator_status */ #include -/* For bt_notification_array */ -#include +/* For bt_notification_array_const */ +#include #ifdef __cplusplus extern "C" { @@ -59,7 +59,7 @@ bt_self_component_port_input_notification_iterator_borrow_component( 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); + bt_notification_array_const *notifs, uint64_t *count); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/self-component-port-input.h b/include/babeltrace/graph/self-component-port-input.h index d25e1144..b5b0aad1 100644 --- a/include/babeltrace/graph/self-component-port-input.h +++ b/include/babeltrace/graph/self-component-port-input.h @@ -43,10 +43,10 @@ bt_self_component_port_input_as_self_component_port( } static inline -struct bt_port_input *bt_self_component_port_input_as_port_input( - struct bt_self_component_port_input *self_component_port) +const struct bt_port_input *bt_self_component_port_input_as_port_input( + const struct bt_self_component_port_input *self_component_port) { - return (void *) self_component_port; + return (const void *) self_component_port; } #ifdef __cplusplus diff --git a/include/babeltrace/graph/self-component-port-output.h b/include/babeltrace/graph/self-component-port-output.h index 6857f3e8..23801ff2 100644 --- a/include/babeltrace/graph/self-component-port-output.h +++ b/include/babeltrace/graph/self-component-port-output.h @@ -43,10 +43,10 @@ bt_self_component_port_output_as_self_component_port( } static inline -struct bt_port_output *bt_self_component_port_output_as_port_output( +const struct bt_port_output *bt_self_component_port_output_as_port_output( struct bt_self_component_port_output *self_component_port) { - return (void *) self_component_port; + return (const void *) self_component_port; } #ifdef __cplusplus diff --git a/include/babeltrace/graph/self-component-port.h b/include/babeltrace/graph/self-component-port.h index 9eaacf1e..49c5380a 100644 --- a/include/babeltrace/graph/self-component-port.h +++ b/include/babeltrace/graph/self-component-port.h @@ -37,10 +37,10 @@ enum bt_self_component_port_status { }; static inline -struct bt_port *bt_self_component_port_as_port( +const struct bt_port *bt_self_component_port_as_port( struct bt_self_component_port *self_port) { - return (void *) self_port; + return (const void *) self_port; } extern struct bt_self_component *bt_self_component_port_borrow_component( @@ -51,7 +51,7 @@ 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); + const struct bt_self_component_port *self_port); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/self-component-sink.h b/include/babeltrace/graph/self-component-sink.h index bdb76c8a..531379ff 100644 --- a/include/babeltrace/graph/self-component-sink.h +++ b/include/babeltrace/graph/self-component-sink.h @@ -45,11 +45,11 @@ struct bt_self_component *bt_self_component_sink_as_self_component( } static inline -struct bt_component_sink * +const struct bt_component_sink * bt_self_component_sink_as_component_sink( struct bt_self_component_sink *self_comp_sink) { - return (void *) self_comp_sink; + return (const void *) self_comp_sink; } extern struct bt_self_component_port_input * diff --git a/include/babeltrace/graph/self-component-source.h b/include/babeltrace/graph/self-component-source.h index 95ccdb7a..c7e644d0 100644 --- a/include/babeltrace/graph/self-component-source.h +++ b/include/babeltrace/graph/self-component-source.h @@ -45,11 +45,11 @@ struct bt_self_component *bt_self_component_source_as_self_component( } static inline -struct bt_component_source * +const struct bt_component_source * bt_self_component_source_as_component_source( struct bt_self_component_source *self_comp_source) { - return (void *) self_comp_source; + return (const void *) self_comp_source; } extern struct bt_self_component_port_output * diff --git a/include/babeltrace/graph/self-component.h b/include/babeltrace/graph/self-component.h index b5d8f551..924ef154 100644 --- a/include/babeltrace/graph/self-component.h +++ b/include/babeltrace/graph/self-component.h @@ -40,14 +40,14 @@ enum bt_self_component_status { }; static inline -struct bt_component *bt_self_component_as_component( +const struct bt_component *bt_self_component_as_component( struct bt_self_component *self_component) { - return (void *) self_component; + return (const void *) self_component; } extern void *bt_self_component_get_data( - struct bt_self_component *private_component); + const struct bt_self_component *private_component); extern void bt_self_component_set_data( struct bt_self_component *private_component, void *data); diff --git a/include/babeltrace/graph/self-notification-iterator.h b/include/babeltrace/graph/self-notification-iterator.h index aa093d27..e3711c57 100644 --- a/include/babeltrace/graph/self-notification-iterator.h +++ b/include/babeltrace/graph/self-notification-iterator.h @@ -55,7 +55,7 @@ extern void bt_self_notification_iterator_set_data( void *user_data); extern void *bt_self_notification_iterator_get_data( - struct bt_self_notification_iterator *notification_iterator); + const struct bt_self_notification_iterator *notification_iterator); #ifdef __cplusplus } diff --git a/include/babeltrace/plugin/plugin-const.h b/include/babeltrace/plugin/plugin-const.h index 906bf062..38771312 100644 --- a/include/babeltrace/plugin/plugin-const.h +++ b/include/babeltrace/plugin/plugin-const.h @@ -97,29 +97,29 @@ extern uint64_t bt_plugin_get_filter_component_class_count( extern uint64_t bt_plugin_get_sink_component_class_count( const struct bt_plugin *plugin); -extern struct bt_component_class_source * +extern const struct bt_component_class_source * bt_plugin_borrow_source_component_class_by_index_const_const( const struct bt_plugin *plugin, uint64_t index); -extern struct bt_component_class_filter * +extern const struct bt_component_class_filter * bt_plugin_borrow_filter_component_class_by_index_const( const struct bt_plugin *plugin, uint64_t index); -extern struct bt_component_class_sink * +extern const struct bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_index_const( const struct bt_plugin *plugin, uint64_t index); -extern struct bt_component_class_source * -bt_plugin_borrow_source_component_class_by_name_const(const struct bt_plugin *plugin, - const char *name); +extern const struct bt_component_class_source * +bt_plugin_borrow_source_component_class_by_name_const( + const struct bt_plugin *plugin, const char *name); -extern struct bt_component_class_filter * -bt_plugin_borrow_filter_component_class_by_name_const(const struct bt_plugin *plugin, - const char *name); +extern const struct bt_component_class_filter * +bt_plugin_borrow_filter_component_class_by_name_const( + const struct bt_plugin *plugin, const char *name); -extern struct bt_component_class_sink * -bt_plugin_borrow_sink_component_class_by_name_const(const struct bt_plugin *plugin, - const char *name); +extern const struct bt_component_class_sink * +bt_plugin_borrow_sink_component_class_by_name_const( + const struct bt_plugin *plugin, const char *name); #ifdef __cplusplus } diff --git a/include/babeltrace/plugin/plugin-dev.h b/include/babeltrace/plugin/plugin-dev.h index 60fa36e4..c83449a8 100644 --- a/include/babeltrace/plugin/plugin-dev.h +++ b/include/babeltrace/plugin/plugin-dev.h @@ -34,10 +34,13 @@ /* For enum bt_plugin_status */ #include -/* For private component class method type definitions */ -#include -#include -#include +/* For enum bt_component_class_type */ +#include + +/* For component class method type definitions */ +#include +#include +#include /* * _BT_HIDDEN: set the hidden attribute for internal functions @@ -149,17 +152,17 @@ struct __bt_plugin_component_class_descriptor { union { /* BT_COMPONENT_CLASS_TYPE_SOURCE */ struct { - bt_private_component_class_source_notification_iterator_next_method notif_iter_next; + bt_component_class_source_notification_iterator_next_method notif_iter_next; } source; /* BT_COMPONENT_CLASS_TYPE_FILTER */ struct { - bt_private_component_class_filter_notification_iterator_next_method notif_iter_next; + bt_component_class_filter_notification_iterator_next_method notif_iter_next; } filter; /* BT_COMPONENT_CLASS_TYPE_SINK */ struct { - bt_private_component_class_sink_consume_method consume; + bt_component_class_sink_consume_method consume; } sink; } methods; } __attribute__((packed)); @@ -204,51 +207,51 @@ struct __bt_plugin_component_class_descriptor_attribute { const char *help; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_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_component_class_source_init_method source_init_method; + bt_component_class_filter_init_method filter_init_method; + bt_component_class_sink_init_method sink_init_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_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_component_class_source_finalize_method source_finalize_method; + bt_component_class_filter_finalize_method filter_finalize_method; + bt_component_class_sink_finalize_method sink_finalize_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_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_component_class_source_query_method source_query_method; + bt_component_class_filter_query_method filter_query_method; + bt_component_class_sink_query_method sink_query_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD */ - bt_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_component_class_filter_accept_input_port_connection_method filter_accept_input_port_connection_method; + bt_component_class_sink_accept_input_port_connection_method sink_accept_input_port_connection_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD */ - bt_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_component_class_source_accept_output_port_connection_method source_accept_output_port_connection_method; + bt_component_class_filter_accept_output_port_connection_method filter_accept_output_port_connection_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD */ - bt_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_component_class_filter_input_port_connected_method filter_input_port_connected_method; + bt_component_class_sink_input_port_connected_method sink_input_port_connected_method; /* 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_component_class_source_output_port_connected_method source_output_port_connected_method; + bt_component_class_filter_output_port_connected_method filter_output_port_connected_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_component_class_filter_input_port_disconnected_method filter_input_port_disconnected_method; + bt_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_component_class_source_output_port_disconnected_method source_output_port_disconnected_method; + bt_component_class_filter_output_port_disconnected_method filter_output_port_disconnected_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_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_component_class_source_notification_iterator_init_method source_notif_iter_init_method; + bt_component_class_filter_notification_iterator_init_method filter_notif_iter_init_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_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; + bt_component_class_source_notification_iterator_finalize_method source_notif_iter_finalize_method; + bt_component_class_filter_notification_iterator_finalize_method filter_notif_iter_finalize_method; } value; } __attribute__((packed)); @@ -514,7 +517,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _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_private_component_class_source_notification_iterator_next_method). + * (bt_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 = { \ @@ -534,7 +537,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _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_private_component_class_filter_notification_iterator_next_method). + * (bt_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 = { \ @@ -554,7 +557,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _comp_class_id: Component class ID (C identifier). * _name: Component class name (C string). * _consume_method: Component class's iterator consume method - * (bt_private_component_class_sink_consume_method). + * (bt_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 = { \ @@ -660,7 +663,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Initialization method (bt_private_component_class_source_init_method). + * _x: Initialization method (bt_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(source_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, source, _x) @@ -671,7 +674,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Initialization method (bt_private_component_class_filter_init_method). + * _x: Initialization method (bt_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(filter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, filter, _x) @@ -682,7 +685,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Initialization method (bt_private_component_class_sink_init_method). + * _x: Initialization method (bt_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(sink_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, sink, _x) @@ -693,7 +696,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Finalize method (bt_private_component_class_source_finalize_method). + * _x: Finalize method (bt_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(source_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, source, _x) @@ -704,7 +707,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Finalize method (bt_private_component_class_filter_finalize_method). + * _x: Finalize method (bt_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(filter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, filter, _x) @@ -715,7 +718,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Finalize method (bt_private_component_class_sink_finalize_method). + * _x: Finalize method (bt_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(sink_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, sink, _x) @@ -726,7 +729,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Finalize method (bt_private_component_class_source_query_method). + * _x: Finalize method (bt_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(source_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, source, _x) @@ -737,7 +740,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Finalize method (bt_private_component_class_filter_query_method). + * _x: Finalize method (bt_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(filter_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, filter, _x) @@ -748,7 +751,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). - * _x: Finalize method (bt_private_component_class_sink_query_method). + * _x: Finalize method (bt_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(sink_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, sink, _x) @@ -760,7 +763,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _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_input_port_connection_method). + * (bt_component_class_filter_accept_input_port_connection_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x) @@ -772,7 +775,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Accept port connection method - * (bt_private_component_class_sink_accept_input_port_connection_method). + * (bt_component_class_sink_accept_input_port_connection_method). */ #define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, sink, _x) @@ -784,7 +787,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Accept port connection method - * (bt_private_component_class_source_accept_output_port_connection_method). + * (bt_component_class_source_accept_output_port_connection_method). */ #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, source, _x) @@ -796,7 +799,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _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). + * (bt_component_class_filter_accept_output_port_connection_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x) @@ -808,7 +811,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Port connected method - * (bt_private_component_class_filter_input_port_connected_method). + * (bt_component_class_filter_input_port_connected_method). */ #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) @@ -820,7 +823,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Port connected method - * (bt_private_component_class_sink_input_port_connected_method). + * (bt_component_class_sink_input_port_connected_method). */ #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) @@ -832,7 +835,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Port connected method - * (bt_private_component_class_source_output_port_connected_method). + * (bt_component_class_source_output_port_connected_method). */ #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) @@ -844,7 +847,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _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). + * (bt_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) @@ -856,7 +859,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Port disconnected method - * (bt_private_component_class_filter_input_port_disconnected_method). + * (bt_component_class_filter_input_port_disconnected_method). */ #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) @@ -868,7 +871,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Port disconnected method - * (bt_private_component_class_sink_input_port_disconnected_method). + * (bt_component_class_sink_input_port_disconnected_method). */ #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) @@ -880,7 +883,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Port disconnected method - * (bt_private_component_class_source_output_port_disconnected_method). + * (bt_component_class_source_output_port_disconnected_method). */ #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) @@ -892,7 +895,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _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). + * (bt_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) @@ -904,7 +907,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator initialization method - * (bt_private_component_class_source_notification_iterator_init_method). + * (bt_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(source_notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, source, _x) @@ -916,7 +919,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator finalize method - * (bt_private_component_class_source_notification_iterator_finalize_method). + * (bt_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(source_notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x) @@ -928,7 +931,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator initialization method - * (bt_private_component_class_filter_notification_iterator_init_method). + * (bt_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(filter_notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, filter, _x) @@ -940,7 +943,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator finalize method - * (bt_private_component_class_filter_notification_iterator_finalize_method). + * (bt_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(filter_notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x) @@ -1010,7 +1013,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _notif_iter_next_method: Component class's iterator next method - * (bt_private_component_class_source_notification_iterator_next_method). + * (bt_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) @@ -1022,7 +1025,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _notif_iter_next_method: Component class's iterator next method - * (bt_private_component_class_filter_notification_iterator_next_method). + * (bt_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) @@ -1034,7 +1037,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _consume_method: Component class's consume method - * (bt_private_component_class_sink_consume_method). + * (bt_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) @@ -1105,7 +1108,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_source_init_method). + * _x: Initialization method (bt_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) @@ -1116,7 +1119,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_filter_init_method). + * _x: Initialization method (bt_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) @@ -1127,7 +1130,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_sink_init_method). + * _x: Initialization method (bt_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) @@ -1138,7 +1141,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_source_finalize_method). + * _x: Initialization method (bt_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) @@ -1149,7 +1152,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_filter_finalize_method). + * _x: Initialization method (bt_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) @@ -1159,7 +1162,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor which is attached to the automatic plugin descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_sink_finalize_method). + * _x: Initialization method (bt_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) @@ -1170,7 +1173,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_source_query_method). + * _x: Initialization method (bt_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) @@ -1181,7 +1184,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_filter_query_method). + * _x: Initialization method (bt_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) @@ -1192,7 +1195,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Initialization method (bt_private_component_class_sink_query_method). + * _x: Initialization method (bt_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) @@ -1204,7 +1207,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Accept port connection method - * (bt_private_component_class_filter_accept_input_port_connection_method). + * (bt_component_class_filter_accept_input_port_connection_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \ BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x) @@ -1216,7 +1219,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Accept port connection method - * (bt_private_component_class_sink_accept_input_port_connection_method). + * (bt_component_class_sink_accept_input_port_connection_method). */ #define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \ BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x) @@ -1228,7 +1231,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Accept port connection method - * (bt_private_component_class_source_accept_output_port_connection_method). + * (bt_component_class_source_accept_output_port_connection_method). */ #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \ BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x) @@ -1240,7 +1243,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Accept port connection method - * (bt_private_component_class_filter_accept_output_port_connection_method). + * (bt_component_class_filter_accept_output_port_connection_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \ BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x) @@ -1251,7 +1254,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Port connected (bt_private_component_class_filter_input_port_connected_method). + * _x: Port connected (bt_component_class_filter_input_port_connected_method). */ #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) @@ -1262,7 +1265,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Port connected (bt_private_component_class_sink_input_port_connected_method). + * _x: Port connected (bt_component_class_sink_input_port_connected_method). */ #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) @@ -1273,7 +1276,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Port connected (bt_private_component_class_source_output_port_connected_method). + * _x: Port connected (bt_component_class_source_output_port_connected_method). */ #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) @@ -1284,7 +1287,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * descriptor. * * _name: Component class name (C identifier). - * _x: Port connected (bt_private_component_class_filter_output_port_connected_method). + * _x: Port connected (bt_component_class_filter_output_port_connected_method). */ #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) @@ -1295,7 +1298,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * plugin descriptor. * * _name: Component class name (C identifier). - * _x: Port disconnected (bt_private_component_class_filter_input_port_disconnected_method). + * _x: Port disconnected (bt_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) @@ -1306,7 +1309,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * plugin descriptor. * * _name: Component class name (C identifier). - * _x: Port disconnected (bt_private_component_class_sink_input_port_disconnected_method). + * _x: Port disconnected (bt_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) @@ -1317,7 +1320,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * plugin descriptor. * * _name: Component class name (C identifier). - * _x: Port disconnected (bt_private_component_class_source_output_port_disconnected_method). + * _x: Port disconnected (bt_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) @@ -1328,7 +1331,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * plugin descriptor. * * _name: Component class name (C identifier). - * _x: Port disconnected (bt_private_component_class_filter_output_port_disconnected_method). + * _x: Port disconnected (bt_component_class_filter_output_port_disconnected_method). */ #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) @@ -1340,7 +1343,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator initialization method - * (bt_private_component_class_source_notification_iterator_init_method). + * (bt_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) @@ -1352,7 +1355,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator finalize method - * (bt_private_component_class_source_notification_iterator_finalize_method). + * (bt_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) @@ -1364,7 +1367,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator initialization method - * (bt_private_component_class_filter_notification_iterator_init_method). + * (bt_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) @@ -1376,7 +1379,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator finalize method - * (bt_private_component_class_filter_notification_iterator_finalize_method). + * (bt_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) diff --git a/lib/babeltrace.c b/lib/babeltrace.c index 35006c7c..1623b6ea 100644 --- a/lib/babeltrace.c +++ b/lib/babeltrace.c @@ -22,7 +22,7 @@ * SOFTWARE. */ -#include +#include #include #include diff --git a/lib/graph/component-class-sink-colander.c b/lib/graph/component-class-sink-colander.c index 0c91aeaa..e256d248 100644 --- a/lib/graph/component-class-sink-colander.c +++ b/lib/graph/component-class-sink-colander.c @@ -24,8 +24,7 @@ #include #include -#include -#include +#include #include #include #include @@ -35,10 +34,10 @@ #include static -struct bt_private_component_class_sink *colander_comp_cls; +struct bt_component_class_sink *colander_comp_cls; struct colander_data { - bt_notification_array notifs; + bt_notification_array_const notifs; uint64_t *count_addr; struct bt_self_component_port_input_notification_iterator *notif_iter; }; @@ -102,7 +101,7 @@ static 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) + const struct bt_port_output *other_port) { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; struct colander_data *colander_data = @@ -135,7 +134,7 @@ enum bt_self_component_status colander_consume( struct colander_data *colander_data = bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); - bt_notification_array notifs; + bt_notification_array_const notifs; BT_ASSERT(colander_data); @@ -180,18 +179,18 @@ struct bt_component_class_sink *bt_component_class_sink_colander_get(void) goto end; } - colander_comp_cls = bt_private_component_class_sink_create( - "colander", colander_consume); + colander_comp_cls = bt_component_class_sink_create("colander", + colander_consume); if (!colander_comp_cls) { BT_LOGE_STR("Cannot create sink colander component class."); goto end; } - (void) bt_private_component_class_sink_set_init_method( + (void) bt_component_class_sink_set_init_method( colander_comp_cls, colander_init); - (void) bt_private_component_class_sink_set_finalize_method( + (void) bt_component_class_sink_set_finalize_method( colander_comp_cls, colander_finalize); - (void) bt_private_component_class_sink_set_input_port_connected_method( + (void) bt_component_class_sink_set_input_port_connected_method( colander_comp_cls, colander_input_port_connected); end: diff --git a/lib/graph/component-class.c b/lib/graph/component-class.c index 36d3970f..3e3c93bd 100644 --- a/lib/graph/component-class.c +++ b/lib/graph/component-class.c @@ -26,10 +26,14 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -38,7 +42,7 @@ #include #define BT_ASSERT_PRE_COMP_CLS_HOT(_cc) \ - BT_ASSERT_PRE_HOT(((struct bt_component_class *) (_cc)), \ + BT_ASSERT_PRE_HOT(((const struct bt_component_class *) (_cc)), \ "Component class", ": %!+C", (_cc)) static @@ -130,10 +134,9 @@ end: return ret; } -struct bt_private_component_class_source * -bt_private_component_class_source_create( +struct bt_component_class_source *bt_component_class_source_create( const char *name, - bt_private_component_class_source_notification_iterator_next_method method) + bt_component_class_source_notification_iterator_next_method method) { struct bt_component_class_source *source_class = NULL; int ret; @@ -169,9 +172,9 @@ end: return (void *) source_class; } -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 *bt_component_class_filter_create( + const char *name, + bt_component_class_filter_notification_iterator_next_method method) { struct bt_component_class_filter *filter_class = NULL; int ret; @@ -207,9 +210,8 @@ end: return (void *) filter_class; } -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 *bt_component_class_sink_create( + const char *name, bt_component_class_sink_consume_method method) { struct bt_component_class_sink *sink_class = NULL; int ret; @@ -245,12 +247,10 @@ end: return (void *) sink_class; } -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 bt_component_class_source_set_init_method( + struct bt_component_class_source *comp_cls, + bt_component_class_source_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); @@ -260,12 +260,10 @@ int bt_private_component_class_source_set_init_method( return 0; } -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 bt_component_class_filter_set_init_method( + struct bt_component_class_filter *comp_cls, + bt_component_class_filter_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); @@ -275,12 +273,10 @@ int bt_private_component_class_filter_set_init_method( return 0; } -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 bt_component_class_sink_set_init_method( + struct bt_component_class_sink *comp_cls, + bt_component_class_sink_init_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); @@ -290,12 +286,10 @@ int bt_private_component_class_sink_set_init_method( return 0; } -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 bt_component_class_source_set_finalize_method( + struct bt_component_class_source *comp_cls, + bt_component_class_source_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); @@ -305,12 +299,10 @@ int bt_private_component_class_source_set_finalize_method( return 0; } -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 bt_component_class_filter_set_finalize_method( + struct bt_component_class_filter *comp_cls, + bt_component_class_filter_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); @@ -320,12 +312,10 @@ int bt_private_component_class_filter_set_finalize_method( return 0; } -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 bt_component_class_sink_set_finalize_method( + struct bt_component_class_sink *comp_cls, + bt_component_class_sink_finalize_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); @@ -335,12 +325,10 @@ int bt_private_component_class_sink_set_finalize_method( return 0; } -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) +int bt_component_class_source_set_query_method( + struct bt_component_class_source *comp_cls, + bt_component_class_source_query_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); @@ -350,12 +338,10 @@ int bt_private_component_class_source_set_query_method( return 0; } -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) +int bt_component_class_filter_set_query_method( + struct bt_component_class_filter *comp_cls, + bt_component_class_filter_query_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); @@ -365,12 +351,10 @@ int bt_private_component_class_filter_set_query_method( return 0; } -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) +int bt_component_class_sink_set_query_method( + struct bt_component_class_sink *comp_cls, + bt_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); @@ -380,12 +364,10 @@ int bt_private_component_class_sink_set_query_method( return 0; } -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) +int bt_component_class_filter_set_accept_input_port_connection_method( + struct bt_component_class_filter *comp_cls, + bt_component_class_filter_accept_input_port_connection_method method) { - 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); @@ -395,12 +377,10 @@ int bt_private_component_class_filter_set_accept_input_port_connection_method( return 0; } -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) +int bt_component_class_sink_set_accept_input_port_connection_method( + struct bt_component_class_sink *comp_cls, + bt_component_class_sink_accept_input_port_connection_method method) { - 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); @@ -410,12 +390,10 @@ int bt_private_component_class_sink_set_accept_input_port_connection_method( return 0; } -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) +int bt_component_class_source_set_accept_output_port_connection_method( + struct bt_component_class_source *comp_cls, + bt_component_class_source_accept_output_port_connection_method method) { - 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); @@ -425,12 +403,10 @@ int bt_private_component_class_source_set_accept_output_port_connection_method( return 0; } -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) +int bt_component_class_filter_set_accept_output_port_connection_method( + struct bt_component_class_filter *comp_cls, + bt_component_class_filter_accept_output_port_connection_method method) { - 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); @@ -440,12 +416,10 @@ int bt_private_component_class_filter_set_accept_output_port_connection_method( return 0; } -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) +int bt_component_class_filter_set_input_port_connected_method( + struct bt_component_class_filter *comp_cls, + bt_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); @@ -455,12 +429,10 @@ int bt_private_component_class_filter_set_input_port_connected_method( return 0; } -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) +int bt_component_class_sink_set_input_port_connected_method( + struct bt_component_class_sink *comp_cls, + bt_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); @@ -470,12 +442,10 @@ int bt_private_component_class_sink_set_input_port_connected_method( return 0; } -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) +int bt_component_class_source_set_output_port_connected_method( + struct bt_component_class_source *comp_cls, + bt_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); @@ -485,12 +455,10 @@ int bt_private_component_class_source_set_output_port_connected_method( return 0; } -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) +int bt_component_class_filter_set_output_port_connected_method( + struct bt_component_class_filter *comp_cls, + bt_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); @@ -500,12 +468,10 @@ int bt_private_component_class_filter_set_output_port_connected_method( return 0; } -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) +int bt_component_class_filter_set_input_port_disconnected_method( + struct bt_component_class_filter *comp_cls, + bt_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); @@ -515,12 +481,10 @@ int bt_private_component_class_filter_set_input_port_disconnected_method( return 0; } -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) +int bt_component_class_sink_set_input_port_disconnected_method( + struct bt_component_class_sink *comp_cls, + bt_component_class_sink_input_port_disconnected_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); @@ -530,12 +494,10 @@ int bt_private_component_class_sink_set_input_port_disconnected_method( return 0; } -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) +int bt_component_class_source_set_output_port_disconnected_method( + struct bt_component_class_source *comp_cls, + bt_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); @@ -545,12 +507,10 @@ int bt_private_component_class_source_set_output_port_disconnected_method( return 0; } -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) +int bt_component_class_filter_set_output_port_disconnected_method( + struct bt_component_class_filter *comp_cls, + bt_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); @@ -560,12 +520,10 @@ int bt_private_component_class_filter_set_output_port_disconnected_method( return 0; } -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) +int bt_component_class_source_set_notification_iterator_init_method( + struct bt_component_class_source *comp_cls, + bt_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); @@ -575,12 +533,10 @@ int bt_private_component_class_source_set_notification_iterator_init_method( return 0; } -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) +int bt_component_class_filter_set_notification_iterator_init_method( + struct bt_component_class_filter *comp_cls, + bt_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); @@ -590,12 +546,10 @@ int bt_private_component_class_filter_set_notification_iterator_init_method( return 0; } -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) +int bt_component_class_source_set_notification_iterator_finalize_method( + struct bt_component_class_source *comp_cls, + bt_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); @@ -605,12 +559,10 @@ int bt_private_component_class_source_set_notification_iterator_finalize_method( return 0; } -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) +int bt_component_class_filter_set_notification_iterator_finalize_method( + struct bt_component_class_filter *comp_cls, + bt_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); @@ -620,12 +572,10 @@ int bt_private_component_class_filter_set_notification_iterator_finalize_method( return 0; } -int bt_private_component_class_set_description( - struct bt_private_component_class *priv_comp_cls, +int bt_component_class_set_description( + struct bt_component_class *comp_cls, const char *description) { - struct bt_component_class *comp_cls = (void *) priv_comp_cls; - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(description, "Description"); BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); @@ -638,12 +588,10 @@ int bt_private_component_class_set_description( return 0; } -int bt_private_component_class_set_help( - struct bt_private_component_class *priv_comp_cls, +int bt_component_class_set_help( + struct bt_component_class *comp_cls, const char *help) { - 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); @@ -652,21 +600,21 @@ int bt_private_component_class_set_help( return 0; } -const char *bt_component_class_get_name(struct bt_component_class *comp_cls) +const char *bt_component_class_get_name(const struct bt_component_class *comp_cls) { 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 *comp_cls) + const struct bt_component_class *comp_cls) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return comp_cls->type; } const char *bt_component_class_get_description( - struct bt_component_class *comp_cls) + const struct bt_component_class *comp_cls) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return comp_cls->description && @@ -675,7 +623,7 @@ const char *bt_component_class_get_description( } const char *bt_component_class_get_help( - struct bt_component_class *comp_cls) + const struct bt_component_class *comp_cls) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return comp_cls->help && @@ -699,9 +647,9 @@ void bt_component_class_add_destroy_listener( } BT_HIDDEN -void _bt_component_class_freeze(struct bt_component_class *comp_cls) +void _bt_component_class_freeze(const struct bt_component_class *comp_cls) { BT_ASSERT(comp_cls); BT_LIB_LOGD("Freezing component class: %!+C", comp_cls); - comp_cls->frozen = true; + ((struct bt_component_class *) comp_cls)->frozen = true; } diff --git a/lib/graph/component-filter.c b/lib/graph/component-filter.c index d9cb06e3..869c3d77 100644 --- a/lib/graph/component-filter.c +++ b/lib/graph/component-filter.c @@ -28,12 +28,10 @@ #include #include #include -#include +#include #include #include #include -#include -#include #include #include #include @@ -46,7 +44,7 @@ void bt_component_filter_destroy(struct bt_component *component) BT_HIDDEN struct bt_component *bt_component_filter_create( - struct bt_component_class *class) + const struct bt_component_class *class) { struct bt_component_filter *filter = NULL; @@ -61,13 +59,14 @@ end: } uint64_t bt_component_filter_get_output_port_count( - struct bt_component_filter *comp) + const 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) +const struct bt_port_output * +bt_component_filter_borrow_output_port_by_name_const( + const struct bt_component_filter *comp, const char *name) { return bt_component_borrow_output_port_by_name( (void *) comp, name); @@ -81,8 +80,9 @@ bt_self_component_filter_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) +const struct bt_port_output * +bt_component_filter_borrow_output_port_by_index_const( + const struct bt_component_filter *comp, uint64_t index) { return bt_component_borrow_output_port_by_index( (void *) comp, index); @@ -124,14 +124,14 @@ end: } uint64_t bt_component_filter_get_input_port_count( - struct bt_component_filter *component) + const 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) +const struct bt_port_input *bt_component_filter_borrow_input_port_by_name_const( + const 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( @@ -147,8 +147,9 @@ bt_self_component_filter_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) +const struct bt_port_input * +bt_component_filter_borrow_input_port_by_index_const( + const 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( diff --git a/lib/graph/component-sink.c b/lib/graph/component-sink.c index 65403b8a..033c8e6e 100644 --- a/lib/graph/component-sink.c +++ b/lib/graph/component-sink.c @@ -28,10 +28,9 @@ #include #include #include -#include +#include #include #include -#include #include #include #include @@ -43,7 +42,8 @@ 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 *bt_component_sink_create( + const struct bt_component_class *class) { struct bt_component_sink *sink = NULL; @@ -58,14 +58,15 @@ end: } uint64_t bt_component_sink_get_input_port_count( - struct bt_component_sink *component) + const 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) +const struct bt_port_input * +bt_component_sink_borrow_input_port_by_name_const( + const 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); @@ -80,8 +81,8 @@ bt_self_component_sink_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) +const struct bt_port_input *bt_component_sink_borrow_input_port_by_index_const( + const 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( diff --git a/lib/graph/component-source.c b/lib/graph/component-source.c index 2d5039aa..0c20858e 100644 --- a/lib/graph/component-source.c +++ b/lib/graph/component-source.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -45,7 +45,7 @@ void bt_component_source_destroy(struct bt_component *component) BT_HIDDEN struct bt_component *bt_component_source_create( - struct bt_component_class *class) + const struct bt_component_class *class) { struct bt_component_source *source = NULL; @@ -60,13 +60,14 @@ end: } uint64_t bt_component_source_get_output_port_count( - struct bt_component_source *comp) + const 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) +const struct bt_port_output * +bt_component_source_borrow_output_port_by_name_const( + const struct bt_component_source *comp, const char *name) { return bt_component_borrow_output_port_by_name((void *) comp, name); } @@ -79,8 +80,9 @@ bt_self_component_source_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) +const struct bt_port_output * +bt_component_source_borrow_output_port_by_index_const( + const struct bt_component_source *comp, uint64_t index) { return bt_component_borrow_output_port_by_index((void *) comp, index); } diff --git a/lib/graph/component.c b/lib/graph/component.c index 84a85010..2d3460a0 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -26,7 +26,10 @@ #include #include -#include +#include +#include +#include +#include #include #include #include @@ -49,7 +52,7 @@ static struct bt_component * (* const component_create_funcs[])( - struct bt_component_class *) = { + const struct bt_component_class *) = { [BT_COMPONENT_CLASS_TYPE_SOURCE] = bt_component_source_create, [BT_COMPONENT_CLASS_TYPE_SINK] = bt_component_sink_create, [BT_COMPONENT_CLASS_TYPE_FILTER] = bt_component_filter_create, @@ -182,7 +185,7 @@ void destroy_component(struct bt_object *obj) } enum bt_component_class_type bt_component_get_class_type( - struct bt_component *component) + const struct bt_component *component) { BT_ASSERT_PRE_NON_NULL(component, "Component"); return component->class->type; @@ -242,14 +245,14 @@ end: } BT_HIDDEN -uint64_t bt_component_get_input_port_count(struct bt_component *comp) +uint64_t bt_component_get_input_port_count(const struct bt_component *comp) { BT_ASSERT_PRE_NON_NULL(comp, "Component"); return (uint64_t) comp->input_ports->len; } BT_HIDDEN -uint64_t bt_component_get_output_port_count(struct bt_component *comp) +uint64_t bt_component_get_output_port_count(const struct bt_component *comp) { BT_ASSERT_PRE_NON_NULL(comp, "Component"); return (uint64_t) comp->output_ports->len; @@ -322,20 +325,20 @@ end: return ret; } -const char *bt_component_get_name(struct bt_component *component) +const char *bt_component_get_name(const struct bt_component *component) { BT_ASSERT_PRE_NON_NULL(component, "Component"); return component->name->str; } struct bt_component_class *bt_component_borrow_class( - struct bt_component *component) + const struct bt_component *component) { BT_ASSERT_PRE_NON_NULL(component, "Component"); return component->class; } -void *bt_self_component_get_data(struct bt_self_component *self_comp) +void *bt_self_component_get_data(const struct bt_self_component *self_comp) { struct bt_component *component = (void *) self_comp; @@ -361,7 +364,7 @@ void bt_component_set_graph(struct bt_component *component, graph ? &graph->base : NULL); } -bt_bool bt_component_graph_is_canceled(struct bt_component *component) +bt_bool bt_component_graph_is_canceled(const struct bt_component *component) { return bt_graph_is_canceled( (void *) bt_object_borrow_parent(&component->base)); @@ -485,7 +488,7 @@ void remove_port_by_index(struct bt_component *component, * 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. + * graph's user. */ bt_object_get_no_null_check(&port->base); @@ -565,7 +568,7 @@ enum bt_self_component_status bt_component_accept_port_connection( struct bt_port *other_port) { typedef enum bt_self_component_status (*method_t)( - void *, void *, void *); + void *, void *, const void *); enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; method_t method = NULL; @@ -628,7 +631,7 @@ enum bt_self_component_status bt_component_accept_port_connection( 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); + status = method(comp, self_port, (void *) other_port); BT_LOGD("User method returned: status=%s", bt_self_component_status_string(status)); } @@ -642,7 +645,7 @@ enum bt_self_component_status bt_component_port_connected( struct bt_port *other_port) { typedef enum bt_self_component_status (*method_t)( - void *, void *, void *); + void *, void *, const void *); enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; method_t method = NULL; @@ -705,7 +708,7 @@ enum bt_self_component_status bt_component_port_connected( 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); + status = method(comp, self_port, (void *) other_port); BT_LOGD("User method returned: status=%s", bt_self_component_status_string(status)); } diff --git a/lib/graph/connection.c b/lib/graph/connection.c index 655b36c9..50e558b4 100644 --- a/lib/graph/connection.c +++ b/lib/graph/connection.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -180,7 +181,8 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph) if (downstream_port) { BT_LIB_LOGD("Disconnecting connection's downstream port: %!+p", downstream_port); - downstream_comp = bt_port_borrow_component(downstream_port); + downstream_comp = bt_port_borrow_component_inline( + downstream_port); bt_port_set_connection(downstream_port, NULL); conn->downstream_port = NULL; } @@ -188,7 +190,8 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph) if (upstream_port) { BT_LIB_LOGD("Disconnecting connection's upstream port: %!+p", upstream_port); - upstream_comp = bt_port_borrow_component(upstream_port); + upstream_comp = bt_port_borrow_component_inline( + upstream_port); bt_port_set_connection(upstream_port, NULL); conn->upstream_port = NULL; } @@ -254,15 +257,15 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph) } } -struct bt_port_output *bt_connection_borrow_upstream_port( - struct bt_connection *connection) +const struct bt_port_output *bt_connection_borrow_upstream_port_const( + const struct bt_connection *connection) { BT_ASSERT_PRE_NON_NULL(connection, "Connection"); return (void *) connection->upstream_port; } -struct bt_port_input *bt_connection_borrow_downstream_port( - struct bt_connection *connection) +const struct bt_port_input *bt_connection_borrow_downstream_port_const( + const struct bt_connection *connection) { BT_ASSERT_PRE_NON_NULL(connection, "Connection"); return (void *) connection->downstream_port; @@ -278,7 +281,7 @@ void bt_connection_remove_iterator(struct bt_connection *conn, try_remove_connection_from_graph(conn); } -bt_bool bt_connection_is_ended(struct bt_connection *connection) +bt_bool bt_connection_is_ended(const struct bt_connection *connection) { return !connection->downstream_port && !connection->upstream_port; } diff --git a/lib/graph/graph.c b/lib/graph/graph.c index f624e659..3ba2321e 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -25,13 +25,14 @@ #include #include -#include +#include +#include #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -47,14 +48,21 @@ #include #include -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 *, const void *, void *); +typedef void (*port_added_func_t)(const void *, const void *, void *); + +typedef void (*port_removed_func_t)(const void *, const void *, void *); + +typedef void (*ports_connected_func_t)(const void *, const void *, const void *, + const void *, void *); + +typedef void (*ports_disconnected_func_t)(const void *, const void *, + const void *, const void *, void *); + +typedef enum bt_self_component_status (*comp_init_method_t)(const void *, + const void *, void *); struct bt_graph_listener { - bt_private_graph_listener_removed removed; + bt_graph_listener_removed_func removed; void *data; }; @@ -103,8 +111,7 @@ struct bt_graph_listener_ports_disconnected { static void destroy_graph(struct bt_object *obj) { - struct bt_graph *graph = container_of(obj, - struct bt_graph, base); + struct bt_graph *graph = container_of(obj, struct bt_graph, base); /* * The graph's reference count is 0 if we're here. Increment @@ -139,7 +146,7 @@ void destroy_graph(struct bt_object *obj) * Cancel the graph to disallow some operations, like creating * notification iterators and adding ports to components. */ - (void) bt_private_graph_cancel((void *) graph); + (void) bt_graph_cancel((void *) graph); /* Call all remove listeners */ CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added, @@ -302,7 +309,7 @@ void notify_notification_graph_is_destroyed(struct bt_notification *notif) bt_notification_unlink_graph(notif); } -struct bt_private_graph *bt_private_graph_create(void) +struct bt_graph *bt_graph_create(void) { struct bt_graph *graph; int ret; @@ -488,13 +495,12 @@ error: goto end; } -enum bt_graph_status bt_private_graph_connect_ports( - struct bt_private_graph *priv_graph, - struct bt_port_output *upstream_port_out, - struct bt_port_input *downstream_port_in, - struct bt_connection **user_connection) +enum bt_graph_status bt_graph_connect_ports( + struct bt_graph *graph, + const struct bt_port_output *upstream_port_out, + const struct bt_port_input *downstream_port_in, + const 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_port *upstream_port = (void *) upstream_port_out; @@ -512,10 +518,10 @@ enum bt_graph_status bt_private_graph_connect_ports( "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), + BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) upstream_port), "Upstream port does not belong to a component: %!+p", upstream_port); - BT_ASSERT_PRE(bt_port_borrow_component((void *) downstream_port), + BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) downstream_port), "Downstream port does not belong to a component: %!+p", downstream_port); init_can_consume = graph->can_consume; @@ -523,9 +529,9 @@ enum bt_graph_status bt_private_graph_connect_ports( "%![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( + upstream_component = bt_port_borrow_component_inline( (void *) upstream_port); - downstream_component = bt_port_borrow_component( + downstream_component = bt_port_borrow_component_inline( (void *) downstream_port); /* @@ -771,10 +777,9 @@ end: return status; } -enum bt_graph_status bt_private_graph_consume( - struct bt_private_graph *priv_graph) +enum bt_graph_status bt_graph_consume( + struct bt_graph *graph) { - struct bt_graph *graph = (void *) priv_graph; enum bt_graph_status status; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); @@ -787,9 +792,8 @@ enum bt_graph_status bt_private_graph_consume( return status; } -enum bt_graph_status bt_private_graph_run(struct bt_private_graph *priv_graph) +enum bt_graph_status bt_graph_run(struct bt_graph *graph) { - struct bt_graph *graph = (void *) priv_graph; enum bt_graph_status status = BT_GRAPH_STATUS_OK; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); @@ -822,7 +826,7 @@ enum bt_graph_status bt_private_graph_run(struct bt_private_graph *priv_graph) * * However, in the case where a single sink is * left, the caller can decide to busy-wait and - * call bt_private_graph_run() continuously + * call bt_graph_run() continuously * until the source is ready or it can decide to * sleep for an arbitrary amount of time. */ @@ -846,13 +850,12 @@ end: } 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, +bt_graph_add_source_component_output_port_added_listener( + struct bt_graph *graph, + bt_graph_source_component_output_port_added_listener_func func, + bt_graph_listener_removed_func 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, @@ -882,13 +885,12 @@ bt_private_graph_add_source_component_output_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_filter_component_output_port_added_listener func, - bt_private_graph_listener_removed listener_removed, void *data, +bt_graph_add_filter_component_output_port_added_listener( + struct bt_graph *graph, + bt_graph_filter_component_output_port_added_listener_func func, + bt_graph_listener_removed_func 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, @@ -918,13 +920,12 @@ bt_private_graph_add_filter_component_output_port_added_listener( } 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, +bt_graph_add_filter_component_input_port_added_listener( + struct bt_graph *graph, + bt_graph_filter_component_input_port_added_listener_func func, + bt_graph_listener_removed_func 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, @@ -954,13 +955,12 @@ bt_private_graph_add_filter_component_input_port_added_listener( } 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, +bt_graph_add_sink_component_input_port_added_listener( + struct bt_graph *graph, + bt_graph_sink_component_input_port_added_listener_func func, + bt_graph_listener_removed_func 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, @@ -990,13 +990,12 @@ bt_private_graph_add_sink_component_input_port_added_listener( } enum bt_graph_status -bt_private_graph_add_source_component_output_port_removed_listener( - struct bt_private_graph *priv_graph, - bt_private_graph_source_component_output_port_removed_listener func, - bt_private_graph_listener_removed listener_removed, void *data, +bt_graph_add_source_component_output_port_removed_listener( + struct bt_graph *graph, + bt_graph_source_component_output_port_removed_listener_func func, + bt_graph_listener_removed_func 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, @@ -1026,13 +1025,12 @@ bt_private_graph_add_source_component_output_port_removed_listener( } 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, +bt_graph_add_filter_component_output_port_removed_listener( + struct bt_graph *graph, + bt_graph_filter_component_output_port_removed_listener_func func, + bt_graph_listener_removed_func 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, @@ -1062,13 +1060,12 @@ bt_private_graph_add_filter_component_output_port_removed_listener( } 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, +bt_graph_add_filter_component_input_port_removed_listener( + struct bt_graph *graph, + bt_graph_filter_component_input_port_removed_listener_func func, + bt_graph_listener_removed_func 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, @@ -1098,13 +1095,12 @@ bt_private_graph_add_filter_component_input_port_removed_listener( } enum bt_graph_status -bt_private_graph_add_sink_component_input_port_removed_listener( - struct bt_private_graph *priv_graph, - bt_private_graph_sink_component_input_port_removed_listener func, - bt_private_graph_listener_removed listener_removed, void *data, +bt_graph_add_sink_component_input_port_removed_listener( + struct bt_graph *graph, + bt_graph_sink_component_input_port_removed_listener_func func, + bt_graph_listener_removed_func 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, @@ -1134,13 +1130,12 @@ bt_private_graph_add_sink_component_input_port_removed_listener( } 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, +bt_graph_add_source_filter_component_ports_connected_listener( + struct bt_graph *graph, + bt_graph_source_filter_component_ports_connected_listener_func func, + bt_graph_listener_removed_func 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, @@ -1171,13 +1166,12 @@ bt_private_graph_add_source_filter_component_ports_connected_listener( } 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, +bt_graph_add_source_sink_component_ports_connected_listener( + struct bt_graph *graph, + bt_graph_source_sink_component_ports_connected_listener_func func, + bt_graph_listener_removed_func 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, @@ -1208,13 +1202,12 @@ bt_private_graph_add_source_sink_component_ports_connected_listener( } enum bt_graph_status -bt_private_graph_add_filter_sink_component_ports_connected_listener( - struct bt_private_graph *priv_graph, - bt_private_graph_filter_sink_component_ports_connected_listener func, - bt_private_graph_listener_removed listener_removed, void *data, +bt_graph_add_filter_sink_component_ports_connected_listener( + struct bt_graph *graph, + bt_graph_filter_sink_component_ports_connected_listener_func func, + bt_graph_listener_removed_func 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, @@ -1245,13 +1238,12 @@ bt_private_graph_add_filter_sink_component_ports_connected_listener( } 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, +bt_graph_add_source_filter_component_ports_disconnected_listener( + struct bt_graph *graph, + bt_graph_source_filter_component_ports_disconnected_listener_func func, + bt_graph_listener_removed_func 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, @@ -1282,13 +1274,12 @@ bt_private_graph_add_source_filter_component_ports_disconnected_listener( } 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, +bt_graph_add_source_sink_component_ports_disconnected_listener( + struct bt_graph *graph, + bt_graph_source_sink_component_ports_disconnected_listener_func func, + bt_graph_listener_removed_func 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, @@ -1319,13 +1310,12 @@ bt_private_graph_add_source_sink_component_ports_disconnected_listener( } 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, +bt_graph_add_filter_sink_component_ports_disconnected_listener( + struct bt_graph *graph, + bt_graph_filter_sink_component_ports_disconnected_listener_func func, + bt_graph_listener_removed_func 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, @@ -1366,7 +1356,7 @@ void bt_graph_notify_port_added(struct bt_graph *graph, struct bt_port *port) 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); + comp = bt_port_borrow_component_inline(port); BT_ASSERT(comp); switch (comp->class->type) { @@ -1504,9 +1494,9 @@ void bt_graph_notify_ports_connected(struct bt_graph *graph, 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); + upstream_comp = bt_port_borrow_component_inline(upstream_port); BT_ASSERT(upstream_comp); - downstream_comp = bt_port_borrow_component(downstream_port); + downstream_comp = bt_port_borrow_component_inline(downstream_port); BT_ASSERT(downstream_comp); switch (upstream_comp->class->type) { @@ -1622,10 +1612,9 @@ void bt_graph_notify_ports_disconnected(struct bt_graph *graph, } } -enum bt_graph_status bt_private_graph_cancel( - struct bt_private_graph *priv_graph) +enum bt_graph_status bt_graph_cancel( + struct bt_graph *graph) { - struct bt_graph *graph = (void *) priv_graph; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); graph->canceled = true; @@ -1633,7 +1622,7 @@ enum bt_graph_status bt_private_graph_cancel( return BT_GRAPH_STATUS_OK; } -bt_bool bt_graph_is_canceled(struct bt_graph *graph) +bt_bool bt_graph_is_canceled(const struct bt_graph *graph) { BT_ASSERT_PRE_NON_NULL(graph, "Graph"); return graph->canceled ? BT_TRUE : BT_FALSE; @@ -1675,13 +1664,12 @@ end: static enum bt_graph_status add_component_with_init_method_data( - struct bt_private_graph *priv_graph, + struct bt_graph *graph, struct bt_component_class *comp_cls, comp_init_method_t init_method, const char *name, const struct bt_value *params, 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_self_component_status comp_status; struct bt_component *component = NULL; @@ -1786,11 +1774,12 @@ end: } 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, +bt_graph_add_source_component_with_init_method_data( + struct bt_graph *graph, + const struct bt_component_class_source *comp_cls, const char *name, const struct bt_value *params, - void *init_method_data, struct bt_component_source **component) + void *init_method_data, + const struct bt_component_source **component) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return add_component_with_init_method_data(graph, @@ -1798,22 +1787,23 @@ bt_private_graph_add_source_component_with_init_method_data( 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, +enum bt_graph_status bt_graph_add_source_component( + struct bt_graph *graph, + const struct bt_component_class_source *comp_cls, const char *name, const struct bt_value *params, - struct bt_component_source **component) + const struct bt_component_source **component) { - return bt_private_graph_add_source_component_with_init_method_data( + return bt_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, +bt_graph_add_filter_component_with_init_method_data( + struct bt_graph *graph, + const struct bt_component_class_filter *comp_cls, const char *name, const struct bt_value *params, - void *init_method_data, struct bt_component_filter **component) + void *init_method_data, + const struct bt_component_filter **component) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return add_component_with_init_method_data(graph, @@ -1821,22 +1811,23 @@ bt_private_graph_add_filter_component_with_init_method_data( 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, +enum bt_graph_status bt_graph_add_filter_component( + struct bt_graph *graph, + const struct bt_component_class_filter *comp_cls, const char *name, const struct bt_value *params, - struct bt_component_filter **component) + const struct bt_component_filter **component) { - return bt_private_graph_add_filter_component_with_init_method_data( + return bt_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_sink *comp_cls, +bt_graph_add_sink_component_with_init_method_data( + struct bt_graph *graph, + const struct bt_component_class_sink *comp_cls, const char *name, const struct bt_value *params, - void *init_method_data, struct bt_component_sink **component) + void *init_method_data, + const struct bt_component_sink **component) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return add_component_with_init_method_data(graph, @@ -1844,13 +1835,13 @@ bt_private_graph_add_sink_component_with_init_method_data( 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, +enum bt_graph_status bt_graph_add_sink_component( + struct bt_graph *graph, + const struct bt_component_class_sink *comp_cls, const char *name, const struct bt_value *params, - struct bt_component_sink **component) + const struct bt_component_sink **component) { - return bt_private_graph_add_sink_component_with_init_method_data( + return bt_graph_add_sink_component_with_init_method_data( graph, comp_cls, name, params, NULL, component); } diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 82f69571..56b68804 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -32,28 +32,29 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include #include -#include -#include +#include +#include #include #include #include #include #include -#include +#include #include -#include +#include #include -#include +#include #include -#include -#include +#include +#include +#include #include #include #include @@ -360,7 +361,7 @@ bt_self_component_port_input_notification_iterator_create( struct bt_component_class *upstream_comp_cls; BT_ASSERT_PRE_NON_NULL(port, "Port"); - comp = bt_port_borrow_component(port); + comp = bt_port_borrow_component_inline(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", @@ -371,7 +372,7 @@ bt_self_component_port_input_notification_iterator_create( BT_ASSERT(port->connection); upstream_port = port->connection->upstream_port; BT_ASSERT(upstream_port); - upstream_comp = bt_port_borrow_component(upstream_port); + upstream_comp = bt_port_borrow_component_inline(upstream_port); BT_ASSERT(upstream_comp); upstream_comp_cls = upstream_comp->class; BT_ASSERT(upstream_comp->class->type == @@ -435,7 +436,7 @@ end: } void *bt_self_notification_iterator_get_data( - struct bt_self_notification_iterator *self_iterator) + const struct bt_self_notification_iterator *self_iterator) { struct bt_self_component_port_input_notification_iterator *iterator = (void *) self_iterator; @@ -458,7 +459,7 @@ void bt_self_notification_iterator_set_data( BT_ASSERT_PRE_FUNC static inline -void bt_notification_borrow_packet_stream(struct bt_notification *notif, +void bt_notification_borrow_packet_stream(const struct bt_notification *notif, const struct bt_stream **stream, const struct bt_packet **packet) { @@ -467,21 +468,21 @@ void bt_notification_borrow_packet_stream(struct bt_notification *notif, switch (notif->type) { case BT_NOTIFICATION_TYPE_EVENT: *packet = bt_event_borrow_packet_const( - bt_notification_event_borrow_event(notif)); + bt_notification_event_borrow_event_const(notif)); *stream = bt_packet_borrow_stream_const(*packet); break; case BT_NOTIFICATION_TYPE_STREAM_BEGIN: - *stream = bt_notification_stream_begin_borrow_stream(notif); + *stream = bt_notification_stream_begin_borrow_stream_const(notif); break; case BT_NOTIFICATION_TYPE_STREAM_END: - *stream = bt_notification_stream_end_borrow_stream(notif); + *stream = bt_notification_stream_end_borrow_stream_const(notif); break; case BT_NOTIFICATION_TYPE_PACKET_BEGIN: - *packet = bt_notification_packet_begin_borrow_packet(notif); + *packet = bt_notification_packet_begin_borrow_packet_const(notif); *stream = bt_packet_borrow_stream_const(*packet); break; case BT_NOTIFICATION_TYPE_PACKET_END: - *packet = bt_notification_packet_end_borrow_packet(notif); + *packet = bt_notification_packet_end_borrow_packet_const(notif); *stream = bt_packet_borrow_stream_const(*packet); break; default: @@ -493,15 +494,16 @@ BT_ASSERT_PRE_FUNC static inline bool validate_notification( struct bt_self_component_port_input_notification_iterator *iterator, - struct bt_notification *notif) + const struct bt_notification *c_notif) { bool is_valid = true; struct stream_state *stream_state; const struct bt_stream *stream = NULL; const struct bt_packet *packet = NULL; + struct bt_notification *notif = (void *) c_notif; BT_ASSERT(notif); - bt_notification_borrow_packet_stream(notif, &stream, &packet); + bt_notification_borrow_packet_stream(c_notif, &stream, &packet); if (!stream) { /* we don't care about notifications not attached to streams */ @@ -515,7 +517,7 @@ bool validate_notification( * MUST be a BT_NOTIFICATION_TYPE_STREAM_BEGIN notification * and its sequence number must be 0. */ - if (notif->type != BT_NOTIFICATION_TYPE_STREAM_BEGIN) { + if (c_notif->type != BT_NOTIFICATION_TYPE_STREAM_BEGIN) { BT_ASSERT_PRE_MSG("Unexpected notification: missing a " "BT_NOTIFICATION_TYPE_STREAM_BEGIN " "notification prior to this notification: " @@ -524,17 +526,17 @@ bool validate_notification( goto end; } - if (notif->seq_num == -1ULL) { + if (c_notif->seq_num == -1ULL) { notif->seq_num = 0; } - if (notif->seq_num != 0) { + if (c_notif->seq_num != 0) { BT_ASSERT_PRE_MSG("Unexpected notification sequence " "number for this notification iterator: " "this is the first notification for this " "stream, expecting sequence number 0: " "seq-num=%" PRIu64 ", %![stream-]+s", - notif->seq_num, stream); + c_notif->seq_num, stream); is_valid = false; goto end; } @@ -564,26 +566,26 @@ bool validate_notification( goto end; } - if (notif->seq_num == -1ULL) { + if (c_notif->seq_num == -1ULL) { notif->seq_num = stream_state->expected_notif_seq_num; } - if (notif->seq_num != -1ULL && - notif->seq_num != stream_state->expected_notif_seq_num) { + if (c_notif->seq_num != -1ULL && + c_notif->seq_num != stream_state->expected_notif_seq_num) { BT_ASSERT_PRE_MSG("Unexpected notification sequence number: " "seq-num=%" PRIu64 ", " "expected-seq-num=%" PRIu64 ", %![stream-]+s", - notif->seq_num, stream_state->expected_notif_seq_num, + c_notif->seq_num, stream_state->expected_notif_seq_num, stream); is_valid = false; goto end; } - switch (notif->type) { + switch (c_notif->type) { case BT_NOTIFICATION_TYPE_STREAM_BEGIN: BT_ASSERT_PRE_MSG("Unexpected BT_NOTIFICATION_TYPE_STREAM_BEGIN " "notification at this point: notif-seq-num=%" PRIu64 ", " - "%![stream-]+s", notif->seq_num, stream); + "%![stream-]+s", c_notif->seq_num, stream); is_valid = false; goto end; case BT_NOTIFICATION_TYPE_STREAM_END: @@ -593,7 +595,7 @@ bool validate_notification( "BT_NOTIFICATION_TYPE_PACKET_END notification " "prior to this notification: " "notif-seq-num=%" PRIu64 ", " - "%![stream-]+s", notif->seq_num, stream); + "%![stream-]+s", c_notif->seq_num, stream); is_valid = false; goto end; } @@ -607,7 +609,7 @@ bool validate_notification( "BT_NOTIFICATION_TYPE_PACKET_END notification " "prior to this notification: " "notif-seq-num=%" PRIu64 ", %![stream-]+s, " - "%![packet-]+a", notif->seq_num, stream, + "%![packet-]+a", c_notif->seq_num, stream, packet); is_valid = false; goto end; @@ -623,7 +625,7 @@ bool validate_notification( "BT_NOTIFICATION_TYPE_PACKET_BEGIN notification " "prior to this notification: " "notif-seq-num=%" PRIu64 ", %![stream-]+s, " - "%![packet-]+a", notif->seq_num, stream, + "%![packet-]+a", c_notif->seq_num, stream, packet); is_valid = false; goto end; @@ -637,7 +639,7 @@ bool validate_notification( "BT_NOTIFICATION_TYPE_EVENT notification: " "notif-seq-num=%" PRIu64 ", %![stream-]+s, " "%![notif-packet-]+a, %![expected-packet-]+a", - notif->seq_num, stream, + c_notif->seq_num, stream, stream_state->cur_packet, packet); is_valid = false; goto end; @@ -659,7 +661,8 @@ bool validate_notifications( uint64_t count) { bool ret = true; - bt_notification_array notifs = (void *) iterator->base.notifs->pdata; + bt_notification_array_const notifs = + (void *) iterator->base.notifs->pdata; uint64_t i; for (i = 0; i < count; i++) { @@ -673,7 +676,7 @@ bool validate_notifications( } BT_ASSERT_PRE_FUNC -static inline bool priv_conn_notif_iter_can_end( +static inline bool self_comp_port_input_notif_iter_can_end( struct bt_self_component_port_input_notification_iterator *iterator) { GHashTableIter iter; @@ -710,10 +713,10 @@ end: 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 *user_count) + bt_notification_array_const *notifs, uint64_t *user_count) { typedef enum bt_self_notification_iterator_status (*method_t)( - void *, bt_notification_array, uint64_t, uint64_t *); + void *, bt_notification_array_const, uint64_t, uint64_t *); method_t method = NULL; struct bt_component_class *comp_cls; @@ -786,7 +789,7 @@ bt_self_component_port_input_notification_iterator_next( */ if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { uint64_t i; - bt_notification_array notifs = + bt_notification_array_const notifs = (void *) iterator->base.notifs->pdata; for (i = 0; i < *user_count; i++) { @@ -809,7 +812,7 @@ bt_self_component_port_input_notification_iterator_next( case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: goto end; case BT_NOTIFICATION_ITERATOR_STATUS_END: - BT_ASSERT_PRE(priv_conn_notif_iter_can_end(iterator), + BT_ASSERT_PRE(self_comp_port_input_notif_iter_can_end(iterator), "Notification iterator cannot end at this point: " "%!+i", iterator); BT_ASSERT(iterator->state == @@ -830,7 +833,7 @@ end: enum bt_notification_iterator_status bt_port_output_notification_iterator_next( struct bt_port_output_notification_iterator *iterator, - bt_notification_array *notifs_to_user, + bt_notification_array_const *notifs_to_user, uint64_t *count_to_user) { enum bt_notification_iterator_status status; @@ -913,14 +916,13 @@ void bt_port_output_notification_iterator_destroy(struct bt_object *obj) struct bt_port_output_notification_iterator * bt_port_output_notification_iterator_create( - struct bt_private_graph *priv_graph, - struct bt_port_output *output_port) + struct bt_graph *graph, + const struct bt_port_output *output_port) { 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_sink *colander_comp; - struct bt_graph *graph = (void *) priv_graph; enum bt_graph_status graph_status; struct bt_port_input *colander_in_port = NULL; struct bt_component_class_sink_colander_data colander_data; @@ -928,7 +930,8 @@ bt_port_output_notification_iterator_create( BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(output_port, "Output port"); - output_port_comp = bt_port_borrow_component((void *) output_port); + output_port_comp = bt_port_borrow_component_inline( + (const void *) output_port); BT_ASSERT_PRE(output_port_comp, "Output port has no component: %!+p", output_port); BT_ASSERT_PRE(bt_component_borrow_graph(output_port_comp) == @@ -968,10 +971,10 @@ bt_port_output_notification_iterator_create( /* Hope that nobody uses this very unique name */ graph_status = - bt_private_graph_add_sink_component_with_init_method_data( + bt_graph_add_sink_component_with_init_method_data( (void *) graph, colander_comp_cls, "colander-36ac3409-b1a8-4d60-ab1f-4fdf341a8fb1", - NULL, &colander_data, &iterator->colander); + NULL, &colander_data, (void *) &iterator->colander); if (graph_status != BT_GRAPH_STATUS_OK) { BT_LIB_LOGW("Cannot add colander sink component to graph: " "%1[graph-]+g, status=%s", graph, @@ -983,10 +986,11 @@ bt_port_output_notification_iterator_create( * Connect provided output port to the colander component's * input port. */ - colander_in_port = bt_component_sink_borrow_input_port_by_index( - iterator->colander, 0); + colander_in_port = + (void *) bt_component_sink_borrow_input_port_by_index_const( + (void *) iterator->colander, 0); BT_ASSERT(colander_in_port); - graph_status = bt_private_graph_connect_ports(priv_graph, + graph_status = bt_graph_connect_ports(graph, output_port, colander_in_port, NULL); if (graph_status != BT_GRAPH_STATUS_OK) { BT_LIB_LOGW("Cannot add colander sink component to graph: " diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c index 9b09bc42..303a6520 100644 --- a/lib/graph/notification/event.c +++ b/lib/graph/notification/event.c @@ -33,7 +33,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -75,7 +76,7 @@ end: return (void *) notification; } -struct bt_private_notification *bt_private_notification_event_create( +struct bt_notification *bt_notification_event_create( struct bt_self_notification_iterator *self_notif_iter, struct bt_event_class *event_class, struct bt_packet *packet) @@ -189,14 +190,14 @@ struct bt_event *borrow_event(struct bt_notification *notification) return event_notification->event; } -struct bt_event *bt_private_notification_event_borrow_event( - struct bt_private_notification *notification) +struct bt_event *bt_notification_event_borrow_event( + struct bt_notification *notification) { - return borrow_event((void *) notification); + return borrow_event(notification); } -const struct bt_event *bt_notification_event_borrow_event( - struct bt_notification *notification) +const struct bt_event *bt_notification_event_borrow_event_const( + const struct bt_notification *notification) { - return borrow_event(notification); + return borrow_event((void *) notification); } diff --git a/lib/graph/notification/inactivity.c b/lib/graph/notification/inactivity.c index 46adbd8f..97e50565 100644 --- a/lib/graph/notification/inactivity.c +++ b/lib/graph/notification/inactivity.c @@ -28,7 +28,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -48,7 +49,7 @@ void bt_notification_inactivity_destroy(struct bt_object *obj) g_free(notification); } -struct bt_private_notification *bt_private_notification_inactivity_create( +struct bt_notification *bt_notification_inactivity_create( struct bt_self_notification_iterator *self_notif_iter, struct bt_clock_class *default_clock_class) { @@ -86,11 +87,9 @@ end: return (void *) ret_notif; } -void bt_private_notification_inactivity_set_default_clock_value( - struct bt_private_notification *priv_notif, - uint64_t value_cycles) +void bt_notification_inactivity_set_default_clock_value( + struct bt_notification *notif, uint64_t value_cycles) { - struct bt_notification *notif = (void *) priv_notif; struct bt_notification_inactivity *inactivity = (void *) notif; BT_ASSERT_PRE_NON_NULL(notif, "Notification"); @@ -101,8 +100,9 @@ void bt_private_notification_inactivity_set_default_clock_value( "%![notif-]+n, value=%" PRIu64, notif, value_cycles); } -struct bt_clock_value *bt_notification_inactivity_borrow_default_clock_value( - struct bt_notification *notif) +const struct bt_clock_value * +bt_notification_inactivity_borrow_default_clock_value_const( + const struct bt_notification *notif) { struct bt_notification_inactivity *inactivity = (void *) notif; diff --git a/lib/graph/notification/notification.c b/lib/graph/notification/notification.c index 5a835092..3a6090b9 100644 --- a/lib/graph/notification/notification.c +++ b/lib/graph/notification/notification.c @@ -25,7 +25,7 @@ #define BT_LOG_TAG "NOTIF" #include -#include +#include #include #include #include @@ -62,7 +62,7 @@ void bt_notification_init(struct bt_notification *notification, } enum bt_notification_type bt_notification_get_type( - struct bt_notification *notification) + const struct bt_notification *notification) { BT_ASSERT_PRE_NON_NULL(notification, "Notification"); return notification->type; diff --git a/lib/graph/notification/packet.c b/lib/graph/notification/packet.c index 6e4a5a1b..a1750764 100644 --- a/lib/graph/notification/packet.c +++ b/lib/graph/notification/packet.c @@ -32,7 +32,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -64,7 +65,7 @@ end: return (void *) notification; } -struct bt_private_notification *bt_private_notification_packet_begin_create( +struct bt_notification *bt_notification_packet_begin_create( struct bt_self_notification_iterator *self_notif_iter, struct bt_packet *packet) { @@ -137,8 +138,8 @@ void bt_notification_packet_begin_recycle(struct bt_notification *notif) bt_object_pool_recycle_object(&graph->packet_begin_notif_pool, notif); } -struct bt_packet *bt_private_notification_packet_begin_borrow_packet( - struct bt_private_notification *notification) +struct bt_packet *bt_notification_packet_begin_borrow_packet( + struct bt_notification *notification) { struct bt_notification_packet_begin *packet_begin; @@ -149,10 +150,10 @@ struct bt_packet *bt_private_notification_packet_begin_borrow_packet( return packet_begin->packet; } -const struct bt_packet *bt_notification_packet_begin_borrow_packet( - struct bt_notification *notification) +const struct bt_packet *bt_notification_packet_begin_borrow_packet_const( + const struct bt_notification *notification) { - return bt_private_notification_packet_begin_borrow_packet( + return bt_notification_packet_begin_borrow_packet( (void *) notification); } @@ -180,7 +181,7 @@ end: return (void *) notification; } -struct bt_private_notification *bt_private_notification_packet_end_create( +struct bt_notification *bt_notification_packet_end_create( struct bt_self_notification_iterator *self_notif_iter, struct bt_packet *packet) { @@ -252,8 +253,8 @@ void bt_notification_packet_end_recycle(struct bt_notification *notif) bt_object_pool_recycle_object(&graph->packet_end_notif_pool, notif); } -struct bt_packet *bt_private_notification_packet_end_borrow_packet( - struct bt_private_notification *notification) +struct bt_packet *bt_notification_packet_end_borrow_packet( + struct bt_notification *notification) { struct bt_notification_packet_end *packet_end; @@ -264,9 +265,9 @@ struct bt_packet *bt_private_notification_packet_end_borrow_packet( return packet_end->packet; } -const struct bt_packet *bt_notification_packet_end_borrow_packet( - struct bt_notification *notification) +const struct bt_packet *bt_notification_packet_end_borrow_packet_const( + const struct bt_notification *notification) { - return bt_private_notification_packet_end_borrow_packet( + return bt_notification_packet_end_borrow_packet( (void *) notification); } diff --git a/lib/graph/notification/stream.c b/lib/graph/notification/stream.c index 9c903112..92336b27 100644 --- a/lib/graph/notification/stream.c +++ b/lib/graph/notification/stream.c @@ -30,7 +30,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -55,7 +56,7 @@ void bt_notification_stream_end_destroy(struct bt_object *obj) g_free(notification); } -struct bt_private_notification *bt_private_notification_stream_end_create( +struct bt_notification *bt_notification_stream_end_create( struct bt_self_notification_iterator *self_notif_iter, struct bt_stream *stream) { @@ -88,8 +89,8 @@ error: return NULL; } -struct bt_stream *bt_private_notification_stream_end_borrow_stream( - struct bt_private_notification *notification) +struct bt_stream *bt_notification_stream_end_borrow_stream( + struct bt_notification *notification) { struct bt_notification_stream_end *stream_end; @@ -100,18 +101,16 @@ struct bt_stream *bt_private_notification_stream_end_borrow_stream( return stream_end->stream; } -const struct bt_stream *bt_notification_stream_end_borrow_stream( - struct bt_notification *notification) +const struct bt_stream *bt_notification_stream_end_borrow_stream_const( + const struct bt_notification *notification) { - return bt_private_notification_stream_end_borrow_stream( + return bt_notification_stream_end_borrow_stream( (void *) notification); } -void bt_private_notification_stream_end_set_default_clock_value( - struct bt_private_notification *priv_notif, - uint64_t value_cycles) +void bt_notification_stream_end_set_default_clock_value( + struct bt_notification *notif, uint64_t value_cycles) { - struct bt_notification *notif = (void *) priv_notif; struct bt_notification_stream_end *se_notif = (void *) notif; BT_ASSERT_PRE_NON_NULL(notif, "Notification"); @@ -159,7 +158,7 @@ void bt_notification_stream_begin_destroy(struct bt_object *obj) g_free(notification); } -struct bt_private_notification *bt_private_notification_stream_begin_create( +struct bt_notification *bt_notification_stream_begin_create( struct bt_self_notification_iterator *self_notif_iter, struct bt_stream *stream) { @@ -191,8 +190,8 @@ error: return NULL; } -struct bt_stream *bt_private_notification_stream_begin_borrow_stream( - struct bt_private_notification *notification) +struct bt_stream *bt_notification_stream_begin_borrow_stream( + struct bt_notification *notification) { struct bt_notification_stream_begin *stream_begin; @@ -203,18 +202,17 @@ struct bt_stream *bt_private_notification_stream_begin_borrow_stream( return stream_begin->stream; } -const struct bt_stream *bt_notification_stream_begin_borrow_stream( - struct bt_notification *notification) +const struct bt_stream *bt_notification_stream_begin_borrow_stream_const( + const struct bt_notification *notification) { - return bt_private_notification_stream_begin_borrow_stream( + return bt_notification_stream_begin_borrow_stream( (void *) notification); } -void bt_private_notification_stream_begin_set_default_clock_value( - struct bt_private_notification *priv_notif, +void bt_notification_stream_begin_set_default_clock_value( + struct bt_notification *notif, uint64_t value_cycles) { - struct bt_notification *notif = (void *) priv_notif; struct bt_notification_stream_begin *sb_notif = (void *) notif; BT_ASSERT_PRE_NON_NULL(notif, "Notification"); diff --git a/lib/graph/port.c b/lib/graph/port.c index aa8ed98f..9c1634dc 100644 --- a/lib/graph/port.c +++ b/lib/graph/port.c @@ -25,7 +25,9 @@ #define BT_LOG_TAG "PORT" #include -#include +#include +#include +#include #include #include #include @@ -90,28 +92,30 @@ end: return port; } -const char *bt_port_get_name(struct bt_port *port) +const char *bt_port_get_name(const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return port->name->str; } -enum bt_port_type bt_port_get_type(struct bt_port *port) +enum bt_port_type bt_port_get_type(const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return port->type; } -struct bt_connection *bt_port_borrow_connection(struct bt_port *port) +const struct bt_connection *bt_port_borrow_connection_const( + const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return port->connection; } -struct bt_component *bt_port_borrow_component(struct bt_port *port) +const struct bt_component *bt_port_borrow_component_const( + const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); - return (struct bt_component *) bt_object_borrow_parent(&port->base); + return bt_port_borrow_component_inline(port); } struct bt_self_component *bt_self_component_port_borrow_component( @@ -157,13 +161,13 @@ end: return BT_SELF_PORT_STATUS_OK; } -bt_bool bt_port_is_connected(struct bt_port *port) +bt_bool bt_port_is_connected(const struct bt_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return port->connection ? BT_TRUE : BT_FALSE; } -void *bt_self_component_port_get_data(struct bt_self_component_port *port) +void *bt_self_component_port_get_data(const struct bt_self_component_port *port) { BT_ASSERT_PRE_NON_NULL(port, "Port"); return ((struct bt_port *) port)->user_data; diff --git a/lib/graph/query-executor.c b/lib/graph/query-executor.c index 4f5a64d8..a24b093d 100644 --- a/lib/graph/query-executor.c +++ b/lib/graph/query-executor.c @@ -23,7 +23,7 @@ #define BT_LOG_TAG "QUERY-EXECUTOR" #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ void bt_query_executor_destroy(struct bt_object *obj) g_free(query_exec); } -struct bt_private_query_executor *bt_private_query_executor_create(void) +struct bt_query_executor *bt_query_executor_create(void) { struct bt_query_executor *query_exec; @@ -65,16 +65,15 @@ end: return (void *) query_exec; } -enum bt_query_executor_status bt_private_query_executor_query( - struct bt_private_query_executor *priv_query_exec, - struct bt_component_class *comp_cls, +enum bt_query_executor_status bt_query_executor_query( + struct bt_query_executor *query_exec, + const struct bt_component_class *comp_cls, const char *object, const struct bt_value *params, const struct bt_value **user_result) { - typedef enum bt_query_status (*method_t)(void *, void *, - const void *, const void *, void *); + typedef enum bt_query_status (*method_t)(void *, const void *, + const void *, const void *, const void *); - struct bt_query_executor *query_exec = (void *) priv_query_exec; enum bt_query_status status; enum bt_query_executor_status exec_status; method_t method = NULL; @@ -127,7 +126,8 @@ enum bt_query_executor_status bt_private_query_executor_query( "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); + status = method((void *) 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_OK || *user_result, @@ -143,18 +143,16 @@ end: return exec_status; } -enum bt_query_executor_status bt_private_query_executor_cancel( - struct bt_private_query_executor *priv_query_exec) +enum bt_query_executor_status bt_query_executor_cancel( + struct bt_query_executor *query_exec) { - 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); return BT_QUERY_EXECUTOR_STATUS_OK; } -bt_bool bt_query_executor_is_canceled(struct bt_query_executor *query_exec) +bt_bool bt_query_executor_is_canceled(const struct bt_query_executor *query_exec) { BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor"); return query_exec->canceled; diff --git a/lib/plugin/plugin-so.c b/lib/plugin/plugin-so.c index 1c3e348a..98e278fe 100644 --- a/lib/plugin/plugin-so.c +++ b/lib/plugin/plugin-so.c @@ -33,10 +33,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -285,37 +285,37 @@ enum bt_plugin_status bt_plugin_so_init( 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; + bt_component_class_source_init_method init; + bt_component_class_source_finalize_method finalize; + bt_component_class_source_query_method query; + bt_component_class_source_accept_output_port_connection_method accept_output_port_connection; + bt_component_class_source_output_port_connected_method output_port_connected; + bt_component_class_source_output_port_disconnected_method output_port_disconnected; + bt_component_class_source_notification_iterator_init_method notif_iter_init; + bt_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; + bt_component_class_filter_init_method init; + bt_component_class_filter_finalize_method finalize; + bt_component_class_filter_query_method query; + bt_component_class_filter_accept_input_port_connection_method accept_input_port_connection; + bt_component_class_filter_accept_output_port_connection_method accept_output_port_connection; + bt_component_class_filter_input_port_connected_method input_port_connected; + bt_component_class_filter_output_port_connected_method output_port_connected; + bt_component_class_filter_input_port_disconnected_method input_port_disconnected; + bt_component_class_filter_output_port_disconnected_method output_port_disconnected; + bt_component_class_filter_notification_iterator_init_method notif_iter_init; + bt_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; + bt_component_class_sink_init_method init; + bt_component_class_sink_finalize_method finalize; + bt_component_class_sink_query_method query; + bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection; + bt_component_class_sink_input_port_connected_method input_port_connected; + bt_component_class_sink_input_port_disconnected_method input_port_disconnected; } sink; } methods; }; @@ -691,10 +691,10 @@ enum bt_plugin_status bt_plugin_so_init( struct comp_class_full_descriptor *cc_full_descr = &g_array_index(comp_class_full_descriptors, struct comp_class_full_descriptor, i); - 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; + struct bt_component_class *comp_class = NULL; + struct bt_component_class_source *src_comp_class = NULL; + struct bt_component_class_filter *flt_comp_class = NULL; + struct bt_component_class_sink *sink_comp_class = NULL; BT_LOGD("Creating and setting properties of plugin's component class: " "plugin-path=\"%s\", plugin-name=\"%s\", " @@ -709,24 +709,24 @@ enum bt_plugin_status bt_plugin_so_init( switch (cc_full_descr->descriptor->type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: - src_comp_class = bt_private_component_class_source_create( + src_comp_class = bt_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_as_private_component_class( + comp_class = bt_component_class_source_as_component_class( src_comp_class); break; case BT_COMPONENT_CLASS_TYPE_FILTER: - flt_comp_class = bt_private_component_class_filter_create( + flt_comp_class = bt_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_as_private_component_class( + comp_class = bt_component_class_filter_as_component_class( flt_comp_class); break; case BT_COMPONENT_CLASS_TYPE_SINK: - sink_comp_class = bt_private_component_class_sink_create( + sink_comp_class = bt_component_class_sink_create( cc_full_descr->descriptor->name, cc_full_descr->descriptor->methods.sink.consume); - comp_class = bt_private_component_class_sink_as_private_component_class( + comp_class = bt_component_class_sink_as_component_class( sink_comp_class); break; default: @@ -756,7 +756,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->description) { - ret = bt_private_component_class_set_description( + ret = bt_component_class_set_description( comp_class, cc_full_descr->description); if (ret) { BT_LOGE_STR("Cannot set component class's description."); @@ -767,7 +767,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->help) { - ret = bt_private_component_class_set_help(comp_class, + ret = bt_component_class_set_help(comp_class, cc_full_descr->help); if (ret) { BT_LOGE_STR("Cannot set component class's help string."); @@ -780,7 +780,7 @@ enum bt_plugin_status bt_plugin_so_init( 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( + ret = bt_component_class_source_set_init_method( src_comp_class, cc_full_descr->methods.source.init); if (ret) { @@ -792,7 +792,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.source.finalize) { - ret = bt_private_component_class_source_set_finalize_method( + ret = bt_component_class_source_set_finalize_method( src_comp_class, cc_full_descr->methods.source.finalize); if (ret) { @@ -804,7 +804,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.source.query) { - ret = bt_private_component_class_source_set_query_method( + ret = bt_component_class_source_set_query_method( src_comp_class, cc_full_descr->methods.source.query); if (ret) { @@ -816,7 +816,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.source.accept_output_port_connection) { - ret = bt_private_component_class_source_set_accept_output_port_connection_method( + ret = bt_component_class_source_set_accept_output_port_connection_method( src_comp_class, cc_full_descr->methods.source.accept_output_port_connection); if (ret) { @@ -828,7 +828,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.source.output_port_connected) { - ret = bt_private_component_class_source_set_output_port_connected_method( + ret = bt_component_class_source_set_output_port_connected_method( src_comp_class, cc_full_descr->methods.source.output_port_connected); if (ret) { @@ -840,7 +840,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.source.output_port_disconnected) { - ret = bt_private_component_class_source_set_output_port_disconnected_method( + ret = bt_component_class_source_set_output_port_disconnected_method( src_comp_class, cc_full_descr->methods.source.output_port_disconnected); if (ret) { @@ -852,7 +852,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.source.notif_iter_init) { - ret = bt_private_component_class_source_set_notification_iterator_init_method( + ret = bt_component_class_source_set_notification_iterator_init_method( src_comp_class, cc_full_descr->methods.source.notif_iter_init); if (ret) { @@ -864,7 +864,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.source.notif_iter_finalize) { - ret = bt_private_component_class_source_set_notification_iterator_finalize_method( + ret = bt_component_class_source_set_notification_iterator_finalize_method( src_comp_class, cc_full_descr->methods.source.notif_iter_finalize); if (ret) { @@ -878,7 +878,7 @@ enum bt_plugin_status bt_plugin_so_init( break; case BT_COMPONENT_CLASS_TYPE_FILTER: if (cc_full_descr->methods.filter.init) { - ret = bt_private_component_class_filter_set_init_method( + ret = bt_component_class_filter_set_init_method( flt_comp_class, cc_full_descr->methods.filter.init); if (ret) { @@ -890,7 +890,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.finalize) { - ret = bt_private_component_class_filter_set_finalize_method( + ret = bt_component_class_filter_set_finalize_method( flt_comp_class, cc_full_descr->methods.filter.finalize); if (ret) { @@ -902,7 +902,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.query) { - ret = bt_private_component_class_filter_set_query_method( + ret = bt_component_class_filter_set_query_method( flt_comp_class, cc_full_descr->methods.filter.query); if (ret) { @@ -914,7 +914,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.accept_input_port_connection) { - ret = bt_private_component_class_filter_set_accept_input_port_connection_method( + ret = bt_component_class_filter_set_accept_input_port_connection_method( flt_comp_class, cc_full_descr->methods.filter.accept_input_port_connection); if (ret) { @@ -926,7 +926,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.accept_output_port_connection) { - ret = bt_private_component_class_filter_set_accept_output_port_connection_method( + ret = bt_component_class_filter_set_accept_output_port_connection_method( flt_comp_class, cc_full_descr->methods.filter.accept_output_port_connection); if (ret) { @@ -938,7 +938,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.input_port_connected) { - ret = bt_private_component_class_filter_set_input_port_connected_method( + ret = bt_component_class_filter_set_input_port_connected_method( flt_comp_class, cc_full_descr->methods.filter.input_port_connected); if (ret) { @@ -950,7 +950,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.output_port_connected) { - ret = bt_private_component_class_filter_set_output_port_connected_method( + ret = bt_component_class_filter_set_output_port_connected_method( flt_comp_class, cc_full_descr->methods.filter.output_port_connected); if (ret) { @@ -962,7 +962,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.input_port_disconnected) { - ret = bt_private_component_class_filter_set_input_port_disconnected_method( + ret = bt_component_class_filter_set_input_port_disconnected_method( flt_comp_class, cc_full_descr->methods.filter.input_port_disconnected); if (ret) { @@ -974,7 +974,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.output_port_disconnected) { - ret = bt_private_component_class_filter_set_output_port_disconnected_method( + ret = bt_component_class_filter_set_output_port_disconnected_method( flt_comp_class, cc_full_descr->methods.filter.output_port_disconnected); if (ret) { @@ -986,7 +986,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.notif_iter_init) { - ret = bt_private_component_class_filter_set_notification_iterator_init_method( + ret = bt_component_class_filter_set_notification_iterator_init_method( flt_comp_class, cc_full_descr->methods.filter.notif_iter_init); if (ret) { @@ -998,7 +998,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.filter.notif_iter_finalize) { - ret = bt_private_component_class_filter_set_notification_iterator_finalize_method( + ret = bt_component_class_filter_set_notification_iterator_finalize_method( flt_comp_class, cc_full_descr->methods.filter.notif_iter_finalize); if (ret) { @@ -1012,7 +1012,7 @@ enum bt_plugin_status bt_plugin_so_init( break; case BT_COMPONENT_CLASS_TYPE_SINK: if (cc_full_descr->methods.sink.init) { - ret = bt_private_component_class_sink_set_init_method( + ret = bt_component_class_sink_set_init_method( sink_comp_class, cc_full_descr->methods.sink.init); if (ret) { @@ -1024,7 +1024,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.sink.finalize) { - ret = bt_private_component_class_sink_set_finalize_method( + ret = bt_component_class_sink_set_finalize_method( sink_comp_class, cc_full_descr->methods.sink.finalize); if (ret) { @@ -1036,7 +1036,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.sink.query) { - ret = bt_private_component_class_sink_set_query_method( + ret = bt_component_class_sink_set_query_method( sink_comp_class, cc_full_descr->methods.sink.query); if (ret) { @@ -1048,7 +1048,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.sink.accept_input_port_connection) { - ret = bt_private_component_class_sink_set_accept_input_port_connection_method( + ret = bt_component_class_sink_set_accept_input_port_connection_method( sink_comp_class, cc_full_descr->methods.sink.accept_input_port_connection); if (ret) { @@ -1060,7 +1060,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.sink.input_port_connected) { - ret = bt_private_component_class_sink_set_input_port_connected_method( + ret = bt_component_class_sink_set_input_port_connected_method( sink_comp_class, cc_full_descr->methods.sink.input_port_connected); if (ret) { @@ -1072,7 +1072,7 @@ enum bt_plugin_status bt_plugin_so_init( } if (cc_full_descr->methods.sink.input_port_disconnected) { - ret = bt_private_component_class_sink_set_input_port_disconnected_method( + ret = bt_component_class_sink_set_input_port_disconnected_method( sink_comp_class, cc_full_descr->methods.sink.input_port_disconnected); if (ret) { diff --git a/lib/plugin/plugin.c b/lib/plugin/plugin.c index 39d6e69f..a0a588a6 100644 --- a/lib/plugin/plugin.c +++ b/lib/plugin/plugin.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -538,28 +538,27 @@ struct bt_component_class *borrow_component_class_by_index( return g_ptr_array_index(comp_classes, index); } - -struct bt_component_class_source * +const struct bt_component_class_source * bt_plugin_borrow_source_component_class_by_index_const_const( const struct bt_plugin *plugin, uint64_t index) { - return (void *) borrow_component_class_by_index(plugin, + return (const void *) borrow_component_class_by_index(plugin, plugin->src_comp_classes, index); } -struct bt_component_class_filter * +const struct bt_component_class_filter * bt_plugin_borrow_filter_component_class_by_index_const( const struct bt_plugin *plugin, uint64_t index) { - return (void *) borrow_component_class_by_index(plugin, + return (const void *) borrow_component_class_by_index(plugin, plugin->flt_comp_classes, index); } -struct bt_component_class_sink * +const struct bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_index_const( const struct bt_plugin *plugin, uint64_t index) { - return (void *) borrow_component_class_by_index(plugin, + return (const void *) borrow_component_class_by_index(plugin, plugin->sink_comp_classes, index); } @@ -591,26 +590,26 @@ struct bt_component_class *borrow_component_class_by_name( return comp_class; } -struct bt_component_class_source * +const struct bt_component_class_source * bt_plugin_borrow_source_component_class_by_name_const( const struct bt_plugin *plugin, const char *name) { - return (void *) borrow_component_class_by_name(plugin, + return (const void *) borrow_component_class_by_name(plugin, plugin->src_comp_classes, name); } -struct bt_component_class_filter * +const struct bt_component_class_filter * bt_plugin_borrow_filter_component_class_by_name_const( const struct bt_plugin *plugin, const char *name) { - return (void *) borrow_component_class_by_name(plugin, + return (const void *) borrow_component_class_by_name(plugin, plugin->flt_comp_classes, name); } -struct bt_component_class_sink * +const struct bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_name_const( const struct bt_plugin *plugin, const char *name) { - return (void *) borrow_component_class_by_name(plugin, + return (const void *) borrow_component_class_by_name(plugin, plugin->sink_comp_classes, name); } diff --git a/lib/trace-ir/event-header-field.c b/lib/trace-ir/event-header-field.c index ae16dd1e..8a5f4693 100644 --- a/lib/trace-ir/event-header-field.c +++ b/lib/trace-ir/event-header-field.c @@ -57,9 +57,8 @@ void bt_event_header_field_release( } struct bt_event_header_field *bt_event_header_field_create( - struct bt_stream_class *priv_stream_class) + struct bt_stream_class *stream_class) { - struct bt_stream_class *stream_class = (void *) priv_stream_class; struct bt_field_wrapper *field_wrapper; BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); diff --git a/lib/trace-ir/packet-context-field.c b/lib/trace-ir/packet-context-field.c index e8c577e8..393e49ad 100644 --- a/lib/trace-ir/packet-context-field.c +++ b/lib/trace-ir/packet-context-field.c @@ -57,9 +57,8 @@ void bt_packet_context_field_release( } struct bt_packet_context_field *bt_packet_context_field_create( - struct bt_stream_class *priv_stream_class) + struct bt_stream_class *stream_class) { - struct bt_stream_class *stream_class = (void *) priv_stream_class; struct bt_field_wrapper *field_wrapper; BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); diff --git a/lib/trace-ir/packet-header-field.c b/lib/trace-ir/packet-header-field.c index cec6936e..6359b882 100644 --- a/lib/trace-ir/packet-header-field.c +++ b/lib/trace-ir/packet-header-field.c @@ -57,10 +57,9 @@ void bt_packet_header_field_release( } struct bt_packet_header_field *bt_packet_header_field_create( - struct bt_trace *priv_trace) + struct bt_trace *trace) { struct bt_field_wrapper *field_wrapper; - struct bt_trace *trace = (void *) priv_trace; BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE(trace->packet_header_fc, diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index b7be219f..2c9efd63 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -145,7 +145,7 @@ struct bt_notif_iter { struct bt_event *event; /* Current event notification (NULL if not created yet) */ - struct bt_private_notification *event_notif; + struct bt_notification *event_notif; /* Database of current dynamic scopes */ struct { @@ -1197,7 +1197,7 @@ enum bt_notif_iter_status set_current_event_notification( struct bt_notif_iter *notit) { enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; - struct bt_private_notification *notif = NULL; + struct bt_notification *notif = NULL; BT_ASSERT(notit->meta.ec); BT_ASSERT(notit->packet); @@ -1207,7 +1207,7 @@ enum bt_notif_iter_status set_current_event_notification( notit->meta.ec->name->str, notit->packet); BT_ASSERT(notit->notif_iter); - notif = bt_private_notification_event_create(notit->notif_iter, + notif = bt_notification_event_create(notit->notif_iter, notit->meta.ec->ir_ec, notit->packet); if (!notif) { BT_LOGE("Cannot create event notification: " @@ -1246,7 +1246,7 @@ enum bt_notif_iter_status after_event_header_state( goto end; } - notit->event = bt_private_notification_event_borrow_event( + notit->event = bt_notification_event_borrow_event( notit->event_notif); BT_ASSERT(notit->event); @@ -2254,7 +2254,7 @@ static void set_event_default_clock_value(struct bt_notif_iter *notit) { struct bt_event *event = - bt_private_notification_event_borrow_event( + bt_notification_event_borrow_event( notit->event_notif); struct bt_stream_class *sc = notit->meta.sc->ir_sc; @@ -2268,10 +2268,10 @@ void set_event_default_clock_value(struct bt_notif_iter *notit) static void notify_new_stream(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + struct bt_notification **notification) { enum bt_notif_iter_status status; - struct bt_private_notification *ret = NULL; + struct bt_notification *ret = NULL; status = set_current_stream(notit); if (status != BT_NOTIF_ITER_STATUS_OK) { @@ -2281,7 +2281,7 @@ void notify_new_stream(struct bt_notif_iter *notit, BT_ASSERT(notit->stream); BT_ASSERT(notit->notif_iter); - ret = bt_private_notification_stream_begin_create(notit->notif_iter, + ret = bt_notification_stream_begin_create(notit->notif_iter, notit->stream); if (!ret) { BT_LOGE("Cannot create stream beginning notification: " @@ -2296,9 +2296,9 @@ end: static void notify_end_of_stream(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + struct bt_notification **notification) { - struct bt_private_notification *ret; + struct bt_notification *ret; if (!notit->stream) { BT_LOGE("Cannot create stream for stream notification: " @@ -2307,7 +2307,7 @@ void notify_end_of_stream(struct bt_notif_iter *notit, } BT_ASSERT(notit->notif_iter); - ret = bt_private_notification_stream_end_create(notit->notif_iter, + ret = bt_notification_stream_end_create(notit->notif_iter, notit->stream); if (!ret) { BT_LOGE("Cannot create stream beginning notification: " @@ -2320,11 +2320,11 @@ void notify_end_of_stream(struct bt_notif_iter *notit, static void notify_new_packet(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + struct bt_notification **notification) { int ret; enum bt_notif_iter_status status; - struct bt_private_notification *notif = NULL; + struct bt_notification *notif = NULL; const struct bt_stream_class *sc; status = set_current_packet(notit); @@ -2399,7 +2399,7 @@ void notify_new_packet(struct bt_notif_iter *notit, } BT_ASSERT(notit->notif_iter); - notif = bt_private_notification_packet_begin_create(notit->notif_iter, + notif = bt_notification_packet_begin_create(notit->notif_iter, notit->packet); if (!notif) { BT_LOGE("Cannot create packet beginning notification: " @@ -2416,9 +2416,9 @@ end: static void notify_end_of_packet(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + struct bt_notification **notification) { - struct bt_private_notification *notif; + struct bt_notification *notif; if (!notit->packet) { return; @@ -2430,7 +2430,7 @@ void notify_end_of_packet(struct bt_notif_iter *notit, } BT_ASSERT(notit->notif_iter); - notif = bt_private_notification_packet_end_create(notit->notif_iter, + notif = bt_notification_packet_end_create(notit->notif_iter, notit->packet); if (!notif) { BT_LOGE("Cannot create packet end notification: " @@ -2542,7 +2542,7 @@ void bt_notif_iter_destroy(struct bt_notif_iter *notit) enum bt_notif_iter_status bt_notif_iter_get_next_notification( struct bt_notif_iter *notit, struct bt_self_notification_iterator *notif_iter, - struct bt_private_notification **notification) + struct bt_notification **notification) { enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; diff --git a/plugins/ctf/common/notif-iter/notif-iter.h b/plugins/ctf/common/notif-iter/notif-iter.h index 7d69bb1f..9fd9b725 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.h +++ b/plugins/ctf/common/notif-iter/notif-iter.h @@ -288,7 +288,7 @@ BT_HIDDEN enum bt_notif_iter_status bt_notif_iter_get_next_notification( struct bt_notif_iter *notit, struct bt_self_notification_iterator *notif_iter, - struct bt_private_notification **notification); + struct bt_notification **notification); /** * Returns the first packet header and context fields. This function diff --git a/plugins/ctf/fs-sink/writer.c b/plugins/ctf/fs-sink/writer.c index b87d78d2..8f2ffd8a 100644 --- a/plugins/ctf/fs-sink/writer.c +++ b/plugins/ctf/fs-sink/writer.c @@ -111,7 +111,7 @@ end: static enum bt_component_status handle_notification( struct writer_component *writer_component, - struct bt_notification *notification) + const struct bt_notification *notification) { enum bt_component_status ret = BT_COMPONENT_STATUS_OK; @@ -201,7 +201,7 @@ BT_HIDDEN void writer_component_port_connected( struct bt_self_component *component, struct bt_private_port *self_port, - struct bt_port *other_port) + const struct bt_port *other_port) { struct bt_private_connection *connection; struct writer_component *writer; @@ -225,7 +225,7 @@ BT_HIDDEN enum bt_component_status writer_run(struct bt_self_component *component) { enum bt_component_status ret; - struct bt_notification *notification = NULL; + const struct bt_notification *notification = NULL; struct bt_notification_iterator *it; struct writer_component *writer_component = bt_self_component_get_user_data(component); diff --git a/plugins/ctf/fs-sink/writer.h b/plugins/ctf/fs-sink/writer.h index 2d40b7e4..ae95f714 100644 --- a/plugins/ctf/fs-sink/writer.h +++ b/plugins/ctf/fs-sink/writer.h @@ -102,7 +102,7 @@ BT_HIDDEN void writer_component_port_connected( struct bt_self_component *component, struct bt_private_port *self_port, - struct bt_port *other_port); + const struct bt_port *other_port); BT_HIDDEN void writer_component_finalize(struct bt_self_component *component); diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index d046b0df..803d424f 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -708,7 +708,7 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file) BT_HIDDEN enum bt_notification_iterator_status ctf_fs_ds_file_next( struct ctf_fs_ds_file *ds_file, - struct bt_private_notification **notif) + struct bt_notification **notif) { enum bt_notif_iter_status notif_iter_status; enum bt_notification_iterator_status status; diff --git a/plugins/ctf/fs-src/data-stream-file.h b/plugins/ctf/fs-src/data-stream-file.h index a0ac6c74..a02501c6 100644 --- a/plugins/ctf/fs-src/data-stream-file.h +++ b/plugins/ctf/fs-src/data-stream-file.h @@ -144,7 +144,7 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream); BT_HIDDEN enum bt_notification_iterator_status ctf_fs_ds_file_next( struct ctf_fs_ds_file *ds_file, - struct bt_private_notification **notif); + struct bt_notification **notif); BT_HIDDEN struct ctf_fs_ds_index *ctf_fs_ds_file_build_index( diff --git a/plugins/ctf/fs-src/fs.c b/plugins/ctf/fs-src/fs.c index a36179fb..3ace7653 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -90,15 +90,15 @@ void ctf_fs_notif_iter_data_destroy( static enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( struct ctf_fs_notif_iter_data *notif_iter_data, - struct bt_notification **notif) + const struct bt_notification **notif) { enum bt_self_notification_iterator_status status; - struct bt_private_notification *priv_notif; + struct bt_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_private_notification_as_notification(priv_notif); + *notif = priv_notif; if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK && bt_notification_get_type(*notif) == @@ -112,7 +112,7 @@ enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( BT_OBJECT_PUT_REF_AND_RESET(*notif); status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif); - *notif = bt_private_notification_as_notification(priv_notif); + *notif = priv_notif; BT_ASSERT(status != BT_SELF_NOTIFICATION_ITERATOR_STATUS_END); goto end; } else { @@ -158,7 +158,7 @@ enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( } status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif); - *notif = bt_private_notification_as_notification(priv_notif); + *notif = priv_notif; /* * If we get a notification, we expect to get a @@ -184,7 +184,7 @@ enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( BT_OBJECT_PUT_REF_AND_RESET(*notif); status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif); - *notif = bt_private_notification_as_notification(priv_notif); + *notif = priv_notif; BT_ASSERT(status != BT_SELF_NOTIFICATION_ITERATOR_STATUS_END); } } @@ -196,7 +196,7 @@ end: BT_HIDDEN enum bt_self_notification_iterator_status ctf_fs_iterator_next( struct bt_self_notification_iterator *iterator, - bt_notification_array notifs, uint64_t capacity, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { enum bt_self_notification_iterator_status status = @@ -1339,7 +1339,7 @@ enum bt_self_component_status ctf_fs_init( BT_HIDDEN enum bt_query_status ctf_fs_query( struct bt_self_component_class_source *comp_class, - struct bt_query_executor *query_exec, + const struct bt_query_executor *query_exec, const char *object, const struct bt_value *params, const struct bt_value **result) { diff --git a/plugins/ctf/fs-src/fs.h b/plugins/ctf/fs-src/fs.h index 4b4dcc01..83cf3a9c 100644 --- a/plugins/ctf/fs-src/fs.h +++ b/plugins/ctf/fs-src/fs.h @@ -162,7 +162,7 @@ void ctf_fs_finalize(struct bt_self_component_source *component); BT_HIDDEN enum bt_query_status ctf_fs_query( struct bt_self_component_class_source *comp_class, - struct bt_query_executor *query_exec, + const struct bt_query_executor *query_exec, const char *object, const struct bt_value *params, const struct bt_value **result); @@ -191,7 +191,7 @@ void ctf_fs_iterator_finalize(struct bt_self_notification_iterator *it); BT_HIDDEN enum bt_self_notification_iterator_status ctf_fs_iterator_next( struct bt_self_notification_iterator *iterator, - bt_notification_array notifs, uint64_t capacity, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count); #endif /* BABELTRACE_PLUGIN_CTF_FS_H */ diff --git a/plugins/ctf/lttng-live/lttng-live-internal.h b/plugins/ctf/lttng-live/lttng-live-internal.h index a698e6be..153db97d 100644 --- a/plugins/ctf/lttng-live/lttng-live-internal.h +++ b/plugins/ctf/lttng-live/lttng-live-internal.h @@ -95,7 +95,7 @@ struct lttng_live_stream_iterator { enum lttng_live_stream_state state; uint64_t current_packet_end_timestamp; - struct bt_notification *packet_end_notif_queue; + const struct bt_notification *packet_end_notif_queue; uint8_t *buf; size_t buflen; @@ -213,8 +213,8 @@ enum bt_component_status lttng_live_component_init(struct bt_self_component *sou struct bt_value *params, void *init_method_data); struct bt_component_class_query_method_return lttng_live_query( - struct bt_component_class *comp_class, - struct bt_query_executor *query_exec, + const struct bt_component_class *comp_class, + const struct bt_query_executor *query_exec, const char *object, struct bt_value *params); void lttng_live_component_finalize(struct bt_self_component *component); @@ -225,7 +225,7 @@ struct bt_notification_iterator_next_method_return lttng_live_iterator_next( enum bt_component_status lttng_live_accept_port_connection( struct bt_self_component *private_component, struct bt_private_port *self_private_port, - struct bt_port *other_port); + const struct bt_port *other_port); enum bt_notification_iterator_status lttng_live_iterator_init( struct bt_self_notification_iterator *it, diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index d8dd3fc7..48789348 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -68,7 +68,7 @@ static const char *print_state(struct lttng_live_stream_iterator *s) static void print_stream_state(struct lttng_live_stream_iterator *stream) { - struct bt_port *port; + const struct bt_port *port; port = bt_port_from_private(stream->port); print_dbg("stream %s state %s last_inact_ts %" PRId64 " cur_inact_ts %" PRId64, @@ -83,7 +83,7 @@ BT_HIDDEN bt_bool lttng_live_is_canceled(struct lttng_live_component *lttng_live) { struct bt_component *component; - struct bt_graph *graph; + const struct bt_graph *graph; bt_bool ret; if (!lttng_live) { @@ -92,7 +92,7 @@ bt_bool lttng_live_is_canceled(struct lttng_live_component *lttng_live) component = bt_component_from_private(lttng_live->private_component); graph = bt_component_get_graph(component); - ret = bt_private_graph_is_canceled(graph); + ret = bt_graph_is_canceled(graph); bt_object_put_ref(graph); bt_object_put_ref(component); return ret; @@ -556,7 +556,7 @@ static enum bt_lttng_live_iterator_status emit_inactivity_notification( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *lttng_live_stream, - struct bt_notification **notification, + const struct bt_notification **notification, uint64_t timestamp) { enum bt_lttng_live_iterator_status ret = @@ -564,7 +564,7 @@ enum bt_lttng_live_iterator_status emit_inactivity_notification( struct lttng_live_trace *trace; const struct bt_clock_class *clock_class = NULL; struct bt_clock_value *clock_value = NULL; - struct bt_notification *notif = NULL; + const struct bt_notification *notif = NULL; int retval; trace = lttng_live_stream->trace; @@ -603,7 +603,7 @@ static enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent_stream( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *lttng_live_stream, - struct bt_notification **notification) + const struct bt_notification **notification) { enum bt_lttng_live_iterator_status ret = BT_LTTNG_LIVE_ITERATOR_STATUS_OK; @@ -636,7 +636,7 @@ static enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_data_stream( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *lttng_live_stream, - struct bt_notification **notification) + const struct bt_notification **notification) { enum bt_lttng_live_iterator_status ret = BT_LTTNG_LIVE_ITERATOR_STATUS_OK; @@ -949,8 +949,8 @@ error: static struct bt_component_class_query_method_return lttng_live_query_list_sessions( - struct bt_component_class *comp_class, - struct bt_query_executor *query_exec, + const struct bt_component_class *comp_class, + const struct bt_query_executor *query_exec, struct bt_value *params) { struct bt_component_class_query_method_return query_ret = { @@ -1005,8 +1005,8 @@ end: BT_HIDDEN struct bt_component_class_query_method_return lttng_live_query( - struct bt_component_class *comp_class, - struct bt_query_executor *query_exec, + const struct bt_component_class *comp_class, + const struct bt_query_executor *query_exec, const char *object, struct bt_value *params) { struct bt_component_class_query_method_return ret = { @@ -1155,13 +1155,13 @@ BT_HIDDEN enum bt_component_status lttng_live_accept_port_connection( struct bt_self_component *private_component, struct bt_private_port *self_private_port, - struct bt_port *other_port) + const struct bt_port *other_port) { struct lttng_live_component *lttng_live = 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); + const struct bt_port *self_port = bt_port_from_private(self_private_port); other_component = bt_port_get_component(other_port); bt_object_put_ref(other_component); /* weak */ diff --git a/plugins/lttng-utils/debug-info.h b/plugins/lttng-utils/debug-info.h index 56f9bc1e..af198164 100644 --- a/plugins/lttng-utils/debug-info.h +++ b/plugins/lttng-utils/debug-info.h @@ -68,7 +68,7 @@ struct debug_info_iterator { GHashTable *trace_map; /* Input iterators associated with this output iterator. */ GPtrArray *input_iterator_group; - struct bt_notification *current_notification; + const struct bt_notification *current_notification; struct bt_notification_iterator *input_iterator; FILE *err; }; diff --git a/plugins/lttng-utils/plugin.c b/plugins/lttng-utils/plugin.c index ae1648a3..c3b24f3f 100644 --- a/plugins/lttng-utils/plugin.c +++ b/plugins/lttng-utils/plugin.c @@ -105,11 +105,11 @@ void debug_info_iterator_destroy(struct bt_self_notification_iterator *it) } static -struct bt_notification *handle_notification(FILE *err, +const struct bt_notification *handle_notification(FILE *err, struct debug_info_iterator *debug_it, - struct bt_notification *notification) + const struct bt_notification *notification) { - struct bt_notification *new_notification = NULL; + const struct bt_notification *new_notification = NULL; switch (bt_notification_get_type(notification)) { case BT_NOTIFICATION_TYPE_PACKET_BEGIN: @@ -227,7 +227,7 @@ struct bt_notification_iterator_next_method_return debug_info_iterator_next( struct bt_self_component *component = NULL; struct debug_info_component *debug_info = NULL; struct bt_notification_iterator *source_it = NULL; - struct bt_notification *notification; + const struct bt_notification *notification; struct bt_notification_iterator_next_method_return ret = { .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, .notification = NULL, diff --git a/plugins/text/dmesg/dmesg.c b/plugins/text/dmesg/dmesg.c index 9a8b5beb..cb2414f0 100644 --- a/plugins/text/dmesg/dmesg.c +++ b/plugins/text/dmesg/dmesg.c @@ -49,7 +49,7 @@ struct dmesg_notif_iter { char *linebuf; size_t linebuf_len; FILE *fp; - struct bt_private_notification *tmp_event_notif; + struct bt_notification *tmp_event_notif; enum { STATE_EMIT_STREAM_BEGINNING, @@ -424,12 +424,12 @@ void dmesg_finalize(struct bt_self_component_source *self_comp) } static -struct bt_private_notification *create_init_event_notif_from_line( +struct bt_notification *create_init_event_notif_from_line( struct dmesg_notif_iter *notif_iter, const char *line, const char **new_start) { struct bt_event *event; - struct bt_private_notification *notif = NULL; + struct bt_notification *notif = NULL; bool has_timestamp = false; unsigned long sec, usec, msec; unsigned int year, mon, mday, hour, min; @@ -499,14 +499,14 @@ skip_ts: goto error; } - notif = bt_private_notification_event_create(notif_iter->pc_notif_iter, + notif = bt_notification_event_create(notif_iter->pc_notif_iter, dmesg_comp->event_class, dmesg_comp->packet); if (!notif) { BT_LOGE_STR("Cannot create event notification."); goto error; } - event = bt_private_notification_event_borrow_event(notif); + event = bt_notification_event_borrow_event(notif); BT_ASSERT(event); if (dmesg_comp->clock_class) { @@ -569,11 +569,11 @@ end: } static -struct bt_private_notification *create_notif_from_line( +struct bt_notification *create_notif_from_line( struct dmesg_notif_iter *dmesg_notif_iter, const char *line) { struct bt_event *event = NULL; - struct bt_private_notification *notif = NULL; + struct bt_notification *notif = NULL; const char *new_start; int ret; @@ -584,7 +584,7 @@ struct bt_private_notification *create_notif_from_line( goto error; } - event = bt_private_notification_event_borrow_event(notif); + event = bt_notification_event_borrow_event(notif); BT_ASSERT(event); ret = fill_event_payload_from_line(new_start, event); if (ret) { @@ -680,7 +680,7 @@ void dmesg_notif_iter_finalize( static enum bt_self_notification_iterator_status dmesg_notif_iter_next_one( struct dmesg_notif_iter *dmesg_notif_iter, - struct bt_private_notification **notif) + struct bt_notification **notif) { ssize_t len; struct dmesg_component *dmesg_comp; @@ -760,13 +760,13 @@ handle_state: switch (dmesg_notif_iter->state) { case STATE_EMIT_STREAM_BEGINNING: BT_ASSERT(dmesg_notif_iter->tmp_event_notif); - *notif = bt_private_notification_stream_begin_create( + *notif = bt_notification_stream_begin_create( dmesg_notif_iter->pc_notif_iter, dmesg_comp->stream); dmesg_notif_iter->state = STATE_EMIT_PACKET_BEGINNING; break; case STATE_EMIT_PACKET_BEGINNING: BT_ASSERT(dmesg_notif_iter->tmp_event_notif); - *notif = bt_private_notification_packet_begin_create( + *notif = bt_notification_packet_begin_create( dmesg_notif_iter->pc_notif_iter, dmesg_comp->packet); dmesg_notif_iter->state = STATE_EMIT_EVENT; break; @@ -776,12 +776,12 @@ handle_state: dmesg_notif_iter->tmp_event_notif = NULL; break; case STATE_EMIT_PACKET_END: - *notif = bt_private_notification_packet_end_create( + *notif = bt_notification_packet_end_create( dmesg_notif_iter->pc_notif_iter, dmesg_comp->packet); dmesg_notif_iter->state = STATE_EMIT_STREAM_END; break; case STATE_EMIT_STREAM_END: - *notif = bt_private_notification_stream_end_create( + *notif = bt_notification_stream_end_create( dmesg_notif_iter->pc_notif_iter, dmesg_comp->stream); dmesg_notif_iter->state = STATE_DONE; break; @@ -802,7 +802,7 @@ end: BT_HIDDEN 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, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { struct dmesg_notif_iter *dmesg_notif_iter = @@ -814,12 +814,11 @@ enum bt_self_notification_iterator_status dmesg_notif_iter_next( while (i < capacity && status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { - struct bt_private_notification *priv_notif = NULL; + struct bt_notification *priv_notif = NULL; status = dmesg_notif_iter_next_one(dmesg_notif_iter, &priv_notif); - notifs[i] = bt_private_notification_as_notification( - priv_notif); + notifs[i] = priv_notif; if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { i++; } diff --git a/plugins/text/dmesg/dmesg.h b/plugins/text/dmesg/dmesg.h index f9fab1bc..be49d421 100644 --- a/plugins/text/dmesg/dmesg.h +++ b/plugins/text/dmesg/dmesg.h @@ -48,7 +48,7 @@ void dmesg_notif_iter_finalize( BT_HIDDEN 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, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count); #endif /* BABELTRACE_PLUGIN_TEXT_DMESG_DMESG_H */ diff --git a/plugins/text/pretty/pretty.c b/plugins/text/pretty/pretty.c index 2d09aa5e..dcf1b5f7 100644 --- a/plugins/text/pretty/pretty.c +++ b/plugins/text/pretty/pretty.c @@ -123,7 +123,7 @@ void pretty_finalize(struct bt_self_component_sink *comp) static enum bt_self_component_status handle_notification( struct pretty_component *pretty, - struct bt_notification *notification) + const struct bt_notification *notification) { enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; @@ -154,7 +154,7 @@ BT_HIDDEN 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) + const struct bt_port_output *other_port) { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; struct pretty_component *pretty; @@ -177,7 +177,7 @@ enum bt_self_component_status pretty_consume( struct bt_self_component_sink *comp) { enum bt_self_component_status ret; - bt_notification_array notifs; + bt_notification_array_const notifs; struct bt_self_component_port_input_notification_iterator *it; struct pretty_component *pretty = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); diff --git a/plugins/text/pretty/pretty.h b/plugins/text/pretty/pretty.h index 7d53088a..b4ad2864 100644 --- a/plugins/text/pretty/pretty.h +++ b/plugins/text/pretty/pretty.h @@ -117,17 +117,17 @@ BT_HIDDEN 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); + const struct bt_port_output *other_port); BT_HIDDEN void pretty_finalize(struct bt_self_component_sink *component); BT_HIDDEN int pretty_print_event(struct pretty_component *pretty, - struct bt_notification *event_notif); + const struct bt_notification *event_notif); BT_HIDDEN int pretty_print_packet(struct pretty_component *pretty, - struct bt_notification *packet_beginning_notif); + const struct bt_notification *packet_beginning_notif); #endif /* BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H */ diff --git a/plugins/text/pretty/print.c b/plugins/text/pretty/print.c index 4dae1882..92de1909 100644 --- a/plugins/text/pretty/print.c +++ b/plugins/text/pretty/print.c @@ -1208,11 +1208,11 @@ end: BT_HIDDEN int pretty_print_event(struct pretty_component *pretty, - struct bt_notification *event_notif) + const struct bt_notification *event_notif) { int ret; const struct bt_event *event = - bt_notification_event_borrow_event(event_notif); + bt_notification_event_borrow_event_const(event_notif); BT_ASSERT(event); pretty->start_line = true; @@ -1382,7 +1382,7 @@ int print_discarded_elements_msg( BT_HIDDEN int pretty_print_packet(struct pretty_component *pretty, - struct bt_notification *packet_beginning_notif) + const struct bt_notification *packet_beginning_notif) { #if 0 const struct bt_packet *packet = bt_notification_packet_begin_borrow_packet_const( diff --git a/plugins/utils/counter/counter.c b/plugins/utils/counter/counter.c index 7b82ae4a..3b24092c 100644 --- a/plugins/utils/counter/counter.c +++ b/plugins/utils/counter/counter.c @@ -179,7 +179,7 @@ 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) + const struct bt_port_output *other_port) { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; struct counter *counter; @@ -209,7 +209,7 @@ enum bt_self_component_status counter_consume( struct counter *counter; enum bt_notification_iterator_status it_ret; uint64_t notif_count; - bt_notification_array notifs; + bt_notification_array_const notifs; counter = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); @@ -235,7 +235,7 @@ enum bt_self_component_status counter_consume( uint64_t i; for (i = 0; i < notif_count; i++) { - struct bt_notification *notif = notifs[i]; + const struct bt_notification *notif = notifs[i]; BT_ASSERT(notif); switch (bt_notification_get_type(notif)) { diff --git a/plugins/utils/counter/counter.h b/plugins/utils/counter/counter.h index 2feeaa50..54da5294 100644 --- a/plugins/utils/counter/counter.h +++ b/plugins/utils/counter/counter.h @@ -57,7 +57,7 @@ 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); + const struct bt_port_output *other_port); BT_HIDDEN enum bt_self_component_status counter_consume(struct bt_self_component_sink *component); diff --git a/plugins/utils/dummy/dummy.c b/plugins/utils/dummy/dummy.c index 2c259156..d6230f72 100644 --- a/plugins/utils/dummy/dummy.c +++ b/plugins/utils/dummy/dummy.c @@ -80,7 +80,7 @@ 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) + const struct bt_port_output *other_port) { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; struct dummy *dummy; @@ -107,7 +107,7 @@ enum bt_self_component_status dummy_consume( struct bt_self_component_sink *component) { enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; - bt_notification_array notifs; + bt_notification_array_const notifs; uint64_t count; struct dummy *dummy; enum bt_notification_iterator_status it_ret; diff --git a/plugins/utils/dummy/dummy.h b/plugins/utils/dummy/dummy.h index 06fcc0e8..d6a9bd12 100644 --- a/plugins/utils/dummy/dummy.h +++ b/plugins/utils/dummy/dummy.h @@ -44,7 +44,7 @@ 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); + const struct bt_port_output *other_port); BT_HIDDEN enum bt_self_component_status dummy_consume( diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index 7c5991ab..a661575f 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -62,7 +62,7 @@ struct muxer_upstream_notif_iter { /* Owned by this, NULL if ended */ struct bt_self_component_port_input_notification_iterator *notif_iter; - /* Contains `struct bt_notification *`, owned by this */ + /* Contains `const struct bt_notification *`, owned by this */ GQueue *notifs; }; @@ -125,7 +125,7 @@ void destroy_muxer_upstream_notif_iter( bt_object_put_ref(muxer_upstream_notif_iter->notif_iter); if (muxer_upstream_notif_iter->notifs) { - struct bt_notification *notif; + const struct bt_notification *notif; while ((notif = g_queue_pop_head( muxer_upstream_notif_iter->notifs))) { @@ -415,7 +415,7 @@ 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_self_component_port_as_port( + const struct bt_port *port = bt_self_component_port_as_port( bt_self_component_port_input_as_self_component_port( self_port)); struct bt_self_component_port_input_notification_iterator *notif_iter = @@ -452,7 +452,7 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next( struct muxer_upstream_notif_iter *muxer_upstream_notif_iter) { enum bt_notification_iterator_status status; - bt_notification_array notifs; + bt_notification_array_const notifs; uint64_t i; uint64_t count; @@ -482,7 +482,7 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next( * from the head first. */ g_queue_push_tail(muxer_upstream_notif_iter->notifs, - notifs[i]); + (void *) notifs[i]); } break; case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: @@ -533,7 +533,7 @@ int muxer_notif_iter_handle_newly_connected_ports( while (true) { GList *node = muxer_notif_iter->newly_connected_self_ports; struct bt_self_component_port_input *self_port; - struct bt_port *port; + const struct bt_port *port; struct bt_self_component_port_input_notification_iterator * upstream_notif_iter = NULL; struct muxer_upstream_notif_iter *muxer_upstream_notif_iter; @@ -600,7 +600,7 @@ end: static int get_notif_ts_ns(struct muxer_comp *muxer_comp, struct muxer_notif_iter *muxer_notif_iter, - struct bt_notification *notif, int64_t last_returned_ts_ns, + const struct bt_notification *notif, int64_t last_returned_ts_ns, int64_t *ts_ns) { const struct bt_clock_class *clock_class = NULL; @@ -621,7 +621,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, switch (bt_notification_get_type(notif)) { case BT_NOTIFICATION_TYPE_EVENT: - event = bt_notification_event_borrow_event(notif); + event = bt_notification_event_borrow_event_const(notif); BT_ASSERT(event); cv_status = bt_event_borrow_default_clock_value_const(event, &clock_value); @@ -629,7 +629,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, case BT_NOTIFICATION_TYPE_INACTIVITY: clock_value = - bt_notification_inactivity_borrow_default_clock_value( + bt_notification_inactivity_borrow_default_clock_value_const( notif); break; default: @@ -871,7 +871,7 @@ muxer_notif_iter_youngest_upstream_notif_iter( *muxer_upstream_notif_iter = NULL; for (i = 0; i < muxer_notif_iter->muxer_upstream_notif_iters->len; i++) { - struct bt_notification *notif; + const struct bt_notification *notif; struct muxer_upstream_notif_iter *cur_muxer_upstream_notif_iter = g_ptr_array_index(muxer_notif_iter->muxer_upstream_notif_iters, i); int64_t notif_ts_ns; @@ -1005,7 +1005,7 @@ static inline enum bt_notification_iterator_status muxer_notif_iter_do_next_one( struct muxer_comp *muxer_comp, struct muxer_notif_iter *muxer_notif_iter, - struct bt_notification **notif) + const struct bt_notification **notif) { enum bt_notification_iterator_status status = BT_NOTIFICATION_ITERATOR_STATUS_OK; @@ -1106,7 +1106,7 @@ static enum bt_notification_iterator_status muxer_notif_iter_do_next( struct muxer_comp *muxer_comp, struct muxer_notif_iter *muxer_notif_iter, - bt_notification_array notifs, uint64_t capacity, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { enum bt_notification_iterator_status status = @@ -1188,7 +1188,7 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp, 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; + const struct bt_port *port; BT_ASSERT(self_port); port = bt_self_component_port_as_port( @@ -1346,7 +1346,7 @@ void muxer_notif_iter_finalize( BT_HIDDEN enum bt_notification_iterator_status muxer_notif_iter_next( struct bt_self_notification_iterator *self_notif_iter, - bt_notification_array notifs, uint64_t capacity, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { enum bt_notification_iterator_status status; @@ -1387,10 +1387,10 @@ BT_HIDDEN 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) + const struct bt_port_output *other_port) { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; - struct bt_port *port = bt_self_component_port_as_port( + const struct bt_port *port = bt_self_component_port_as_port( bt_self_component_port_input_as_self_component_port( self_port)); struct muxer_comp *muxer_comp = @@ -1408,7 +1408,7 @@ enum bt_self_component_status muxer_input_port_connected( "other-port-addr=%p, other-port-name=\"%s\"", self_comp, muxer_comp, self_port, bt_port_get_name(port), other_port, - bt_port_get_name(bt_port_output_as_port(other_port))); + bt_port_get_name(bt_port_output_as_port_const(other_port))); for (i = 0; i < muxer_comp->muxer_notif_iters->len; i++) { struct muxer_notif_iter *muxer_notif_iter = @@ -1468,7 +1468,7 @@ void muxer_input_port_disconnected( bt_self_component_get_data( bt_self_component_filter_as_self_component( self_component)); - struct bt_port *port = + const struct bt_port *port = bt_self_component_port_as_port( bt_self_component_port_input_as_self_component_port( self_port)); diff --git a/plugins/utils/muxer/muxer.h b/plugins/utils/muxer/muxer.h index 27bffa9e..b070d5c5 100644 --- a/plugins/utils/muxer/muxer.h +++ b/plugins/utils/muxer/muxer.h @@ -49,14 +49,14 @@ void muxer_notif_iter_finalize( BT_HIDDEN 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, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count); BT_HIDDEN 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); + const struct bt_port_output *other_port); BT_HIDDEN void muxer_input_port_disconnected( diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index 6b5699a2..0ea086e4 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -174,8 +174,8 @@ error: } static -struct bt_notification *evaluate_event_notification( - struct bt_notification *notification, +const struct bt_notification *evaluate_event_notification( + const struct bt_notification *notification, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *_event_in_range, bool *finished) @@ -190,7 +190,7 @@ struct bt_notification *evaluate_event_notification( const struct bt_stream_class *stream_class = NULL; struct bt_clock_value *clock_value = NULL; bool lazy_update = false; - struct bt_notification *new_notification = NULL; + const struct bt_notification *new_notification = NULL; struct bt_clock_class_priority_map *cc_prio_map; event = bt_notification_event_get_event(notification); @@ -375,8 +375,8 @@ int64_t get_raw_timestamp(const struct bt_packet *writer_packet, } static -struct bt_notification *evaluate_packet_notification( - struct bt_notification *notification, +const struct bt_notification *evaluate_packet_notification( + const struct bt_notification *notification, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *_packet_in_range, bool *finished) @@ -387,7 +387,7 @@ struct bt_notification *evaluate_packet_notification( const struct bt_field *packet_context = NULL, *timestamp_begin = NULL, *timestamp_end = NULL; - struct bt_notification *new_notification = NULL; + const struct bt_notification *new_notification = NULL; enum bt_component_status ret; bool lazy_update = false; @@ -501,8 +501,8 @@ end_no_notif: } static -struct bt_notification *evaluate_stream_notification( - struct bt_notification *notification, +const struct bt_notification *evaluate_stream_notification( + const struct bt_notification *notification, struct trimmer_iterator *trim_it) { const struct bt_stream *stream; @@ -517,13 +517,13 @@ struct bt_notification *evaluate_stream_notification( /* Return true if the notification should be forwarded. */ static enum bt_notification_iterator_status evaluate_notification( - struct bt_notification **notification, + const struct bt_notification **notification, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *in_range) { enum bt_notification_type type; - struct bt_notification *new_notification = NULL; + const struct bt_notification *new_notification = NULL; bool finished = false; *in_range = true; diff --git a/plugins/utils/trimmer/iterator.h b/plugins/utils/trimmer/iterator.h index 0d35e7e5..e6be66a0 100644 --- a/plugins/utils/trimmer/iterator.h +++ b/plugins/utils/trimmer/iterator.h @@ -33,7 +33,7 @@ struct trimmer_iterator { /* Input iterator associated with this output iterator. */ struct bt_notification_iterator *input_iterator; - struct bt_notification *current_notification; + const struct bt_notification *current_notification; FILE *err; /* Map between reader and writer packets. */ GHashTable *packet_map; diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index 2234c04c..91066435 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -47,7 +47,7 @@ static void dummy_iterator_finalize_method( 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, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; @@ -55,7 +55,7 @@ static enum bt_self_notification_iterator_status dummy_iterator_next_method( static enum bt_query_status flt_query_method( struct bt_self_component_class_filter *component_class, - struct bt_query_executor *query_exec, + const struct bt_query_executor *query_exec, const char *object, const struct bt_value *params, const struct bt_value **result) { diff --git a/tests/lib/test_bt_notification_iterator.c b/tests/lib/test_bt_notification_iterator.c index 3b1b1527..82f7dfb7 100644 --- a/tests/lib/test_bt_notification_iterator.c +++ b/tests/lib/test_bt_notification_iterator.c @@ -54,7 +54,7 @@ struct test_event { static bool debug = false; static enum test current_test; static GArray *test_events; -static struct bt_private_graph *graph; +static struct bt_graph *graph; static struct bt_stream_class *src_stream_class; static struct bt_event_class *src_event_class; static struct bt_stream *src_stream1; @@ -347,70 +347,58 @@ enum bt_self_notification_iterator_status src_iter_init( static void src_iter_next_seq_one(struct bt_self_notification_iterator* notif_iter, struct src_iter_user_data *user_data, - struct bt_notification **notif) + const struct bt_notification **notif) { struct bt_packet *event_packet = NULL; switch (user_data->seq[user_data->at]) { case SEQ_STREAM1_BEGIN: - *notif = bt_private_notification_as_notification( - bt_private_notification_stream_begin_create( - notif_iter, src_stream1)); + *notif = bt_notification_stream_begin_create(notif_iter, + src_stream1); break; case SEQ_STREAM2_BEGIN: - *notif = bt_private_notification_as_notification( - bt_private_notification_stream_begin_create( - notif_iter, src_stream2)); + *notif = bt_notification_stream_begin_create(notif_iter, + src_stream2); break; case SEQ_STREAM1_END: - *notif = bt_private_notification_as_notification( - bt_private_notification_stream_end_create( - notif_iter, src_stream1)); + *notif = bt_notification_stream_end_create(notif_iter, + src_stream1); break; case SEQ_STREAM2_END: - *notif = bt_private_notification_as_notification( - bt_private_notification_stream_end_create( - notif_iter, src_stream2)); + *notif = bt_notification_stream_end_create(notif_iter, + src_stream2); break; case SEQ_STREAM1_PACKET1_BEGIN: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_begin_create( - notif_iter, src_stream1_packet1)); + *notif = bt_notification_packet_begin_create(notif_iter, + src_stream1_packet1); break; case SEQ_STREAM1_PACKET2_BEGIN: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_begin_create( - notif_iter, src_stream1_packet2)); + *notif = bt_notification_packet_begin_create(notif_iter, + src_stream1_packet2); break; case SEQ_STREAM2_PACKET1_BEGIN: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_begin_create( - notif_iter, src_stream2_packet1)); + *notif = bt_notification_packet_begin_create(notif_iter, + src_stream2_packet1); break; case SEQ_STREAM2_PACKET2_BEGIN: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_begin_create( - notif_iter, src_stream2_packet2)); + *notif = bt_notification_packet_begin_create(notif_iter, + src_stream2_packet2); break; case SEQ_STREAM1_PACKET1_END: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_end_create( - notif_iter, src_stream1_packet1)); + *notif = bt_notification_packet_end_create(notif_iter, + src_stream1_packet1); break; case SEQ_STREAM1_PACKET2_END: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_end_create( - notif_iter, src_stream1_packet2)); + *notif = bt_notification_packet_end_create(notif_iter, + src_stream1_packet2); break; case SEQ_STREAM2_PACKET1_END: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_end_create( - notif_iter, src_stream2_packet1)); + *notif = bt_notification_packet_end_create(notif_iter, + src_stream2_packet1); break; case SEQ_STREAM2_PACKET2_END: - *notif = bt_private_notification_as_notification( - bt_private_notification_packet_end_create( - notif_iter, src_stream2_packet2)); + *notif = bt_notification_packet_end_create(notif_iter, + src_stream2_packet2); break; case SEQ_EVENT_STREAM1_PACKET1: event_packet = src_stream1_packet1; @@ -429,9 +417,9 @@ void src_iter_next_seq_one(struct bt_self_notification_iterator* notif_iter, } if (event_packet) { - *notif = bt_private_notification_as_notification( - bt_private_notification_event_create( - notif_iter, src_event_class, event_packet)); + *notif = bt_notification_event_create(notif_iter, + src_event_class, + event_packet); } BT_ASSERT(*notif); @@ -442,7 +430,7 @@ static 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, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { enum bt_self_notification_iterator_status status = @@ -471,7 +459,7 @@ end: static enum bt_self_notification_iterator_status src_iter_next( struct bt_self_notification_iterator *self_notif_iter, - bt_notification_array notifs, uint64_t capacity, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { struct src_iter_user_data *user_data = @@ -501,7 +489,7 @@ void src_finalize(struct bt_self_component_source *self_comp) } static -void append_test_events_from_notification(struct bt_notification *notification) +void append_test_events_from_notification(const struct bt_notification *notification) { struct test_event test_event = { 0 }; @@ -511,7 +499,7 @@ void append_test_events_from_notification(struct bt_notification *notification) const struct bt_event *event; test_event.type = TEST_EV_TYPE_NOTIF_EVENT; - event = bt_notification_event_borrow_event(notification); + event = bt_notification_event_borrow_event_const(notification); BT_ASSERT(event); test_event.packet = bt_event_borrow_packet_const(event); BT_ASSERT(test_event.packet); @@ -520,27 +508,25 @@ void append_test_events_from_notification(struct bt_notification *notification) case BT_NOTIFICATION_TYPE_STREAM_BEGIN: test_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN; test_event.stream = - bt_notification_stream_begin_borrow_stream( - notification); + bt_notification_stream_begin_borrow_stream_const(notification); BT_ASSERT(test_event.stream); break; case BT_NOTIFICATION_TYPE_STREAM_END: test_event.type = TEST_EV_TYPE_NOTIF_STREAM_END; test_event.stream = - bt_notification_stream_end_borrow_stream(notification); + bt_notification_stream_end_borrow_stream_const(notification); BT_ASSERT(test_event.stream); break; case BT_NOTIFICATION_TYPE_PACKET_BEGIN: test_event.type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN; test_event.packet = - bt_notification_packet_begin_borrow_packet( - notification); + bt_notification_packet_begin_borrow_packet_const(notification); BT_ASSERT(test_event.packet); break; case BT_NOTIFICATION_TYPE_PACKET_END: test_event.type = TEST_EV_TYPE_NOTIF_PACKET_END; test_event.packet = - bt_notification_packet_end_borrow_packet(notification); + bt_notification_packet_end_borrow_packet_const(notification); BT_ASSERT(test_event.packet); break; default: @@ -562,7 +548,7 @@ enum bt_notification_iterator_status common_consume( void *notif_iter, bool is_output_port_notif_iter) { enum bt_notification_iterator_status ret; - bt_notification_array notifications = NULL; + bt_notification_array_const notifications = NULL; uint64_t count = 0; struct test_event test_event = { 0 }; uint64_t i; @@ -642,7 +628,7 @@ static 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) + const struct bt_port_output *other_port) { struct sink_user_data *user_data = bt_self_component_get_data( @@ -689,54 +675,52 @@ void sink_finalize(struct bt_self_component_sink *self_comp) } static -void create_source_sink(struct bt_private_graph *graph, - struct bt_component_source **source, - struct bt_component_sink **sink) +void create_source_sink(struct bt_graph *graph, + const struct bt_component_source **source, + const struct bt_component_sink **sink) { - struct bt_private_component_class_source *src_comp_class; - struct bt_private_component_class_sink *sink_comp_class; + struct bt_component_class_source *src_comp_class; + struct bt_component_class_sink *sink_comp_class; int ret; /* Create source component */ if (source) { - src_comp_class = bt_private_component_class_source_create("src", + src_comp_class = bt_component_class_source_create("src", src_iter_next); BT_ASSERT(src_comp_class); - ret = bt_private_component_class_source_set_init_method( + ret = bt_component_class_source_set_init_method( src_comp_class, src_init); BT_ASSERT(ret == 0); - ret = bt_private_component_class_source_set_finalize_method( + ret = bt_component_class_source_set_finalize_method( src_comp_class, src_finalize); BT_ASSERT(ret == 0); - ret = bt_private_component_class_source_set_notification_iterator_init_method( + ret = bt_component_class_source_set_notification_iterator_init_method( src_comp_class, src_iter_init); BT_ASSERT(ret == 0); - ret = bt_private_component_class_source_set_notification_iterator_finalize_method( + ret = bt_component_class_source_set_notification_iterator_finalize_method( src_comp_class, src_iter_finalize); BT_ASSERT(ret == 0); - ret = bt_private_graph_add_source_component(graph, - bt_private_component_class_source_as_component_class_source( - src_comp_class), "source", NULL, source); + ret = bt_graph_add_source_component(graph, + 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_private_component_class_sink_create("sink", + sink_comp_class = bt_component_class_sink_create("sink", sink_consume); BT_ASSERT(sink_comp_class); - ret = bt_private_component_class_sink_set_init_method( + ret = bt_component_class_sink_set_init_method( sink_comp_class, sink_init); BT_ASSERT(ret == 0); - ret = bt_private_component_class_sink_set_finalize_method( + ret = bt_component_class_sink_set_finalize_method( sink_comp_class, sink_finalize); - ret = bt_private_component_class_sink_set_input_port_connected_method( + ret = bt_component_class_sink_set_input_port_connected_method( sink_comp_class, sink_port_connected); BT_ASSERT(ret == 0); - ret = bt_private_graph_add_sink_component(graph, - bt_private_component_class_sink_as_component_class_sink( - sink_comp_class), + ret = bt_graph_add_sink_component(graph, + sink_comp_class, "sink", NULL, sink); BT_ASSERT(ret == 0); bt_object_put_ref(sink_comp_class); @@ -747,34 +731,35 @@ static void do_std_test(enum test test, const char *name, const struct test_event *expected_test_events) { - struct bt_component_source *src_comp; - struct bt_component_sink *sink_comp; - struct bt_port_output *upstream_port; - struct bt_port_input *downstream_port; + const struct bt_component_source *src_comp; + const struct bt_component_sink *sink_comp; + const struct bt_port_output *upstream_port; + const struct bt_port_input *downstream_port; enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK; clear_test_events(); current_test = test; diag("test: %s", name); BT_ASSERT(!graph); - graph = bt_private_graph_create(); + graph = bt_graph_create(); BT_ASSERT(graph); create_source_sink(graph, &src_comp, &sink_comp); /* Connect source to sink */ - upstream_port = bt_component_source_borrow_output_port_by_name( - src_comp, "out"); + upstream_port = + bt_component_source_borrow_output_port_by_name_const( + src_comp, "out"); BT_ASSERT(upstream_port); - downstream_port = bt_component_sink_borrow_input_port_by_name( + downstream_port = bt_component_sink_borrow_input_port_by_name_const( sink_comp, "in"); BT_ASSERT(downstream_port); - graph_status = bt_private_graph_connect_ports(graph, upstream_port, + graph_status = bt_graph_connect_ports(graph, upstream_port, downstream_port, NULL); /* Run the graph until the end */ while (graph_status == BT_GRAPH_STATUS_OK || graph_status == BT_GRAPH_STATUS_AGAIN) { - graph_status = bt_private_graph_run(graph); + graph_status = bt_graph_run(graph); } ok(graph_status == BT_GRAPH_STATUS_END, @@ -842,23 +827,23 @@ void test_output_port_notification_iterator(void) { .type = TEST_EV_TYPE_END, }, { .type = TEST_EV_TYPE_SENTINEL, }, }; - struct bt_component_source *src_comp; + const 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_output *upstream_port; + const struct bt_port_output *upstream_port; clear_test_events(); current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR; diag("test: output port notification iterator"); BT_ASSERT(!graph); - graph = bt_private_graph_create(); + graph = bt_graph_create(); BT_ASSERT(graph); create_source_sink(graph, &src_comp, NULL); /* Create notification iterator on source's output port */ - upstream_port = bt_component_source_borrow_output_port_by_name( - src_comp, "out"); + upstream_port = bt_component_source_borrow_output_port_by_name_const(src_comp, + "out"); notif_iter = bt_port_output_notification_iterator_create(graph, upstream_port); ok(notif_iter, "bt_private_output_port_notification_iterator_create() succeeds"); diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index d89d86b2..720dfb06 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -58,78 +58,78 @@ struct event { union { struct { - struct bt_component *comp; - struct bt_port *self_port; - struct bt_port *other_port; + const struct bt_component *comp; + const struct bt_port *self_port; + const struct bt_port *other_port; } src_comp_accept_output_port_connection; struct { - struct bt_component *comp; - struct bt_port *self_port; - struct bt_port *other_port; + const struct bt_component *comp; + const struct bt_port *self_port; + const 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; + const struct bt_component *comp; + const struct bt_port *self_port; + const 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; + const struct bt_component *comp; + const struct bt_port *self_port; + const struct bt_port *other_port; } sink_comp_input_port_connected; struct { - struct bt_component *comp; - struct bt_port *self_port; + const struct bt_component *comp; + const struct bt_port *self_port; } src_comp_output_port_disconnected; struct { - struct bt_component *comp; - struct bt_port *self_port; + const struct bt_component *comp; + const struct bt_port *self_port; } sink_comp_input_port_disconnected; struct { - struct bt_component *comp; - struct bt_port *port; + const struct bt_component *comp; + const struct bt_port *port; } graph_src_output_port_added; struct { - struct bt_component *comp; - struct bt_port *port; + const struct bt_component *comp; + const struct bt_port *port; } graph_sink_input_port_added; struct { - struct bt_component *comp; - struct bt_port *port; + const struct bt_component *comp; + const struct bt_port *port; } graph_src_output_port_removed; struct { - struct bt_component *comp; - struct bt_port *port; + const struct bt_component *comp; + const 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; + const struct bt_component *upstream_comp; + const struct bt_component *downstream_comp; + const struct bt_port *upstream_port; + const struct bt_port *downstream_port; } 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; + const struct bt_component *upstream_comp; + const struct bt_component *downstream_comp; + const struct bt_port *upstream_port; + const struct bt_port *downstream_port; } graph_src_sink_ports_disconnected; } data; }; static GArray *events; -static struct bt_private_component_class_source *src_comp_class; -static struct bt_private_component_class_sink *sink_comp_class; +static struct bt_component_class_source *src_comp_class; +static struct bt_component_class_sink *sink_comp_class; static enum test current_test; static @@ -366,7 +366,7 @@ size_t event_pos(struct event *event) static enum bt_self_notification_iterator_status src_iter_next( struct bt_self_notification_iterator *self_iterator, - bt_notification_array notifs, uint64_t capacity, + bt_notification_array_const notifs, uint64_t capacity, uint64_t *count) { return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; @@ -376,7 +376,7 @@ static 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) + const struct bt_port_input *other_port) { struct event event = { .type = SRC_COMP_ACCEPT_OUTPUT_PORT_CONNECTION, @@ -387,7 +387,7 @@ enum bt_self_component_status src_accept_output_port_connection( .self_port = bt_self_component_port_as_port( bt_self_component_port_output_as_self_component_port( self_comp_port)), - .other_port = bt_port_input_as_port(other_port), + .other_port = bt_port_input_as_port_const(other_port), }, }; @@ -399,7 +399,7 @@ static 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) + const struct bt_port_output *other_port) { struct event event = { .type = SINK_COMP_ACCEPT_INPUT_PORT_CONNECTION, @@ -410,7 +410,7 @@ enum bt_self_component_status sink_accept_input_port_connection( .self_port = bt_self_component_port_as_port( bt_self_component_port_input_as_self_component_port( self_comp_port)), - .other_port = bt_port_output_as_port(other_port), + .other_port = bt_port_output_as_port_const(other_port), }, }; @@ -422,7 +422,7 @@ 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) + const struct bt_port_input *other_port) { int ret; struct event event = { @@ -434,7 +434,7 @@ enum bt_self_component_status src_output_port_connected( .self_port = bt_self_component_port_as_port( bt_self_component_port_output_as_self_component_port( self_comp_port)), - .other_port = bt_port_input_as_port(other_port), + .other_port = bt_port_input_as_port_const(other_port), }, }; @@ -459,7 +459,7 @@ static 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) + const struct bt_port_output *other_port) { struct event event = { .type = SINK_COMP_INPUT_PORT_CONNECTED, @@ -470,7 +470,7 @@ enum bt_self_component_status sink_input_port_connected( .self_port = bt_self_component_port_as_port( bt_self_component_port_input_as_self_component_port( self_comp_port)), - .other_port = bt_port_output_as_port(other_port), + .other_port = bt_port_output_as_port_const(other_port), }, }; @@ -584,14 +584,14 @@ enum bt_self_component_status sink_consume( } static -void graph_src_output_port_added(struct bt_component_source *comp, - struct bt_port_output *port, void *data) +void graph_src_output_port_added(const struct bt_component_source *comp, + const struct bt_port_output *port, void *data) { struct event event = { .type = GRAPH_SRC_OUTPUT_PORT_ADDED, .data.graph_src_output_port_added = { - .comp = bt_component_source_as_component(comp), - .port = bt_port_output_as_port(port), + .comp = bt_component_source_as_component_const(comp), + .port = bt_port_output_as_port_const(port), }, }; @@ -599,14 +599,14 @@ void graph_src_output_port_added(struct bt_component_source *comp, } static -void graph_sink_input_port_added(struct bt_component_sink *comp, - struct bt_port_input *port, void *data) +void graph_sink_input_port_added(const struct bt_component_sink *comp, + const struct bt_port_input *port, void *data) { struct event event = { .type = GRAPH_SINK_INPUT_PORT_ADDED, .data.graph_sink_input_port_added = { - .comp = bt_component_sink_as_component(comp), - .port = bt_port_input_as_port(port), + .comp = bt_component_sink_as_component_const(comp), + .port = bt_port_input_as_port_const(port), }, }; @@ -614,14 +614,14 @@ void graph_sink_input_port_added(struct bt_component_sink *comp, } static -void graph_src_output_port_removed(struct bt_component_source *comp, - struct bt_port_output *port, void *data) +void graph_src_output_port_removed(const struct bt_component_source *comp, + const struct bt_port_output *port, void *data) { struct event event = { .type = GRAPH_SRC_OUTPUT_PORT_REMOVED, .data.graph_src_output_port_removed = { - .comp = bt_component_source_as_component(comp), - .port = bt_port_output_as_port(port), + .comp = bt_component_source_as_component_const(comp), + .port = bt_port_output_as_port_const(port), }, }; @@ -629,14 +629,14 @@ void graph_src_output_port_removed(struct bt_component_source *comp, } static -void graph_sink_input_port_removed(struct bt_component_sink *comp, - struct bt_port_input *port, void *data) +void graph_sink_input_port_removed(const struct bt_component_sink *comp, + const struct bt_port_input *port, void *data) { struct event event = { .type = GRAPH_SINK_INPUT_PORT_REMOVED, .data.graph_sink_input_port_removed = { - .comp = bt_component_sink_as_component(comp), - .port = bt_port_input_as_port(port), + .comp = bt_component_sink_as_component_const(comp), + .port = bt_port_input_as_port_const(port), }, }; @@ -644,22 +644,22 @@ void graph_sink_input_port_removed(struct bt_component_sink *comp, } static -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) +void graph_src_sink_ports_connected(const struct bt_component_source *upstream_comp, + const struct bt_component_sink *downstream_comp, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, void *data) { struct event event = { .type = GRAPH_SRC_SINK_PORTS_CONNECTED, .data.graph_src_sink_ports_connected = { .upstream_comp = - bt_component_source_as_component(upstream_comp), - .downstream_comp = - bt_component_sink_as_component(downstream_comp), - .upstream_port = - bt_port_output_as_port(upstream_port), - .downstream_port = - bt_port_input_as_port(downstream_port), + bt_component_source_as_component_const(upstream_comp), + .downstream_comp = + bt_component_sink_as_component_const(downstream_comp), + .upstream_port = + bt_port_output_as_port_const(upstream_port), + .downstream_port = + bt_port_input_as_port_const(downstream_port), }, }; @@ -667,22 +667,22 @@ void graph_src_sink_ports_connected(struct bt_component_source *upstream_comp, } static -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) +void graph_src_sink_ports_disconnected(const struct bt_component_source *upstream_comp, + const struct bt_component_sink *downstream_comp, + const struct bt_port_output *upstream_port, + const struct bt_port_input *downstream_port, void *data) { struct event event = { .type = GRAPH_SRC_SINK_PORTS_DISCONNECTED, .data.graph_src_sink_ports_disconnected = { .upstream_comp = - bt_component_source_as_component(upstream_comp), - .downstream_comp = - bt_component_sink_as_component(downstream_comp), - .upstream_port = - bt_port_output_as_port(upstream_port), - .downstream_port = - bt_port_input_as_port(downstream_port), + bt_component_source_as_component_const(upstream_comp), + .downstream_comp = + bt_component_sink_as_component_const(downstream_comp), + .upstream_port = + bt_port_output_as_port_const(upstream_port), + .downstream_port = + bt_port_input_as_port_const(downstream_port), }, }; @@ -694,34 +694,34 @@ void init_test(void) { int ret; - src_comp_class = bt_private_component_class_source_create( + src_comp_class = bt_component_class_source_create( "src", src_iter_next); BT_ASSERT(src_comp_class); - ret = bt_private_component_class_source_set_init_method( + ret = bt_component_class_source_set_init_method( src_comp_class, src_init); BT_ASSERT(ret == 0); - ret = bt_private_component_class_source_set_accept_output_port_connection_method( + ret = bt_component_class_source_set_accept_output_port_connection_method( src_comp_class, src_accept_output_port_connection); BT_ASSERT(ret == 0); - ret = bt_private_component_class_source_set_output_port_connected_method( + ret = bt_component_class_source_set_output_port_connected_method( src_comp_class, src_output_port_connected); BT_ASSERT(ret == 0); - ret = bt_private_component_class_source_set_output_port_disconnected_method( + ret = bt_component_class_source_set_output_port_disconnected_method( src_comp_class, src_output_port_disconnected); BT_ASSERT(ret == 0); - sink_comp_class = bt_private_component_class_sink_create("sink", + sink_comp_class = bt_component_class_sink_create("sink", sink_consume); BT_ASSERT(sink_comp_class); - ret = bt_private_component_class_sink_set_init_method(sink_comp_class, + ret = bt_component_class_sink_set_init_method(sink_comp_class, sink_init); BT_ASSERT(ret == 0); - ret = bt_private_component_class_sink_set_accept_input_port_connection_method( + ret = bt_component_class_sink_set_accept_input_port_connection_method( sink_comp_class, sink_accept_input_port_connection); BT_ASSERT(ret == 0); - ret = bt_private_component_class_sink_set_input_port_connected_method( + ret = bt_component_class_sink_set_input_port_connected_method( sink_comp_class, sink_input_port_connected); BT_ASSERT(ret == 0); - ret = bt_private_component_class_sink_set_input_port_disconnected_method( + ret = bt_component_class_sink_set_input_port_disconnected_method( sink_comp_class, sink_input_port_disconnected); BT_ASSERT(ret == 0); events = g_array_new(FALSE, TRUE, sizeof(struct event)); @@ -737,56 +737,52 @@ void fini_test(void) } static -struct bt_component_source *create_src(struct bt_private_graph *graph) +const struct bt_component_source *create_src(struct bt_graph *graph) { - struct bt_component_source *comp; + const struct bt_component_source *comp; int ret; - ret = bt_private_graph_add_source_component(graph, - bt_private_component_class_source_as_component_class_source( - src_comp_class), + ret = bt_graph_add_source_component(graph, src_comp_class, "src-comp", NULL, &comp); BT_ASSERT(ret == 0); return comp; } static -struct bt_component_sink *create_sink(struct bt_private_graph *graph) +const struct bt_component_sink *create_sink(struct bt_graph *graph) { - struct bt_component_sink *comp; + const struct bt_component_sink *comp; int ret; - ret = bt_private_graph_add_sink_component(graph, - bt_private_component_class_sink_as_component_class_sink( - sink_comp_class), + ret = bt_graph_add_sink_component(graph, sink_comp_class, "sink-comp", NULL, &comp); BT_ASSERT(ret == 0); return comp; } static -struct bt_private_graph *create_graph(void) +struct bt_graph *create_graph(void) { - struct bt_private_graph *graph = bt_private_graph_create(); + struct bt_graph *graph = bt_graph_create(); int ret; BT_ASSERT(graph); - ret = bt_private_graph_add_source_component_output_port_added_listener( + ret = bt_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( + ret = bt_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_source_component_output_port_removed_listener( + ret = bt_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_sink_component_input_port_removed_listener( + ret = bt_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_source_sink_component_ports_connected_listener( + ret = bt_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( + ret = bt_graph_add_source_sink_component_ports_disconnected_listener( graph, graph_src_sink_ports_disconnected, NULL, NULL, NULL); BT_ASSERT(ret >= 0); return graph; @@ -804,15 +800,15 @@ static void test_sink_removes_port_in_consume_then_src_removes_disconnected_port(void) { int ret; - 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_output *src_def_port; - struct bt_port_input *sink_def_port; - struct bt_port *gsrc_def_port; - struct bt_port *gsink_def_port; + const struct bt_component_source *src; + const struct bt_component_sink *sink; + const struct bt_component *gsrc; + const struct bt_component *gsink; + struct bt_graph *graph; + const struct bt_port_output *src_def_port; + const struct bt_port_input *sink_def_port; + const struct bt_port *gsrc_def_port; + const struct bt_port *gsink_def_port; struct event event; enum bt_graph_status status; size_t src_accept_port_connection_pos; @@ -832,17 +828,19 @@ void test_sink_removes_port_in_consume_then_src_removes_disconnected_port(void) BT_ASSERT(graph); src = create_src(graph); sink = create_sink(graph); - src_def_port = bt_component_source_borrow_output_port_by_name(src, "out"); + src_def_port = bt_component_source_borrow_output_port_by_name_const(src, + "out"); BT_ASSERT(src_def_port); - sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in"); + sink_def_port = bt_component_sink_borrow_input_port_by_name_const(sink, + "in"); BT_ASSERT(sink_def_port); - status = bt_private_graph_connect_ports(graph, src_def_port, + status = bt_graph_connect_ports(graph, src_def_port, sink_def_port, NULL); BT_ASSERT(status == 0); - gsrc = bt_component_source_as_component(src); - gsink = bt_component_sink_as_component(sink); - gsrc_def_port = bt_port_output_as_port(src_def_port); - gsink_def_port = bt_port_input_as_port(sink_def_port); + gsrc = bt_component_source_as_component_const(src); + gsink = bt_component_sink_as_component_const(sink); + gsrc_def_port = bt_port_output_as_port_const(src_def_port); + gsink_def_port = bt_port_input_as_port_const(sink_def_port); /* We're supposed to have 7 events so far */ ok(events->len == 7, "we have the expected number of events (before consume)"); @@ -912,7 +910,7 @@ void test_sink_removes_port_in_consume_then_src_removes_disconnected_port(void) /* Consume sink once */ clear_events(); - ret = bt_private_graph_consume(graph); + ret = bt_graph_consume(graph); BT_ASSERT(ret == 0); /* We're supposed to have 5 new events */ @@ -984,15 +982,15 @@ static void test_sink_removes_port_in_consume(void) { int ret; - 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_output *src_def_port; - struct bt_port_input *sink_def_port; - struct bt_port *gsrc_def_port; - struct bt_port *gsink_def_port; + const struct bt_component_source *src; + const struct bt_component_sink *sink; + const struct bt_component *gsrc; + const struct bt_component *gsink; + struct bt_graph *graph; + const struct bt_port_output *src_def_port; + const struct bt_port_input *sink_def_port; + const struct bt_port *gsrc_def_port; + const struct bt_port *gsink_def_port; struct event event; enum bt_graph_status status; size_t src_accept_port_connection_pos; @@ -1011,17 +1009,19 @@ void test_sink_removes_port_in_consume(void) BT_ASSERT(graph); src = create_src(graph); sink = create_sink(graph); - src_def_port = bt_component_source_borrow_output_port_by_name(src, "out"); + src_def_port = bt_component_source_borrow_output_port_by_name_const(src, + "out"); BT_ASSERT(src_def_port); - sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in"); + sink_def_port = bt_component_sink_borrow_input_port_by_name_const(sink, + "in"); BT_ASSERT(sink_def_port); - status = bt_private_graph_connect_ports(graph, src_def_port, + status = bt_graph_connect_ports(graph, src_def_port, sink_def_port, NULL); BT_ASSERT(status == 0); - gsrc = bt_component_source_as_component(src); - gsink = bt_component_sink_as_component(sink); - gsrc_def_port = bt_port_output_as_port(src_def_port); - gsink_def_port = bt_port_input_as_port(sink_def_port); + gsrc = bt_component_source_as_component_const(src); + gsink = bt_component_sink_as_component_const(sink); + gsrc_def_port = bt_port_output_as_port_const(src_def_port); + gsink_def_port = bt_port_input_as_port_const(sink_def_port); /* We're supposed to have 7 events so far */ ok(events->len == 7, "we have the expected number of events (before consume)"); @@ -1091,7 +1091,7 @@ void test_sink_removes_port_in_consume(void) /* Consume sink once */ clear_events(); - ret = bt_private_graph_consume(graph); + ret = bt_graph_consume(graph); BT_ASSERT(ret == 0); /* We're supposed to have 4 new events */ @@ -1147,17 +1147,17 @@ void test_sink_removes_port_in_consume(void) static void test_src_adds_port_in_port_connected(void) { - 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_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; + const struct bt_component_source *src; + const struct bt_component_sink *sink; + const struct bt_component *gsrc; + const struct bt_component *gsink; + struct bt_graph *graph; + const struct bt_port_output *src_def_port; + const struct bt_port_output *src_hello_port; + const struct bt_port_input *sink_def_port; + const struct bt_port *gsrc_def_port; + const struct bt_port *gsrc_hello_port; + const struct bt_port *gsink_def_port; struct event event; enum bt_graph_status status; size_t src_accept_port_connection_pos; @@ -1173,21 +1173,23 @@ void test_src_adds_port_in_port_connected(void) BT_ASSERT(graph); src = create_src(graph); sink = create_sink(graph); - src_def_port = bt_component_source_borrow_output_port_by_name(src, "out"); + src_def_port = bt_component_source_borrow_output_port_by_name_const(src, + "out"); BT_ASSERT(src_def_port); - sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in"); + sink_def_port = bt_component_sink_borrow_input_port_by_name_const(sink, + "in"); BT_ASSERT(sink_def_port); - status = bt_private_graph_connect_ports(graph, src_def_port, + status = bt_graph_connect_ports(graph, src_def_port, sink_def_port, NULL); BT_ASSERT(status == 0); - src_hello_port = bt_component_source_borrow_output_port_by_name(src, - "hello"); + src_hello_port = bt_component_source_borrow_output_port_by_name_const(src, + "hello"); BT_ASSERT(src_hello_port); - gsrc = bt_component_source_as_component(src); - gsink = bt_component_sink_as_component(sink); - gsrc_def_port = bt_port_output_as_port(src_def_port); - gsrc_hello_port = bt_port_output_as_port(src_hello_port); - gsink_def_port = bt_port_input_as_port(sink_def_port); + gsrc = bt_component_source_as_component_const(src); + gsink = bt_component_sink_as_component_const(sink); + gsrc_def_port = bt_port_output_as_port_const(src_def_port); + gsrc_hello_port = bt_port_output_as_port_const(src_hello_port); + gsink_def_port = bt_port_input_as_port_const(sink_def_port); /* We're supposed to have 8 events */ ok(events->len == 8, "we have the expected number of events"); @@ -1274,15 +1276,15 @@ void test_src_adds_port_in_port_connected(void) static void test_simple(void) { - 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_output *src_def_port; - struct bt_port_input *sink_def_port; - struct bt_port *gsrc_def_port; - struct bt_port *gsink_def_port; + const struct bt_component_source *src; + const struct bt_component_sink *sink; + const struct bt_component *gsrc; + const struct bt_component *gsink; + struct bt_graph *graph; + const struct bt_port_output *src_def_port; + const struct bt_port_input *sink_def_port; + const struct bt_port *gsrc_def_port; + const struct bt_port *gsink_def_port; struct event event; enum bt_graph_status status; size_t src_accept_port_connection_pos; @@ -1296,17 +1298,19 @@ void test_simple(void) BT_ASSERT(graph); src = create_src(graph); sink = create_sink(graph); - src_def_port = bt_component_source_borrow_output_port_by_name(src, "out"); + src_def_port = bt_component_source_borrow_output_port_by_name_const(src, + "out"); BT_ASSERT(src_def_port); - sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in"); + sink_def_port = bt_component_sink_borrow_input_port_by_name_const(sink, + "in"); BT_ASSERT(sink_def_port); - status = bt_private_graph_connect_ports(graph, src_def_port, + status = bt_graph_connect_ports(graph, src_def_port, sink_def_port, NULL); BT_ASSERT(status == 0); - gsrc = bt_component_source_as_component(src); - gsink = bt_component_sink_as_component(sink); - gsrc_def_port = bt_port_output_as_port(src_def_port); - gsink_def_port = bt_port_input_as_port(sink_def_port); + gsrc = bt_component_source_as_component_const(src); + gsink = bt_component_sink_as_component_const(sink); + gsrc_def_port = bt_port_output_as_port_const(src_def_port); + gsink_def_port = bt_port_input_as_port_const(sink_def_port); /* We're supposed to have 7 events */ ok(events->len == 7, "we have the expected number of events"); @@ -1382,16 +1386,16 @@ void test_simple(void) static void test_src_port_connected_error(void) { - 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_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; + const struct bt_component_source *src; + const struct bt_component_sink *sink; + const struct bt_component *gsrc; + const struct bt_component *gsink; + struct bt_graph *graph; + const struct bt_port_output *src_def_port; + const struct bt_port_input *sink_def_port; + const struct bt_port *gsrc_def_port; + const struct bt_port *gsink_def_port; + const struct bt_connection *conn = NULL; struct event event; enum bt_graph_status status; size_t src_accept_port_connection_pos; @@ -1402,19 +1406,21 @@ void test_src_port_connected_error(void) BT_ASSERT(graph); src = create_src(graph); sink = create_sink(graph); - src_def_port = bt_component_source_borrow_output_port_by_name(src, "out"); + src_def_port = bt_component_source_borrow_output_port_by_name_const(src, + "out"); BT_ASSERT(src_def_port); - sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in"); + sink_def_port = bt_component_sink_borrow_input_port_by_name_const(sink, + "in"); BT_ASSERT(sink_def_port); - status = bt_private_graph_connect_ports(graph, src_def_port, + status = bt_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"); + "bt_graph_connect_ports() returns an error"); ok(!conn, "returned connection is still NULL"); - gsrc = bt_component_source_as_component(src); - gsink = bt_component_sink_as_component(sink); - gsrc_def_port = bt_port_output_as_port(src_def_port); - gsink_def_port = bt_port_input_as_port(sink_def_port); + gsrc = bt_component_source_as_component_const(src); + gsink = bt_component_sink_as_component_const(sink); + gsrc_def_port = bt_port_output_as_port_const(src_def_port); + gsink_def_port = bt_port_input_as_port_const(sink_def_port); /* We're supposed to have 5 events */ ok(events->len == 5, "we have the expected number of events"); @@ -1467,16 +1473,16 @@ void test_src_port_connected_error(void) static void test_sink_port_connected_error(void) { - 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_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; + const struct bt_component_source *src; + const struct bt_component_sink *sink; + const struct bt_component *gsrc; + const struct bt_component *gsink; + struct bt_graph *graph; + const struct bt_port_output *src_def_port; + const struct bt_port_input *sink_def_port; + const struct bt_port *gsrc_def_port; + const struct bt_port *gsink_def_port; + const struct bt_connection *conn = NULL; struct event event; enum bt_graph_status status; size_t src_accept_port_connection_pos; @@ -1490,19 +1496,21 @@ void test_sink_port_connected_error(void) BT_ASSERT(graph); src = create_src(graph); sink = create_sink(graph); - src_def_port = bt_component_source_borrow_output_port_by_name(src, "out"); + src_def_port = bt_component_source_borrow_output_port_by_name_const(src, + "out"); BT_ASSERT(src_def_port); - sink_def_port = bt_component_sink_borrow_input_port_by_name(sink, "in"); + sink_def_port = bt_component_sink_borrow_input_port_by_name_const(sink, + "in"); BT_ASSERT(sink_def_port); - status = bt_private_graph_connect_ports(graph, src_def_port, + status = bt_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"); + "bt_graph_connect_ports() returns an error"); ok(!conn, "returned connection is still NULL"); - gsrc = bt_component_source_as_component(src); - gsink = bt_component_sink_as_component(sink); - gsrc_def_port = bt_port_output_as_port(src_def_port); - gsink_def_port = bt_port_input_as_port(sink_def_port); + gsrc = bt_component_source_as_component_const(src); + gsink = bt_component_sink_as_component_const(sink); + gsrc_def_port = bt_port_output_as_port_const(src_def_port); + gsink_def_port = bt_port_input_as_port_const(sink_def_port); /* We're supposed to have 5 events */ ok(events->len == 7, "we have the expected number of events"); @@ -1575,7 +1583,7 @@ void test_sink_port_connected_error(void) static void test_empty_graph(void) { - struct bt_private_graph *graph; + struct bt_graph *graph; prepare_test(TEST_EMPTY_GRAPH, "empty graph"); graph = create_graph(); diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index 4cc11255..a8ddcb50 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -111,10 +111,10 @@ static void test_sfs(const char *plugin_dir) { const struct bt_plugin_set *plugin_set; const struct bt_plugin *plugin; - 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; + const struct bt_component_class_sink *sink_comp_class; + const struct bt_component_class_source *source_comp_class; + const struct bt_component_class_filter *filter_comp_class; + const struct bt_component_sink *sink_component; char *sfs_path = get_test_plugin_path(plugin_dir, "sfs"); unsigned int major, minor, patch; const char *extra; @@ -122,11 +122,10 @@ static void test_sfs(const char *plugin_dir) const struct bt_value *results; const struct bt_value *object; const struct bt_value *res_params; - struct bt_private_graph *graph; + struct bt_graph *graph; const char *object_str; enum bt_graph_status graph_ret; - struct bt_private_query_executor *query_exec = - bt_private_query_executor_create(); + struct bt_query_executor *query_exec = bt_query_executor_create(); int ret; BT_ASSERT(query_exec); @@ -163,12 +162,11 @@ static void test_sfs(const char *plugin_dir) plugin, "sink"); ok(sink_comp_class, "bt_plugin_borrow_sink_component_class_by_name_const() finds a sink component class"); - ok(strcmp(bt_component_class_get_help( - bt_component_class_sink_as_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, + ok(strcmp(bt_component_class_get_help(bt_component_class_sink_as_component_class_const(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_borrow_filter_component_class_by_name_const( @@ -177,10 +175,10 @@ static void test_sfs(const char *plugin_dir) "bt_plugin_borrow_filter_component_class_by_name_const() finds a filter component class"); params = bt_value_integer_create_init(23); BT_ASSERT(params); - ret = bt_private_query_executor_query(query_exec, - bt_component_class_filter_as_component_class(filter_comp_class), + ret = bt_query_executor_query(query_exec, + bt_component_class_filter_as_component_class_const(filter_comp_class), "get-something", params, &results); - ok(ret == 0 && results, "bt_private_query_executor_query() succeeds"); + ok(ret == 0 && results, "bt_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_const(results, 0); BT_ASSERT(object && bt_value_is_string(object)); @@ -194,12 +192,12 @@ static void test_sfs(const char *plugin_dir) 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(); + graph = bt_graph_create(); BT_ASSERT(graph); - graph_ret = bt_private_graph_add_sink_component(graph, sink_comp_class, "the-sink", - NULL, &sink_component); + graph_ret = bt_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_sink_component() still works after the plugin object is destroyed"); + "bt_graph_add_sink_component() still works after the plugin object is destroyed"); BT_OBJECT_PUT_REF_AND_RESET(sink_component); bt_object_put_ref(graph); -- 2.34.1