3d8ddb4bbe8a7c496e89b3af4141ab025134d800
[babeltrace.git] / src / plugins / ctf / fs-sink / fs-sink-trace.h
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
26 #include "common/macros.h"
27 #include <babeltrace2/babeltrace.h>
28 #include "ctfser/ctfser.h"
29 #include <glib.h>
30 #include <stdbool.h>
31 #include <stdint.h>
32
33 #include "fs-sink-ctf-meta.h"
34
35 struct fs_sink_comp;
36
37 struct fs_sink_trace {
38 bt_logging_level log_level;
39 struct fs_sink_comp *fs_sink;
40
41 /* Owned by this */
42 struct fs_sink_ctf_trace *trace;
43
44 /*
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.
50 *
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.
55 */
56 const bt_trace *ir_trace;
57
58 bt_listener_id ir_trace_destruction_listener_id;
59
60 /* Trace's directory */
61 GString *path;
62
63 /* `metadata` file path */
64 GString *metadata_path;
65
66 /*
67 * Hash table of `const bt_stream *` (weak) to
68 * `struct fs_sink_stream *` (owned by hash table).
69 */
70 GHashTable *streams;
71 };
72
73 BT_HIDDEN
74 struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink,
75 const bt_trace *ir_trace);
76
77 BT_HIDDEN
78 void fs_sink_trace_destroy(struct fs_sink_trace *trace);
79
80 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_TRACE_H */
This page took 0.033502 seconds and 3 git commands to generate.