00001 /* selectpostlist.h: Parent class for classes which only return selected docs 00002 * 00003 * ----START-LICENCE---- 00004 * Copyright 1999,2000,2001 BrightStation PLC 00005 * Copyright 2003,2004 Olly Betts 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as 00009 * published by the Free Software Foundation; either version 2 of the 00010 * License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 * -----END-LICENCE----- 00022 */ 00023 00024 #ifndef OM_HGUARD_SELECTPOSTLIST_H 00025 #define OM_HGUARD_SELECTPOSTLIST_H 00026 00027 #include "postlist.h" 00028 00032 class SelectPostList : public PostList { 00033 private: 00034 // Prevent copying 00035 SelectPostList(const SelectPostList &); 00036 SelectPostList & operator=(const SelectPostList &); 00037 00038 protected: 00039 PostList *source; 00040 00044 virtual bool test_doc() = 0; 00045 public: 00046 PostList *next(Xapian::weight w_min); 00047 PostList *skip_to(Xapian::docid did, Xapian::weight w_min); 00048 00049 // pass all these through to the underlying source PostList 00050 Xapian::doccount get_termfreq_max() const { return source->get_termfreq_max(); } 00051 Xapian::doccount get_termfreq_min() const { return 0; } 00052 Xapian::weight get_maxweight() const { return source->get_maxweight(); } 00053 Xapian::docid get_docid() const { return source->get_docid(); } 00054 Xapian::weight get_weight() const { return source->get_weight(); } 00055 Xapian::doclength get_doclength() const { return source->get_doclength(); } 00056 Xapian::weight recalc_maxweight() { return source->recalc_maxweight(); } 00057 PositionList * read_position_list() { return source->read_position_list(); } 00058 PositionList * open_position_list() const { return source->open_position_list(); } 00059 bool at_end() const { return source->at_end(); } 00060 00061 std::string get_description() const; 00062 00063 SelectPostList(PostList *source_) : source(source_) { } 00064 ~SelectPostList() { delete source; } 00065 }; 00066 00067 inline std::string 00068 SelectPostList::get_description() const 00069 { 00070 return "(Select " + source->get_description() + ")"; 00071 } 00072 00073 #endif /* OM_HGUARD_SELECTPOSTLIST_H */