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