ProteoWizard
MemoryMRUCache.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 _MEMORYMRUCACHE_HPP_
23#define _MEMORYMRUCACHE_HPP_
24
25
28
29
30namespace pwiz {
31namespace msdata {
32
33
34enum PWIZ_API_DECL MemoryMRUCacheMode
35{
39 MemoryMRUCacheMode_MetaDataAndBinaryData
40};
41
42
43/// an MRU cache for SpectrumPtrs or ChromatogramPtrs
44template <typename PtrType, typename KeyExtractor = boost::multi_index::identity<PtrType> >
45class MemoryMRUCache : public pwiz::util::mru_list<PtrType, KeyExtractor>
46{
47 public:
48 MemoryMRUCache(MemoryMRUCacheMode mode, size_t size)
49 : pwiz::util::mru_list<PtrType, KeyExtractor>(size), mode_(mode)
50 {}
51
52 /// set the caching mode
53 /// note: if the new mode is different than the current mode, the cache will be cleared
54 void setMode(MemoryMRUCacheMode mode)
55 {
56 if (mode != mode_)
58 mode_ = mode;
59 }
60
61 /// get the current caching mode
62 MemoryMRUCacheMode mode() const {return mode_;}
63
64 private:
65 MemoryMRUCacheMode mode_;
66};
67
68
69} // namespace msdata
70} // namespace pwiz
71
72
73#endif // _MEMORYMRUCACHE_HPP_
#define PWIZ_API_DECL
Definition Export.hpp:32
MemoryMRUCacheMode_MetaDataOnly
MemoryMRUCacheMode_BinaryDataOnly
MemoryMRUCacheMode_Off
an MRU cache for SpectrumPtrs or ChromatogramPtrs
MemoryMRUCache(MemoryMRUCacheMode mode, size_t size)
void setMode(MemoryMRUCacheMode mode)
set the caching mode note: if the new mode is different than the current mode, the cache will be clea...
MemoryMRUCacheMode mode() const
get the current caching mode
std::size_t size() const
Definition mru_list.hpp:92
mru_list(std::size_t max_num_items_)
Definition mru_list.hpp:69