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