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
33namespace pwiz {
34namespace 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
99 const Config& config = Config());
100
101 /// copy constructor
103
104 /// \name input iterator interface
105 //@{
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;
120 //@}
121
122 private:
123
124 class Impl;
125 boost::shared_ptr<Impl> impl_;
126
127 /// no copying
129
130 /// don't do this -- avoid temporary copy
132};
133
134
135} // namespace msdata
136} // namespace pwiz
137
138
139#endif // _SPECTRUMITERATOR_HPP_
140
#define PWIZ_API_DECL
Definition Export.hpp:32
interface for filtering based on ScanInfo
virtual bool accept(const Spectrum &spectrum) const
SpectrumIterator provides convenient iteration through a set of scans in a SpectrumList.
SpectrumIterator(const SpectrumIterator &)
copy constructor
SpectrumIterator & operator=(const SpectrumIterator &)
no copying
SpectrumIterator()
special default object for marking past-the-end
const Spectrum & operator*() const
const Spectrum * operator->() const
SpectrumIterator & operator++()
SpectrumIterator operator++(int)
don't do this – avoid temporary copy
std::input_iterator_tag iterator_category
SpectrumIterator(const MSData &msd, const Config &config=Config())
constructor using MSData object
boost::shared_ptr< Impl > impl_
SpectrumIterator(const SpectrumList &spectrumList, const Config &config=Config())
constructor for normal initialization of the iterator
bool operator==(const SpectrumIterator &that) const
bool operator!=(const SpectrumIterator &that) const
Interface for accessing spectra, which may be stored in memory or backed by a data file (RAW,...
Definition MSData.hpp:661
a virtual container of integers, accessible via an iterator interface, stored as union of intervals
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition MSData.hpp:850
The structure that captures the generation of a peak list (including the underlying acquisitions)
Definition MSData.hpp:506
SpectrumIterator configuration – note that constructors allow automatic conversion from IntegerSet or...
Config(const IntegerSet &_scanNumbers, bool _getBinaryData=true)
Config(const Sieve &_sieve, bool _getBinaryData=true)