Commit | Line | Data |
---|---|---|
15fe47e0 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
15fe47e0 | 3 | * |
0235b0db | 4 | * Copyright 2019 Philippe Proulx <pproulx@efficios.com> |
15fe47e0 PP |
5 | */ |
6 | ||
0235b0db MJ |
7 | #ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H |
8 | #define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H | |
9 | ||
15fe47e0 | 10 | #include <glib.h> |
15fe47e0 | 11 | |
c802cacb SM |
12 | #include <babeltrace2/babeltrace.h> |
13 | ||
150640e8 SM |
14 | struct fs_sink_comp; |
15 | struct fs_sink_ctf_trace; | |
16 | ||
4164020e SM |
17 | struct fs_sink_trace |
18 | { | |
150640e8 SM |
19 | bt_logging_level log_level = BT_LOGGING_LEVEL_NONE; |
20 | fs_sink_comp *fs_sink = nullptr; | |
4164020e SM |
21 | |
22 | /* Owned by this */ | |
150640e8 | 23 | fs_sink_ctf_trace *trace = nullptr; |
4164020e SM |
24 | |
25 | /* | |
26 | * Weak reference: this object does not own it, and `trace` | |
27 | * above does not own its trace IR trace and trace class either. | |
28 | * Instead, we add a "trace destruction" listener (in | |
29 | * create_trace()) so that this object gets destroyed when the | |
30 | * trace object is destroyed. | |
31 | * | |
32 | * Otherwise (with a strong reference), we would keep this trace | |
33 | * object alive until the upstream message iterator ends. This | |
34 | * could "leak" resources (memory, file descriptors) associated | |
35 | * to traces and streams which otherwise would not exist. | |
36 | */ | |
150640e8 | 37 | const bt_trace *ir_trace = nullptr; |
4164020e | 38 | |
150640e8 | 39 | bt_listener_id ir_trace_destruction_listener_id = 0; |
4164020e SM |
40 | |
41 | /* Trace's directory */ | |
150640e8 | 42 | GString *path = nullptr; |
4164020e SM |
43 | |
44 | /* `metadata` file path */ | |
150640e8 | 45 | GString *metadata_path = nullptr; |
4164020e SM |
46 | |
47 | /* | |
48 | * Hash table of `const bt_stream *` (weak) to | |
49 | * `struct fs_sink_stream *` (owned by hash table). | |
50 | */ | |
150640e8 | 51 | GHashTable *streams = nullptr; |
15fe47e0 PP |
52 | }; |
53 | ||
4164020e | 54 | struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink, const bt_trace *ir_trace); |
15fe47e0 | 55 | |
15fe47e0 PP |
56 | void fs_sink_trace_destroy(struct fs_sink_trace *trace); |
57 | ||
58 | #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H */ |