1 #ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H
2 #define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H
5 * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include "common/macros.h"
27 #include <babeltrace2/babeltrace.h>
28 #include "ctfser/ctfser.h"
33 #include "fs-sink-ctf-meta.h"
37 struct fs_sink_trace
{
38 bt_logging_level log_level
;
39 struct fs_sink_comp
*fs_sink
;
42 struct fs_sink_ctf_trace
*trace
;
45 * Weak reference: this object does not own it, and `trace`
46 * above does not own its trace IR trace and trace class either.
47 * Instead, we add a "trace destruction" listener (in
48 * create_trace()) so that this object gets destroyed when the
49 * trace object is destroyed.
51 * Otherwise (with a strong reference), we would keep this trace
52 * object alive until the upstream message iterator ends. This
53 * could "leak" resources (memory, file descriptors) associated
54 * to traces and streams which otherwise would not exist.
56 const bt_trace
*ir_trace
;
58 bt_listener_id ir_trace_destruction_listener_id
;
60 /* Trace's directory */
63 /* `metadata` file path */
64 GString
*metadata_path
;
67 * Hash table of `const bt_stream *` (weak) to
68 * `struct fs_sink_stream *` (owned by hash table).
74 struct fs_sink_trace
*fs_sink_trace_create(struct fs_sink_comp
*fs_sink
,
75 const bt_trace
*ir_trace
);
78 void fs_sink_trace_destroy(struct fs_sink_trace
*trace
);
80 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H */