Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

Peak2D.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Stephan Aiche$
00032 // $Authors: Marc Sturm $
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 } // namespace OpenMS
00364 
00365 #endif // OPENMS_KERNEL_PEAK2D_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:43 using doxygen 1.7.1