.gitignore: add installed_files.txt
[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
ae2be88d
SM
10#ifndef BABELTRACE_PLUGINS_CTF_FS_SRC_FS_HPP
11#define BABELTRACE_PLUGINS_CTF_FS_SRC_FS_HPP
0235b0db 12
c7e1be4b 13#include <glib.h>
c802cacb 14
c7e1be4b 15#include <babeltrace2/babeltrace.h>
c802cacb 16
9328f86b 17#include "cpp-common/bt2c/aliases.hpp"
0f5c5d5c
SM
18#include "cpp-common/bt2c/logging.hpp"
19
cdf7de78 20#include "data-stream-file.hpp"
9328f86b
SM
21#include "plugins/ctf/common/src/metadata/metadata-stream-parser-utils.hpp"
22#include "plugins/ctf/common/src/msg-iter.hpp"
23
24#define CTF_FS_METADATA_FILENAME "metadata"
490db841 25
78bb6992 26extern bool ctf_fs_debug;
56a1cced 27
9328f86b 28struct ctf_fs_trace
4164020e 29{
9328f86b 30 using UP = std::unique_ptr<ctf_fs_trace>;
1a9f7075 31
9328f86b
SM
32 explicit ctf_fs_trace(const ctf::src::ClkClsCfg& clkClsCfg,
33 const bt2::OptionalBorrowedObject<bt2::SelfComponent> selfComp,
34 const bt2c::Logger& parentLogger) :
51d13bc2 35 _mLogger {parentLogger, "PLUGIN/SRC.CTF.FS/TRACE"},
9328f86b
SM
36 _mClkClsCfg {clkClsCfg}, _mSelfComp {selfComp}
37 {
38 }
44c440bc 39
9328f86b
SM
40 const ctf::src::TraceCls *cls() const
41 {
42 BT_ASSERT(_mParseRet);
43 BT_ASSERT(_mParseRet->traceCls);
44 return _mParseRet->traceCls.get();
45 }
56a1cced 46
9328f86b
SM
47 const bt2s::optional<bt2c::Uuid>& metadataStreamUuid() const noexcept
48 {
49 BT_ASSERT(_mParseRet);
50 return _mParseRet->uuid;
51 }
7df773f2 52
9328f86b 53 void parseMetadata(const bt2c::ConstBytes buffer)
0f5c5d5c 54 {
51d13bc2 55 _mParseRet = ctf::src::parseMetadataStream(_mSelfComp, _mClkClsCfg, buffer, _mLogger);
0f5c5d5c 56 }
98903a3e 57
e44859b1 58 bt2::Trace::Shared trace;
862ca4ed 59
cdf7de78 60 std::vector<ctf_fs_ds_file_group::UP> ds_file_groups;
94cf822e 61
cee8a466 62 std::string path;
1a9f7075 63
4164020e 64 /* Next automatic stream ID when not provided by packet header */
afb0f12b 65 uint64_t next_stream_id = 0;
9328f86b
SM
66
67private:
51d13bc2 68 bt2c::Logger _mLogger;
9328f86b
SM
69 ctf::src::ClkClsCfg _mClkClsCfg;
70 bt2::OptionalBorrowedObject<bt2::SelfComponent> _mSelfComp;
71 bt2s::optional<ctf::src::MetadataStreamParser::ParseRet> _mParseRet;
1a9f7075
PP
72};
73
09721481
SM
74struct ctf_fs_port_data
75{
945312a2
SM
76 using UP = std::unique_ptr<ctf_fs_port_data>;
77
09721481
SM
78 /* Weak, belongs to ctf_fs_trace */
79 struct ctf_fs_ds_file_group *ds_file_group = nullptr;
80
81 /* Weak */
82 struct ctf_fs_component *ctf_fs = nullptr;
83};
84
09721481
SM
85struct ctf_fs_component
86{
57ec0a35 87 using UP = std::unique_ptr<ctf_fs_component>;
09721481 88
e1d200e5
SM
89 explicit ctf_fs_component(const ctf::src::ClkClsCfg& clkClsCfgParam,
90 const bt2c::Logger& parentLogger) noexcept :
91 logger {parentLogger, "PLUGIN/SRC.CTF.FS/COMP"},
92 clkClsCfg {clkClsCfgParam}
09721481
SM
93 {
94 }
95
96 bt2c::Logger logger;
97
945312a2 98 std::vector<ctf_fs_port_data::UP> port_data;
09721481 99
7df773f2 100 ctf_fs_trace::UP trace;
09721481
SM
101
102 ctf::src::ClkClsCfg clkClsCfg;
9328f86b 103 ctf::src::MsgIterQuirks quirks;
09721481
SM
104};
105
4164020e
SM
106struct ctf_fs_msg_iter_data
107{
adf452d1
SM
108 using UP = std::unique_ptr<ctf_fs_msg_iter_data>;
109
4d6634b8
SM
110 explicit ctf_fs_msg_iter_data(const bt2::SelfMessageIterator selfMsgIterParam) :
111 selfMsgIter {selfMsgIterParam}, logger {selfMsgIter, "PLUGIN/SRC.CTF.FS/MSG-ITER"}
0f5c5d5c
SM
112 {
113 }
4c65a157 114
4d6634b8 115 bt2::SelfMessageIterator selfMsgIter;
5c563278 116
0f5c5d5c
SM
117 bt2c::Logger logger;
118
9328f86b
SM
119 /* Weak, belongs to ctf_fs_component */
120 ctf_fs_port_data *port_data = nullptr;
94cf822e 121
9328f86b 122 bt2s::optional<ctf::src::MsgIter> msgIter;
cbca1c06 123
4164020e
SM
124 /*
125 * Saved error. If we hit an error in the _next method, but have some
126 * messages ready to return, we save the error here and return it on
127 * the next _next call.
128 */
afb0f12b
SM
129 bt_message_iterator_class_next_method_status next_saved_status =
130 BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
131 const struct bt_error *next_saved_error = nullptr;
94cf822e
PP
132};
133
4164020e
SM
134bt_component_class_initialize_method_status
135ctf_fs_init(bt_self_component_source *source, bt_self_component_source_configuration *config,
136 const bt_value *params, void *init_method_data);
490db841 137
b19ff26f 138void ctf_fs_finalize(bt_self_component_source *component);
d3e4dcd8 139
4164020e
SM
140bt_component_class_query_method_status ctf_fs_query(bt_self_component_class_source *comp_class,
141 bt_private_query_executor *priv_query_exec,
142 const char *object, const bt_value *params,
143 void *method_data, const bt_value **result);
55314f2a 144
4164020e
SM
145bt_message_iterator_class_initialize_method_status
146ctf_fs_iterator_init(bt_self_message_iterator *self_msg_iter,
147 bt_self_message_iterator_configuration *config,
148 bt_self_component_port_output *self_port);
d94d92ac 149
d6e69534 150void ctf_fs_iterator_finalize(bt_self_message_iterator *it);
d3eb6e8f 151
4164020e
SM
152bt_message_iterator_class_next_method_status
153ctf_fs_iterator_next(bt_self_message_iterator *iterator, bt_message_array_const msgs,
154 uint64_t capacity, uint64_t *count);
d3eb6e8f 155
4164020e
SM
156bt_message_iterator_class_seek_beginning_method_status
157ctf_fs_iterator_seek_beginning(bt_self_message_iterator *message_iterator);
6a9bb5e9 158
f280892e 159/*
a0cd55ad
SM
160 * Create one `struct ctf_fs_trace` from one trace, or multiple traces sharing
161 * the same UUID.
162 *
163 * `paths_value` must be an array of strings,
164 *
165 * The created `struct ctf_fs_trace` is assigned to `ctf_fs->trace`.
f280892e
SM
166 */
167
4164020e 168int ctf_fs_component_create_ctf_fs_trace(struct ctf_fs_component *ctf_fs,
c5a5a936 169 bt2::ConstArrayValue pathsValue, const char *traceName,
4d6634b8 170 bt2::OptionalBorrowedObject<bt2::SelfComponent> selfComp);
f280892e 171
c5a5a936
SM
172namespace ctf {
173namespace src {
174namespace fs {
175
176/* `src.ctf.fs` parameters */
177
178struct Parameters
179{
180 explicit Parameters(const bt2::ConstArrayValue inputsParam) noexcept : inputs {inputsParam}
181 {
182 }
183
184 bt2::ConstArrayValue inputs;
185 bt2s::optional<std::string> traceName;
186 ClkClsCfg clkClsCfg;
187};
188
189} /* namespace fs */
190} /* namespace src */
191} /* namespace ctf */
192
d907165c
SM
193/*
194 * Read and validate parameters taken by the src.ctf.fs plugin.
195 *
c5a5a936 196 * Throw if any parameter doesn't pass validation.
d907165c 197 */
f280892e 198
c5a5a936
SM
199ctf::src::fs::Parameters read_src_fs_parameters(bt2::ConstMapValue params,
200 const bt2c::Logger& logger);
f280892e 201
a38d7650
SM
202/*
203 * Generate the port name to be used for a given data stream file group.
a38d7650
SM
204 */
205
3045bbcb 206std::string ctf_fs_make_port_name(ctf_fs_ds_file_group *ds_file_group);
a38d7650 207
ae2be88d 208#endif /* BABELTRACE_PLUGINS_CTF_FS_SRC_FS_HPP */
This page took 0.117679 seconds and 4 git commands to generate.