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 #ifndef OPENMS_KERNEL_RAWDATAPOINT2D_H
00028 #define OPENMS_KERNEL_RAWDATAPOINT2D_H
00029
00030 #include <OpenMS/CONCEPT/Types.h>
00031 #include <OpenMS/DATASTRUCTURES/DPosition.h>
00032
00033 #include <ostream>
00034 #include <functional>
00035
00036 namespace OpenMS
00037 {
00038
00047 class RawDataPoint2D
00048 {
00049 public:
00050
00054
00056 typedef Real IntensityType;
00058 typedef DoubleReal CoordinateType;
00060 typedef DPosition<2> PositionType;
00062
00064
00065
00067 enum DimensionDescription
00068 {
00069 RT = 0,
00070 MZ = 1,
00071 DIMENSION = 2
00072 };
00073
00075 static char const * shortDimensionName(UInt const dim);
00077 static char const * shortDimensionNameRT();
00079 static char const * shortDimensionNameMZ();
00080
00082 static char const * fullDimensionName(UInt const dim);
00084 static char const * fullDimensionNameRT();
00086 static char const * fullDimensionNameMZ();
00087
00089 static char const * shortDimensionUnit(UInt const dim);
00091 static char const * shortDimensionUnitRT();
00093 static char const * shortDimensionUnitMZ();
00094
00096 static char const * fullDimensionUnit(UInt const dim);
00098 static char const * fullDimensionUnitRT();
00100 static char const * fullDimensionUnitMZ();
00101
00102 protected:
00104 static char const * const dimension_name_short_[DIMENSION];
00105
00107 static char const * const dimension_name_full_[DIMENSION];
00108
00110 static char const * const dimension_unit_short_[DIMENSION];
00111
00113 static char const * const dimension_unit_full_[DIMENSION];
00114
00116
00117 public:
00118
00122
00123 inline RawDataPoint2D()
00124 : position_(),
00125 intensity_(0)
00126 {
00127 }
00129 inline RawDataPoint2D(const RawDataPoint2D& p)
00130 : position_(p.position_),
00131 intensity_(p.intensity_)
00132 {
00133 }
00134
00143 ~RawDataPoint2D()
00144 {
00145 }
00147
00152
00153 inline IntensityType getIntensity() const { return intensity_; }
00155 inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
00156
00158 inline PositionType const & getPosition() const
00159 {
00160 return position_;
00161 }
00163 inline PositionType& getPosition()
00164 {
00165 return position_;
00166 }
00168 inline void setPosition(const PositionType& position)
00169 {
00170 position_ = position;
00171 }
00172
00174 inline CoordinateType getMZ() const
00175 {
00176 return position_[1];
00177 }
00179 inline void setMZ(CoordinateType coordinate)
00180 {
00181 position_[1] = coordinate;
00182 }
00183
00185 inline CoordinateType getRT() const
00186 {
00187 return position_[0];
00188 }
00190 inline void setRT(CoordinateType coordinate)
00191 {
00192 position_[0] = coordinate;
00193 }
00194
00196
00198 inline RawDataPoint2D& operator = (const RawDataPoint2D& rhs)
00199 {
00200 if (this==&rhs) return *this;
00201
00202 intensity_ = rhs.intensity_;
00203 position_ = rhs.position_;
00204
00205 return *this;
00206 }
00207
00209 inline bool operator == (const RawDataPoint2D& rhs) const
00210 {
00211 return intensity_ == rhs.intensity_ && position_ == rhs.position_ ;
00212 }
00213
00215 inline bool operator != (const RawDataPoint2D& rhs) const
00216 {
00217 return !( operator==(rhs) );
00218 }
00219
00220
00227
00229 struct IntensityLess
00230 : std::binary_function < RawDataPoint2D, RawDataPoint2D, bool >
00231 {
00232 inline bool operator () ( RawDataPoint2D const & left, RawDataPoint2D const & right ) const
00233 {
00234 return ( left.getIntensity() < right.getIntensity() );
00235 }
00236 inline bool operator () ( RawDataPoint2D const & left, IntensityType const & right ) const
00237 {
00238 return ( left.getIntensity() < right );
00239 }
00240 inline bool operator () ( IntensityType const & left, RawDataPoint2D const & right ) const
00241 {
00242 return ( left< right.getIntensity() );
00243 }
00244 inline bool operator () ( IntensityType const & left, IntensityType const & right ) const
00245 {
00246 return ( left < right );
00247 }
00248 };
00249
00253 template <UInt i>
00254 struct NthPositionLess
00255 : std::binary_function <RawDataPoint2D, RawDataPoint2D, bool>
00256 {
00257 enum { DIMENSION = i };
00258
00260 inline bool operator () ( RawDataPoint2D const & left, RawDataPoint2D const & right ) const throw()
00261 {
00262 return (left.getPosition()[i] < right.getPosition()[i]);
00263 }
00264
00266 inline bool operator () ( RawDataPoint2D const & left, CoordinateType right ) const throw()
00267 {
00268 return (left.getPosition()[i] < right );
00269 }
00270
00272 inline bool operator () ( CoordinateType left, RawDataPoint2D const & right ) const throw()
00273 {
00274 return (left < right.getPosition()[i] );
00275 }
00276
00283 inline bool operator () ( CoordinateType left, CoordinateType right ) const throw()
00284 {
00285 return (left < right );
00286 }
00287
00288 };
00289
00291 typedef NthPositionLess < RT > LessRT;
00292
00294 typedef NthPositionLess < MZ > LessMZ;
00295
00296
00302 struct PositionLess
00303 : public std::binary_function <RawDataPoint2D, RawDataPoint2D, bool>
00304 {
00305 inline bool operator () (const RawDataPoint2D& a, const RawDataPoint2D& b) const
00306 {
00307 return (a.getPosition() < b.getPosition());
00308 }
00309 };
00310
00312
00313 protected:
00315 PositionType position_;
00317 IntensityType intensity_;
00318 };
00319
00321 std::ostream& operator << (std::ostream& os, const RawDataPoint2D& point);
00322
00323 }
00324
00325 #endif // OPENMS_KERNEL_RAWDATAPOINT2D_H