Branch data Line data Source code
1 : : /** @file valuestreamdocument.h
2 : : * @brief A document which gets its values from a ValueStreamManager.
3 : : */
4 : : /* Copyright (C) 2009 Olly Betts
5 : : *
6 : : * This program is free software; you can redistribute it and/or modify
7 : : * it under the terms of the GNU General Public License as published by
8 : : * the Free Software Foundation; either version 2 of the License, or
9 : : * (at your option) any later version.
10 : : *
11 : : * This program is distributed in the hope that it will be useful,
12 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : : * GNU General Public License for more details.
15 : : *
16 : : * You should have received a copy of the GNU General Public License
17 : : * along with this program; if not, write to the Free Software
18 : : * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 : : */
20 : :
21 : : #ifndef XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H
22 : : #define XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H
23 : :
24 : : #include "document.h"
25 : : #include "valuelist.h"
26 : : #include "xapian/types.h"
27 : :
28 : : #include <map>
29 : :
30 : : /// A document which gets its values from a ValueStreamManager.
31 : : class ValueStreamDocument : public Xapian::Document::Internal {
32 : : /// Don't allow assignment.
33 : : void operator=(const ValueStreamDocument &);
34 : :
35 : : /// Don't allow copying.
36 : : ValueStreamDocument(const ValueStreamDocument &);
37 : :
38 : : mutable std::map<Xapian::valueno, ValueList *> valuelists;
39 : :
40 : : Xapian::Database db;
41 : :
42 : : size_t current;
43 : :
44 : : mutable Xapian::Document::Internal * doc;
45 : :
46 : : public:
47 : 175211 : ValueStreamDocument(const Xapian::Database & db_)
48 : 175211 : : Internal(db_.internal[0], 0), db(db_), current(0), doc(NULL) { }
49 : :
50 : : void new_subdb(int n);
51 : :
52 : : ~ValueStreamDocument();
53 : :
54 : 47266030 : void set_document(Xapian::docid did_) {
55 : 47266030 : did = did_;
56 [ + + ]: 47266030 : delete doc;
57 : 47266030 : doc = NULL;
58 : 47266030 : }
59 : :
60 : : // Optimise away the virtual call when the matcher wants to know a value.
61 : 55611 : string get_value(Xapian::valueno slot) const {
62 : 55611 : return ValueStreamDocument::do_get_value(slot);
63 : : }
64 : :
65 : : private:
66 : : /** Implementation of virtual methods @{ */
67 : : string do_get_value(Xapian::valueno slot) const;
68 : : void do_get_all_values(map<Xapian::valueno, string> & values_) const;
69 : : string do_get_data() const;
70 : : /** @} */
71 : : };
72 : :
73 : : #endif // XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H
|