1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1
// --------------------------------------------------------------------------
2
// OpenMS -- Open-Source Mass Spectrometry
3
// --------------------------------------------------------------------------
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
7
// This software is released under a three-clause BSD license:
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright
11
// notice, this list of conditions and the following disclaimer in the
12
// documentation and/or other materials provided with the distribution.
13
// * Neither the name of any author or any participating institution
14
// may be used to endorse or promote products derived from this software
15
// without specific prior written permission.
16
// For a full list of authors, refer to the file AUTHORS.
17
// --------------------------------------------------------------------------
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Stephan Aiche$
87
93
static char const * fullDimensionNameMZ();
89
95
/// Unit of measurement (abbreviated form)
90
static char const * shortDimensionUnit(UInt const dim);
91
/// Unit of measurement (abbreviated form)
92
static char const * shortDimensionUnitRT();
93
/// Unit of measurement (abbreviated form)
94
static char const * shortDimensionUnitMZ();
96
/// Unit of measurement (self-explanatory form)
97
static char const * fullDimensionUnit(UInt const dim);
98
/// Unit of measurement (self-explanatory form)
99
static char const * fullDimensionUnitRT();
100
/// Unit of measurement (self-explanatory form)
101
static char const * fullDimensionUnitMZ();
107
/// @name Dimension descriptions
96
static char const * shortDimensionUnit(UInt const dim);
97
/// Unit of measurement (abbreviated form)
98
static char const * shortDimensionUnitRT();
99
/// Unit of measurement (abbreviated form)
100
static char const * shortDimensionUnitMZ();
102
/// Unit of measurement (self-explanatory form)
103
static char const * fullDimensionUnit(UInt const dim);
104
/// Unit of measurement (self-explanatory form)
105
static char const * fullDimensionUnitRT();
106
/// Unit of measurement (self-explanatory form)
107
static char const * fullDimensionUnitMZ();
113
/// @name Dimension descriptions
110
116
/// Short name of the dimension (abbreviated form)
111
static char const * const dimension_name_short_[DIMENSION];
117
static char const * const dimension_name_short_[DIMENSION];
113
119
/// Full name of the dimension (self-explanatory form)
114
120
static char const * const dimension_name_full_[DIMENSION];
116
122
/// Unit of measurement (abbreviated form)
117
123
static char const * const dimension_unit_short_[DIMENSION];
119
125
/// Unit of measurement (self-explanatory form)
120
126
static char const * const dimension_unit_full_[DIMENSION];
126
/** @name Constructors and Destructor
129
/// Default constructor
136
Peak2D(const Peak2D& p)
137
: position_(p.position_),
138
intensity_(p.intensity_)
144
@note The destructor is non-virtual although many classes are derived from
145
Peak2D. This is intentional, since otherwise we would "waste"
146
space for a vtable pointer in each instance. Normally you should not derive other classes from
147
Peak2D (unless you know what you are doing, of course).
158
/// Non-mutable access to the data point intensity (height)
159
IntensityType getIntensity() const
164
/// Non-mutable access to the data point intensity (height)
165
void setIntensity(IntensityType intensity)
167
intensity_ = intensity;
170
/// Non-mutable access to the position
171
PositionType const & getPosition() const
175
/// Mutable access to the position
176
PositionType& getPosition()
180
/// Mutable access to the position
181
void setPosition(const PositionType& position)
183
position_ = position;
132
///@name Constructors and Destructor
134
/// Default constructor
141
Peak2D(const Peak2D & p) :
142
position_(p.position_),
143
intensity_(p.intensity_)
149
@note The destructor is non-virtual although many classes are derived from
150
Peak2D. This is intentional, since otherwise we would "waste"
151
space for a vtable pointer in each instance. Normally you should not derive other classes from
152
Peak2D (unless you know what you are doing, of course).
160
/// Non-mutable access to the data point intensity (height)
161
IntensityType getIntensity() const
166
/// Non-mutable access to the data point intensity (height)
167
void setIntensity(IntensityType intensity)
169
intensity_ = intensity;
172
/// Non-mutable access to the position
173
PositionType const & getPosition() const
178
/// Mutable access to the position
179
PositionType & getPosition()
184
/// Mutable access to the position
185
void setPosition(const PositionType & position)
187
position_ = position;
186
190
/// Returns the m/z coordinate (index 1)
187
CoordinateType getMZ() const
189
return position_[MZ];
191
CoordinateType getMZ() const
193
return position_[MZ];
191
196
/// Mutable access to the m/z coordinate (index 1)
192
void setMZ(CoordinateType coordinate)
194
position_[MZ] = coordinate;
197
void setMZ(CoordinateType coordinate)
199
position_[MZ] = coordinate;
197
202
/// Returns the RT coordinate (index 0)
198
CoordinateType getRT() const
200
return position_[RT];
203
CoordinateType getRT() const
205
return position_[RT];
202
208
/// Mutable access to the RT coordinate (index 0)
203
void setRT(CoordinateType coordinate)
205
position_[RT] = coordinate;
210
/// Assignment operator
211
Peak2D& operator = (const Peak2D& rhs)
213
if (this==&rhs) return *this;
215
intensity_ = rhs.intensity_;
216
position_ = rhs.position_;
221
/// Equality operator
222
bool operator == (const Peak2D& rhs) const
224
return intensity_ == rhs.intensity_ && position_ == rhs.position_ ;
227
/// Equality operator
228
bool operator != (const Peak2D& rhs) const
230
return !( operator==(rhs) );
234
/** @name Comparator classes.
235
These classes implement binary predicates that can be used
236
to compare two peaks with respect to their intensities, positions, etc.
239
/// Comparator by intensity
241
: std::binary_function < Peak2D, Peak2D, bool >
243
bool operator () ( const Peak2D& left, const Peak2D& right ) const
245
return ( left.getIntensity() < right.getIntensity() );
247
bool operator () ( const Peak2D& left, IntensityType right ) const
249
return ( left.getIntensity() < right );
251
bool operator () ( IntensityType left, const Peak2D& right ) const
253
return ( left< right.getIntensity() );
255
bool operator () ( IntensityType left, IntensityType right ) const
257
return ( left < right );
261
/// Comparator by RT position
263
: std::binary_function <Peak2D, Peak2D, bool>
265
bool operator () (const Peak2D& left, const Peak2D& right ) const
267
return (left.getRT() < right.getRT());
269
bool operator () ( const Peak2D& left, CoordinateType right ) const
271
return (left.getRT() < right );
273
bool operator () ( CoordinateType left, const Peak2D& right ) const
275
return (left < right.getRT() );
277
bool operator () ( CoordinateType left, CoordinateType right ) const
279
return (left < right );
283
/// Comparator by m/z position
285
: std::binary_function <Peak2D, Peak2D, bool>
287
bool operator () ( const Peak2D& left, const Peak2D& right ) const
289
return (left.getMZ() < right.getMZ());
291
bool operator () ( const Peak2D& left, CoordinateType right ) const
293
return (left.getMZ() < right );
295
bool operator () ( CoordinateType left, const Peak2D& right ) const
297
return (left < right.getMZ() );
299
bool operator () ( CoordinateType left, CoordinateType right ) const
301
return (left < right );
304
/// Comparator by position. Lexicographical comparison (first RT then m/z) is done.
306
: public std::binary_function <Peak2D, Peak2D, bool>
308
bool operator () ( const Peak2D& left, const Peak2D& right) const
310
return (left.getPosition() < right.getPosition());
312
bool operator () ( const Peak2D& left, const PositionType& right ) const
314
return (left.getPosition() < right );
316
bool operator () ( const PositionType& left, const Peak2D& right ) const
318
return (left < right.getPosition() );
320
bool operator () ( const PositionType& left, const PositionType& right ) const
322
return (left < right );
327
friend OPENMS_DLLAPI std::ostream& operator << (std::ostream& os, const Peak2D& point);
331
/// The data point position
332
PositionType position_;
333
/// The data point intensity
334
IntensityType intensity_;
337
///Print the contents to a stream.
338
OPENMS_DLLAPI std::ostream& operator << (std::ostream& os, const Peak2D& point);
209
void setRT(CoordinateType coordinate)
211
position_[RT] = coordinate;
216
/// Assignment operator
217
Peak2D & operator=(const Peak2D & rhs)
219
if (this == &rhs) return *this;
221
intensity_ = rhs.intensity_;
222
position_ = rhs.position_;
227
/// Equality operator
228
bool operator==(const Peak2D & rhs) const
230
return intensity_ == rhs.intensity_ && position_ == rhs.position_;
233
/// Equality operator
234
bool operator!=(const Peak2D & rhs) const
236
return !(operator==(rhs));
240
@name Comparator classes.
241
These classes implement binary predicates that can be used
242
to compare two peaks with respect to their intensities, positions, etc.
245
/// Comparator by intensity
246
struct IntensityLess :
247
std::binary_function<Peak2D, Peak2D, bool>
249
bool operator()(const Peak2D & left, const Peak2D & right) const
251
return left.getIntensity() < right.getIntensity();
254
bool operator()(const Peak2D & left, IntensityType right) const
256
return left.getIntensity() < right;
259
bool operator()(IntensityType left, const Peak2D & right) const
261
return left < right.getIntensity();
264
bool operator()(IntensityType left, IntensityType right) const
271
/// Comparator by RT position
273
std::binary_function<Peak2D, Peak2D, bool>
275
bool operator()(const Peak2D & left, const Peak2D & right) const
277
return left.getRT() < right.getRT();
280
bool operator()(const Peak2D & left, CoordinateType right) const
282
return left.getRT() < right;
285
bool operator()(CoordinateType left, const Peak2D & right) const
287
return left < right.getRT();
290
bool operator()(CoordinateType left, CoordinateType right) const
297
/// Comparator by m/z position
299
std::binary_function<Peak2D, Peak2D, bool>
301
bool operator()(const Peak2D & left, const Peak2D & right) const
303
return left.getMZ() < right.getMZ();
306
bool operator()(const Peak2D & left, CoordinateType right) const
308
return left.getMZ() < right;
311
bool operator()(CoordinateType left, const Peak2D & right) const
313
return left < right.getMZ();
316
bool operator()(CoordinateType left, CoordinateType right) const
323
/// Comparator by position. Lexicographical comparison (first RT then m/z) is done.
324
struct PositionLess :
325
public std::binary_function<Peak2D, Peak2D, bool>
327
bool operator()(const Peak2D & left, const Peak2D & right) const
329
return left.getPosition() < right.getPosition();
332
bool operator()(const Peak2D & left, const PositionType & right) const
334
return left.getPosition() < right;
337
bool operator()(const PositionType & left, const Peak2D & right) const
339
return left < right.getPosition();
342
bool operator()(const PositionType & left, const PositionType & right) const
350
friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
354
/// The data point position
355
PositionType position_;
356
/// The data point intensity
357
IntensityType intensity_;
360
/// Print the contents to a stream.
361
OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
340
363
} // namespace OpenMS