refactor operations delegated to subsequence by sortseq and filtspec into superclass
This commit is contained in:
parent
5b879ea0e7
commit
3d69417539
@ -27,6 +27,7 @@ using std::vector;
|
||||
#endif
|
||||
|
||||
#include "rcldoc.h"
|
||||
#include "refcntr.h"
|
||||
|
||||
// A result list entry.
|
||||
struct ResListEntry {
|
||||
@ -120,7 +121,7 @@ class DocSequence {
|
||||
{
|
||||
terms.clear(); groups.clear(); gslks.clear(); return true;
|
||||
}
|
||||
virtual list<string> expand(Rcl::Doc &) {list<string> e; return e;}
|
||||
virtual list<string> expand(Rcl::Doc &) {return list<string>();}
|
||||
|
||||
/** Optional functionality. Yeah, not nice */
|
||||
virtual bool canFilter() {return false;}
|
||||
@ -132,4 +133,34 @@ class DocSequence {
|
||||
string m_title;
|
||||
};
|
||||
|
||||
/** A modifier has a child sequence which does the real work and does
|
||||
* something with the results. Some operations are just delegated
|
||||
*/
|
||||
class DocSeqModifier : public DocSequence {
|
||||
public:
|
||||
DocSeqModifier(const string &t, RefCntr<DocSequence> iseq)
|
||||
: DocSequence(t), m_seq(iseq)
|
||||
{}
|
||||
virtual ~DocSeqModifier() {}
|
||||
|
||||
virtual string getAbstract(Rcl::Doc& doc)
|
||||
{
|
||||
return m_seq->getAbstract(doc);
|
||||
}
|
||||
virtual string getDescription()
|
||||
{
|
||||
return m_seq->getDescription();
|
||||
}
|
||||
virtual bool getTerms(vector<string>& terms,
|
||||
vector<vector<string> >& groups,
|
||||
vector<int>& gslks)
|
||||
{
|
||||
return m_seq->getTerms(terms, groups, gslks);
|
||||
}
|
||||
|
||||
protected:
|
||||
RefCntr<DocSequence> m_seq;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _DOCSEQ_H_INCLUDED_ */
|
||||
|
||||
@ -43,7 +43,7 @@ static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x)
|
||||
DocSeqFiltered::DocSeqFiltered(RefCntr<DocSequence> iseq,
|
||||
DocSeqFiltSpec &filtspec,
|
||||
const std::string &t)
|
||||
: DocSequence(t), m_seq(iseq), m_spec(filtspec)
|
||||
: DocSeqModifier(t, iseq), m_spec(filtspec)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
* A filtered sequence is created from another one by selecting entries
|
||||
* according to the given criteria.
|
||||
*/
|
||||
class DocSeqFiltered : public DocSequence {
|
||||
class DocSeqFiltered : public DocSeqModifier {
|
||||
public:
|
||||
DocSeqFiltered(RefCntr<DocSequence> iseq, DocSeqFiltSpec &filtspec,
|
||||
const std::string &t);
|
||||
@ -38,13 +38,7 @@ class DocSeqFiltered : public DocSequence {
|
||||
virtual bool setFiltSpec(DocSeqFiltSpec &filtspec);
|
||||
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
|
||||
virtual int getResCnt() {return m_seq->getResCnt();}
|
||||
virtual string getAbstract(Rcl::Doc& doc) {
|
||||
return m_seq->getAbstract(doc);
|
||||
}
|
||||
virtual string getDescription() {return m_seq->getDescription();}
|
||||
|
||||
private:
|
||||
RefCntr<DocSequence> m_seq;
|
||||
DocSeqFiltSpec m_spec;
|
||||
vector<int> m_dbindices;
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ public:
|
||||
|
||||
DocSeqSorted::DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
|
||||
const std::string &t)
|
||||
: DocSequence(t), m_seq(iseq)
|
||||
: DocSeqModifier(t, iseq)
|
||||
{
|
||||
setSortSpec(sortspec);
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
* A sorted sequence is created from the first N documents of another one,
|
||||
* and sorts them according to the given criteria.
|
||||
*/
|
||||
class DocSeqSorted : public DocSequence {
|
||||
class DocSeqSorted : public DocSeqModifier {
|
||||
public:
|
||||
DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
|
||||
const std::string &t);
|
||||
@ -37,13 +37,7 @@ class DocSeqSorted : public DocSequence {
|
||||
virtual bool setSortSpec(DocSeqSortSpec &sortspec);
|
||||
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
|
||||
virtual int getResCnt() {return m_spec.sortdepth;}
|
||||
virtual string getAbstract(Rcl::Doc& doc) {
|
||||
return m_seq->getAbstract(doc);
|
||||
}
|
||||
virtual string getDescription() {return m_seq->getDescription();}
|
||||
|
||||
private:
|
||||
RefCntr<DocSequence> m_seq;
|
||||
DocSeqSortSpec m_spec;
|
||||
std::vector<Rcl::Doc> m_docs;
|
||||
std::vector<Rcl::Doc *> m_docsp;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user