Switch to unified view

a/src/query/docseq.h b/src/query/docseq.h
1
#ifndef _DOCSEQ_H_INCLUDED_
1
#ifndef _DOCSEQ_H_INCLUDED_
2
#define _DOCSEQ_H_INCLUDED_
2
#define _DOCSEQ_H_INCLUDED_
3
/* @(#$Id: docseq.h,v 1.3 2005-12-05 16:13:12 dockes Exp $  (C) 2004 J.F.Dockes */
3
/* @(#$Id: docseq.h,v 1.4 2006-01-11 15:08:22 dockes Exp $  (C) 2004 J.F.Dockes */
4
4
5
#include "rcldb.h"
5
#include "rcldb.h"
6
#include "history.h"
6
#include "history.h"
7
7
8
/** Interface for a list of documents coming from some source.
8
/** Interface for a list of documents coming from some source.
9
9
10
    The result list display data may come from different sources (ie:
10
    The result list display data may come from different sources (ie:
11
    history or Db query). We have an interface to make things cleaner.
11
    history or Db query). We have an interface to make things cleaner.
12
*/
12
*/
13
class DocSequence {
13
class DocSequence {
14
    std::string m_title;
14
 public:
15
 public:
16
    DocSequence(const std::string &t) : m_title(t) {}
17
    virtual ~DocSequence() {}
15
    virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0) 
18
    virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0) 
16
    = 0;
19
    = 0;
17
    virtual int getResCnt() = 0;
20
    virtual int getResCnt() = 0;
18
    virtual std::string title() = 0;
21
    virtual std::string title() {return m_title;}
19
};
22
};
20
23
21
24
22
/** A DocSequence from a Db query (there should be one active for this
25
/** A DocSequence from a Db query (there should be one active for this
23
    to make sense */
26
    to make sense */
24
class DocSequenceDb : public DocSequence {
27
class DocSequenceDb : public DocSequence {
25
 public:
28
 public:
29
    DocSequenceDb(Rcl::Db *d, const std::string &t) : 
26
    DocSequenceDb(Rcl::Db *d) : m_db(d), m_rescnt(-1) {}
30
  DocSequence(t), m_db(d), m_rescnt(-1) 
31
  {}
27
    virtual ~DocSequenceDb() {}
32
    virtual ~DocSequenceDb() {}
28
    virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string * = 0);
33
    virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string * = 0);
29
    virtual int getResCnt();
34
    virtual int getResCnt();
30
    virtual std::string title() {return string("Query results");}
31
 private:
35
 private:
32
    Rcl::Db *m_db;
36
    Rcl::Db *m_db;
33
    int m_rescnt;
37
    int m_rescnt;
34
};
38
};
35
39
36
/** A DocSequence coming from the history file */
40
/** A DocSequence coming from the history file */
37
class DocSequenceHistory : public DocSequence {
41
class DocSequenceHistory : public DocSequence {
38
 public:
42
 public:
39
    DocSequenceHistory(Rcl::Db *d, RclDHistory *h) 
43
    DocSequenceHistory(Rcl::Db *d, RclDHistory *h, const std::string &t) 
40
    : m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {}
44
    : DocSequence(t), m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {}
41
    virtual ~DocSequenceHistory() {}
45
    virtual ~DocSequenceHistory() {}
42
46
43
    virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
47
    virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
44
    virtual int getResCnt();
48
    virtual int getResCnt();
45
    virtual std::string title() {return string("Document history");}
46
 private:
49
 private:
47
    Rcl::Db *m_db;
50
    Rcl::Db *m_db;
48
    RclDHistory *m_hist;
51
    RclDHistory *m_hist;
49
    int m_prevnum;
52
    int m_prevnum;
50
    long m_prevtime;
53
    long m_prevtime;