Commit | Line | Data |
---|---|---|
15fe47e0 PP |
1 | #ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H |
2 | #define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H | |
3 | ||
4 | /* | |
5 | * Copyright 2019 Philippe Proulx <pproulx@efficios.com> | |
6 | * | |
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: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
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 | |
23 | * SOFTWARE. | |
24 | */ | |
25 | ||
91d81473 | 26 | #include "common/macros.h" |
3fadfbc0 | 27 | #include <babeltrace2/babeltrace.h> |
578e048b | 28 | #include "ctfser/ctfser.h" |
15fe47e0 | 29 | #include <glib.h> |
15fe47e0 PP |
30 | #include <stdint.h> |
31 | ||
32 | #include "fs-sink-ctf-meta.h" | |
33 | ||
34 | struct fs_sink_comp; | |
35 | ||
36 | struct fs_sink_trace { | |
ffa3b2b3 | 37 | bt_logging_level log_level; |
15fe47e0 PP |
38 | struct fs_sink_comp *fs_sink; |
39 | ||
40 | /* Owned by this */ | |
335a2da5 | 41 | struct fs_sink_ctf_trace *trace; |
15fe47e0 PP |
42 | |
43 | /* | |
335a2da5 PP |
44 | * Weak reference: this object does not own it, and `trace` |
45 | * above does not own its trace IR trace and trace class either. | |
46 | * Instead, we add a "trace destruction" listener (in | |
47 | * create_trace()) so that this object gets destroyed when the | |
48 | * trace object is destroyed. | |
15fe47e0 PP |
49 | * |
50 | * Otherwise (with a strong reference), we would keep this trace | |
51 | * object alive until the upstream message iterator ends. This | |
52 | * could "leak" resources (memory, file descriptors) associated | |
53 | * to traces and streams which otherwise would not exist. | |
54 | */ | |
55 | const bt_trace *ir_trace; | |
56 | ||
2054a0d1 | 57 | bt_listener_id ir_trace_destruction_listener_id; |
15fe47e0 PP |
58 | |
59 | /* Trace's directory */ | |
60 | GString *path; | |
61 | ||
62 | /* `metadata` file path */ | |
63 | GString *metadata_path; | |
64 | ||
65 | /* | |
66 | * Hash table of `const bt_stream *` (weak) to | |
67 | * `struct fs_sink_stream *` (owned by hash table). | |
68 | */ | |
69 | GHashTable *streams; | |
70 | }; | |
71 | ||
72 | BT_HIDDEN | |
73 | struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink, | |
74 | const bt_trace *ir_trace); | |
75 | ||
76 | BT_HIDDEN | |
77 | void fs_sink_trace_destroy(struct fs_sink_trace *trace); | |
78 | ||
79 | #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H */ |