libpappsomspp
Library for mass spectrometry
psmfilescanprocess.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/psm/psmfilescanprocess.h
3 * \date 12/07/2025
4 * \author Olivier Langella
5 * \brief PSM file reader designed to parallelize scan process
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
29#include "psmfilescanprocess.h"
30#include "../../../pappsoexception.h"
31#include <QtConcurrent>
32
33
35{
36 m_bufferScanSize = buffer_scan_size;
37}
38
40{
41}
42
43void
45{
46 for(CborScanMapBase *cbor_scan_p : m_cborScanList)
47 {
48 delete cbor_scan_p;
49 }
50 m_cborScanList.clear();
51}
52
53
54void
56{
57 qDebug();
58 // auto& ref = elections.emplace_back("Nelson Mandela", "South Africa", 1994);
59 CborScanMapBase *scan_map_p = newCborScanMap();
60 m_cborScanList.push_back(scan_map_p);
61
62 if(!mpa_cborReader->readCborMap(*scan_map_p))
63 {
64 throw pappso::PappsoException(QObject::tr("readCborMap scan failed"));
65 }
66 // m_cborScanList.push_back(scan_map);
67 qDebug() << "scan end";
68 scanFinished(monitor);
69 qDebug();
70}
71
72void
74{
75 if(m_cborScanList.size() > m_bufferScanSize)
76 {
77 processBufferScan(monitor);
78 clearScanBuffer();
79 }
80}
81
82void
84{
85 processBufferScan(monitor);
86 clearScanBuffer();
87}
88
89
90void
92{
93 // you decide how to process the list of scans
94
95 std::function<void(pappso::cbor::psm::CborScanMapBase *)> mapProcessCborScan =
96 [](pappso::cbor::psm::CborScanMapBase *cbor_scan_p) { cbor_scan_p->process(); };
97
98
99 QFuture<void> res = QtConcurrent::map<std::vector<CborScanMapBase *>::iterator>(
100 m_cborScanList.begin(), m_cborScanList.end(), mapProcessCborScan);
101 res.waitForFinished();
102 processBufferScanDone(monitor);
103}
104
105void
107{
108 // you decide what to do with processed scans
109}
void scanFinished(pappso::UiMonitorInterface &monitor) override
void readScan(pappso::UiMonitorInterface &monitor) override
void sampleFinished(pappso::UiMonitorInterface &monitor) override
virtual void processBufferScanDone(pappso::UiMonitorInterface &monitor)
PsmFileScanProcess(std::size_t buffer_scan_size)
virtual void processBufferScan(pappso::UiMonitorInterface &monitor)
PSM file reader designed to parallelize scan process.