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_PEAK1D_H
00036 #define OPENMS_KERNEL_PEAK1D_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 Peak1D
00056 {
00057 public:
00058
00062 enum {DIMENSION = 1};
00064 typedef Real IntensityType;
00066 typedef DPosition<1> PositionType;
00068 typedef DoubleReal CoordinateType;
00070
00074 inline Peak1D() :
00075 position_(),
00076 intensity_(0)
00077 {}
00078
00080 inline Peak1D(const Peak1D & p) :
00081 position_(p.position_),
00082 intensity_(p.intensity_)
00083 {}
00084
00093 ~Peak1D()
00094 {}
00095
00097
00101
00102
00103 inline IntensityType getIntensity() const { return intensity_; }
00105 inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
00106
00108 inline CoordinateType getMZ() const
00109 {
00110 return position_[0];
00111 }
00112
00114 inline void setMZ(CoordinateType mz)
00115 {
00116 position_[0] = mz;
00117 }
00118
00120 inline CoordinateType getPos() const
00121 {
00122 return position_[0];
00123 }
00124
00126 inline void setPos(CoordinateType pos)
00127 {
00128 position_[0] = pos;
00129 }
00130
00132 inline PositionType const & getPosition() const
00133 {
00134 return position_;
00135 }
00136
00138 inline PositionType & getPosition()
00139 {
00140 return position_;
00141 }
00142
00144 inline void setPosition(PositionType const & position)
00145 {
00146 position_ = position;
00147 }
00148
00150
00152 inline Peak1D & operator=(const Peak1D & rhs)
00153 {
00154 if (this == &rhs) return *this;
00155
00156 intensity_ = rhs.intensity_;
00157 position_ = rhs.position_;
00158
00159 return *this;
00160 }
00161
00163 inline bool operator==(const Peak1D & rhs) const
00164 {
00165 return intensity_ == rhs.intensity_ && position_ == rhs.position_;
00166 }
00167
00169 inline bool operator!=(const Peak1D & rhs) const
00170 {
00171 return !(operator==(rhs));
00172 }
00173
00178
00179
00180 struct IntensityLess :
00181 std::binary_function<Peak1D, Peak1D, bool>
00182 {
00183 inline bool operator()(Peak1D const & left, Peak1D const & right) const
00184 {
00185 return left.getIntensity() < right.getIntensity();
00186 }
00187
00188 inline bool operator()(Peak1D const & left, IntensityType right) const
00189 {
00190 return left.getIntensity() < right;
00191 }
00192
00193 inline bool operator()(IntensityType left, Peak1D const & right) const
00194 {
00195 return left < right.getIntensity();
00196 }
00197
00198 inline bool operator()(IntensityType left, IntensityType right) const
00199 {
00200 return left < right;
00201 }
00202
00203 };
00204
00206 struct MZLess :
00207 public std::binary_function<Peak1D, Peak1D, bool>
00208 {
00209 inline bool operator()(const Peak1D & left, const Peak1D & right) const
00210 {
00211 return left.getMZ() < right.getMZ();
00212 }
00213
00214 inline bool operator()(Peak1D const & left, CoordinateType right) const
00215 {
00216 return left.getMZ() < right;
00217 }
00218
00219 inline bool operator()(CoordinateType left, Peak1D const & right) const
00220 {
00221 return left < right.getMZ();
00222 }
00223
00224 inline bool operator()(CoordinateType left, CoordinateType right) const
00225 {
00226 return left < right;
00227 }
00228
00229 };
00230
00232 struct PositionLess :
00233 public std::binary_function<Peak1D, Peak1D, bool>
00234 {
00235 inline bool operator()(const Peak1D & left, const Peak1D & right) const
00236 {
00237 return left.getPosition() < right.getPosition();
00238 }
00239
00240 inline bool operator()(const Peak1D & left, const PositionType & right) const
00241 {
00242 return left.getPosition() < right;
00243 }
00244
00245 inline bool operator()(const PositionType & left, const Peak1D & right) const
00246 {
00247 return left < right.getPosition();
00248 }
00249
00250 inline bool operator()(const PositionType & left, const PositionType & right) const
00251 {
00252 return left < right;
00253 }
00254
00255 };
00257
00258 protected:
00260 PositionType position_;
00262 IntensityType intensity_;
00263 };
00264
00266 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
00267
00268 }
00269
00270 #endif // OPENMS_KERNEL_PEAK1D_H