projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: lib: usage of output port message iterator
[babeltrace.git]
/
lib
/
graph
/
component-class-sink-colander.c
diff --git
a/lib/graph/component-class-sink-colander.c
b/lib/graph/component-class-sink-colander.c
index 712c473177c632cbe944315ab8a046f92e0c9fae..7f3cfeca6329f94604cc4f9127d4bd6f782c7fe6 100644
(file)
--- a/
lib/graph/component-class-sink-colander.c
+++ b/
lib/graph/component-class-sink-colander.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017
-2018
Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@
-23,33
+23,27
@@
#define BT_LOG_TAG "COLANDER"
#include <babeltrace/lib-logging-internal.h>
#define BT_LOG_TAG "COLANDER"
#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/object.h>
-#include <babeltrace/graph/connection.h>
-#include <babeltrace/graph/private-component-class-sink.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/object-internal.h>
+#include <babeltrace/graph/component-class-sink.h>
#include <babeltrace/graph/self-component-sink.h>
#include <babeltrace/graph/self-component-port.h>
#include <babeltrace/graph/self-component-sink.h>
#include <babeltrace/graph/self-component-port.h>
-#include <babeltrace/graph/self-component-port-input-
notification
-iterator.h>
+#include <babeltrace/graph/self-component-port-input-
message
-iterator.h>
#include <babeltrace/graph/self-component.h>
#include <babeltrace/graph/component-class-sink-colander-internal.h>
#include <babeltrace/graph/self-component.h>
#include <babeltrace/graph/component-class-sink-colander-internal.h>
-#include <babeltrace/assert-internal.h>
#include <glib.h>
static
#include <glib.h>
static
-struct bt_private_component_class_sink *colander_comp_cls;
-
-struct colander_data {
- bt_notification_array notifs;
- uint64_t *count_addr;
- struct bt_self_component_port_input_notification_iterator *notif_iter;
-};
+struct bt_component_class_sink *colander_comp_cls;
static
enum bt_self_component_status colander_init(
struct bt_self_component_sink *self_comp,
static
enum bt_self_component_status colander_init(
struct bt_self_component_sink *self_comp,
- struct bt_value *params, void *init_method_data)
+
const
struct bt_value *params, void *init_method_data)
{
enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
{
enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
- struct
colander
_data *colander_data = NULL;
+ struct
bt_component_class_sink_colander_priv
_data *colander_data = NULL;
struct bt_component_class_sink_colander_data *user_provided_data =
init_method_data;
struct bt_component_class_sink_colander_data *user_provided_data =
init_method_data;
@@
-59,14
+53,15
@@
enum bt_self_component_status colander_init(
goto end;
}
goto end;
}
- colander_data = g_new0(struct colander_data, 1);
+ colander_data = g_new0(
+ struct bt_component_class_sink_colander_priv_data, 1);
if (!colander_data) {
BT_LOGE_STR("Failed to allocate colander data.");
status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
if (!colander_data) {
BT_LOGE_STR("Failed to allocate colander data.");
status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
- colander_data->
notifs = user_provided_data->notif
s;
+ colander_data->
msgs = user_provided_data->msg
s;
colander_data->count_addr = user_provided_data->count_addr;
status = bt_self_component_sink_add_input_port(self_comp, "in",
NULL, NULL);
colander_data->count_addr = user_provided_data->count_addr;
status = bt_self_component_sink_add_input_port(self_comp, "in",
NULL, NULL);
@@
-86,7
+81,7
@@
end:
static
void colander_finalize(struct bt_self_component_sink *self_comp)
{
static
void colander_finalize(struct bt_self_component_sink *self_comp)
{
- struct
colander
_data *colander_data =
+ struct
bt_component_class_sink_colander_priv
_data *colander_data =
bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_comp));
bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_comp));
@@
-94,28
+89,30
@@
void colander_finalize(struct bt_self_component_sink *self_comp)
return;
}
return;
}
- BT_OBJECT_PUT_REF_AND_RESET(colander_data->
notif
_iter);
+ BT_OBJECT_PUT_REF_AND_RESET(colander_data->
msg
_iter);
g_free(colander_data);
}
static
g_free(colander_data);
}
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)
+enum bt_self_component_status colander_graph_is_configured(
+ bt_self_component_sink *self_comp)
{
enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
{
enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
- struct
colander
_data *colander_data =
+ struct
bt_component_class_sink_colander_priv
_data *colander_data =
bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_comp));
bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_comp));
+ struct bt_self_component_port_input *self_port =
+ bt_self_component_sink_borrow_input_port_by_name(self_comp, "in");
+ BT_ASSERT(self_port);
+
BT_ASSERT(colander_data);
BT_ASSERT(colander_data);
- BT_OBJECT_PUT_REF_AND_RESET(colander_data->
notif
_iter);
- colander_data->
notif
_iter =
- bt_self_component_port_input_
notification
_iterator_create(
+ BT_OBJECT_PUT_REF_AND_RESET(colander_data->
msg
_iter);
+ colander_data->
msg
_iter =
+ bt_self_component_port_input_
message
_iterator_create(
self_port);
self_port);
- if (!colander_data->
notif
_iter) {
- BT_LIB_LOGE("Cannot create
notification
iterator on "
+ if (!colander_data->
msg
_iter) {
+ BT_LIB_LOGE("Cannot create
message
iterator on "
"self component input port: %![port-]+p",
self_port);
status = BT_SELF_COMPONENT_STATUS_NOMEM;
"self component input port: %![port-]+p",
self_port);
status = BT_SELF_COMPONENT_STATUS_NOMEM;
@@
-131,39
+128,36
@@
enum bt_self_component_status colander_consume(
struct bt_self_component_sink *self_comp)
{
enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct bt_self_component_sink *self_comp)
{
enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
- enum bt_
notification_iterator_status notif
_iter_status;
- struct
colander
_data *colander_data =
+ enum bt_
message_iterator_status msg
_iter_status;
+ struct
bt_component_class_sink_colander_priv
_data *colander_data =
bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_comp));
bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_comp));
- bt_
notification_array notif
s;
+ bt_
message_array_const msg
s;
BT_ASSERT(colander_data);
BT_ASSERT(colander_data);
- if (!colander_data->
notif
_iter) {
+ if (!colander_data->
msg
_iter) {
BT_LIB_LOGW("Trying to consume without an "
BT_LIB_LOGW("Trying to consume without an "
- "upstream
notification
iterator: %![comp-]+c",
+ "upstream
message
iterator: %![comp-]+c",
self_comp);
goto end;
}
self_comp);
goto end;
}
-
notif
_iter_status =
- bt_self_component_port_input_
notification
_iterator_next(
- colander_data->
notif_iter, ¬if
s,
+
msg
_iter_status =
+ bt_self_component_port_input_
message
_iterator_next(
+ colander_data->
msg_iter, &msg
s,
colander_data->count_addr);
colander_data->count_addr);
- switch (notif_iter_status) {
- case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED:
- status = BT_SELF_COMPONENT_STATUS_OK;
- goto end;
- case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
+ switch (msg_iter_status) {
+ case BT_MESSAGE_ITERATOR_STATUS_AGAIN:
status = BT_SELF_COMPONENT_STATUS_AGAIN;
goto end;
status = BT_SELF_COMPONENT_STATUS_AGAIN;
goto end;
- case BT_
NOTIFICATION
_ITERATOR_STATUS_END:
+ case BT_
MESSAGE
_ITERATOR_STATUS_END:
status = BT_SELF_COMPONENT_STATUS_END;
goto end;
status = BT_SELF_COMPONENT_STATUS_END;
goto end;
- case BT_
NOTIFICATION
_ITERATOR_STATUS_OK:
- /* Move
notification
s to user (count already set) */
- memcpy(colander_data->
notifs, notif
s,
- sizeof(*
notif
s) * *colander_data->count_addr);
+ case BT_
MESSAGE
_ITERATOR_STATUS_OK:
+ /* Move
message
s to user (count already set) */
+ memcpy(colander_data->
msgs, msg
s,
+ sizeof(*
msg
s) * *colander_data->count_addr);
break;
default:
status = BT_SELF_COMPONENT_STATUS_ERROR;
break;
default:
status = BT_SELF_COMPONENT_STATUS_ERROR;
@@
-180,24
+174,23
@@
struct bt_component_class_sink *bt_component_class_sink_colander_get(void)
goto end;
}
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;
}
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);
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);
colander_comp_cls, colander_finalize);
- (void) bt_
private_component_class_sink_set_input_port_connect
ed_method(
- colander_comp_cls, colander_
input_port_connect
ed);
+ (void) bt_
component_class_sink_set_graph_is_configur
ed_method(
+ colander_comp_cls, colander_
graph_is_configur
ed);
end:
end:
- return bt_object_get_ref(
- bt_private_component_class_sink_as_component_class_sink(
- colander_comp_cls));
+ bt_object_get_ref(colander_comp_cls);
+ return (void *) colander_comp_cls;
}
__attribute__((destructor)) static
}
__attribute__((destructor)) static
This page took
0.02837 seconds
and
4
git commands to generate.