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