2 * SPDX-License-Identifier: MIT
4 * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
7 #ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H
8 #define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H
12 #include <babeltrace2/babeltrace.h>
14 #include "cpp-common/bt2c/logging.hpp"
17 struct fs_sink_ctf_trace;
21 explicit fs_sink_trace(const bt2c::Logger& parentLogger) :
22 logger {parentLogger, "PLUGIN/SINK.CTF.FS/TRACE"}
27 fs_sink_comp *fs_sink = nullptr;
30 fs_sink_ctf_trace *trace = nullptr;
33 * Weak reference: this object does not own it, and `trace`
34 * above does not own its trace IR trace and trace class either.
35 * Instead, we add a "trace destruction" listener (in
36 * create_trace()) so that this object gets destroyed when the
37 * trace object is destroyed.
39 * Otherwise (with a strong reference), we would keep this trace
40 * object alive until the upstream message iterator ends. This
41 * could "leak" resources (memory, file descriptors) associated
42 * to traces and streams which otherwise would not exist.
44 const bt_trace *ir_trace = nullptr;
46 bt_listener_id ir_trace_destruction_listener_id = 0;
48 /* Trace's directory */
49 GString *path = nullptr;
51 /* `metadata` file path */
52 GString *metadata_path = nullptr;
55 * Hash table of `const bt_stream *` (weak) to
56 * `struct fs_sink_stream *` (owned by hash table).
58 GHashTable *streams = nullptr;
61 struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink, const bt_trace *ir_trace);
63 void fs_sink_trace_destroy(struct fs_sink_trace *trace);
65 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H */