ProteoWizard
Main Page
Namespaces
Classes
Files
File List
File Members
pwiz
data
common
Index.hpp
Go to the documentation of this file.
1
//
2
// $Id: Index.hpp 1704 2010-01-15 23:42:49Z chambm $
3
//
4
//
5
// Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6
//
7
// Copyright 2009 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 _INDEX_HPP_
23
#define _INDEX_HPP_
24
25
26
#include "
pwiz/utility/misc/Export.hpp
"
27
#include <string>
28
#include <vector>
29
#include <boost/iostreams/positioning.hpp>
30
#include <boost/shared_ptr.hpp>
31
#include <boost/cstdint.hpp>
32
33
34
namespace
pwiz {
35
namespace
data {
36
37
38
/// generic interface for creating and using an index on a stream of serialized objects
39
class
PWIZ_API_DECL
Index
40
{
41
public
:
42
43
typedef
boost::iostreams::stream_offset
stream_offset
;
44
45
/// generic type identifying an indexed item by string id, ordinal index, and stream offset
46
struct
PWIZ_API_DECL
Entry
47
{
48
std::string
id
;
49
boost::uint64_t
index
;
50
stream_offset
offset
;
51
};
52
53
typedef
boost::shared_ptr<Entry>
EntryPtr
;
54
55
/// create the index from specified list of entries;
56
/// the list is non-const because the index implementation may resort the list
57
virtual
void
create(std::vector<Entry>& entries) = 0;
58
59
/// returns the number of entries in the index
60
virtual
size_t
size()
const
= 0;
61
62
/// returns the entry for the specified string id, or null if the id is not in the index
63
virtual
EntryPtr
find(
const
std::string&
id
)
const
= 0;
64
65
/// returns the entry for the specified ordinal index, or null if the ordinal is not in the index
66
virtual
EntryPtr
find(
size_t
index)
const
= 0;
67
68
virtual
~Index
() {}
69
};
70
71
72
typedef
boost::shared_ptr<Index>
IndexPtr
;
73
74
75
}
// namespace data
76
}
// namespace pwiz
77
78
79
#endif // _INDEX_HPP_
Generated on Mon Nov 26 2012 18:05:47 for ProteoWizard by
1.8.1.1