LCOV - code coverage report
Current view: top level - matcher - selectpostlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 11 16 68.8 %
Date: 2011-08-21 Functions: 10 16 62.5 %
Branches: 2 8 25.0 %

           Branch data     Line data    Source code
       1                 :            : /* selectpostlist.h: Parent class for classes which only return selected docs
       2                 :            :  *
       3                 :            :  * Copyright 1999,2000,2001 BrightStation PLC
       4                 :            :  * Copyright 2003,2004,2009,2010 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or
       7                 :            :  * modify it under the terms of the GNU General Public License as
       8                 :            :  * published by the Free Software Foundation; either version 2 of the
       9                 :            :  * License, or (at your option) any later version.
      10                 :            :  *
      11                 :            :  * This program is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this program; if not, write to the Free Software
      18                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      19                 :            :  * USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #ifndef OM_HGUARD_SELECTPOSTLIST_H
      23                 :            : #define OM_HGUARD_SELECTPOSTLIST_H
      24                 :            : 
      25                 :            : #include "postlist.h"
      26                 :            : 
      27                 :            : /** A postlist parent class for classes which only return selected docs
      28                 :            :  *  from a source postlist (e.g. NEAR and PHRASE)
      29                 :            :  */
      30                 :            : class SelectPostList : public PostList {
      31                 :            :     private:
      32                 :            :         // Prevent copying
      33                 :            :         SelectPostList(const SelectPostList &);
      34                 :            :         SelectPostList & operator=(const SelectPostList &);
      35                 :            : 
      36                 :            :     protected:
      37                 :            :         PostList *source;
      38                 :            : 
      39                 :            :         /** Subclasses should override test_doc() with a method which returns
      40                 :            :          *  true if a document meets the appropriate criterion, false in not
      41                 :            :          */
      42                 :            :         virtual bool test_doc() = 0;
      43                 :            :     public:
      44                 :            :         PostList *next(Xapian::weight w_min);
      45                 :            :         PostList *skip_to(Xapian::docid did, Xapian::weight w_min);
      46                 :            :         PostList *check(Xapian::docid did, Xapian::weight w_min, bool &valid);
      47                 :            : 
      48                 :            :         // pass all these through to the underlying source PostList
      49                 :       1008 :         Xapian::doccount get_termfreq_max() const { return source->get_termfreq_max(); }
      50                 :        912 :         Xapian::doccount get_termfreq_min() const { return 0; }
      51                 :          0 :         Xapian::weight get_maxweight() const { return source->get_maxweight(); }
      52                 :       1322 :         Xapian::docid get_docid() const { return source->get_docid(); }
      53                 :       1235 :         Xapian::weight get_weight() const { return source->get_weight(); }
      54                 :         52 :         Xapian::termcount get_doclength() const { return source->get_doclength(); }
      55                 :       1027 :         Xapian::weight recalc_maxweight() { return source->recalc_maxweight(); }
      56                 :          0 :         PositionList * read_position_list() { return source->read_position_list(); }
      57                 :          0 :         PositionList * open_position_list() const { return source->open_position_list(); }
      58                 :       2507 :         bool at_end() const { return source->at_end(); }
      59                 :            : 
      60                 :         13 :         Xapian::termcount count_matching_subqs() const {
      61                 :         13 :             return source->count_matching_subqs();
      62                 :            :         }
      63                 :            : 
      64                 :            :         std::string get_description() const;    
      65                 :            :     
      66                 :       1024 :         SelectPostList(PostList *source_) : source(source_) { }
      67 [ +  - ][ -  + ]:       1024 :         ~SelectPostList() { delete source; }
         [ #  # ][ #  # ]
      68                 :            : };
      69                 :            : 
      70                 :            : inline std::string
      71                 :          0 : SelectPostList::get_description() const
      72                 :            : {
      73                 :          0 :     return "(Select " + source->get_description() + ")";
      74                 :            : }
      75                 :            : 
      76                 :            : #endif /* OM_HGUARD_SELECTPOSTLIST_H */

Generated by: LCOV version 1.8