Sort includes in C++ files
[babeltrace.git] / src / plugins / ctf / fs-src / fs.hpp
CommitLineData
490db841 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
490db841 3 *
f3bc2010 4 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
56a1cced 5 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
490db841 6 *
0235b0db 7 * BabelTrace - CTF on File System Component
490db841
JG
8 */
9
0235b0db
MJ
10#ifndef BABELTRACE_PLUGIN_CTF_FS_H
11#define BABELTRACE_PLUGIN_CTF_FS_H
12
c55a9f58 13#include <stdbool.h>
c802cacb 14
3fadfbc0 15#include <babeltrace2/babeltrace.h>
c802cacb
SM
16
17#include "common/macros.h"
18
19#include "../common/metadata/decoder.hpp"
087cd0f5
SM
20#include "data-stream-file.hpp"
21#include "metadata.hpp"
490db841 22
78bb6992 23extern bool ctf_fs_debug;
56a1cced 24
4164020e
SM
25struct ctf_fs_file
26{
27 bt_logging_level log_level;
98903a3e 28
4164020e
SM
29 /* Weak */
30 bt_self_component *self_comp;
4c65a157 31
4164020e
SM
32 /* Owned by this */
33 GString *path;
1a9f7075 34
4164020e
SM
35 /* Owned by this */
36 FILE *fp;
1a9f7075 37
4164020e 38 off_t size;
56a1cced
JG
39};
40
4164020e
SM
41struct ctf_fs_metadata
42{
43 /* Owned by this */
44 struct ctf_metadata_decoder *decoder;
44c440bc 45
4164020e
SM
46 /* Owned by this */
47 bt_trace_class *trace_class;
1a9f7075 48
4164020e
SM
49 /* Weak (owned by `decoder` above) */
50 struct ctf_trace_class *tc;
44c440bc 51
4164020e
SM
52 /* Owned by this */
53 char *text;
1a9f7075 54
4164020e 55 int bo;
56a1cced
JG
56};
57
4164020e
SM
58struct ctf_fs_component
59{
60 bt_logging_level log_level;
98903a3e 61
4164020e
SM
62 /* Array of struct ctf_fs_port_data *, owned by this */
63 GPtrArray *port_data;
1a9f7075 64
4164020e
SM
65 /* Owned by this */
66 struct ctf_fs_trace *trace;
1a9f7075 67
4164020e 68 struct ctf_fs_metadata_config metadata_config;
1a9f7075
PP
69};
70
4164020e
SM
71struct ctf_fs_trace
72{
73 bt_logging_level log_level;
98903a3e 74
4164020e
SM
75 /*
76 * Weak. These are mostly used to generate log messages or to append
77 * error causes. They are mutually exclusive, only one of them must be
78 * set.
79 */
80 bt_self_component *self_comp;
81 bt_self_component_class *self_comp_class;
4c65a157 82
4164020e
SM
83 /* Owned by this */
84 struct ctf_fs_metadata *metadata;
1a9f7075 85
4164020e
SM
86 /* Owned by this */
87 bt_trace *trace;
862ca4ed 88
4164020e
SM
89 /* Array of struct ctf_fs_ds_file_group *, owned by this */
90 GPtrArray *ds_file_groups;
94cf822e 91
4164020e
SM
92 /* Owned by this */
93 GString *path;
1a9f7075 94
4164020e
SM
95 /* Next automatic stream ID when not provided by packet header */
96 uint64_t next_stream_id;
1a9f7075
PP
97};
98
4164020e
SM
99struct ctf_fs_ds_index_entry
100{
101 /* Weak, belongs to ctf_fs_ds_file_info. */
102 const char *path;
103
104 /* Position, in bytes, of the packet from the beginning of the file. */
105 uint64_t offset;
106
107 /* Size of the packet, in bytes. */
108 uint64_t packet_size;
109
110 /*
111 * Extracted from the packet context, relative to the respective fields'
112 * mapped clock classes (in cycles).
113 */
114 uint64_t timestamp_begin, timestamp_end;
115
116 /*
117 * Converted from the packet context, relative to the trace's EPOCH
118 * (in ns since EPOCH).
119 */
120 int64_t timestamp_begin_ns, timestamp_end_ns;
121
122 /*
123 * Packet sequence number, or UINT64_MAX if not present in the index.
124 */
125 uint64_t packet_seq_num;
7ed5243a
FD
126};
127
4164020e
SM
128struct ctf_fs_ds_index
129{
130 /* Array of pointer to struct ctf_fs_ds_index_entry. */
131 GPtrArray *entries;
7ed5243a
FD
132};
133
4164020e
SM
134struct ctf_fs_ds_file_group
135{
136 /*
137 * Array of struct ctf_fs_ds_file_info, owned by this.
138 *
139 * This is an _ordered_ array of data stream file infos which
140 * belong to this group (a single stream instance).
141 *
142 * You can call ctf_fs_ds_file_create() with one of those paths
143 * and the trace IR stream below.
144 */
145 GPtrArray *ds_file_infos;
146
147 /* Owned by this */
148 struct ctf_stream_class *sc;
149
150 /* Owned by this */
151 bt_stream *stream;
152
153 /* Stream (instance) ID; -1ULL means none */
154 uint64_t stream_id;
155
156 /* Weak, belongs to component */
157 struct ctf_fs_trace *ctf_fs_trace;
158
159 /*
160 * Owned by this.
161 */
162 struct ctf_fs_ds_index *index;
ea0b4b9e
JG
163};
164
4164020e
SM
165struct ctf_fs_port_data
166{
167 /* Weak, belongs to ctf_fs_trace */
168 struct ctf_fs_ds_file_group *ds_file_group;
5c563278 169
4164020e
SM
170 /* Weak */
171 struct ctf_fs_component *ctf_fs;
94cf822e
PP
172};
173
4164020e
SM
174struct ctf_fs_msg_iter_data
175{
176 bt_logging_level log_level;
98903a3e 177
4164020e
SM
178 /* Weak */
179 bt_self_component *self_comp;
4c65a157 180
4164020e
SM
181 /* Weak */
182 bt_self_message_iterator *self_msg_iter;
5c563278 183
4164020e
SM
184 /* Weak, belongs to ctf_fs_trace */
185 struct ctf_fs_ds_file_group *ds_file_group;
94cf822e 186
4164020e
SM
187 /* Owned by this */
188 struct ctf_msg_iter *msg_iter;
cbca1c06 189
4164020e
SM
190 /*
191 * Saved error. If we hit an error in the _next method, but have some
192 * messages ready to return, we save the error here and return it on
193 * the next _next call.
194 */
195 bt_message_iterator_class_next_method_status next_saved_status;
196 const struct bt_error *next_saved_error;
f6e68e70 197
4164020e 198 struct ctf_fs_ds_group_medops_data *msg_iter_medops_data;
94cf822e
PP
199};
200
4164020e
SM
201bt_component_class_initialize_method_status
202ctf_fs_init(bt_self_component_source *source, bt_self_component_source_configuration *config,
203 const bt_value *params, void *init_method_data);
490db841 204
b19ff26f 205void ctf_fs_finalize(bt_self_component_source *component);
d3e4dcd8 206
4164020e
SM
207bt_component_class_query_method_status ctf_fs_query(bt_self_component_class_source *comp_class,
208 bt_private_query_executor *priv_query_exec,
209 const char *object, const bt_value *params,
210 void *method_data, const bt_value **result);
55314f2a 211
4164020e
SM
212bt_message_iterator_class_initialize_method_status
213ctf_fs_iterator_init(bt_self_message_iterator *self_msg_iter,
214 bt_self_message_iterator_configuration *config,
215 bt_self_component_port_output *self_port);
d94d92ac 216
d6e69534 217void ctf_fs_iterator_finalize(bt_self_message_iterator *it);
d3eb6e8f 218
4164020e
SM
219bt_message_iterator_class_next_method_status
220ctf_fs_iterator_next(bt_self_message_iterator *iterator, bt_message_array_const msgs,
221 uint64_t capacity, uint64_t *count);
d3eb6e8f 222
4164020e
SM
223bt_message_iterator_class_seek_beginning_method_status
224ctf_fs_iterator_seek_beginning(bt_self_message_iterator *message_iterator);
6a9bb5e9 225
f280892e
SM
226/* Create and initialize a new, empty ctf_fs_component. */
227
50b9f4b5 228struct ctf_fs_component *ctf_fs_component_create(bt_logging_level log_level);
f280892e
SM
229
230/*
a0cd55ad
SM
231 * Create one `struct ctf_fs_trace` from one trace, or multiple traces sharing
232 * the same UUID.
233 *
234 * `paths_value` must be an array of strings,
235 *
236 * The created `struct ctf_fs_trace` is assigned to `ctf_fs->trace`.
d23b766e
SM
237 *
238 * `self_comp` and `self_comp_class` are used for logging, only one of them
239 * should be set.
f280892e
SM
240 */
241
4164020e
SM
242int ctf_fs_component_create_ctf_fs_trace(struct ctf_fs_component *ctf_fs,
243 const bt_value *paths_value,
244 const bt_value *trace_name_value,
245 bt_self_component *self_comp,
246 bt_self_component_class *self_comp_class);
f280892e
SM
247
248/* Free `ctf_fs` and everything it owns. */
249
f280892e
SM
250void ctf_fs_destroy(struct ctf_fs_component *ctf_fs);
251
d907165c
SM
252/*
253 * Read and validate parameters taken by the src.ctf.fs plugin.
254 *
255 * - The mandatory `paths` parameter is returned in `*paths`.
256 * - The optional `clock-class-offset-s` and `clock-class-offset-ns`, if
257 * present, are recorded in the `ctf_fs` structure.
005d49d6
SM
258 * - The optional `trace-name` parameter is returned in `*trace_name` if
259 * present, else `*trace_name` is set to NULL.
d907165c 260 *
d23b766e
SM
261 * `self_comp` and `self_comp_class` are used for logging, only one of them
262 * should be set.
263 *
d907165c
SM
264 * Return true on success, false if any parameter didn't pass validation.
265 */
f280892e 266
4164020e
SM
267bool read_src_fs_parameters(const bt_value *params, const bt_value **paths,
268 const bt_value **trace_name, struct ctf_fs_component *ctf_fs,
269 bt_self_component *self_comp, bt_self_component_class *self_comp_class);
f280892e 270
a38d7650
SM
271/*
272 * Generate the port name to be used for a given data stream file group.
273 *
274 * The result must be freed using g_free by the caller.
275 */
276
a38d7650
SM
277gchar *ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group);
278
541b0a11 279#endif /* BABELTRACE_PLUGIN_CTF_FS_H */
This page took 0.103005 seconds and 4 git commands to generate.