summaryrefslogtreecommitdiffstats
path: root/debian/htdig/htdig-3.2.0b6/htsearch/DocMatch.h
blob: 798aadb395279b0095024d956dbc54cf38120186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// DocMatch.h
//
// DocMatch: Data object only. Contains information related to a given
//           document that was matched by a search. For instance, the
//           score of the document for this search.
//           
// Part of the ht://Dig package   <http://www.htdig.org/>
// Copyright (c) 1995-2004 The ht://Dig Group
// For copyright details, see the file COPYING in your distribution
// or the GNU Library General Public License (LGPL) version 2 or later
// <http://www.gnu.org/copyleft/lgpl.html>
//
// $Id: DocMatch.h,v 1.9 2004/05/28 13:15:24 lha Exp $
//

#ifndef _DocMatch_h_
#define _DocMatch_h_

#ifdef HAVE_CONFIG_H
#include "htconfig.h"
#endif

#include "Object.h"
#include "List.h"

class Collection;

//
// an element of the DocMatch location list
//
struct Location : public Object
{
	Location(int f, int t, unsigned int l, double w = 1.0) :
		from(f), to(t), flags(l), weight(w) {}
	Location(const Location &l) :
		from(l.from), to(l.to), flags(l.flags), weight(l.weight) {}
	int from;
	int to;
	unsigned int flags;
	double weight;
};

//
// an element of a ResultList
//
class DocMatch : public Object
{
public:
	// default constructor
	DocMatch() :
		locations(new List),
		score(-1.0),
		id(0),
		anchor(0),
		collection(0) {}

	// copy constructor	
	DocMatch(const DocMatch &);

	// destructor
	~DocMatch();

	// match join
	void Merge(const DocMatch &);

	// score accessor
	double GetScore();
	void SetScore(double);

	// doc id accessors
	int GetId() const { return id; }
	void SetId(int x) { id = x; }

	// anchor accessors
	int GetAnchor() const { return anchor; }
	void SetAnchor(int x) { anchor = x; }

	// location list accessors
	const List *GetLocations() const { return locations; }
	void SetLocations(List *);
	void AddLocations(const List *);

	// add one location to the list
	// use with caution -- does not ensure {ordered}
	void AddLocation(Location *x) { locations->Add(x); }

	// set weight of all locations
	void SetWeight(double weight);

	// debug
	void Dump();
	
private:
	List			*locations;
// the rest should be private:
// but is already used by the old htsearch
public:

	double				score;
	int				id;
	int				anchor;
	short int			orMatches;
	Collection                      *collection; // Multiple databases
};

#endif