GCC Code Coverage Report


source/XpertMassCore/src/
File: source/XpertMassCore/src/IsotopicDataBaseHandler.cpp
Date: 2025-11-20 01:41:33
Lines:
18/19
94.7%
Functions:
6/6
100.0%
Branches:
9/22
40.9%

Line Branch Exec Source
1 /* BEGIN software license
2 *
3 * MsXpertSuite - mass spectrometry software suite
4 * -----------------------------------------------
5 * Copyright (C) 2009--2020 Filippo Rusconi
6 *
7 * http://www.msxpertsuite.org
8 *
9 * This file is part of the MsXpertSuite project.
10 *
11 * The MsXpertSuite project is the successor of the massXpert project. This
12 * project now includes various independent modules:
13 *
14 * - massXpert, model polymer chemistries and simulate mass spectrometric data;
15 * - mineXpert, a powerful TIC chromatogram/mass spectrum viewer/miner;
16 *
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *
30 * END software license
31 */
32
33
34 /////////////////////// Qt includes
35 #include <QDebug>
36
37
38 /////////////////////// IsoSpec
39 #include <IsoSpec++/isoSpec++.h>
40 #include <IsoSpec++/element_tables.h>
41
42
43 /////////////////////// Local includes
44 #include "MsXpS/libXpertMassCore/globals.hpp"
45 #include "MsXpS/libXpertMassCore/IsotopicDataBaseHandler.hpp"
46
47
48 namespace MsXpS
49 {
50
51 namespace libXpertMassCore
52 {
53
54 /*!
55 \class MsXpS::libXpertMassCore::IsotopicDataBaseHandler
56 \inmodule libXpertMassCore
57 \ingroup PolChemDefBuildingdBlocks
58 \inheaderfile IsotopicDataBaseHandler.hpp
59
60 \brief The IsotopicDataBaseHandler class features basic handling of
61 \l{IsotopicData}.
62
63 The IsotopicDataBaseHandler class provides the skeleton for derived classes
64 to handle \l{IsotopicData}.
65
66 There are different isotopic data handlers:
67
68 \list
69 \li The \l{IsotopicDataLibraryHandler} that handles isotopic data from the
70 IsoSpec element data tables directly from the library's data. These are the
71 reference, pristine \e{unmodified} isotopic data.
72 \li The \l{IsotopicDataUserConfigHandler} that handles isotopic data with the
73 exact same format of those from the IsoSpec element data tables. However, these
74 data correspond to user-modified isotopic data, \e{not} the reference, pristine
75 \e{unmodified} isotopic data.
76 \li The \l{IsotopicDataManualConfigHandler} that handles user-defined data
77 according to an entirely different format. These data are typically used when
78 the user defines new chemical elements that cannot fit in the IsoSpec element
79 data tables format.
80 \endlist
81
82 \sa IsotopicDataLibraryHandler, IsotopicDataUserConfigHandler,
83 IsotopicDataManualConfigHandler
84 */
85
86 /*!
87 \variable int MsXpS::libXpertMassCore::IsotopicDataBaseHandler::msp_isotopicData
88
89 \brief The msp_isotopicData is a pointer to \l{IsotopicData}.
90 */
91
92 /*!
93 \variable int MsXpS::libXpertMassCore::IsotopicDataBaseHandler::m_fileName
94
95 \brief The m_fileName is the filename in which to store the \l{IsotopicData}
96 for from with to load the \l{IsotopicData}.
97 */
98
99 /*!
100 \brief Constructs the \l{IsotopicDataBaseHandler} with \a file_name.
101
102 The msp_isotopicData is initialized by creating an empty IsotopicData
103 instance.
104 */
105 98 IsotopicDataBaseHandler::IsotopicDataBaseHandler(const QString &file_name)
106
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 75 times.
98 : m_fileName(file_name)
107 {
108 // We cannot allow to have a nullptr msp_isotopicData member.
109
2/4
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
98 msp_isotopicData = std::make_shared<IsotopicData>();
110
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
98 }
111
112 /*!
113 \brief Constructs the \l{IsotopicDataBaseHandler}.
114
115 \a isotopic_data_sp Isotopic data
116
117 \a file_name File name
118 */
119 69 IsotopicDataBaseHandler::IsotopicDataBaseHandler(
120 69 IsotopicDataSPtr isotopic_data_sp, const QString &file_name)
121
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 69 times.
69 : msp_isotopicData(isotopic_data_sp), m_fileName(file_name)
122 {
123 // We cannot allow to have a nullptr msp_isotopicData member.
124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(msp_isotopicData == nullptr)
125 qFatalStream() << "Programming error. The pointer cannot be nullptr.";
126
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
69 }
127
128 /*!
129 \brief Destructs the \l{IsotopicDataBaseHandler}.
130 */
131 340 IsotopicDataBaseHandler::~IsotopicDataBaseHandler()
132 {
133 // qDebug();
134
1/2
✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
340 }
135
136 /*!
137 \brief Returns the IsotopicData
138 */
139 IsotopicDataSPtr
140 106 IsotopicDataBaseHandler::getIsotopicData()
141 {
142 106 return msp_isotopicData;
143 }
144
145 /*!
146 \brief Sets the file name to \a file_name
147 */
148 void
149 24 IsotopicDataBaseHandler::setFileName(const QString &file_name)
150 {
151 24 m_fileName = file_name;
152 24 }
153
154 /*!
155 \brief Returns the file name
156 */
157 QString
158 10 IsotopicDataBaseHandler::getFileName()
159 {
160
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 return m_fileName;
161 }
162
163
164 } // namespace libXpertMassCore
165 } // namespace MsXpS
166