Switch to unified view

a/src/query/docseq.h b/src/query/docseq.h
...
...
42
    enum Field {RCLFLD_MIMETYPE, RCLFLD_MTIME};
42
    enum Field {RCLFLD_MIMETYPE, RCLFLD_MTIME};
43
    void addCrit(Field fld, bool desc = false) {
43
    void addCrit(Field fld, bool desc = false) {
44
    crits.push_back(fld);
44
    crits.push_back(fld);
45
    dirs.push_back(desc);
45
    dirs.push_back(desc);
46
    }
46
    }
47
    bool isNotNull() {return sortdepth > 0;}
47
    bool isNotNull() const {return sortdepth > 0;}
48
48
    void reset() {crits.clear(); dirs.clear();sortdepth = 0;}
49
    int sortdepth; // We only re-sort the first sortdepth most relevant docs
49
    int sortdepth; // We only re-sort the first sortdepth most relevant docs
50
    std::vector<Field> crits;
50
    std::vector<Field> crits;
51
    std::vector<bool> dirs;
51
    std::vector<bool> dirs;
52
};
52
};
53
53
...
...
62
    values.push_back(value);
62
    values.push_back(value);
63
    }
63
    }
64
    std::vector<Crit> crits;
64
    std::vector<Crit> crits;
65
    std::vector<string> values;
65
    std::vector<string> values;
66
    void reset() {crits.clear(); values.clear();}
66
    void reset() {crits.clear(); values.clear();}
67
    bool isNotNull() {return crits.size() != 0;}
67
    bool isNotNull() const {return crits.size() != 0;}
68
};
68
};
69
69
70
/** Interface for a list of documents coming from some source.
70
/** Interface for a list of documents coming from some source.
71
71
72
    The result list display data may come from different sources (ie:
72
    The result list display data may come from different sources (ie:
...
...
92
     * @return true if ok, false for error or end of data
92
     * @return true if ok, false for error or end of data
93
     */
93
     */
94
    virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) = 0;
94
    virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) = 0;
95
95
96
    /** Get next page of documents. This accumulates entries into the result
96
    /** Get next page of documents. This accumulates entries into the result
97
     *  list (doesn't reset it). */
97
     *  list parameter (doesn't reset it). */
98
    virtual int getSeqSlice(int offs, int cnt, vector<ResListEntry>& result);
98
    virtual int getSeqSlice(int offs, int cnt, vector<ResListEntry>& result);
99
99
100
    /** Get abstract for document. This is special because it may take time.
100
    /** Get abstract for document. This is special because it may take time.
101
     *  The default is to return the input doc's abstract fields, but some 
101
     *  The default is to return the input doc's abstract fields, but some 
102
     *  sequences can compute a better value (ie: docseqdb) */
102
     *  sequences can compute a better value (ie: docseqdb) */
...
...
128
    {
128
    {
129
    terms.clear(); 
129
    terms.clear(); 
130
    }
130
    }
131
    virtual list<string> expand(Rcl::Doc &) {return list<string>();}
131
    virtual list<string> expand(Rcl::Doc &) {return list<string>();}
132
132
133
    /** Optional functionality. Yeah, not nice */
133
    /** Optional functionality. */
134
    virtual bool canFilter() {return false;}
134
    virtual bool canFilter() {return false;}
135
    virtual bool setFiltSpec(DocSeqFiltSpec &) {return false;}
136
    virtual bool canSort() {return false;}
135
    virtual bool canSort() {return false;}
136
    virtual bool setFiltSpec(const DocSeqFiltSpec &) {return false;}
137
    virtual bool setSortSpec(DocSeqSortSpec &) {return false;}
137
    virtual bool setSortSpec(const DocSeqSortSpec &) {return false;}
138
    virtual RefCntr<DocSequence> getSourceSeq() {return RefCntr<DocSequence>();}
138
139
139
 private:
140
 private:
140
    string m_title;
141
    string          m_title;
141
};
142
};
142
143
143
/** A modifier has a child sequence which does the real work and does
144
/** A modifier has a child sequence which does the real work and does
144
 * something with the results. Some operations are just delegated
145
 * something with the results. Some operations are just delegated
145
 */
146
 */
146
class DocSeqModifier : public DocSequence {
147
class DocSeqModifier : public DocSequence {
147
public:
148
public:
148
    DocSeqModifier(const string &t, RefCntr<DocSequence> iseq) 
149
    DocSeqModifier(RefCntr<DocSequence> iseq) 
149
    : DocSequence(t), m_seq(iseq) 
150
    : DocSequence(""), m_seq(iseq) 
150
    {}
151
    {}
151
    virtual ~DocSeqModifier() {}
152
    virtual ~DocSeqModifier() {}
152
153
153
    virtual string getAbstract(Rcl::Doc& doc) 
154
    virtual string getAbstract(Rcl::Doc& doc) 
154
    {
155
    {
...
...
166
    }
167
    }
167
    virtual void getUTerms(vector<string>& terms)
168
    virtual void getUTerms(vector<string>& terms)
168
    {
169
    {
169
    m_seq->getUTerms(terms);
170
    m_seq->getUTerms(terms);
170
    }
171
    }
172
    virtual string title() {return m_seq->title();}
173
    virtual RefCntr<DocSequence> getSourceSeq() {return m_seq;}
171
174
172
protected:
175
protected:
173
    RefCntr<DocSequence>    m_seq;
176
    RefCntr<DocSequence>    m_seq;
174
};
177
};
175
178
179
// A DocSource can juggle docseqs of different kinds to implement
180
// sorting and filtering in ways depending on the base seqs capabilities
181
class DocSource : public DocSeqModifier {
182
public:
183
    DocSource(RefCntr<DocSequence> iseq) 
184
  : DocSeqModifier(iseq)
185
    {}
186
    virtual bool canFilter() {return true;}
187
    virtual bool canSort() {return true;}
188
    virtual bool setFiltSpec(const DocSeqFiltSpec &);
189
    virtual bool setSortSpec(const DocSeqSortSpec &);
190
    virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0)
191
    {
192
  return m_seq->getDoc(num, doc, sh);
193
    }
194
    virtual int getResCnt()
195
    {
196
  return m_seq->getResCnt();
197
    }
198
    static void set_translations(const string& sort, const string& filt)
199
    {
200
  o_sort_trans = sort;
201
  o_filt_trans = filt;
202
    }
203
    virtual string title();
204
private:
205
    bool buildStack();
206
    void unwind();
207
    DocSeqFiltSpec  m_fspec;
208
    DocSeqSortSpec  m_sspec;
209
    static string o_sort_trans;
210
    static string o_filt_trans;
211
};
176
212
177
#endif /* _DOCSEQ_H_INCLUDED_ */
213
#endif /* _DOCSEQ_H_INCLUDED_ */