Line |
Branch |
Exec |
Source |
1 |
|
|
/* BEGIN software license |
2 |
|
|
* |
3 |
|
|
* MsXpertSuite - mass spectrometry software suite |
4 |
|
|
* ----------------------------------------------- |
5 |
|
|
* Copyright(C) 2009,...,2018 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 |
|
|
/////////////////////// Local includes |
35 |
|
|
#include "PolChemDefEntity.hpp" |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
namespace MsXpS |
39 |
|
|
{ |
40 |
|
|
|
41 |
|
|
namespace libXpertMass |
42 |
|
|
{ |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
/*! |
46 |
|
|
\class MsXpS::libXpertMass::PolChemDefEntity |
47 |
|
|
\inmodule libXpertMass |
48 |
|
|
\ingroup PolChemDef |
49 |
|
|
\inheaderfile PolChemDefEntity.hpp |
50 |
|
|
|
51 |
|
|
\brief The PolChemDefEntity class describes a chemical entity that belongs to a |
52 |
|
|
specific \l PolChemDef polymer chemistry definition. |
53 |
|
|
*/ |
54 |
|
|
|
55 |
|
|
/*! |
56 |
|
|
\variable MsXpS::libXpertMass::PolChemDefEntity::m_name |
57 |
|
|
|
58 |
|
|
\brief The name of the chemical entity. |
59 |
|
|
*/ |
60 |
|
|
|
61 |
|
|
/*! |
62 |
|
|
\variable MsXpS::libXpertMass::PolChemDefEntity::mcsp_polChemDef |
63 |
|
|
|
64 |
|
|
\brief The polymer chemistry definition that is the context of this |
65 |
|
|
chemical entity. |
66 |
|
|
*/ |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
/*! Constructs a polymer chemistry definition entity. |
70 |
|
|
|
71 |
|
|
\a pol_chem_def_csp reference polymer chemistry definition. This pointer |
72 |
|
|
cannot be nullptr. |
73 |
|
|
|
74 |
|
|
\a name name of the entity. |
75 |
|
|
*/ |
76 |
|
62328 |
PolChemDefEntity::PolChemDefEntity(PolChemDefCstSPtr pol_chem_def_csp, |
77 |
|
62328 |
const QString &name) |
78 |
|
|
{ |
79 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62328 times.
|
62328 |
Q_ASSERT(pol_chem_def_csp); |
80 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62328 times.
|
62328 |
Q_ASSERT(pol_chem_def_csp.get()); |
81 |
|
|
|
82 |
|
62328 |
mcsp_polChemDef = pol_chem_def_csp; |
83 |
|
|
|
84 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62328 times.
|
62328 |
Q_ASSERT(!name.isEmpty()); |
85 |
|
62328 |
m_name = name; |
86 |
|
62328 |
} |
87 |
|
|
|
88 |
|
|
|
89 |
|
|
/*! Constructs a PolChemDefEntity instance as a copy of \a other. |
90 |
|
|
*/ |
91 |
|
2192 |
PolChemDefEntity::PolChemDefEntity(const PolChemDefEntity &other) |
92 |
|
2192 |
: mcsp_polChemDef(other.mcsp_polChemDef), m_name(other.m_name) |
93 |
|
|
{ |
94 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2192 times.
|
2192 |
if(mcsp_polChemDef == nullptr) |
95 |
|
✗ |
qFatal("Programming error. The pointer cannot be nullptr."); |
96 |
|
|
|
97 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2192 times.
|
2192 |
if(m_name.isEmpty()) |
98 |
|
✗ |
qFatal( |
99 |
|
|
"Programming error. The polymer chemistry entity cannot have an empty " |
100 |
|
|
"name."); |
101 |
|
2192 |
} |
102 |
|
|
|
103 |
|
|
/*! |
104 |
|
|
\brief Destructs this PolChemDefEntity instance. |
105 |
|
|
*/ |
106 |
|
66296 |
PolChemDefEntity::~PolChemDefEntity() |
107 |
|
|
{ |
108 |
|
66296 |
} |
109 |
|
|
|
110 |
|
|
/*! |
111 |
|
|
\brief Assigns \a other to this PolChemDef instance. |
112 |
|
|
|
113 |
|
|
Returns a reference to this PolChemDef instance |
114 |
|
|
*/ |
115 |
|
|
PolChemDefEntity & |
116 |
|
30516 |
PolChemDefEntity::operator=(const PolChemDefEntity &other) |
117 |
|
|
{ |
118 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30516 times.
|
30516 |
if(&other == this) |
119 |
|
✗ |
return *this; |
120 |
|
|
|
121 |
|
30516 |
mcsp_polChemDef = other.mcsp_polChemDef; |
122 |
|
30516 |
m_name = other.m_name; |
123 |
|
|
|
124 |
|
30516 |
return *this; |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
|
128 |
|
|
/*! |
129 |
|
|
\brief Sets the \a name. |
130 |
|
|
*/ |
131 |
|
|
void |
132 |
|
16 |
PolChemDefEntity::setName(const QString &name) |
133 |
|
|
{ |
134 |
|
16 |
m_name = name; |
135 |
|
16 |
} |
136 |
|
|
|
137 |
|
|
|
138 |
|
|
/*! |
139 |
|
|
\brief Returns the name. |
140 |
|
|
*/ |
141 |
|
|
QString |
142 |
|
163116 |
PolChemDefEntity::name() const |
143 |
|
|
{ |
144 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 163116 times.
|
163116 |
Q_ASSERT(!m_name.isEmpty()); |
145 |
|
163116 |
return m_name; |
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
|
149 |
|
|
/*! |
150 |
|
|
\brief Sets this PolChemDefEntity's \a pol_chem_def_csp. |
151 |
|
|
*/ |
152 |
|
|
void |
153 |
|
✗ |
PolChemDefEntity::setPolChemDefCstSPtr(PolChemDefCstSPtr pol_chem_def_csp) |
154 |
|
|
{ |
155 |
|
✗ |
mcsp_polChemDef = pol_chem_def_csp; |
156 |
|
✗ |
} |
157 |
|
|
|
158 |
|
|
|
159 |
|
|
/*! |
160 |
|
|
\brief Returns the polymer chemistry definition. |
161 |
|
|
*/ |
162 |
|
|
PolChemDefCstSPtr |
163 |
|
240 |
PolChemDefEntity::getPolChemDefCstSPtr() const |
164 |
|
|
{ |
165 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 240 times.
|
240 |
Q_ASSERT(mcsp_polChemDef); |
166 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 240 times.
|
240 |
Q_ASSERT(mcsp_polChemDef.get()); |
167 |
|
240 |
return mcsp_polChemDef; |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
/*! |
171 |
|
|
\brief Returns true if \c this PolChemDefEntity instance and \a other are |
172 |
|
|
identical, false otherwise. |
173 |
|
|
*/ |
174 |
|
|
bool |
175 |
|
2656 |
PolChemDefEntity::operator==(const PolChemDefEntity &other) const |
176 |
|
|
{ |
177 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2656 times.
|
2656 |
if(this == &other) |
178 |
|
✗ |
return true; |
179 |
|
|
|
180 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2656 times.
|
2656 |
if(mcsp_polChemDef != other.mcsp_polChemDef) |
181 |
|
✗ |
return false; |
182 |
|
|
|
183 |
|
|
|
184 |
2/2
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 2640 times.
|
2656 |
if(m_name != other.m_name) |
185 |
|
16 |
return false; |
186 |
|
|
|
187 |
|
2640 |
return true; |
188 |
|
|
} |
189 |
|
|
|
190 |
|
|
/*! Returns true if \c this PolChemDefEntity instance and \a other differ, false |
191 |
|
|
otherwise. |
192 |
|
|
|
193 |
|
|
Returns the negation of operator==(other). |
194 |
|
|
*/ |
195 |
|
|
bool |
196 |
|
2656 |
PolChemDefEntity::operator!=(const PolChemDefEntity &other) const |
197 |
|
|
{ |
198 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2656 times.
|
2656 |
if(this == &other) |
199 |
|
✗ |
return false; |
200 |
|
|
|
201 |
|
2656 |
return !operator==(other); |
202 |
|
|
} |
203 |
|
|
|
204 |
|
|
/*! |
205 |
|
|
\brief Returns true if this PolChemDef instance validates successfully, false |
206 |
|
|
otherwise. |
207 |
|
|
|
208 |
|
|
The name cannot be empty and the polymer chemistry definition cannot be nullptr. |
209 |
|
|
*/ |
210 |
|
|
bool |
211 |
|
8 |
PolChemDefEntity::validate() const |
212 |
|
|
{ |
213 |
3/6
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8 times.
|
8 |
if(m_name.isNull() || m_name.isEmpty()) |
214 |
|
✗ |
return false; |
215 |
|
|
|
216 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 |
if(mcsp_polChemDef == nullptr) |
217 |
|
✗ |
return false; |
218 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 |
if(mcsp_polChemDef.get() == nullptr) |
219 |
|
✗ |
return false; |
220 |
|
|
|
221 |
|
8 |
return true; |
222 |
|
|
} |
223 |
|
|
|
224 |
|
|
} // namespace libXpertMass |
225 |
|
|
|
226 |
|
|
} // namespace MsXpS |
227 |
|
|
|