ctf: allocate some structures with new
[babeltrace.git] / src / plugins / ctf / fs-src / data-stream-file.hpp
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2016 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 #ifndef CTF_FS_DS_FILE_H
8 #define CTF_FS_DS_FILE_H
9
10 #include <glib.h>
11 #include <stdio.h>
12
13 #include <babeltrace2/babeltrace.h>
14
15 #include "../common/src/msg-iter/msg-iter.hpp"
16
17 struct ctf_fs_ds_file_info
18 {
19 /* Owned by this. */
20 GString *path = nullptr;
21
22 /* Guaranteed to be set, as opposed to the index. */
23 int64_t begin_ns = 0;
24 };
25
26 struct ctf_fs_ds_file
27 {
28 bt_logging_level log_level = (bt_logging_level) 0;
29
30 /* Weak */
31 bt_self_component *self_comp = nullptr;
32
33 /* Weak */
34 struct ctf_fs_metadata *metadata = nullptr;
35
36 /* Owned by this */
37 struct ctf_fs_file *file = nullptr;
38
39 /* Owned by this */
40 bt_stream *stream = nullptr;
41
42 void *mmap_addr = nullptr;
43
44 /*
45 * Max length of chunk to mmap() when updating the current mapping.
46 * This value must be page-aligned.
47 */
48 size_t mmap_max_len = 0;
49
50 /* Length of the current mapping. Never exceeds the file's length. */
51 size_t mmap_len = 0;
52
53 /* Offset in the file where the current mapping starts. */
54 off_t mmap_offset_in_file = 0;
55
56 /*
57 * Offset, in the current mapping, of the address to return on the next
58 * request.
59 */
60 off_t request_offset_in_mapping = 0;
61 };
62
63 struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, bt_stream *stream,
64 const char *path, bt_logging_level log_level);
65
66 void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream);
67
68 struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file,
69 struct ctf_fs_ds_file_info *ds_file_info,
70 struct ctf_msg_iter *msg_iter);
71
72 struct ctf_fs_ds_index *ctf_fs_ds_index_create(bt_logging_level log_level,
73 bt_self_component *self_comp);
74
75 void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index);
76
77 /*
78 * Medium operations to iterate on a single ctf_fs_ds_file.
79 *
80 * The data pointer when using this must be a pointer to the ctf_fs_ds_file.
81 */
82 extern struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops;
83
84 /*
85 * Medium operations to iterate on the packet of a ctf_fs_ds_group.
86 *
87 * The iteration is done based on the index of the group.
88 *
89 * The data pointer when using these medops must be a pointer to a ctf_fs_ds
90 * group_medops_data structure.
91 */
92 extern struct ctf_msg_iter_medium_ops ctf_fs_ds_group_medops;
93
94 enum ctf_msg_iter_medium_status ctf_fs_ds_group_medops_data_create(
95 struct ctf_fs_ds_file_group *ds_file_group, bt_self_message_iterator *self_msg_iter,
96 bt_logging_level log_level, struct ctf_fs_ds_group_medops_data **out);
97
98 void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data);
99
100 void ctf_fs_ds_group_medops_data_destroy(struct ctf_fs_ds_group_medops_data *data);
101
102 #endif /* CTF_FS_DS_FILE_H */
This page took 0.032353 seconds and 4 git commands to generate.