ProteoWizard
SpectrumListCache.hpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumListCache.hpp 6945 2014-11-26 18:58:33Z chambm $
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6 //
7 // Copyright 2008 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 #ifndef _SPECTRUMLISTCACHE_HPP_
23 #define _SPECTRUMLISTCACHE_HPP_
24 
25 
27 #include "MSData.hpp"
28 #include "MemoryMRUCache.hpp"
29 #include "SpectrumListWrapper.hpp"
30 
31 
32 namespace pwiz {
33 namespace msdata {
34 
35 
36 /// adds a level of flexible MRU caching to a SpectrumList processor chain
38 {
39  public:
40 
41  /// a cache mapping spectrum indices to SpectrumPtrs
42  struct CacheEntry { CacheEntry(size_t i, SpectrumPtr s) : index(i), spectrum(s) {}; size_t index; SpectrumPtr spectrum; };
44 
46  MemoryMRUCacheMode cacheMode,
47  size_t cacheSize);
48 
49  /// returns the requested spectrum which may or may not be cached depending on
50  /// the current cache mode
51  virtual SpectrumPtr spectrum(size_t index, bool getBinaryData = false) const;
52 
53  /// returns a reference to the cache, to enable clearing it or changing the mode
54  CacheType& spectrumCache();
55 
56  /// returns a const-reference to the cache
57  const CacheType& spectrumCache() const;
58 
59  protected:
60  mutable CacheType spectrumCache_;
61 
62  private:
65 };
66 
67 
68 } // namespace msdata
69 } // namespace pwiz
70 
71 
72 #endif // _SPECTRUMLISTCACHE_HPP_
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:569
Inheritable pass-through implementation for wrapping a SpectrumList.
a cache mapping spectrum indices to SpectrumPtrs
adds a level of flexible MRU caching to a SpectrumList processor chain
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
MemoryMRUCache< CacheEntry, BOOST_MULTI_INDEX_MEMBER(CacheEntry, size_t, index) > CacheType
#define PWIZ_API_DECL
Definition: Export.hpp:32
SpectrumPtr spectrum