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

MSSpectrum.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_MSSPECTRUM_H
00028 #define OPENMS_KERNEL_MSSPECTRUM_H
00029 
00030 #include <OpenMS/KERNEL/DSpectrum.h>
00031 #include <OpenMS/KERNEL/DPeakArray.h>
00032 #include <OpenMS/KERNEL/Peak1D.h>
00033 #include <OpenMS/METADATA/SpectrumSettings.h>
00034 #include <OpenMS/FORMAT/PersistentObject.h>
00035 
00036 #include <map>
00037 
00038 namespace OpenMS
00039 {
00057   template <typename PeakT = Peak1D, typename AllocT = std::allocator<PeakT> >
00058   class MSSpectrum
00059     : public DSpectrum< DPeakArray< PeakT, AllocT > >,
00060       public SpectrumSettings,
00061       public PersistentObject
00062   {
00063    public:
00064 
00066     struct RTLess
00067       : public std::binary_function <MSSpectrum, MSSpectrum, bool>
00068     {
00069       inline bool operator () (const MSSpectrum& a, const MSSpectrum& b) const
00070       {
00071         return (a.getRT() < b.getRT());
00072       }
00073     };
00074 
00076     typedef PeakT PeakType;
00077 
00079     typedef DSpectrum< DPeakArray< PeakT, AllocT > > BaseSpectrum;
00080 
00082     MSSpectrum():
00083       BaseSpectrum(),
00084       SpectrumSettings(),
00085       PersistentObject()
00086     {
00087     }
00088     
00090     MSSpectrum(const AllocT& alloc):
00091       BaseSpectrum(alloc),
00092       SpectrumSettings(),
00093       PersistentObject()
00094     {
00095     }
00096     
00097     
00099     MSSpectrum(const MSSpectrum& source):
00100       BaseSpectrum(source),
00101       SpectrumSettings(source),
00102       PersistentObject(source)
00103     {
00104 
00105     }
00106     
00107     
00109     template <typename AllocT2>
00110     MSSpectrum(const MSSpectrum<PeakT, AllocT2>& source):
00111       BaseSpectrum(source),
00112       SpectrumSettings(source),
00113       PersistentObject(source)
00114     {
00115     }
00116     
00118     template <typename AllocT2>
00119     MSSpectrum(const MSSpectrum<PeakT, AllocT2>& source, const AllocT& alloc):
00120       BaseSpectrum(source, alloc),
00121       SpectrumSettings(source),
00122       PersistentObject(source)
00123     {
00124     }
00125 
00126         
00128     ~MSSpectrum()
00129     {
00130 
00131     }
00132 
00134     MSSpectrum& operator= (const MSSpectrum& source)
00135     {
00136       if (&source == this) return *this;
00137 
00138       BaseSpectrum::operator=(source);
00139       SpectrumSettings::operator=(source);
00140       PersistentObject::operator=(source);
00141       return *this;
00142     }
00143 
00144     
00146     template <typename AllocT2>
00147     MSSpectrum& operator= (const MSSpectrum<PeakT, AllocT2>& source)
00148     {
00149       //if (&source == this) return *this;
00150 
00151       BaseSpectrum::operator=(source);
00152       SpectrumSettings::operator=(source);
00153       PersistentObject::operator=(source);
00154       return *this;
00155     }
00156     
00157     
00159     bool operator== (const MSSpectrum& rhs) const
00160     {
00161       return
00162         SpectrumSettings::operator==(rhs) &&
00163         BaseSpectrum::operator==(rhs)
00164         ;
00165     }
00167     bool operator!= (const MSSpectrum& rhs) const
00168     {
00169       return !(operator==(rhs));
00170     }
00171 
00172    protected:
00173     // Docu in base class
00174     virtual void clearChildIds_()
00175     {
00176       BaseSpectrum::container_.clearId(true);
00177     }
00178 
00179   };
00180 
00182   template <typename PeakT, typename AllocT>
00183   std::ostream& operator << (std::ostream& os, const MSSpectrum<PeakT, AllocT>& spec)
00184   {
00185     os << "-- MSSPECTRUM BEGIN --"<<std::endl;
00186 
00187     //spectrum settings
00188     os << static_cast<const SpectrumSettings&>(spec);
00189 
00190     //peaklist
00191     os << static_cast<const typename MSSpectrum<PeakT, AllocT>::BaseSpectrum&>(spec);
00192 
00193     os << "-- MSSPECTRUM END --"<<std::endl;
00194 
00195     return os;
00196   }
00197 
00198 } // namespace OpenMS
00199 
00200 #endif // OPENMS_KERNEL_MSSPECTRUM_H

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