ProteoWizard
SpectrumList_ABI.hpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumList_ABI.hpp 4181 2012-12-10 21:03:19Z chambm $
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6 //
7 // Copyright 2009 Vanderbilt University - Nashville, TN 37232
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
22 
27 #include <boost/thread/mutex.hpp>
28 
29 #ifdef PWIZ_READER_ABI
30 #include "pwiz_aux/msrc/utility/vendor_api/ABI/WiffFile.hpp"
32 using namespace pwiz::vendor_api::ABI;
33 #endif // PWIZ_READER_ABI
34 
35 
36 namespace pwiz {
37 namespace msdata {
38 namespace detail {
39 
41 {
42  public:
43 
44  virtual size_t size() const;
45  virtual const SpectrumIdentity& spectrumIdentity(size_t index) const;
46  virtual size_t find(const std::string& id) const;
47  virtual SpectrumPtr spectrum(size_t index, bool getBinaryData) const;
48  virtual SpectrumPtr spectrum(size_t index, DetailLevel detailLevel) const;
49  virtual SpectrumPtr spectrum(size_t index, bool getBinaryData, const pwiz::util::IntegerSet& msLevelsToCentroid) const;
50  virtual SpectrumPtr spectrum(size_t index, DetailLevel detailLevel, const pwiz::util::IntegerSet& msLevelsToCentroid) const;
51 
52 #ifdef PWIZ_READER_ABI
53  SpectrumList_ABI(const MSData& msd, WiffFilePtr wifffile,
54  const ExperimentsMap& experimentsMap, int sample,
55  const Reader::Config& config);
56 
57  private:
58 
59  const MSData& msd_;
60  WiffFilePtr wifffile_;
61  const Reader::Config config_;
62  ExperimentsMap experimentsMap_;
63  int sample;
64 
65  mutable size_t size_;
66 
67  mutable util::once_flag_proxy indexInitialized_;
68 
69  struct IndexEntry : public SpectrumIdentity
70  {
71  int sample;
72  int period;
73  int cycle;
74  ExperimentPtr experiment;
75  int transition;
76  };
77 
78  mutable std::vector<IndexEntry> index_;
79  mutable std::map<std::string, size_t> idToIndexMap_;
80 
81  // Cache last accessed spectrum for fast in order access
82  mutable boost::mutex spectrum_mutex;
83  mutable size_t spectrumLastIndex_;
84  mutable pwiz::vendor_api::ABI::SpectrumPtr spectrumLast_;
85 
86  void createIndex() const;
87 #endif // PWIZ_READER_ABI
88 };
89 
90 
91 } // detail
92 } // msdata
93 } // pwiz