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"
30
31
32namespace pwiz {
33namespace proteome {
34
35
36enum 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:
78 ProteinListCacheMode mode_;
79};
80
81
82} // namespace msdata
83} // namespace pwiz
84
85
86#endif // _PROTEINLISTCACHE_HPP_
#define PWIZ_API_DECL
Definition Export.hpp:32
ProteinListCacheMode_Off
ProteinListCacheMode_MetaDataOnly
adds a level of flexible MRU caching to a ProteinList processor chain
std::pair< size_t, ProteinPtr > KeyValuePair
a cache mapping spectrum indices to ProteinPtrs
const CacheType & cache() const
get a const-reference to the cache
ProteinListCacheMode mode() const
get the current caching mode
pwiz::util::mru_list< KeyValuePair, boost::multi_index::member_offset< KeyValuePair, size_t, first_offset > > CacheType
BOOST_STATIC_CONSTANT(unsigned, first_offset=offsetof(KeyValuePair, first))
ProteinListCache & operator=(ProteinListCache &)
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
void setMode(ProteinListCacheMode mode)
set the caching mode note: if the new mode is different than the current mode, the cache will be clea...
virtual size_t find(const std::string &id) const
ProteinListCache(const ProteinListPtr &inner, ProteinListCacheMode cacheMode, size_t cacheSize)
ProteinListCache(ProteinListCache &)
Inheritable pass-through implementation for wrapping a ProteinList.
boost::shared_ptr< Protein > ProteinPtr
boost::shared_ptr< ProteinList > ProteinListPtr