The filter component class implementation and the shared object plugin macros are in the same file, distill.c
:
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <babeltrace2/babeltrace.h>
struct distill {
};
static
const bt_value *params,
void *initialize_method_data)
{
struct distill *distill = malloc(sizeof(*distill));
distill->names_value =
distill);
"in", NULL, &distill->in_port);
"out", NULL, NULL);
}
static
{
free(distill);
}
struct distill_message_iterator {
struct distill *distill;
};
static
distill_message_iterator_initialize(
{
struct distill_message_iterator *distill_iter =
malloc(sizeof(*distill_iter));
distill_iter->distill = distill;
distill->in_port, &distill_iter->message_iterator);
}
static
void distill_message_iterator_finalize(
{
struct distill_message_iterator *distill_iter =
free(distill_iter);
}
static
bool message_passes(struct distill_message_iterator *distill_iter,
{
bool passes = true;
goto end;
}
distill_iter->distill->names_value); i++) {
distill_iter->distill->names_value, i));
if (strcmp(name, discard_name) == 0) {
passes = false;
goto end;
}
}
end:
return passes;
}
static
uint64_t *count)
{
struct distill_message_iterator *distill_iter =
uint64_t upstream_message_count;
consume_upstream_messages:
&upstream_messages, &upstream_message_count);
switch (next_status) {
goto end;
goto end;
goto end;
goto end;
default:
break;
}
uint64_t i = 0;
for (uint64_t upstream_i = 0; upstream_i < upstream_message_count;
upstream_i++) {
const bt_message *upstream_message = upstream_messages[upstream_i];
if (message_passes(distill_iter, upstream_message)) {
messages[i] = upstream_message;
i++;
continue;
}
}
if (i == 0) {
goto consume_upstream_messages;
}
*count = i;
end:
return status;
}
theone, distill_message_iterator_initialize);
distill_message_iterator_finalize);
bt_message const ** bt_message_array_const
Array of constant messages.
Definition types.h:182
bt_component_class_initialize_method_status
Status codes for bt_component_class_source_initialize_method, bt_component_class_filter_initialize_me...
Definition component-class-dev.h:891
@ BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK
Success.
Definition component-class-dev.h:896
bt_message_iterator_class_initialize_method_status
Status codes for bt_message_iterator_class_initialize_method.
Definition message-iterator-class.h:661
bt_message_iterator_class_next_method_status
Status codes for bt_message_iterator_class_next_method.
Definition message-iterator-class.h:718
@ BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK
Success.
Definition message-iterator-class.h:666
@ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR
Out of memory.
Definition message-iterator-class.h:741
@ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK
Success.
Definition message-iterator-class.h:723
@ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END
End of iteration.
Definition message-iterator-class.h:729
@ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR
User error.
Definition message-iterator-class.h:747
@ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN
Try again.
Definition message-iterator-class.h:735
void bt_message_iterator_put_ref(const bt_message_iterator *message_iterator)
Decrements the reference count of the message iterator message_iterator.
bt_message_iterator_next_status bt_message_iterator_next(bt_message_iterator *message_iterator, bt_message_array_const *messages, uint64_t *count)
Returns the next messages of the message iterator message_iterator into the *messages array of size *...
bt_message_iterator_create_from_message_iterator_status bt_message_iterator_create_from_message_iterator(bt_self_message_iterator *self_message_iterator, bt_self_component_port_input *port, bt_message_iterator **message_iterator)
Creates a message iterator on the input port port from another message iterator self_message_iterator...
bt_message_iterator_next_status
Status code for bt_message_iterator_next().
Definition message-iterator.h:371
struct bt_message_iterator bt_message_iterator
Message iterator.
Definition types.h:59
@ BT_MESSAGE_ITERATOR_NEXT_STATUS_END
End of iteration.
Definition message-iterator.h:382
@ BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR
Out of memory.
Definition message-iterator.h:394
@ BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR
Other error.
Definition message-iterator.h:400
@ BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN
Try again.
Definition message-iterator.h:388
struct bt_message bt_message
Message.
Definition types.h:58
const bt_event * bt_message_event_borrow_event_const(const bt_message *message)
Borrows the event of the event message message (const version).
bt_message_type bt_message_get_type(const bt_message *message)
Returns the type enumerator of the message message.
void bt_message_put_ref(const bt_message *message)
Decrements the reference count of the message message.
@ BT_MESSAGE_TYPE_EVENT
Event message.
Definition message.h:993
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(_name, _method)
Alias of BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID() with the _plugin_id parameter set...
Definition plugin-dev.h:1696
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD(_name, _method)
Alias of BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID() with the _plugin_id parameter s...
Definition plugin-dev.h:1787
#define BT_PLUGIN_MODULE()
Defines a plugin module.
Definition plugin-dev.h:335
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(_name, _method)
Alias of BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD_WITH_ID() with the _...
Definition plugin-dev.h:1880
#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(_name, _method)
Alias of BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_WITH_ID() with the...
Definition plugin-dev.h:1926
#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _message_iterator_class_next_method)
Alias of BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID() with the _plugin_id parameter set to auto,...
Definition plugin-dev.h:839
#define BT_PLUGIN(_name)
Alias of BT_PLUGIN_WITH_ID() with the _id parameter set to auto.
Definition plugin-dev.h:423
struct bt_self_component_port_output bt_self_component_port_output
Self component output port.
Definition types.h:81
struct bt_self_component_port_input bt_self_component_port_input
Self component input port.
Definition types.h:79
bt_self_component_add_port_status bt_self_component_filter_add_input_port(bt_self_component_filter *self_component, const char *name, void *user_data, bt_self_component_port_input **self_component_port)
Adds an input port named name and having the user data user_data to the filter component self_compone...
struct bt_self_component_filter_configuration bt_self_component_filter_configuration
Self filter component configuration.
Definition types.h:77
bt_self_component_add_port_status bt_self_component_filter_add_output_port(bt_self_component_filter *self_component, const char *name, void *user_data, bt_self_component_port_output **self_component_port)
Adds an output port named name and having the user data user_data to the filter component self_compon...
void * bt_self_component_get_data(const bt_self_component *self_component)
Returns the user data of the component self_component.
static bt_self_component * bt_self_component_filter_as_self_component(bt_self_component_filter *self_component)
Upcasts the self filter component self_component to the common bt_self_component type.
Definition self-component.h:834
struct bt_self_component_filter bt_self_component_filter
Self filter component.
Definition types.h:76
void bt_self_component_set_data(bt_self_component *self_component, void *user_data)
Sets the user data of the component self_component to data.
struct bt_self_message_iterator_configuration bt_self_message_iterator_configuration
Self message iterator configuration.
Definition types.h:87
bt_self_component * bt_self_message_iterator_borrow_component(bt_self_message_iterator *self_message_iterator)
Borrows the component which provides the message iterator self_message_iterator.
void * bt_self_message_iterator_get_data(const bt_self_message_iterator *self_message_iterator)
Returns the user data of the message iterator self_message_iterator.
struct bt_self_message_iterator bt_self_message_iterator
Self message iterator.
Definition types.h:86
void bt_self_message_iterator_set_data(bt_self_message_iterator *self_message_iterator, void *user_data)
Sets the user data of the message iterator self_message_iterator to data.
const char * bt_event_class_get_name(const bt_event_class *event_class)
Returns the name of the event class event_class.
struct bt_event_class bt_event_class
Event class.
Definition types.h:37
const bt_event_class * bt_event_borrow_class_const(const bt_event *event)
Borrows the class of the event event (const version).
struct bt_event bt_event
Event.
Definition types.h:36
struct bt_value bt_value
Value.
Definition types.h:93
void bt_value_get_ref(const bt_value *value)
Increments the reference count of the value value.
void bt_value_put_ref(const bt_value *value)
Decrements the reference count of the value value.
const char * bt_value_string_get(const bt_value *value)
Returns the raw value of the string value value.
const bt_value * bt_value_map_borrow_entry_value_const(const bt_value *value, const char *key)
Borrows the value of the entry with the key key in the map value value (const version).
const bt_value * bt_value_array_borrow_element_by_index_const(const bt_value *value, uint64_t index)
Borrows the element at index index from the array value value (const version).
uint64_t bt_value_array_get_length(const bt_value *value)
Returns the length of the array value value.