ProteoWizard
pwiz
data
common
Index.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 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_
Export.hpp
PWIZ_API_DECL
#define PWIZ_API_DECL
Definition
Export.hpp:32
pwiz::data::Index
generic interface for creating and using an index on a stream of serialized objects
Definition
Index.hpp:40
pwiz::data::Index::EntryPtr
boost::shared_ptr< Entry > EntryPtr
Definition
Index.hpp:53
pwiz::data::Index::~Index
virtual ~Index()
Definition
Index.hpp:68
pwiz::data::Index::stream_offset
boost::iostreams::stream_offset stream_offset
Definition
Index.hpp:43
pwiz::data::Index::size
virtual size_t size() const =0
returns the number of entries in the index
pwiz::data::Index::find
virtual EntryPtr find(const std::string &id) const =0
returns the entry for the specified string id, or null if the id is not in the index
pwiz::data::Index::create
virtual void create(std::vector< Entry > &entries)=0
create the index from specified list of entries; the list is non-const because the index implementati...
pwiz::data::Index::find
virtual EntryPtr find(size_t index) const =0
returns the entry for the specified ordinal index, or null if the ordinal is not in the index
pwiz::data::IndexPtr
boost::shared_ptr< Index > IndexPtr
Definition
Index.hpp:72
pwiz
Definition
ChromatogramList_Filter.hpp:36
pwiz::data::Index::Entry
generic type identifying an indexed item by string id, ordinal index, and stream offset
Definition
Index.hpp:47
pwiz::data::Index::Entry::id
std::string id
Definition
Index.hpp:48
pwiz::data::Index::Entry::index
boost::uint64_t index
Definition
Index.hpp:49
pwiz::data::Index::Entry::offset
stream_offset offset
Definition
Index.hpp:50
Generated by
1.9.8