ProteoWizard
SpectrumIterator.hpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2007 Spielberg Family Center for Applied Proteomics
8 // Cedars-Sinai Medical Center, Los Angeles, California 90048
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 
23 
24 #ifndef _SPECTRUMITERATOR_HPP_
25 #define _SPECTRUMITERATOR_HPP_
26 
27 
29 #include "MSData.hpp"
31 
32 
33 namespace pwiz {
34 namespace msdata {
35 
36 
38 
39 
40 ///
41 /// SpectrumIterator provides convenient iteration through a set of scans in a SpectrumList.
42 ///
43 /// Its behavior is similar to istream_iterator. In particular:
44 /// - the default constructed SpectrumIterator() is a past-the-end marker
45 /// - references to the current Spectrum are invalidated by preincrement
46 ///
47 /// Because SpectrumIterator holds a copy of the current Spectrum internally,
48 /// copy assignment and postincrement have been disabled.
49 ///
50 /// Iteration may be customized in a number of ways:
51 /// - clients may specify an IntegerSet of scan numbers through which to iterate.
52 /// - clients may specify a Sieve to filter based on Spectrum fields.
53 /// - clients may specify whether binary data is retrieved in the Spectrum object (default==true)
54 ///
55 /// For usage examples, see SpectrumIteratorTest.cpp
56 ///
58 {
59  public:
60 
61  /// interface for filtering based on ScanInfo
63  {
64  public:
65  virtual bool accept(const Spectrum& spectrum) const {return true;}
66  virtual ~Sieve(){}
67  };
68 
69  /// SpectrumIterator configuration -- note that constructors allow automatic
70  /// conversion from IntegerSet or Sieve to Config
72  {
74  const Sieve* sieve;
76 
78  : scanNumbers(0), sieve(0), getBinaryData(true)
79  {}
80 
81  Config(const IntegerSet& _scanNumbers, bool _getBinaryData = true)
82  : scanNumbers(&_scanNumbers), sieve(0), getBinaryData(_getBinaryData)
83  {}
84 
85  Config(const Sieve& _sieve, bool _getBinaryData = true)
86  : scanNumbers(0), sieve(&_sieve), getBinaryData(_getBinaryData)
87  {}
88  };
89 
90  /// special default object for marking past-the-end
92 
93  /// constructor for normal initialization of the iterator
94  SpectrumIterator(const SpectrumList& spectrumList,
95  const Config& config = Config());
96 
97  /// constructor using MSData object
98  SpectrumIterator(const MSData& msd,
99  const Config& config = Config());
100 
101  /// copy constructor
103 
104  /// \name input iterator interface
105  //@{
106  SpectrumIterator& operator++();
107  const Spectrum& operator*() const;
108  const Spectrum* operator->() const;
109  bool operator==(const SpectrumIterator& that) const;
110  bool operator!=(const SpectrumIterator& that) const;
111  //@}
112 
113  /// \name standard iterator typedefs
114  //@{
115  typedef std::input_iterator_tag iterator_category;
117  typedef int difference_type;
118  typedef value_type* pointer;
120  //@}
121 
122  private:
123 
124  class Impl;
125  boost::shared_ptr<Impl> impl_;
126 
127  /// no copying
128  SpectrumIterator& operator=(const SpectrumIterator&);
129 
130  /// don't do this -- avoid temporary copy
131  SpectrumIterator operator++(int);
132 };
133 
134 
135 } // namespace msdata
136 } // namespace pwiz
137 
138 
139 #endif // _SPECTRUMITERATOR_HPP_
140 
pwiz::msdata::Spectrum
The structure that captures the generation of a peak list (including the underlying acquisitions)
Definition: MSData.hpp:505
pwiz
Definition: ChromatogramList_Filter.hpp:36
MSData.hpp
pwiz::frequency::operator==
PWIZ_API_DECL bool operator==(const TruncatedLorentzianParameters &t, const TruncatedLorentzianParameters &u)
pwiz::msdata::SpectrumIterator::Config::Config
Config(const Sieve &_sieve, bool _getBinaryData=true)
Definition: SpectrumIterator.hpp:85
PWIZ_API_DECL
#define PWIZ_API_DECL
Definition: Export.hpp:32
pwiz::msdata::SpectrumIterator::iterator_category
std::input_iterator_tag iterator_category
Definition: SpectrumIterator.hpp:115
pwiz::msdata::SpectrumIterator::Sieve::accept
virtual bool accept(const Spectrum &spectrum) const
Definition: SpectrumIterator.hpp:65
Export.hpp
pwiz::msdata::SpectrumIterator::Sieve
interface for filtering based on ScanInfo
Definition: SpectrumIterator.hpp:62
pwiz::msdata::SpectrumIterator::reference
value_type & reference
Definition: SpectrumIterator.hpp:119
pwiz::msdata::SpectrumIterator::Config::scanNumbers
const IntegerSet * scanNumbers
Definition: SpectrumIterator.hpp:73
pwiz::msdata::SpectrumIterator::impl_
boost::shared_ptr< Impl > impl_
Definition: SpectrumIterator.hpp:124
pwiz::msdata::SpectrumIterator::Config::sieve
const Sieve * sieve
Definition: SpectrumIterator.hpp:74
pwiz::msdata::SpectrumIterator::pointer
value_type * pointer
Definition: SpectrumIterator.hpp:118
pwiz::msdata::SpectrumIterator::value_type
Spectrum value_type
Definition: SpectrumIterator.hpp:116
pwiz::msdata::SpectrumIterator::Config::Config
Config(const IntegerSet &_scanNumbers, bool _getBinaryData=true)
Definition: SpectrumIterator.hpp:81
pwiz::msdata::SpectrumIterator
SpectrumIterator provides convenient iteration through a set of scans in a SpectrumList.
Definition: SpectrumIterator.hpp:57
pwiz::msdata::SpectrumIterator::Config::Config
Config()
Definition: SpectrumIterator.hpp:77
pwiz::msdata::MSData
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:849
pwiz::msdata::SpectrumIterator::difference_type
int difference_type
Definition: SpectrumIterator.hpp:117
pwiz::msdata::SpectrumIterator::Config
SpectrumIterator configuration – note that constructors allow automatic conversion from IntegerSet ...
Definition: SpectrumIterator.hpp:71
IntegerSet.hpp
pwiz::frequency::operator!=
PWIZ_API_DECL bool operator!=(const TruncatedLorentzianParameters &t, const TruncatedLorentzianParameters &u)
pwiz::msdata::SpectrumIterator::Sieve::~Sieve
virtual ~Sieve()
Definition: SpectrumIterator.hpp:66
pwiz::msdata::SpectrumList
Interface for accessing spectra, which may be stored in memory or backed by a data file (RAW,...
Definition: MSData.hpp:660
pwiz::util::IntegerSet
a virtual container of integers, accessible via an iterator interface, stored as union of intervals
Definition: IntegerSet.hpp:37
pwiz::msdata::SpectrumIterator::Config::getBinaryData
bool getBinaryData
Definition: SpectrumIterator.hpp:75
pwiz::chemistry::operator*
PWIZ_API_DECL Formula operator*(const Formula &a, int scalar)