/*
- * babeltrace.c
- *
- * Babeltrace Trace Converter
- *
* Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
*
* Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
};
/* Application's processing graph (weak) */
-static struct bt_graph *the_graph;
+static struct bt_private_graph *the_graph;
static struct bt_query_executor *the_query_executor;
static bool canceled = false;
GPtrArray *loaded_plugins;
#ifdef __MINGW32__
+
#include <windows.h>
static
BOOL WINAPI signal_handler(DWORD signal) {
if (the_graph) {
- bt_graph_cancel(the_graph);
+ bt_private_graph_cancel(the_graph);
}
canceled = true;
BT_LOGE("Failed to set the ctrl+c handler.");
}
}
+
#else /* __MINGW32__ */
+
static
void signal_handler(int signum)
{
}
if (the_graph) {
- bt_graph_cancel(the_graph);
+ bt_private_graph_cancel(the_graph);
}
if (the_query_executor) {
sigaction(SIGINT, &new_action, NULL);
}
}
+
#endif /* __MINGW32__ */
static
GHashTable *components;
/* Owned by this */
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
/* Weak */
struct bt_config *cfg;
ret = 0;
ctx->connect_ports = false;
- graph_status = bt_graph_add_component(ctx->graph,
+ graph_status = bt_private_graph_add_component(ctx->graph,
trimmer_class, trimmer_name,
bt_value_borrow_from_private(trimmer_params),
&trimmer);
}
/* We have a winner! */
- status = bt_graph_connect_ports(ctx->graph,
+ status = bt_private_graph_connect_ports(ctx->graph,
upstream_port, downstream_port, NULL);
BT_OBJECT_PUT_REF_AND_RESET(downstream_port);
switch (status) {
}
}
- ctx->graph = bt_graph_create();
+ ctx->graph = bt_private_graph_create();
if (!ctx->graph) {
goto error;
}
the_graph = ctx->graph;
- ret = bt_graph_add_port_added_listener(ctx->graph,
+ ret = bt_private_graph_add_port_added_listener(ctx->graph,
graph_port_added_listener, NULL, ctx);
if (ret < 0) {
BT_LOGE_STR("Cannot add \"port added\" listener to graph.");
goto error;
}
- ret = bt_graph_add_port_removed_listener(ctx->graph,
+ ret = bt_private_graph_add_port_removed_listener(ctx->graph,
graph_port_removed_listener, NULL, ctx);
if (ret < 0) {
BT_LOGE_STR("Cannot add \"port removed\" listener to graph.");
goto error;
}
- ret = bt_graph_add_ports_connected_listener(ctx->graph,
+ ret = bt_private_graph_add_ports_connected_listener(ctx->graph,
graph_ports_connected_listener, NULL, ctx);
if (ret < 0) {
BT_LOGE_STR("Cannot add \"ports connected\" listener to graph.");
goto error;
}
- ret = bt_graph_add_ports_disconnected_listener(ctx->graph,
+ ret = bt_private_graph_add_ports_disconnected_listener(ctx->graph,
graph_ports_disconnected_listener, NULL, ctx);
if (ret < 0) {
BT_LOGE_STR("Cannot add \"ports disconnected\" listener to graph.");
goto error;
}
- ret = bt_graph_add_component(ctx->graph, comp_cls,
+ ret = bt_private_graph_add_component(ctx->graph, comp_cls,
cfg_comp->instance_name->str,
bt_value_borrow_from_private(cfg_comp->params), &comp);
if (ret) {
/* Run the graph */
while (true) {
- enum bt_graph_status graph_status = bt_graph_run(ctx.graph);
+ enum bt_graph_status graph_status = bt_private_graph_run(ctx.graph);
/*
* Reset console in case something messed with console
printf("%s", bt_common_color_reset());
fflush(stdout);
fprintf(stderr, "%s", bt_common_color_reset());
- BT_LOGV("bt_graph_run() returned: status=%s",
+ BT_LOGV("bt_private_graph_run() returned: status=%s",
bt_graph_status_str(graph_status));
switch (graph_status) {
BT_LOGI_STR("Graph was canceled by user.");
goto error;
case BT_GRAPH_STATUS_AGAIN:
- if (bt_graph_is_canceled(ctx.graph)) {
+ if (bt_graph_is_canceled(
+ bt_graph_borrow_from_private(ctx.graph))) {
BT_LOGI_STR("Graph was canceled by user.");
goto error;
}
cfg->cmd_data.run.retry_duration_us);
if (usleep(cfg->cmd_data.run.retry_duration_us)) {
- if (bt_graph_is_canceled(ctx.graph)) {
+ if (bt_graph_is_canceled(
+ bt_graph_borrow_from_private(ctx.graph))) {
BT_LOGI_STR("Graph was canceled by user.");
goto error;
}
babeltrace/ctf-ir/trace.h \
babeltrace/ctf-ir/utils.h
-
# Trace IR API
babeltracetraceirincludedir = "$(includedir)/babeltrace/trace-ir"
babeltracetraceirinclude_HEADERS = \
babeltrace/graph/private-connection-notification-iterator.h \
babeltrace/graph/private-connection-private-notification-iterator.h \
babeltrace/graph/private-connection.h \
+ babeltrace/graph/private-graph.h \
babeltrace/graph/private-notification-event.h \
babeltrace/graph/private-notification-inactivity.h \
babeltrace/graph/private-notification-packet.h \
#include <babeltrace/graph/private-connection-notification-iterator.h>
#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/graph/private-connection.h>
+#include <babeltrace/graph/private-graph.h>
#include <babeltrace/graph/private-notification-event.h>
#include <babeltrace/graph/private-notification-inactivity.h>
#include <babeltrace/graph/private-notification-packet.h>
*/
#include <babeltrace/graph/graph.h>
+#include <babeltrace/graph/connection-internal.h>
#include <babeltrace/graph/component-status.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/babeltrace-internal.h>
#define BABELTRACE_GRAPH_GRAPH_H
/*
- * BabelTrace - Babeltrace Graph Interface
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
extern "C" {
#endif
-struct bt_port;
-struct bt_connection;
-struct bt_component;
-struct bt_component_class;
-struct bt_value;
+struct bt_graph;
enum bt_graph_status {
BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111,
BT_GRAPH_STATUS_NOMEM = BT_COMPONENT_STATUS_NOMEM,
};
-typedef void (*bt_graph_port_added_listener)(struct bt_port *port,
- void *data);
-typedef void (*bt_graph_port_removed_listener)(struct bt_component *component,
- struct bt_port *port, void *data);
-typedef void (*bt_graph_ports_connected_listener)(struct bt_port *upstream_port,
- struct bt_port *downstream_port, void *data);
-typedef void (*bt_graph_ports_disconnected_listener)(
- struct bt_component *upstream_component,
- struct bt_component *downstream_component,
- struct bt_port *upstream_port, struct bt_port *downstream_port,
- void *data);
-typedef void (* bt_graph_listener_removed)(void *data);
-
-extern struct bt_graph *bt_graph_create(void);
-
-extern enum bt_graph_status bt_graph_add_component(
- struct bt_graph *graph,
- struct bt_component_class *component_class,
- const char *name, struct bt_value *params,
- struct bt_component **component);
-
-extern enum bt_graph_status bt_graph_add_component_with_init_method_data(
- struct bt_graph *graph,
- struct bt_component_class *component_class,
- const char *name, struct bt_value *params,
- void *init_method_data,
- struct bt_component **component);
-
-/**
- * Creates a connection between two components using the two ports specified
- * and adds the connection and components (if not already added) to the graph.
- */
-extern enum bt_graph_status bt_graph_connect_ports(struct bt_graph *graph,
- struct bt_port *upstream, struct bt_port *downstream,
- struct bt_connection **connection);
-
-/**
- * Run graph to completion or until a single sink is left and "AGAIN" is received.
- *
- * Runs "bt_component_sink_consume()" on all sinks in round-robin until they all
- * indicate that the end is reached or that an error occured.
- */
-extern enum bt_graph_status bt_graph_run(struct bt_graph *graph);
-
-/**
- * Runs "bt_component_sink_consume()" on the graph's sinks. Each invokation will
- * invoke "bt_component_sink_consume()" on the next sink, in round-robin, until
- * they all indicated that the end is reached.
- */
-extern enum bt_graph_status bt_graph_consume(struct bt_graph *graph);
-
-extern int bt_graph_add_port_added_listener(struct bt_graph *graph,
- bt_graph_port_added_listener listener,
- bt_graph_listener_removed listener_removed, void *data);
-
-extern int bt_graph_add_port_removed_listener(struct bt_graph *graph,
- bt_graph_port_removed_listener listener,
- bt_graph_listener_removed listener_removed, void *data);
-
-extern int bt_graph_add_ports_connected_listener(struct bt_graph *graph,
- bt_graph_ports_connected_listener listener,
- bt_graph_listener_removed listener_removed, void *data);
-
-extern int bt_graph_add_ports_disconnected_listener(struct bt_graph *graph,
- bt_graph_ports_disconnected_listener listener,
- bt_graph_listener_removed listener_removed, void *data);
-
-extern enum bt_graph_status bt_graph_cancel(struct bt_graph *graph);
extern bt_bool bt_graph_is_canceled(struct bt_graph *graph);
#ifdef __cplusplus
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PRIVATE_GRAPH_H
+#define BABELTRACE_GRAPH_PRIVATE_GRAPH_H
+
+/*
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* For bt_bool */
+#include <babeltrace/types.h>
+
+/* For enum bt_graph_status */
+#include <babeltrace/graph/graph.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_graph;
+struct bt_private_graph;
+struct bt_port;
+struct bt_connection;
+struct bt_component;
+struct bt_component_class;
+struct bt_value;
+
+typedef void (*bt_private_graph_port_added_listener)(struct bt_port *port,
+ void *data);
+
+typedef void (*bt_private_graph_port_removed_listener)(
+ struct bt_component *component,
+ struct bt_port *port, void *data);
+
+typedef void (*bt_private_graph_ports_connected_listener)(
+ struct bt_port *upstream_port,
+ struct bt_port *downstream_port, void *data);
+
+typedef void (*bt_private_graph_ports_disconnected_listener)(
+ struct bt_component *upstream_component,
+ struct bt_component *downstream_component,
+ struct bt_port *upstream_port, struct bt_port *downstream_port,
+ void *data);
+
+typedef void (* bt_private_graph_listener_removed)(void *data);
+
+extern struct bt_graph *bt_graph_borrow_from_private(
+ struct bt_private_graph *priv_graph);
+
+extern struct bt_private_graph *bt_private_graph_create(void);
+
+extern enum bt_graph_status bt_private_graph_add_component(
+ struct bt_private_graph *graph,
+ struct bt_component_class *component_class,
+ const char *name, struct bt_value *params,
+ struct bt_component **component);
+
+extern enum bt_graph_status
+bt_private_graph_add_component_with_init_method_data(
+ struct bt_private_graph *graph,
+ struct bt_component_class *component_class,
+ const char *name, struct bt_value *params,
+ void *init_method_data, struct bt_component **component);
+
+/**
+ * Creates a connection between two components using the two ports specified
+ * and adds the connection and components (if not already added) to the graph.
+ */
+extern enum bt_graph_status bt_private_graph_connect_ports(
+ struct bt_private_graph *graph,
+ struct bt_port *upstream, struct bt_port *downstream,
+ struct bt_connection **connection);
+
+/**
+ * Run graph to completion or until a single sink is left and "AGAIN" is received.
+ *
+ * Runs "bt_component_sink_consume()" on all sinks in round-robin until they all
+ * indicate that the end is reached or that an error occured.
+ */
+extern enum bt_graph_status bt_private_graph_run(
+ struct bt_private_graph *graph);
+
+/**
+ * Runs "bt_component_sink_consume()" on the graph's sinks. Each invokation will
+ * invoke "bt_component_sink_consume()" on the next sink, in round-robin, until
+ * they all indicated that the end is reached.
+ */
+extern enum bt_graph_status bt_private_graph_consume(
+ struct bt_private_graph *graph);
+
+extern int bt_private_graph_add_port_added_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_port_added_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data);
+
+extern int bt_private_graph_add_port_removed_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_port_removed_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data);
+
+extern int bt_private_graph_add_ports_connected_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_ports_connected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data);
+
+extern int bt_private_graph_add_ports_disconnected_listener(
+ struct bt_private_graph *graph,
+ bt_private_graph_ports_disconnected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data);
+
+extern enum bt_graph_status bt_private_graph_cancel(
+ struct bt_private_graph *graph);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PRIVATE_GRAPH_H */
/*
- * graph.c
- *
- * Babeltrace Plugin Component Graph
- *
* Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017 Philippe Proulx <pproulx@efficios.com>
*
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/graph/component-internal.h>
+#include <babeltrace/graph/private-graph.h>
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/connection-internal.h>
#include <babeltrace/graph/component-sink-internal.h>
struct bt_graph_listener {
void *func;
- bt_graph_listener_removed removed;
+ bt_private_graph_listener_removed removed;
void *data;
};
* Cancel the graph to disallow some operations, like creating
* notification iterators and adding ports to components.
*/
- (void) bt_graph_cancel(graph);
+ (void) bt_private_graph_cancel((void *) graph);
/* Call all remove listeners */
call_remove_listeners(graph->listeners.port_added);
bt_notification_unlink_graph(notif);
}
-struct bt_graph *bt_graph_create(void)
+struct bt_private_graph *bt_private_graph_create(void)
{
struct bt_graph *graph;
int ret;
BT_LOGD("Created graph object: addr=%p", graph);
end:
- return graph;
+ return (void *) graph;
error:
BT_OBJECT_PUT_REF_AND_RESET(graph);
goto end;
}
-enum bt_graph_status bt_graph_connect_ports(struct bt_graph *graph,
+enum bt_graph_status bt_private_graph_connect_ports(
+ struct bt_private_graph *priv_graph,
struct bt_port *upstream_port, struct bt_port *downstream_port,
struct bt_connection **user_connection)
{
+ struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status status = BT_GRAPH_STATUS_OK;
struct bt_connection *connection = NULL;
struct bt_graph *upstream_graph = NULL;
return status;
}
-enum bt_graph_status bt_graph_consume(struct bt_graph *graph)
+enum bt_graph_status bt_private_graph_consume(
+ struct bt_private_graph *priv_graph)
{
+ struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status status;
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
return status;
}
-enum bt_graph_status bt_graph_run(struct bt_graph *graph)
+enum bt_graph_status bt_private_graph_run(
+ struct bt_private_graph *priv_graph)
{
+ struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status status = BT_GRAPH_STATUS_OK;
if (!graph) {
return listeners->len - 1;
}
-int bt_graph_add_port_added_listener(
- struct bt_graph *graph,
- bt_graph_port_added_listener listener,
- bt_graph_listener_removed listener_removed, void *data)
+int bt_private_graph_add_port_added_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_port_added_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data)
{
+ struct bt_graph *graph = (void *) priv_graph;
int ret;
if (!graph) {
return ret;
}
-int bt_graph_add_port_removed_listener(
- struct bt_graph *graph,
- bt_graph_port_removed_listener listener,
- bt_graph_listener_removed listener_removed, void *data)
+int bt_private_graph_add_port_removed_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_port_removed_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data)
{
+ struct bt_graph *graph = (void *) priv_graph;
int ret;
if (!graph) {
return ret;
}
-int bt_graph_add_ports_connected_listener(
- struct bt_graph *graph,
- bt_graph_ports_connected_listener listener,
- bt_graph_listener_removed listener_removed, void *data)
+int bt_private_graph_add_ports_connected_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_ports_connected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data)
{
+ struct bt_graph *graph = (void *) priv_graph;
int ret;
if (!graph) {
return ret;
}
-int bt_graph_add_ports_disconnected_listener(
- struct bt_graph *graph,
- bt_graph_ports_disconnected_listener listener,
- bt_graph_listener_removed listener_removed, void *data)
+int bt_private_graph_add_ports_disconnected_listener(
+ struct bt_private_graph *priv_graph,
+ bt_private_graph_ports_disconnected_listener listener,
+ bt_private_graph_listener_removed listener_removed, void *data)
{
+ struct bt_graph *graph = (void *) priv_graph;
int ret;
if (!graph) {
struct bt_graph_listener listener =
g_array_index(graph->listeners.port_added,
struct bt_graph_listener, i);
- bt_graph_port_added_listener func = listener.func;
+ bt_private_graph_port_added_listener func = listener.func;
BT_ASSERT(func);
func(port, listener.data);
struct bt_graph_listener listener =
g_array_index(graph->listeners.port_removed,
struct bt_graph_listener, i);
- bt_graph_port_removed_listener func = listener.func;
+ bt_private_graph_port_removed_listener func = listener.func;
BT_ASSERT(func);
func(comp, port, listener.data);
struct bt_graph_listener listener =
g_array_index(graph->listeners.ports_connected,
struct bt_graph_listener, i);
- bt_graph_ports_connected_listener func = listener.func;
+ bt_private_graph_ports_connected_listener func = listener.func;
BT_ASSERT(func);
func(upstream_port, downstream_port, listener.data);
struct bt_graph_listener listener =
g_array_index(graph->listeners.ports_disconnected,
struct bt_graph_listener, i);
- bt_graph_ports_disconnected_listener func = listener.func;
+ bt_private_graph_ports_disconnected_listener func = listener.func;
BT_ASSERT(func);
func(upstream_comp, downstream_comp, upstream_port,
}
}
-enum bt_graph_status bt_graph_cancel(struct bt_graph *graph)
+enum bt_graph_status bt_private_graph_cancel(
+ struct bt_private_graph *priv_graph)
{
+ struct bt_graph *graph = (void *) priv_graph;
enum bt_graph_status ret = BT_GRAPH_STATUS_OK;
if (!graph) {
g_ptr_array_remove(graph->connections, connection);
}
-enum bt_graph_status bt_graph_add_component_with_init_method_data(
- struct bt_graph *graph,
+enum bt_graph_status bt_private_graph_add_component_with_init_method_data(
+ struct bt_private_graph *priv_graph,
struct bt_component_class *component_class,
const char *name, 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_component_status comp_status;
struct bt_component *component = NULL;
return graph_status;
}
-enum bt_graph_status bt_graph_add_component(
- struct bt_graph *graph,
+enum bt_graph_status bt_private_graph_add_component(
+ struct bt_private_graph *graph,
struct bt_component_class *component_class,
const char *name, struct bt_value *params,
struct bt_component **component)
{
- return bt_graph_add_component_with_init_method_data(graph,
+ return bt_private_graph_add_component_with_init_method_data(graph,
component_class, name, params, NULL, component);
}
*/
g_ptr_array_add(graph->notifications, notif);
}
+
+struct bt_graph *bt_graph_borrow_from_private(
+ struct bt_private_graph *priv_graph)
+{
+ return (void *) priv_graph;
+}
#include <babeltrace/graph/notification-stream.h>
#include <babeltrace/graph/notification-stream-internal.h>
#include <babeltrace/graph/port.h>
+#include <babeltrace/graph/private-graph.h>
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
colander_data.notifs = (void *) iterator->base.notifs->pdata;
colander_data.count_addr = &iterator->count;
- graph_status = bt_graph_add_component_with_init_method_data(
- iterator->graph, colander_comp_cls, colander_comp_name,
+ graph_status = bt_private_graph_add_component_with_init_method_data(
+ (void *) iterator->graph, colander_comp_cls, colander_comp_name,
NULL, &colander_data, &iterator->colander);
if (graph_status != BT_GRAPH_STATUS_OK) {
BT_LOGW("Cannot add colander sink component to graph: "
colander_in_port = bt_component_sink_get_input_port_by_index(
iterator->colander, 0);
BT_ASSERT(colander_in_port);
- graph_status = bt_graph_connect_ports(iterator->graph,
+ graph_status = bt_private_graph_connect_ports((void *) iterator->graph,
output_port, colander_in_port, NULL);
if (graph_status != BT_GRAPH_STATUS_OK) {
BT_LOGW("Cannot add colander sink component to graph: "
component = bt_component_from_private(lttng_live->private_component);
graph = bt_component_get_graph(component);
- ret = bt_graph_is_canceled(graph);
+ ret = bt_private_graph_is_canceled(graph);
bt_object_put_ref(graph);
bt_object_put_ref(component);
return ret;
static bool debug = false;
static enum test current_test;
static GArray *test_events;
-static struct bt_graph *graph;
+static struct bt_private_graph *graph;
static struct bt_private_connection_private_notification_iterator *cur_notif_iter;
static struct bt_private_stream_class *src_stream_class;
static struct bt_private_event_class *src_event_class;
}
static
-void create_source_sink(struct bt_graph *graph, struct bt_component **source,
+void create_source_sink(struct bt_private_graph *graph, struct bt_component **source,
struct bt_component **sink)
{
struct bt_component_class *src_comp_class;
ret = bt_component_class_source_set_notification_iterator_finalize_method(
src_comp_class, src_iter_finalize);
BT_ASSERT(ret == 0);
- ret = bt_graph_add_component(graph, src_comp_class, "source",
+ ret = bt_private_graph_add_component(graph, src_comp_class, "source",
NULL, source);
BT_ASSERT(ret == 0);
bt_object_put_ref(src_comp_class);
ret = bt_component_class_set_port_connected_method(
sink_comp_class, sink_port_connected);
BT_ASSERT(ret == 0);
- ret = bt_graph_add_component(graph, sink_comp_class, "sink",
+ ret = bt_private_graph_add_component(graph, sink_comp_class, "sink",
NULL, sink);
BT_ASSERT(ret == 0);
bt_object_put_ref(sink_comp_class);
current_test = test;
diag("test: %s", name);
BT_ASSERT(!graph);
- graph = bt_graph_create();
+ graph = bt_private_graph_create();
BT_ASSERT(graph);
create_source_sink(graph, &src_comp, &sink_comp);
BT_ASSERT(upstream_port);
downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in");
BT_ASSERT(downstream_port);
- graph_status = bt_graph_connect_ports(graph, upstream_port,
+ graph_status = bt_private_graph_connect_ports(graph, upstream_port,
downstream_port, NULL);
bt_object_put_ref(upstream_port);
bt_object_put_ref(downstream_port);
/* Run the graph until the end */
while (graph_status == BT_GRAPH_STATUS_OK ||
graph_status == BT_GRAPH_STATUS_AGAIN) {
- graph_status = bt_graph_run(graph);
+ graph_status = bt_private_graph_run(graph);
}
ok(graph_status == BT_GRAPH_STATUS_END, "graph finishes without any error");
current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR;
diag("test: output port notification iterator");
BT_ASSERT(!graph);
- graph = bt_graph_create();
+ graph = bt_private_graph_create();
BT_ASSERT(graph);
create_source_sink(graph, &src_comp, NULL);
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/component-source.h>
#include <babeltrace/graph/component-sink.h>
+#include <babeltrace/graph/private-graph.h>
#include <babeltrace/graph/graph.h>
#include <babeltrace/graph/connection.h>
#include <babeltrace/graph/port.h>
}
static
-struct bt_component *create_src(struct bt_graph *graph)
+struct bt_component *create_src(struct bt_private_graph *graph)
{
struct bt_component *comp;
int ret;
- ret = bt_graph_add_component(graph, src_comp_class, "src-comp", NULL,
+ ret = bt_private_graph_add_component(graph, src_comp_class, "src-comp", NULL,
&comp);
BT_ASSERT(ret == 0);
return comp;
}
static
-struct bt_component *create_sink(struct bt_graph *graph)
+struct bt_component *create_sink(struct bt_private_graph *graph)
{
struct bt_component *comp;
int ret;
- ret = bt_graph_add_component(graph, sink_comp_class, "sink-comp",
+ ret = bt_private_graph_add_component(graph, sink_comp_class, "sink-comp",
NULL, &comp);
BT_ASSERT(ret == 0);
return comp;
}
static
-struct bt_graph *create_graph(void)
+struct bt_private_graph *create_graph(void)
{
- struct bt_graph *graph = bt_graph_create();
+ struct bt_private_graph *graph = bt_private_graph_create();
int ret;
BT_ASSERT(graph);
- ret = bt_graph_add_port_added_listener(graph, graph_port_added, NULL,
+ ret = bt_private_graph_add_port_added_listener(graph, graph_port_added, NULL,
NULL);
BT_ASSERT(ret >= 0);
- ret = bt_graph_add_port_removed_listener(graph, graph_port_removed,
+ ret = bt_private_graph_add_port_removed_listener(graph, graph_port_removed,
NULL, NULL);
BT_ASSERT(ret >= 0);
- ret = bt_graph_add_ports_connected_listener(graph,
+ ret = bt_private_graph_add_ports_connected_listener(graph,
graph_ports_connected, NULL, NULL);
BT_ASSERT(ret >= 0);
- ret = bt_graph_add_ports_disconnected_listener(graph,
+ ret = bt_private_graph_add_ports_disconnected_listener(graph,
graph_ports_disconnected, NULL, NULL);
BT_ASSERT(ret >= 0);
return graph;
int ret;
struct bt_component *src;
struct bt_component *sink;
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
struct bt_port *src_def_port;
struct bt_port *sink_def_port;
struct bt_connection *conn;
BT_ASSERT(src_def_port);
sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_graph_connect_ports(graph, src_def_port, sink_def_port,
+ status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
&conn);
BT_ASSERT(status == 0);
BT_ASSERT(conn);
/* Consume sink once */
clear_events();
- ret = bt_graph_consume(graph);
+ ret = bt_private_graph_consume(graph);
BT_ASSERT(ret == 0);
/* We're supposed to have 5 new events */
int ret;
struct bt_component *src;
struct bt_component *sink;
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
struct bt_port *src_def_port;
struct bt_port *sink_def_port;
struct bt_connection *conn;
BT_ASSERT(src_def_port);
sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_graph_connect_ports(graph, src_def_port, sink_def_port,
+ status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
&conn);
BT_ASSERT(status == 0);
/* Consume sink once */
clear_events();
- ret = bt_graph_consume(graph);
+ ret = bt_private_graph_consume(graph);
BT_ASSERT(ret == 0);
/* We're supposed to have 4 new events */
{
struct bt_component *src;
struct bt_component *sink;
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
struct bt_port *src_def_port;
struct bt_port *sink_def_port;
struct bt_port *src_hello_port;
BT_ASSERT(src_def_port);
sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_graph_connect_ports(graph, src_def_port, sink_def_port,
+ status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
&conn);
BT_ASSERT(status == 0);
src_hello_port = bt_component_source_get_output_port_by_name(src,
{
struct bt_component *src;
struct bt_component *sink;
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
struct bt_port *src_def_port;
struct bt_port *sink_def_port;
struct bt_connection *conn;
BT_ASSERT(src_def_port);
sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_graph_connect_ports(graph, src_def_port, sink_def_port,
+ status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
&conn);
BT_ASSERT(status == 0);
{
struct bt_component *src;
struct bt_component *sink;
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
struct bt_port *src_def_port;
struct bt_port *sink_def_port;
struct bt_connection *conn = NULL;
BT_ASSERT(src_def_port);
sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_graph_connect_ports(graph, src_def_port, sink_def_port,
+ status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
&conn);
ok(status != BT_GRAPH_STATUS_OK,
- "bt_graph_connect_ports() returns an error");
+ "bt_private_graph_connect_ports() returns an error");
ok(!conn, "returned connection is NULL");
/* We're supposed to have 5 events */
{
struct bt_component *src;
struct bt_component *sink;
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
struct bt_port *src_def_port;
struct bt_port *sink_def_port;
struct bt_connection *conn = NULL;
BT_ASSERT(src_def_port);
sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in");
BT_ASSERT(sink_def_port);
- status = bt_graph_connect_ports(graph, src_def_port, sink_def_port,
+ status = bt_private_graph_connect_ports(graph, src_def_port, sink_def_port,
&conn);
ok(status != BT_GRAPH_STATUS_OK,
- "bt_graph_connect_ports() returns an error");
+ "bt_private_graph_connect_ports() returns an error");
ok(!conn, "returned connection is NULL");
/* We're supposed to have 5 events */
static
void test_empty_graph(void)
{
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
prepare_test(TEST_EMPTY_GRAPH, "empty graph");
graph = create_graph();
/*
- * test_plugin.c
- *
- * Trace IR Reference Count test
- *
* Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
*
* This program is free software; you can redistribute it and/or modify
#include <babeltrace/values.h>
#include <babeltrace/private-values.h>
#include <babeltrace/graph/component.h>
+#include <babeltrace/graph/private-graph.h>
#include <babeltrace/graph/graph.h>
#include <babeltrace/graph/query-executor.h>
#include <stdlib.h>
struct bt_value *results;
struct bt_value *object;
struct bt_value *res_params;
- struct bt_graph *graph;
+ struct bt_private_graph *graph;
const char *object_str;
enum bt_graph_status graph_ret;
struct bt_query_executor *query_exec = bt_query_executor_create();
diag("> putting the plugin object here");
BT_OBJECT_PUT_REF_AND_RESET(plugin);
- graph = bt_graph_create();
+ graph = bt_private_graph_create();
BT_ASSERT(graph);
- graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink",
+ graph_ret = bt_private_graph_add_component(graph, sink_comp_class, "the-sink",
NULL, &sink_component);
ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
- "bt_graph_add_component() still works after the plugin object is destroyed");
+ "bt_private_graph_add_component() still works after the plugin object is destroyed");
BT_OBJECT_PUT_REF_AND_RESET(sink_component);
BT_OBJECT_PUT_REF_AND_RESET(source_comp_class);
bt_object_put_ref(graph);
- graph = bt_graph_create();
+ graph = bt_private_graph_create();
BT_ASSERT(graph);
- graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink",
+ graph_ret = bt_private_graph_add_component(graph, sink_comp_class, "the-sink",
NULL, &sink_component);
ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
- "bt_graph_add_component() still works after the source component class object is destroyed");
+ "bt_private_graph_add_component() still works after the source component class object is destroyed");
BT_OBJECT_PUT_REF_AND_RESET(sink_component);
BT_OBJECT_PUT_REF_AND_RESET(filter_comp_class);
bt_object_put_ref(graph);
- graph = bt_graph_create();
+ graph = bt_private_graph_create();
BT_ASSERT(graph);
- graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink",
+ graph_ret = bt_private_graph_add_component(graph, sink_comp_class, "the-sink",
NULL, &sink_component);
ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
- "bt_graph_add_component() still works after the filter component class object is destroyed");
+ "bt_private_graph_add_component() still works after the filter component class object is destroyed");
BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
BT_OBJECT_PUT_REF_AND_RESET(sink_component);