ProteoWizard
SpectrumListBase.hpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumListBase.hpp 8725 2015-08-04 15:49:57Z pcbrefugee $
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 
30 #include <boost/functional/hash.hpp>
31 #include <stdexcept>
32 #include <iostream>
33 
34 
35 namespace pwiz {
36 namespace msdata {
37 
38 
39 /// common functionality for base SpectrumList implementations
41 {
42  public:
43  SpectrumListBase() : MSLevelsNone() {};
44 
45  /// implementation of SpectrumList
46  virtual const boost::shared_ptr<const DataProcessing> dataProcessingPtr() const {return dp_;}
47 
48  /// set DataProcessing
49  virtual void setDataProcessingPtr(DataProcessingPtr dp) { dp_ = dp; }
50 
51  /// issues a warning once per SpectrumList instance (based on string hash)
52  virtual void warn_once(const char* msg) const
53  {
54  boost::hash<const char*> H;
55  if (warn_msg_hashes.insert(H(msg)).second) // .second is true iff value is new
56  {
57  std::cerr << msg << std::endl;
58  }
59  }
60 
61  protected:
62 
64 
65  // Useful for avoiding repeated ctor when you just want an empty set
67 
68  private:
69 
70  mutable std::set<size_t> warn_msg_hashes; // for warn_once use
71 };
72 
73 
74 } // namespace msdata
75 } // namespace pwiz
76 
77 
78 #endif // _SPECTRUMLISTBASE_HPP_
79 
common functionality for base SpectrumList implementations
virtual void warn_once(const char *msg) const
issues a warning once per SpectrumList instance (based on string hash)
a virtual container of integers, accessible via an iterator interface, stored as union of intervals ...
Definition: IntegerSet.hpp:37
virtual void setDataProcessingPtr(DataProcessingPtr dp)
set DataProcessing
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition: MSData.hpp:287
virtual const boost::shared_ptr< const DataProcessing > dataProcessingPtr() const
implementation of SpectrumList
const pwiz::util::IntegerSet MSLevelsNone
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