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 | ||
91d81473 | 10 | #include "common/macros.h" |
3fadfbc0 | 11 | #include <babeltrace2/babeltrace.h> |
578e048b | 12 | #include "ctfser/ctfser.h" |
15fe47e0 | 13 | #include <glib.h> |
15fe47e0 PP |
14 | #include <stdint.h> |
15 | ||
16 | #include "fs-sink-ctf-meta.h" | |
17 | ||
18 | struct fs_sink_comp; | |
19 | ||
20 | struct fs_sink_trace { | |
ffa3b2b3 | 21 | bt_logging_level log_level; |
15fe47e0 PP |
22 | struct fs_sink_comp *fs_sink; |
23 | ||
24 | /* Owned by this */ | |
335a2da5 | 25 | struct fs_sink_ctf_trace *trace; |
15fe47e0 PP |
26 | |
27 | /* | |
335a2da5 PP |
28 | * Weak reference: this object does not own it, and `trace` |
29 | * above does not own its trace IR trace and trace class either. | |
30 | * Instead, we add a "trace destruction" listener (in | |
31 | * create_trace()) so that this object gets destroyed when the | |
32 | * trace object is destroyed. | |
15fe47e0 PP |
33 | * |
34 | * Otherwise (with a strong reference), we would keep this trace | |
35 | * object alive until the upstream message iterator ends. This | |
36 | * could "leak" resources (memory, file descriptors) associated | |
37 | * to traces and streams which otherwise would not exist. | |
38 | */ | |
39 | const bt_trace *ir_trace; | |
40 | ||
2054a0d1 | 41 | bt_listener_id ir_trace_destruction_listener_id; |
15fe47e0 PP |
42 | |
43 | /* Trace's directory */ | |
44 | GString *path; | |
45 | ||
46 | /* `metadata` file path */ | |
47 | GString *metadata_path; | |
48 | ||
49 | /* | |
50 | * Hash table of `const bt_stream *` (weak) to | |
51 | * `struct fs_sink_stream *` (owned by hash table). | |
52 | */ | |
53 | GHashTable *streams; | |
54 | }; | |
55 | ||
56 | BT_HIDDEN | |
57 | struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink, | |
58 | const bt_trace *ir_trace); | |
59 | ||
60 | BT_HIDDEN | |
61 | void fs_sink_trace_destroy(struct fs_sink_trace *trace); | |
62 | ||
63 | #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H */ |