#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-event.h>
#include <babeltrace/graph/notification-packet.h>
+#include <babeltrace/graph/notification-stream.h>
#include <plugins-common.h>
#include <stdio.h>
#include <stdbool.h>
#include "writer.h"
#include <assert.h>
+gboolean empty_trace_map(gpointer key, gpointer value, gpointer user_data)
+{
+ struct fs_writer *fs_writer = value;
+ struct writer_component *writer_component = user_data;
+
+ fs_writer->trace_static = 1;
+ writer_close(writer_component, fs_writer);
+
+ return TRUE;
+}
+
static
void destroy_writer_component_data(struct writer_component *writer_component)
{
bt_put(writer_component->input_iterator);
- g_hash_table_destroy(writer_component->stream_map);
- g_hash_table_destroy(writer_component->stream_class_map);
+
+ g_hash_table_foreach_remove(writer_component->trace_map,
+ empty_trace_map, writer_component);
g_hash_table_destroy(writer_component->trace_map);
+
g_string_free(writer_component->base_path, true);
g_string_free(writer_component->trace_name_base, true);
}
}
static
-void unref_stream_class(struct bt_ctf_stream_class *writer_stream_class)
-{
- bt_put(writer_stream_class);
-}
-
-static
-void unref_stream(struct bt_ctf_stream_class *writer_stream)
-{
- bt_put(writer_stream);
-}
-
-static
-void unref_trace(struct bt_ctf_writer *writer)
+void free_fs_writer(struct fs_writer *fs_writer)
{
- bt_put(writer);
+ bt_put(fs_writer->writer);
+ g_free(fs_writer);
}
static
writer_component->err = stderr;
writer_component->trace_id = 0;
writer_component->trace_name_base = g_string_new("trace");
- writer_component->processed_first_event = false;
if (!writer_component->trace_name_base) {
g_free(writer_component);
writer_component = NULL;
* Reader to writer corresponding structures.
*/
writer_component->trace_map = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, NULL, (GDestroyNotify) unref_trace);
- writer_component->stream_class_map = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, NULL, (GDestroyNotify) unref_stream_class);
- writer_component->stream_map = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, NULL, (GDestroyNotify) unref_stream);
+ g_direct_equal, NULL, (GDestroyNotify) free_fs_writer);
end:
return writer_component;
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
- ret = BT_COMPONENT_STATUS_OK;
ret = writer_output_event(writer_component, event);
bt_put(event);
if (ret != BT_COMPONENT_STATUS_OK) {
}
break;
}
+ case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
+ {
+ struct bt_ctf_stream *stream =
+ bt_notification_stream_begin_get_stream(notification);
+
+ if (!stream) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ ret = writer_stream_begin(writer_component, stream);
+ bt_put(stream);
+ break;
+ }
case BT_NOTIFICATION_TYPE_STREAM_END:
+ {
+ struct bt_ctf_stream *stream =
+ bt_notification_stream_end_get_stream(notification);
+
+ if (!stream) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ ret = writer_stream_end(writer_component, stream);
+ bt_put(stream);
break;
+ }
default:
puts("Unhandled notification type");
}
struct bt_private_connection *connection;
struct writer_component *writer;
static const enum bt_notification_type notif_types[] = {
+ BT_NOTIFICATION_TYPE_EVENT,
BT_NOTIFICATION_TYPE_PACKET_BEGIN,
BT_NOTIFICATION_TYPE_PACKET_END,
+ BT_NOTIFICATION_TYPE_STREAM_BEGIN,
+ BT_NOTIFICATION_TYPE_STREAM_END,
BT_NOTIFICATION_TYPE_SENTINEL,
};