ProteoWizard
ProteinListCache.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 _PROTEINLISTCACHE_HPP_
23 #define _PROTEINLISTCACHE_HPP_
24 
25 
27 #include "ProteomeData.hpp"
28 #include "ProteinListWrapper.hpp"
30 
31 
32 namespace pwiz {
33 namespace proteome {
34 
35 
36 enum PWIZ_API_DECL ProteinListCacheMode
37 {
40  ProteinListCacheMode_MetaDataAndSequence
41 };
42 
43 
44 /// adds a level of flexible MRU caching to a ProteinList processor chain
46 {
47  public:
48 
49  /// a cache mapping spectrum indices to ProteinPtrs
50  typedef std::pair<size_t, ProteinPtr> KeyValuePair;
51  BOOST_STATIC_CONSTANT(unsigned, first_offset = offsetof(KeyValuePair, first));
53 
55  ProteinListCacheMode cacheMode,
56  size_t cacheSize);
57 
58  /// returns the requested spectrum which may or may not be cached depending on
59  /// the current cache mode
60  virtual ProteinPtr protein(size_t index, bool getSequence = true) const;
61 
62  virtual size_t find(const std::string& id) const;
63 
64  /// set the caching mode
65  /// note: if the new mode is different than the current mode, the cache will be cleared
66  void setMode(ProteinListCacheMode mode);
67 
68  /// get the current caching mode
69  ProteinListCacheMode mode() const;
70 
71  /// get a const-reference to the cache
72  const CacheType& cache() const {return cache_;}
73 
74  private:
77  mutable CacheType cache_;
78  ProteinListCacheMode mode_;
79 };
80 
81 
82 } // namespace msdata
83 } // namespace pwiz
84 
85 
86 #endif // _PROTEINLISTCACHE_HPP_
ProteinListCacheMode_Off
ProteinListCacheMode_Off
Definition: ProteinListCache.hpp:38
pwiz::proteome::ProteinListCache::find
virtual size_t find(const std::string &id) const
pwiz::proteome::ProteinListCache::cache
const CacheType & cache() const
get a const-reference to the cache
Definition: ProteinListCache.hpp:72
pwiz::proteome::ProteinListWrapper
Inheritable pass-through implementation for wrapping a ProteinList.
Definition: ProteinListWrapper.hpp:38
pwiz::proteome::ProteinListCache::cache_
CacheType cache_
Definition: ProteinListCache.hpp:77
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::proteome
Definition: AminoAcid.hpp:35
pwiz::proteome::ProteinListCache::setMode
void setMode(ProteinListCacheMode mode)
set the caching mode note: if the new mode is different than the current mode, the cache will be clea...
PWIZ_API_DECL
#define PWIZ_API_DECL
Definition: Export.hpp:32
pwiz::proteome::ProteinListCache::mode_
ProteinListCacheMode mode_
Definition: ProteinListCache.hpp:78
Export.hpp
pwiz::proteome::ProteinListCache::ProteinListCache
ProteinListCache(ProteinListCache &)
ProteinListWrapper.hpp
pwiz::proteome::ProteinListCache::CacheType
pwiz::util::mru_list< KeyValuePair, boost::multi_index::member_offset< KeyValuePair, size_t, first_offset > > CacheType
Definition: ProteinListCache.hpp:52
pwiz::proteome::ProteinListCache::protein
virtual ProteinPtr protein(size_t index, bool getSequence=true) const
returns the requested spectrum which may or may not be cached depending on the current cache mode
pwiz::proteome::ProteinListCache::mode
ProteinListCacheMode mode() const
get the current caching mode
pwiz::proteome::ProteinListCache::operator=
ProteinListCache & operator=(ProteinListCache &)
pwiz::proteome::ProteinListPtr
boost::shared_ptr< ProteinList > ProteinListPtr
Definition: ProteomeData.hpp:73
pwiz::proteome::ProteinListCache::KeyValuePair
std::pair< size_t, ProteinPtr > KeyValuePair
a cache mapping spectrum indices to ProteinPtrs
Definition: ProteinListCache.hpp:50
ProteomeData.hpp
mru_list.hpp
ProteinListCacheMode_MetaDataOnly
ProteinListCacheMode_MetaDataOnly
Definition: ProteinListCache.hpp:39
pwiz::util::mru_list
Definition: mru_list.hpp:50
pwiz::proteome::ProteinListCache::ProteinListCache
ProteinListCache(const ProteinListPtr &inner, ProteinListCacheMode cacheMode, size_t cacheSize)
pwiz::proteome::ProteinListCache
adds a level of flexible MRU caching to a ProteinList processor chain
Definition: ProteinListCache.hpp:46
pwiz::proteome::ProteinListCache::BOOST_STATIC_CONSTANT
BOOST_STATIC_CONSTANT(unsigned, first_offset=offsetof(KeyValuePair, first))
pwiz::proteome::ProteinPtr
boost::shared_ptr< Protein > ProteinPtr
Definition: ProteomeData.hpp:48