ProteoWizard
SpectrumListBase.hpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumListBase.hpp 6385 2014-06-12 22:56:04Z chambm $
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2009 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 _SPECTRUMLISTBASE_HPP_
25 #define _SPECTRUMLISTBASE_HPP_
26 
27 
29 #include <boost/functional/hash.hpp>
30 #include <stdexcept>
31 #include <iostream>
32 
33 
34 namespace pwiz {
35 namespace msdata {
36 
37 
38 /// common functionality for base SpectrumList implementations
40 {
41  public:
42 
43  /// implementation of SpectrumList
44  virtual const boost::shared_ptr<const DataProcessing> dataProcessingPtr() const {return dp_;}
45 
46  /// set DataProcessing
47  virtual void setDataProcessingPtr(DataProcessingPtr dp) { dp_ = dp; }
48 
49  /// issues a warning once per SpectrumList instance (based on string hash)
50  virtual void warn_once(const char* msg) const
51  {
52  boost::hash<const char*> H;
53  if (warn_msg_hashes.insert(H(msg)).second) // .second is true iff value is new
54  {
55  std::cerr << msg << std::endl;
56  }
57  }
58 
59  protected:
60 
62 
63  private:
64 
65  mutable std::set<size_t> warn_msg_hashes; // for warn_once use
66 };
67 
68 
69 } // namespace msdata
70 } // namespace pwiz
71 
72 
73 #endif // _SPECTRUMLISTBASE_HPP_
74 
common functionality for base SpectrumList implementations
virtual void setDataProcessingPtr(DataProcessingPtr dp)
set DataProcessing
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition: MSData.hpp:287
virtual void warn_once(const char *msg) const
issues a warning once per SpectrumList instance (based on string hash)
Interface for accessing spectra, which may be stored in memory or backed by a data file (RAW...
Definition: MSData.hpp:656
#define PWIZ_API_DECL
Definition: Export.hpp:32
H
Definition: Chemistry.hpp:80
virtual const boost::shared_ptr< const DataProcessing > dataProcessingPtr() const
implementation of SpectrumList