9bd1e501184b7a9bcdd4c93e39a76a54270a266c
[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 <stdio.h>
11 #include <stdbool.h>
12 #include <glib.h>
13 #include "common/macros.h"
14 #include <babeltrace2/babeltrace.h>
15
16 #include "../common/msg-iter/msg-iter.hpp"
17 #include "lttng-index.hpp"
18
19 struct ctf_fs_component;
20 struct ctf_fs_file;
21 struct ctf_fs_trace;
22 struct ctf_fs_ds_file;
23 struct ctf_fs_ds_file_group;
24 struct ctf_fs_ds_group_medops_data;
25
26 struct ctf_fs_ds_file_info {
27 /* Owned by this. */
28 GString *path;
29
30 /* Guaranteed to be set, as opposed to the index. */
31 int64_t begin_ns;
32 };
33
34 struct ctf_fs_metadata;
35
36 struct ctf_fs_ds_file {
37 bt_logging_level log_level;
38
39 /* Weak */
40 bt_self_component *self_comp;
41
42 /* Weak */
43 bt_self_message_iterator *self_msg_iter;
44
45 /* Weak */
46 struct ctf_fs_metadata *metadata;
47
48 /* Owned by this */
49 struct ctf_fs_file *file;
50
51 /* Owned by this */
52 bt_stream *stream;
53
54 void *mmap_addr;
55
56 /*
57 * Max length of chunk to mmap() when updating the current mapping.
58 * This value must be page-aligned.
59 */
60 size_t mmap_max_len;
61
62 /* Length of the current mapping. Never exceeds the file's length. */
63 size_t mmap_len;
64
65 /* Offset in the file where the current mapping starts. */
66 off_t mmap_offset_in_file;
67
68 /*
69 * Offset, in the current mapping, of the address to return on the next
70 * request.
71 */
72 off_t request_offset_in_mapping;
73 };
74
75 BT_HIDDEN
76 struct ctf_fs_ds_file *ctf_fs_ds_file_create(
77 struct ctf_fs_trace *ctf_fs_trace,
78 bt_self_message_iterator *self_msg_iter,
79 bt_stream *stream, const char *path,
80 bt_logging_level log_level);
81
82 BT_HIDDEN
83 void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream);
84
85 BT_HIDDEN
86 struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(
87 struct ctf_fs_ds_file *ds_file,
88 struct ctf_fs_ds_file_info *ds_file_info,
89 struct ctf_msg_iter *msg_iter);
90
91 BT_HIDDEN
92 struct ctf_fs_ds_index *ctf_fs_ds_index_create(bt_logging_level log_level,
93 bt_self_component *self_comp);
94
95 BT_HIDDEN
96 void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index);
97
98 /*
99 * Medium operations to iterate on a single ctf_fs_ds_file.
100 *
101 * The data pointer when using this must be a pointer to the ctf_fs_ds_file.
102 */
103 extern struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops;
104
105 /*
106 * Medium operations to iterate on the packet of a ctf_fs_ds_group.
107 *
108 * The iteration is done based on the index of the group.
109 *
110 * The data pointer when using these medops must be a pointer to a ctf_fs_ds
111 * group_medops_data structure.
112 */
113 BT_HIDDEN
114 extern struct ctf_msg_iter_medium_ops ctf_fs_ds_group_medops;
115
116 BT_HIDDEN
117 enum ctf_msg_iter_medium_status ctf_fs_ds_group_medops_data_create(
118 struct ctf_fs_ds_file_group *ds_file_group,
119 bt_self_message_iterator *self_msg_iter,
120 bt_logging_level log_level,
121 struct ctf_fs_ds_group_medops_data **out);
122
123 BT_HIDDEN
124 void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data);
125
126 BT_HIDDEN
127 void ctf_fs_ds_group_medops_data_destroy(
128 struct ctf_fs_ds_group_medops_data *data);
129
130 #endif /* CTF_FS_DS_FILE_H */
This page took 0.031373 seconds and 3 git commands to generate.