ProteoWizard
SpectrumListCache.hpp
Go to the documentation of this file.
1 //
2 // $Id$
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; };
43  typedef MemoryMRUCache<CacheEntry, BOOST_MULTI_INDEX_MEMBER(CacheEntry, size_t, index) > CacheType;
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:
61 
62  private:
65 };
66 
67 
68 } // namespace msdata
69 } // namespace pwiz
70 
71 
72 #endif // _SPECTRUMLISTCACHE_HPP_
pwiz::msdata::SpectrumListPtr
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:711
pwiz::msdata::SpectrumListCache::CacheEntry
a cache mapping spectrum indices to SpectrumPtrs
Definition: SpectrumListCache.hpp:42
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::msdata::SpectrumListCache::spectrumCache_
CacheType spectrumCache_
Definition: SpectrumListCache.hpp:60
MemoryMRUCache.hpp
pwiz::msdata::SpectrumListWrapper
Inheritable pass-through implementation for wrapping a SpectrumList.
Definition: SpectrumListWrapper.hpp:37
MSData.hpp
pwiz::msdata::SpectrumListCache::CacheEntry::spectrum
SpectrumPtr spectrum
Definition: SpectrumListCache.hpp:42
PWIZ_API_DECL
#define PWIZ_API_DECL
Definition: Export.hpp:32
pwiz::msdata::MemoryMRUCache
an MRU cache for SpectrumPtrs or ChromatogramPtrs
Definition: MemoryMRUCache.hpp:45
Export.hpp
pwiz::msdata::SpectrumPtr
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:573
pwiz::msdata::SpectrumListCache
adds a level of flexible MRU caching to a SpectrumList processor chain
Definition: SpectrumListCache.hpp:37
pwiz::msdata::SpectrumListCache::CacheType
MemoryMRUCache< CacheEntry, BOOST_MULTI_INDEX_MEMBER(CacheEntry, size_t, index) > CacheType
Definition: SpectrumListCache.hpp:43
SpectrumListWrapper.hpp