ProteoWizard
Main Page
Namespaces
Classes
Files
File List
File Members
pwiz
data
msdata
MemoryMRUCache.hpp
Go to the documentation of this file.
1
//
2
// $Id: MemoryMRUCache.hpp 2595 2011-03-28 14:40:59Z 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 _MEMORYMRUCACHE_HPP_
23
#define _MEMORYMRUCACHE_HPP_
24
25
26
#include "
pwiz/utility/misc/Export.hpp
"
27
#include "
pwiz/utility/misc/mru_list.hpp
"
28
29
30
namespace
pwiz {
31
namespace
msdata {
32
33
34
enum
PWIZ_API_DECL
MemoryMRUCacheMode
35
{
36
MemoryMRUCacheMode_Off
,
37
MemoryMRUCacheMode_MetaDataOnly
,
38
MemoryMRUCacheMode_BinaryDataOnly
,
39
MemoryMRUCacheMode_MetaDataAndBinaryData
40
};
41
42
43
/// an MRU cache for SpectrumPtrs or ChromatogramPtrs
44
template
<
typename
PtrType,
typename
KeyExtractor = boost::multi_index::
id
entity<PtrType> >
45
class
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_
)
57
pwiz::util::mru_list<PtrType, KeyExtractor>::clear
();
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_
Generated on Mon Nov 26 2012 18:05:48 for ProteoWizard by
1.8.1.1