libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
cborstreamwriter.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/processing/cbor/cborstreamwriter.cpp
3
* \date 05/07/2025
4
* \author Olivier Langella
5
* \brief PAPPSO CBOR stream writer
6
*/
7
8
/*******************************************************************************
9
* Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
10
*
11
* This file is part of PAPPSOms-tools.
12
*
13
* PAPPSOms-tools is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation, either version 3 of the License, or
16
* (at your option) any later version.
17
*
18
* PAPPSOms-tools is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25
*
26
******************************************************************************/
27
28
#include "
cborstreamwriter.h
"
29
#include <QDateTime>
30
#include <QThreadPool>
31
#include "
pappsomspp/core/utils.h
"
32
#include <QCborValue>
33
#include <qcborvalue.h>
34
35
namespace
pappso
36
{
37
namespace
cbor
38
{
39
CborStreamWriter::CborStreamWriter
(QByteArray *data) : QCborStreamWriter(data)
40
{
41
}
42
43
CborStreamWriter::CborStreamWriter
(QIODevice *device) : QCborStreamWriter(device)
44
{
45
}
46
47
48
CborStreamWriter::~CborStreamWriter
()
49
{
50
}
51
52
53
const
QString &
54
CborStreamWriter::getUuid
()
const
55
{
56
return
m_uuid
;
57
}
58
59
void
60
CborStreamWriter::writeInformations
(
const
QString &software_name,
61
const
QString &software_version,
62
const
QString &type,
63
const
QString &operation)
64
{
65
append(
"informations"
);
66
startMap();
67
append(QLatin1String(
"software"
));
68
append(software_name);
69
append(QLatin1String(
"version"
));
70
append(software_version);
71
append(QLatin1String(
"type"
));
72
append(type);
73
append(QLatin1String(
"operation"
));
74
append(operation);
75
append(QLatin1String(
"cpu_used"
));
76
append(QThreadPool::globalInstance()->maxThreadCount());
77
append(QLatin1String(
"pappsomspp_version"
));
78
append(
pappso::Utils::getVersion
());
79
append(QLatin1String(
"sysinfo_machine_hostname"
));
80
append(QSysInfo::machineHostName());
81
append(QLatin1String(
"sysinfo_product_name"
));
82
append(QSysInfo::prettyProductName());
83
append(QLatin1String(
"timestamp"
));
84
append(QDateTime::currentDateTime().toString(Qt::ISODate));
85
86
append(QLatin1String(
"uuid"
));
87
m_uuid
= QUuid::createUuid().toString();
88
append(
m_uuid
);
89
endMap();
90
}
91
92
93
void
94
CborStreamWriter::writeArray
(
const
std::vector<std::size_t> &int_list)
95
{
96
startArray(int_list.size());
97
for
(
auto
num : int_list)
98
{
99
append((quint64)num);
100
}
101
endArray();
102
}
103
104
void
105
CborStreamWriter::writeArray
(
const
std::vector<double> &double_list)
106
{
107
startArray(double_list.size());
108
for
(
auto
num : double_list)
109
{
110
append(num);
111
}
112
endArray();
113
}
114
115
void
116
CborStreamWriter::writeArray
(
const
std::vector<int> &positions)
117
{
118
119
startArray(positions.size());
120
for
(
auto
num : positions)
121
{
122
append(num);
123
}
124
endArray();
125
}
126
127
void
128
CborStreamWriter::writeArray
(
const
std::vector<std::uint8_t> &small_uint_list)
129
{
130
131
startArray(small_uint_list.size());
132
for
(
int
num : small_uint_list)
133
{
134
append(num);
135
}
136
endArray();
137
}
138
139
void
140
CborStreamWriter::writeArray
(
const
std::vector<qint64> &int_list)
141
{
142
143
startArray(int_list.size());
144
for
(
auto
num : int_list)
145
{
146
append(num);
147
}
148
endArray();
149
}
150
151
void
152
CborStreamWriter::writeArray
(
const
QStringList &str_list)
153
{
154
startArray(str_list.size());
155
for
(
auto
str_item : str_list)
156
{
157
append(str_item);
158
}
159
endArray();
160
}
161
162
void
163
CborStreamWriter::writeArray
(
const
std::vector<QString> &str_list)
164
{
165
startArray(str_list.size());
166
for
(
auto
str_item : str_list)
167
{
168
append(str_item);
169
}
170
endArray();
171
}
172
void
173
CborStreamWriter::writeCborValue
(
const
QCborValue &cbor_value)
174
{
175
cbor_value.toCbor(*
this
);
176
}
177
178
void
179
CborStreamWriter::writeCborMap
(
const
QCborMap &cbor_map)
180
{
181
QCborValue(cbor_map).toCbor(*
this
);
182
}
183
184
void
185
CborStreamWriter::writeCborArray
(
const
QCborArray &cbor_array)
186
{
187
QCborValue(cbor_array).toCbor(*
this
);
188
}
189
190
void
191
CborStreamWriter::writeTrace
(
const
pappso::Trace
&trace,
192
const
QString &x_label,
193
const
QString &y_label)
194
{
195
startMap(2);
196
append(x_label);
197
writeArray
(trace.
xValues
());
198
append(y_label);
199
writeArray
(trace.
yValues
());
200
endMap();
201
}
202
203
204
void
205
CborStreamWriter::writeXicCoord
(
const
pappso::XicCoord
&xic_coord)
206
{
207
startMap();
208
xic_coord.
writeCborStream
(*
this
);
209
210
if
(xic_coord.
xicSptr
.get() !=
nullptr
)
211
{
212
append(
"xic"
);
213
writeTrace
(*xic_coord.
xicSptr
.get(),
"rt"
,
"intensities"
);
214
}
215
endMap();
216
}
217
218
219
void
220
CborStreamWriter::writeXicCoordList
(
const
std::vector<pappso::XicCoordSPtr> &xic_coord_list)
221
{
222
223
startArray(xic_coord_list.size());
224
for
(
auto
&xic_coord_sp : xic_coord_list)
225
{
226
writeXicCoord
(*xic_coord_sp.get());
227
}
228
endArray();
229
}
230
231
}
// namespace cbor
232
}
// namespace pappso
cborstreamwriter.h
pappso::Trace
A simple container of DataPoint instances.
Definition
trace.h:152
pappso::Trace::xValues
std::vector< pappso_double > xValues() const
Definition
trace.cpp:697
pappso::Trace::yValues
std::vector< pappso_double > yValues() const
Definition
trace.cpp:711
pappso::Utils::getVersion
static QString getVersion()
Definition
utils.cpp:669
pappso::cbor::CborStreamWriter::CborStreamWriter
CborStreamWriter(QByteArray *data)
Definition
cborstreamwriter.cpp:39
pappso::cbor::CborStreamWriter::writeInformations
void writeInformations(const QString &software_name, const QString &software_version, const QString &type, const QString &operation)
automatically produces an informations CBOR map the "informations" map contains default parameters : ...
Definition
cborstreamwriter.cpp:60
pappso::cbor::CborStreamWriter::writeXicCoord
void writeXicCoord(const pappso::XicCoord &xic_coord)
serialize a PAPPSO xic coordinate object to CBOR
Definition
cborstreamwriter.cpp:205
pappso::cbor::CborStreamWriter::writeCborValue
void writeCborValue(const QCborValue &cbor_value)
Definition
cborstreamwriter.cpp:173
pappso::cbor::CborStreamWriter::writeArray
void writeArray(const std::vector< std::size_t > &int_list)
Definition
cborstreamwriter.cpp:94
pappso::cbor::CborStreamWriter::writeXicCoordList
void writeXicCoordList(const std::vector< pappso::XicCoordSPtr > &xic_coord_list)
serialize a PAPPSO xic coordinate object list to CBOR
Definition
cborstreamwriter.cpp:220
pappso::cbor::CborStreamWriter::~CborStreamWriter
virtual ~CborStreamWriter()
Definition
cborstreamwriter.cpp:48
pappso::cbor::CborStreamWriter::writeTrace
void writeTrace(const pappso::Trace &trace, const QString &x_label="x", const QString &y_label="y")
serialize a PAPPSO trace object to CBOR
Definition
cborstreamwriter.cpp:191
pappso::cbor::CborStreamWriter::getUuid
const QString & getUuid() const
get UUID intialized when using writeInformations
Definition
cborstreamwriter.cpp:54
pappso::cbor::CborStreamWriter::writeCborMap
void writeCborMap(const QCborMap &cbor_map)
Definition
cborstreamwriter.cpp:179
pappso::cbor::CborStreamWriter::writeCborArray
void writeCborArray(const QCborArray &cbor_array)
Definition
cborstreamwriter.cpp:185
pappso::cbor::CborStreamWriter::m_uuid
QString m_uuid
Definition
cborstreamwriter.h:106
pappso::cbor
Definition
cborstreamreader.cpp:35
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::XicCoord
coordinates of the XIC to extract and the resulting XIC after extraction
Definition
xiccoord.h:68
pappso::XicCoord::xicSptr
XicSPtr xicSptr
extracted xic
Definition
xiccoord.h:135
pappso::XicCoord::writeCborStream
virtual void writeCborStream(QCborStreamWriter &cbor_writer) const
writes xic coordinates in a cbor stream
Definition
xiccoord.cpp:127
utils.h
pappsomspp
core
processing
cbor
cborstreamwriter.cpp
Generated on
for libpappsomspp by
1.17.0