LCOV - code coverage report
Current view: top level - include/xapian - matchdecider.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 7822d31adece Lines: 2 2 100.0 %
Date: 2019-05-23 11:15:29 Functions: 2 2 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file matchdecider.h
       2                 :            :  * @brief Abstract base class for match deciders
       3                 :            :  */
       4                 :            : /* Copyright (C) 2017 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 2 of the License, or
       9                 :            :  * (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 USA
      19                 :            :  */
      20                 :            : 
      21                 :            : #ifndef XAPIAN_INCLUDED_MATCHDECIDER_H
      22                 :            : #define XAPIAN_INCLUDED_MATCHDECIDER_H
      23                 :            : 
      24                 :            : #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
      25                 :            : # error "Never use <xapian/matchdecider.h> directly; include <xapian.h> instead."
      26                 :            : #endif
      27                 :            : 
      28                 :            : #include <xapian/attributes.h>
      29                 :            : #include <xapian/types.h>
      30                 :            : #include <xapian/visibility.h>
      31                 :            : 
      32                 :            : namespace Xapian {
      33                 :            : 
      34                 :            : class Document;
      35                 :            : 
      36                 :            : /// Abstract base class for match deciders.
      37                 :            : class XAPIAN_VISIBILITY_DEFAULT MatchDecider {
      38                 :            :   private:
      39                 :            :     /// Don't allow assignment.
      40                 :            :     void operator=(const MatchDecider &) = delete;
      41                 :            : 
      42                 :            :     /// Don't allow copying.
      43                 :            :     MatchDecider(const MatchDecider &) = delete;
      44                 :            : 
      45                 :            :   public:
      46                 :            :     /// Default constructor, needed by subclass constructors.
      47                 :         30 :     XAPIAN_NOTHROW(MatchDecider()) {}
      48                 :            : 
      49                 :            :     /** Virtual destructor, because we have virtual methods. */
      50         [ -  + ]:         60 :     virtual ~MatchDecider() { }
      51                 :            : 
      52                 :            :     /** Decide whether to accept a document.
      53                 :            :      *
      54                 :            :      *  This is called by the matcher for documents before adding them to the
      55                 :            :      *  candidate result set.  Note that documents accepted here may still not
      56                 :            :      *  appear in the final MSet (better documents may be found, for example).
      57                 :            :      *
      58                 :            :      *  @param doc The document to consider.
      59                 :            :      *
      60                 :            :      *  @return true if the document should be considered further.
      61                 :            :      */
      62                 :            :     virtual bool operator()(const Xapian::Document &doc) const = 0;
      63                 :            : 
      64                 :            :     /** @private @internal Count of documents accepted by this object.
      65                 :            :      *
      66                 :            :      *  Used to return stats to the matcher.
      67                 :            :      */
      68                 :            :     mutable Xapian::doccount docs_allowed_;
      69                 :            : 
      70                 :            :     /** @private @internal Count of documents rejected by this object.
      71                 :            :      *
      72                 :            :      *  Used to return stats to the matcher.
      73                 :            :      */
      74                 :            :     mutable Xapian::doccount docs_denied_;
      75                 :            : };
      76                 :            : 
      77                 :            : }
      78                 :            : 
      79                 :            : #endif // XAPIAN_INCLUDED_MATCHDECIDER_H

Generated by: LCOV version 1.11