ProteoWizard
SpectrumListWrapper.hpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumListWrapper.hpp 6585 2014-08-07 22:49:28Z chambm $
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2008 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 _SPECTRUMLISTWRAPPER_HPP_
25 #define _SPECTRUMLISTWRAPPER_HPP_
26 
27 
29 #include <stdexcept>
30 
31 
32 namespace pwiz {
33 namespace msdata {
34 
35 
36 /// Inheritable pass-through implementation for wrapping a SpectrumList
38 {
39  public:
40 
42  : inner_(inner),
43  dp_(inner->dataProcessingPtr().get() ? new DataProcessing(*inner->dataProcessingPtr())
44  : new DataProcessing("pwiz_Spectrum_Processing"))
45  {
46  if (!inner.get()) throw std::runtime_error("[SpectrumListWrapper] Null SpectrumListPtr.");
47  }
48 
49  virtual size_t size() const {return inner_->size();}
50  virtual bool empty() const {return size() == 0;}
51  virtual const SpectrumIdentity& spectrumIdentity(size_t index) const {return inner_->spectrumIdentity(index);}
52 
53  // no default implementation, because otherwise subclasses could override the DetailLevel overload and the getBinaryData overload would be inconsistent
54  virtual SpectrumPtr spectrum(size_t index, bool getBinaryData = false) const = 0;
55 
56  virtual SpectrumPtr spectrum(size_t index, DetailLevel detailLevel) const {return spectrum(index, detailLevel == DetailLevel_FullData);}
57 
58  virtual const boost::shared_ptr<const DataProcessing> dataProcessingPtr() const {return dp_;}
59 
60  SpectrumListPtr inner() const {return inner_;}
61 
63  {
64  if(dynamic_cast<SpectrumListWrapper*>(&*inner_))
65  return dynamic_cast<SpectrumListWrapper*>(&*inner_)->innermost();
66  else
67  return inner();
68  }
69 
70  protected:
71 
74 };
75 
76 
77 } // namespace msdata
78 } // namespace pwiz
79 
80 
81 #endif // _SPECTRUMLISTWRAPPER_HPP_
82 
Description of the way in which a particular software was used.
Definition: MSData.hpp:272
virtual const boost::shared_ptr< const DataProcessing > dataProcessingPtr() const
returns the data processing affecting spectra retrieved through this interface
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:569
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition: MSData.hpp:287
Interface for accessing spectra, which may be stored in memory or backed by a data file (RAW...
Definition: MSData.hpp:656
SpectrumListWrapper(const SpectrumListPtr &inner)
T get(const char *name, const T &defaultValue)
Definition: Environment.hpp:34
Inheritable pass-through implementation for wrapping a SpectrumList.
virtual size_t size() const
returns the number of spectra
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
#define PWIZ_API_DECL
Definition: Export.hpp:32
virtual bool empty() const
returns true iff (size() == 0) and (dataProcessingPtr.get() == NULL)
Identifying information for a spectrum.
Definition: MSData.hpp:469
virtual const SpectrumIdentity & spectrumIdentity(size_t index) const
access to a spectrum index
virtual SpectrumPtr spectrum(size_t index, DetailLevel detailLevel) const
retrieve a spectrum by index