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

DRawDataPoint.h (Maintainer: Marc Sturm)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Marc Sturm $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_KERNEL_DRAWDATAPOINT_H
00028 #define OPENMS_KERNEL_DRAWDATAPOINT_H
00029 
00030 #include <OpenMS/DATASTRUCTURES/DPosition.h>
00031 
00032 #include <sstream>
00033 
00034 namespace OpenMS
00035 {
00036   
00045   template <UInt D>
00046   class DRawDataPoint
00047   {
00048     public:
00049       
00053       
00055       enum
00056       {
00057         DIMENSION = D
00058       };
00059       
00061       typedef Real IntensityType;
00062       
00064       typedef DoubleReal CoordinateType;
00065       
00067       typedef DPosition<D> PositionType;
00068       
00070       
00074 
00075       DRawDataPoint() : position_(), intensity_(0)
00076       {}
00078       DRawDataPoint(const DRawDataPoint& p)
00079       : position_(p.position_), intensity_(p.intensity_)
00080       {}
00089       ~DRawDataPoint()
00090       {}
00092       
00097       
00099       IntensityType getIntensity() const
00100       { return intensity_; }
00101       
00103       void setIntensity(IntensityType intensity)
00104       { intensity_ = intensity; }
00105       
00107       const PositionType& getPosition() const
00108       { return position_; }
00109       
00111       PositionType& getPosition()
00112       { return position_; }
00113       
00115       void setPosition(PositionType const& position)
00116       { position_ = position; }
00117       
00119       
00121       DRawDataPoint& operator = (const DRawDataPoint& rhs)
00122       {
00123         if (this==&rhs) return *this;
00124         
00125         intensity_ = rhs.intensity_;
00126         position_ = rhs.position_;
00127         
00128         return *this;
00129       }
00130       
00132       bool operator == (const DRawDataPoint& rhs) const
00133       {
00134         return  intensity_ == rhs.intensity_ && position_ == rhs.position_ ;
00135       }
00136       
00138       bool operator != (const DRawDataPoint& rhs) const
00139       {
00140         return !( operator==(rhs) );
00141       }
00142       
00143       
00150       
00152       struct IntensityLess
00153       : std::binary_function < DRawDataPoint, DRawDataPoint, bool >
00154       {
00155         inline bool operator () ( DRawDataPoint const & left, DRawDataPoint const & right ) const
00156         {
00157           return ( left.getIntensity() < right.getIntensity() );
00158         }
00159         inline bool operator () ( DRawDataPoint const & left, IntensityType const & right ) const
00160         {
00161           return ( left.getIntensity() < right );
00162         }
00163         inline bool operator () ( IntensityType const & left, DRawDataPoint const & right ) const
00164         {
00165           return ( left< right.getIntensity() );
00166         }
00167         inline bool operator () ( IntensityType const & left, IntensityType const & right ) const
00168         {
00169           return ( left < right );
00170         }
00171       };
00172       
00176       template <UInt i>
00177       struct NthPositionLess
00178       : std::binary_function <DRawDataPoint, DRawDataPoint, bool>
00179       {
00180         enum
00181         { DIMENSION = i };
00182         
00184         inline bool operator () ( DRawDataPoint const & left, DRawDataPoint const & right ) const throw()
00185         {
00186           return (left.getPosition()[i] < right.getPosition()[i]);
00187         }
00188         
00190         inline bool operator () ( DRawDataPoint const & left, CoordinateType right ) const throw()
00191         {
00192           return (left.getPosition()[i] < right );
00193         }
00194         
00196         inline bool operator () ( CoordinateType left, DRawDataPoint const & right ) const throw()
00197         {
00198           return (left < right.getPosition()[i] );
00199         }
00200         
00207         inline bool operator () ( CoordinateType left, CoordinateType right ) const throw()
00208         {
00209           return (left < right );
00210         }
00211         
00212       };
00213       
00219       struct PositionLess
00220       : public std::binary_function <DRawDataPoint, DRawDataPoint, bool>
00221       {
00222         inline bool operator () (const DRawDataPoint& a, const DRawDataPoint& b) const
00223         {
00224           return (a.getPosition() < b.getPosition());
00225         }
00226       };
00227       
00229       
00230       protected:
00232         PositionType  position_;
00234         IntensityType intensity_;
00235   };
00236   
00238   template <UInt D>
00239   std::ostream& operator << (std::ostream& os, const DRawDataPoint<D>& point)
00240   {
00241     os << "POS: "<< point.getPosition() << " INT: "<<point.getIntensity();
00242     
00243     return os;
00244   }
00245   
00246 } // namespace OpenMS
00247 
00248 #endif // OPENMS_KERNEL_DRAWDATAPOINT_H

Generated Tue Apr 1 15:36:33 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1