Switch to unified view

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
20
#include "autoconfig.h"
21
19
#include <string>
22
#include <string>
20
#include <list>
23
#include <list>
21
#include <vector>
24
#include <vector>
22
25
#include MEMORY_INCLUDE
23
26
24
#include "rcldoc.h"
27
#include "rcldoc.h"
25
#include "refcntr.h"
26
#include "hldata.h"
28
#include "hldata.h"
27
#include "ptmutex.h"
29
#include "ptmutex.h"
28
30
29
// Need this for the "Snippet" class def.
31
// Need this for the "Snippet" class def.
30
#include "rclquery.h"
32
#include "rclquery.h"
...
...
151
    /** Optional functionality. */
153
    /** Optional functionality. */
152
    virtual bool canFilter() {return false;}
154
    virtual bool canFilter() {return false;}
153
    virtual bool canSort() {return false;}
155
    virtual bool canSort() {return false;}
154
    virtual bool setFiltSpec(const DocSeqFiltSpec &) {return false;}
156
    virtual bool setFiltSpec(const DocSeqFiltSpec &) {return false;}
155
    virtual bool setSortSpec(const DocSeqSortSpec &) {return false;}
157
    virtual bool setSortSpec(const DocSeqSortSpec &) {return false;}
156
    virtual RefCntr<DocSequence> getSourceSeq() {return RefCntr<DocSequence>();}
158
    virtual STD_SHARED_PTR<DocSequence> getSourceSeq() {return STD_SHARED_PTR<DocSequence>();}
157
159
158
    static void set_translations(const std::string& sort, const std::string& filt)
160
    static void set_translations(const std::string& sort, const std::string& filt)
159
    {
161
    {
160
    o_sort_trans = sort;
162
    o_sort_trans = sort;
161
    o_filt_trans = filt;
163
    o_filt_trans = filt;
...
...
177
/** A modifier has a child sequence which does the real work and does
179
/** A modifier has a child sequence which does the real work and does
178
 * something with the results. Some operations are just delegated
180
 * something with the results. Some operations are just delegated
179
 */
181
 */
180
class DocSeqModifier : public DocSequence {
182
class DocSeqModifier : public DocSequence {
181
public:
183
public:
182
    DocSeqModifier(RefCntr<DocSequence> iseq) 
184
    DocSeqModifier(STD_SHARED_PTR<DocSequence> iseq) 
183
    : DocSequence(""), m_seq(iseq) 
185
    : DocSequence(""), m_seq(iseq) 
184
    {}
186
    {}
185
    virtual ~DocSeqModifier() {}
187
    virtual ~DocSeqModifier() {}
186
188
187
    virtual bool getAbstract(Rcl::Doc& doc, std::vector<std::string>& abs) 
189
    virtual bool getAbstract(Rcl::Doc& doc, std::vector<std::string>& abs) 
188
    {
190
    {
189
  if (m_seq.isNull())
191
  if (!m_seq)
190
        return false;
192
        return false;
191
    return m_seq->getAbstract(doc, abs);
193
    return m_seq->getAbstract(doc, abs);
192
    }
194
    }
193
    virtual bool getAbstract(Rcl::Doc& doc, 
195
    virtual bool getAbstract(Rcl::Doc& doc, 
194
                 std::vector<Rcl::Snippet>& abs) 
196
                 std::vector<Rcl::Snippet>& abs) 
195
    {
197
    {
196
  if (m_seq.isNull())
198
  if (!m_seq)
197
        return false;
199
        return false;
198
    return m_seq->getAbstract(doc, abs);
200
    return m_seq->getAbstract(doc, abs);
199
    }
201
    }
200
    /** Get duplicates. */
202
    /** Get duplicates. */
201
    virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
203
    virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
202
    {
204
    {
203
  if (m_seq.isNull())
205
  if (!m_seq)
204
        return false;
206
        return false;
205
    return m_seq->docDups(doc, dups);
207
    return m_seq->docDups(doc, dups);
206
    }
208
    }
207
209
208
    virtual bool snippetsCapable()
210
    virtual bool snippetsCapable()
209
    {
211
    {
210
  if (m_seq.isNull())
212
  if (!m_seq)
211
        return false;
213
        return false;
212
    return m_seq->snippetsCapable();
214
    return m_seq->snippetsCapable();
213
    }
215
    }
214
    virtual std::string getDescription() 
216
    virtual std::string getDescription() 
215
    {
217
    {
216
  if (m_seq.isNull())
218
  if (!m_seq)
217
        return "";
219
        return "";
218
    return m_seq->getDescription();
220
    return m_seq->getDescription();
219
    }
221
    }
220
    virtual void getTerms(HighlightData& hld)
222
    virtual void getTerms(HighlightData& hld)
221
    {
223
    {
222
  if (m_seq.isNull())
224
  if (!m_seq)
223
        return;
225
        return;
224
    m_seq->getTerms(hld);
226
    m_seq->getTerms(hld);
225
    }
227
    }
226
    virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc) 
228
    virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc) 
227
    {
229
    {
228
  if (m_seq.isNull())
230
  if (!m_seq)
229
        return false;
231
        return false;
230
    return m_seq->getEnclosing(doc, pdoc);
232
    return m_seq->getEnclosing(doc, pdoc);
231
    }
233
    }
232
    virtual std::string getReason() 
234
    virtual std::string getReason() 
233
    {
235
    {
234
  if (m_seq.isNull())
236
  if (!m_seq)
235
        return string();
237
        return string();
236
    return m_seq->getReason();
238
    return m_seq->getReason();
237
    }
239
    }
238
    virtual std::string title() 
240
    virtual std::string title() 
239
    {
241
    {
240
    return m_seq->title();
242
    return m_seq->title();
241
    }
243
    }
242
    virtual RefCntr<DocSequence> getSourceSeq() 
244
    virtual STD_SHARED_PTR<DocSequence> getSourceSeq() 
243
    {
245
    {
244
    return m_seq;
246
    return m_seq;
245
    }
247
    }
246
248
247
protected:
249
protected:
248
    virtual Rcl::Db *getDb()
250
    virtual Rcl::Db *getDb()
249
    {
251
    {
250
  if (m_seq.isNull())
252
  if (!m_seq)
251
        return 0;
253
        return 0;
252
    return m_seq->getDb();
254
    return m_seq->getDb();
253
    }
255
    }
254
256
255
    RefCntr<DocSequence>    m_seq;
257
    STD_SHARED_PTR<DocSequence>    m_seq;
256
};
258
};
257
259
258
class RclConfig;
260
class RclConfig;
259
261
260
// A DocSource can juggle docseqs of different kinds to implement
262
// A DocSource can juggle docseqs of different kinds to implement
261
// sorting and filtering in ways depending on the base seqs capabilities
263
// sorting and filtering in ways depending on the base seqs capabilities
262
class DocSource : public DocSeqModifier {
264
class DocSource : public DocSeqModifier {
263
public:
265
public:
264
    DocSource(RclConfig *config, RefCntr<DocSequence> iseq) 
266
    DocSource(RclConfig *config, STD_SHARED_PTR<DocSequence> iseq) 
265
    : DocSeqModifier(iseq), m_config(config)
267
    : DocSeqModifier(iseq), m_config(config)
266
    {}
268
    {}
267
    virtual bool canFilter() {return true;}
269
    virtual bool canFilter() {return true;}
268
    virtual bool canSort() {return true;}
270
    virtual bool canSort() {return true;}
269
    virtual bool setFiltSpec(const DocSeqFiltSpec &);
271
    virtual bool setFiltSpec(const DocSeqFiltSpec &);
270
    virtual bool setSortSpec(const DocSeqSortSpec &);
272
    virtual bool setSortSpec(const DocSeqSortSpec &);
271
    virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0)
273
    virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0)
272
    {
274
    {
273
  if (m_seq.isNull())
275
  if (!m_seq)
274
        return false;
276
        return false;
275
    return m_seq->getDoc(num, doc, sh);
277
    return m_seq->getDoc(num, doc, sh);
276
    }
278
    }
277
    virtual int getResCnt()
279
    virtual int getResCnt()
278
    {
280
    {
279
  if (m_seq.isNull())
281
  if (!m_seq)
280
        return 0;
282
        return 0;
281
    return m_seq->getResCnt();
283
    return m_seq->getResCnt();
282
    }
284
    }
283
    virtual std::string title();
285
    virtual std::string title();
284
private:
286
private: