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

Peak1D.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_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 } // namespace OpenMS
00269 
00270 #endif // OPENMS_KERNEL_PEAK1D_H

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