Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_KERNEL_PEAK2D_H
00036 #define OPENMS_KERNEL_PEAK2D_H
00037
00038 #include <OpenMS/CONCEPT/Types.h>
00039 #include <OpenMS/DATASTRUCTURES/DPosition.h>
00040
00041 #include <ostream>
00042 #include <functional>
00043
00044 namespace OpenMS
00045 {
00046
00055 class OPENMS_DLLAPI Peak2D
00056 {
00057 public:
00058
00061
00063 typedef Real IntensityType;
00065 typedef DoubleReal CoordinateType;
00067 typedef DPosition<2> PositionType;
00069
00072
00074 enum DimensionDescription
00075 {
00076 RT = 0,
00077 MZ = 1,
00078 DIMENSION = 2
00079 };
00080
00082 static char const * shortDimensionName(UInt const dim);
00084 static char const * shortDimensionNameRT();
00086 static char const * shortDimensionNameMZ();
00087
00089 static char const * fullDimensionName(UInt const dim);
00091 static char const * fullDimensionNameRT();
00093 static char const * fullDimensionNameMZ();
00094
00096 static char const * shortDimensionUnit(UInt const dim);
00098 static char const * shortDimensionUnitRT();
00100 static char const * shortDimensionUnitMZ();
00101
00103 static char const * fullDimensionUnit(UInt const dim);
00105 static char const * fullDimensionUnitRT();
00107 static char const * fullDimensionUnitMZ();
00108
00110
00111 protected:
00112
00115
00117 static char const * const dimension_name_short_[DIMENSION];
00118
00120 static char const * const dimension_name_full_[DIMENSION];
00121
00123 static char const * const dimension_unit_short_[DIMENSION];
00124
00126 static char const * const dimension_unit_full_[DIMENSION];
00127
00129
00130 public:
00131
00135 Peak2D() :
00136 position_(),
00137 intensity_(0)
00138 {}
00139
00141 Peak2D(const Peak2D & p) :
00142 position_(p.position_),
00143 intensity_(p.intensity_)
00144 {}
00145
00154 ~Peak2D()
00155 {}
00157
00161 IntensityType getIntensity() const
00162 {
00163 return intensity_;
00164 }
00165
00167 void setIntensity(IntensityType intensity)
00168 {
00169 intensity_ = intensity;
00170 }
00171
00173 PositionType const & getPosition() const
00174 {
00175 return position_;
00176 }
00177
00179 PositionType & getPosition()
00180 {
00181 return position_;
00182 }
00183
00185 void setPosition(const PositionType & position)
00186 {
00187 position_ = position;
00188 }
00189
00191 CoordinateType getMZ() const
00192 {
00193 return position_[MZ];
00194 }
00195
00197 void setMZ(CoordinateType coordinate)
00198 {
00199 position_[MZ] = coordinate;
00200 }
00201
00203 CoordinateType getRT() const
00204 {
00205 return position_[RT];
00206 }
00207
00209 void setRT(CoordinateType coordinate)
00210 {
00211 position_[RT] = coordinate;
00212 }
00213
00215
00217 Peak2D & operator=(const Peak2D & rhs)
00218 {
00219 if (this == &rhs) return *this;
00220
00221 intensity_ = rhs.intensity_;
00222 position_ = rhs.position_;
00223
00224 return *this;
00225 }
00226
00228 bool operator==(const Peak2D & rhs) const
00229 {
00230 return intensity_ == rhs.intensity_ && position_ == rhs.position_;
00231 }
00232
00234 bool operator!=(const Peak2D & rhs) const
00235 {
00236 return !(operator==(rhs));
00237 }
00238
00244
00245
00246 struct IntensityLess :
00247 std::binary_function<Peak2D, Peak2D, bool>
00248 {
00249 bool operator()(const Peak2D & left, const Peak2D & right) const
00250 {
00251 return left.getIntensity() < right.getIntensity();
00252 }
00253
00254 bool operator()(const Peak2D & left, IntensityType right) const
00255 {
00256 return left.getIntensity() < right;
00257 }
00258
00259 bool operator()(IntensityType left, const Peak2D & right) const
00260 {
00261 return left < right.getIntensity();
00262 }
00263
00264 bool operator()(IntensityType left, IntensityType right) const
00265 {
00266 return left < right;
00267 }
00268
00269 };
00270
00272 struct RTLess :
00273 std::binary_function<Peak2D, Peak2D, bool>
00274 {
00275 bool operator()(const Peak2D & left, const Peak2D & right) const
00276 {
00277 return left.getRT() < right.getRT();
00278 }
00279
00280 bool operator()(const Peak2D & left, CoordinateType right) const
00281 {
00282 return left.getRT() < right;
00283 }
00284
00285 bool operator()(CoordinateType left, const Peak2D & right) const
00286 {
00287 return left < right.getRT();
00288 }
00289
00290 bool operator()(CoordinateType left, CoordinateType right) const
00291 {
00292 return left < right;
00293 }
00294
00295 };
00296
00298 struct MZLess :
00299 std::binary_function<Peak2D, Peak2D, bool>
00300 {
00301 bool operator()(const Peak2D & left, const Peak2D & right) const
00302 {
00303 return left.getMZ() < right.getMZ();
00304 }
00305
00306 bool operator()(const Peak2D & left, CoordinateType right) const
00307 {
00308 return left.getMZ() < right;
00309 }
00310
00311 bool operator()(CoordinateType left, const Peak2D & right) const
00312 {
00313 return left < right.getMZ();
00314 }
00315
00316 bool operator()(CoordinateType left, CoordinateType right) const
00317 {
00318 return left < right;
00319 }
00320
00321 };
00322
00324 struct PositionLess :
00325 public std::binary_function<Peak2D, Peak2D, bool>
00326 {
00327 bool operator()(const Peak2D & left, const Peak2D & right) const
00328 {
00329 return left.getPosition() < right.getPosition();
00330 }
00331
00332 bool operator()(const Peak2D & left, const PositionType & right) const
00333 {
00334 return left.getPosition() < right;
00335 }
00336
00337 bool operator()(const PositionType & left, const Peak2D & right) const
00338 {
00339 return left < right.getPosition();
00340 }
00341
00342 bool operator()(const PositionType & left, const PositionType & right) const
00343 {
00344 return left < right;
00345 }
00346
00347 };
00349
00350 friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
00351
00352 protected:
00353
00355 PositionType position_;
00357 IntensityType intensity_;
00358 };
00359
00361 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
00362
00363 }
00364
00365 #endif // OPENMS_KERNEL_PEAK2D_H