|
a/src/query/docseq.h |
|
b/src/query/docseq.h |
|
... |
|
... |
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#ifndef _DOCSEQ_H_INCLUDED_
|
17 |
#ifndef _DOCSEQ_H_INCLUDED_
|
18 |
#define _DOCSEQ_H_INCLUDED_
|
18 |
#define _DOCSEQ_H_INCLUDED_
|
19 |
/* @(#$Id: docseq.h,v 1.8 2006-09-11 09:08:44 dockes Exp $ (C) 2004 J.F.Dockes */
|
19 |
/* @(#$Id: docseq.h,v 1.9 2006-09-13 14:57:56 dockes Exp $ (C) 2004 J.F.Dockes */
|
|
|
20 |
#include <string>
|
|
|
21 |
#include <list>
|
|
|
22 |
|
|
|
23 |
#ifndef NO_NAMESPACES
|
|
|
24 |
using std::string;
|
|
|
25 |
using std::list;
|
|
|
26 |
#endif
|
20 |
|
27 |
|
21 |
#include "rcldb.h"
|
28 |
#include "rcldb.h"
|
22 |
#include "history.h"
|
29 |
#include "history.h"
|
23 |
|
30 |
|
24 |
/** Interface for a list of documents coming from some source.
|
31 |
/** Interface for a list of documents coming from some source.
|
|
... |
|
... |
26 |
The result list display data may come from different sources (ie:
|
33 |
The result list display data may come from different sources (ie:
|
27 |
history or Db query). We have an interface to make things cleaner.
|
34 |
history or Db query). We have an interface to make things cleaner.
|
28 |
*/
|
35 |
*/
|
29 |
class DocSequence {
|
36 |
class DocSequence {
|
30 |
public:
|
37 |
public:
|
31 |
DocSequence(const std::string &t) : m_title(t) {}
|
38 |
DocSequence(const string &t) : m_title(t) {}
|
32 |
virtual ~DocSequence() {}
|
39 |
virtual ~DocSequence() {}
|
33 |
/** Get document at given rank
|
40 |
/** Get document at given rank
|
34 |
*
|
41 |
*
|
35 |
* @param num document rank in sequence
|
42 |
* @param num document rank in sequence
|
36 |
* @param doc return data
|
43 |
* @param doc return data
|
|
... |
|
... |
44 |
* @return true if ok, false for error or end of data
|
51 |
* @return true if ok, false for error or end of data
|
45 |
*/
|
52 |
*/
|
46 |
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0)
|
53 |
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0)
|
47 |
= 0;
|
54 |
= 0;
|
48 |
virtual int getResCnt() = 0;
|
55 |
virtual int getResCnt() = 0;
|
49 |
virtual std::string title() {return m_title;}
|
56 |
virtual string title() {return m_title;}
|
|
|
57 |
virtual void getTerms(list<string>& t) {t.clear();}
|
50 |
|
58 |
|
51 |
private:
|
59 |
private:
|
52 |
std::string m_title;
|
60 |
string m_title;
|
53 |
};
|
61 |
};
|
54 |
|
62 |
|
55 |
|
63 |
|
56 |
/** A DocSequence from a Db query (there should be one active for this
|
64 |
/** A DocSequence from a Db query (there should be one active for this
|
57 |
to make sense */
|
65 |
to make sense */
|
58 |
class DocSequenceDb : public DocSequence {
|
66 |
class DocSequenceDb : public DocSequence {
|
59 |
public:
|
67 |
public:
|
60 |
DocSequenceDb(Rcl::Db *d, const std::string &t) :
|
68 |
DocSequenceDb(Rcl::Db *d, const string &t) :
|
61 |
DocSequence(t), m_db(d), m_rescnt(-1)
|
69 |
DocSequence(t), m_db(d), m_rescnt(-1)
|
62 |
{}
|
70 |
{}
|
63 |
virtual ~DocSequenceDb() {}
|
71 |
virtual ~DocSequenceDb() {}
|
64 |
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string * = 0);
|
72 |
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string * = 0);
|
65 |
virtual int getResCnt();
|
73 |
virtual int getResCnt();
|
|
|
74 |
virtual void getTerms(list<string>&);
|
|
|
75 |
|
66 |
private:
|
76 |
private:
|
67 |
Rcl::Db *m_db;
|
77 |
Rcl::Db *m_db;
|
68 |
int m_rescnt;
|
78 |
int m_rescnt;
|
69 |
};
|
79 |
};
|
70 |
|
80 |
|
71 |
/** A DocSequence coming from the history file */
|
81 |
/** A DocSequence coming from the history file */
|
72 |
class DocSequenceHistory : public DocSequence {
|
82 |
class DocSequenceHistory : public DocSequence {
|
73 |
public:
|
83 |
public:
|
74 |
DocSequenceHistory(Rcl::Db *d, RclHistory *h, const std::string &t)
|
84 |
DocSequenceHistory(Rcl::Db *d, RclHistory *h, const string &t)
|
75 |
: DocSequence(t), m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {}
|
85 |
: DocSequence(t), m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {}
|
76 |
virtual ~DocSequenceHistory() {}
|
86 |
virtual ~DocSequenceHistory() {}
|
77 |
|
87 |
|
78 |
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
|
88 |
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
|
79 |
virtual int getResCnt();
|
89 |
virtual int getResCnt();
|
|
... |
|
... |
81 |
Rcl::Db *m_db;
|
91 |
Rcl::Db *m_db;
|
82 |
RclHistory *m_hist;
|
92 |
RclHistory *m_hist;
|
83 |
int m_prevnum;
|
93 |
int m_prevnum;
|
84 |
long m_prevtime;
|
94 |
long m_prevtime;
|
85 |
|
95 |
|
86 |
std::list<RclDHistoryEntry> m_hlist;
|
96 |
list<RclDHistoryEntry> m_hlist;
|
87 |
std::list<RclDHistoryEntry>::const_iterator m_it;
|
97 |
list<RclDHistoryEntry>::const_iterator m_it;
|
88 |
};
|
98 |
};
|
89 |
|
99 |
|
90 |
#endif /* _DOCSEQ_H_INCLUDED_ */
|
100 |
#endif /* _DOCSEQ_H_INCLUDED_ */
|