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