LCOV - code coverage report
Current view: top level - include/xapian - rset.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: 5 5 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file  rset.h
       2                 :            :  *  @brief Set of documents judged as relevant
       3                 :            :  */
       4                 :            : /* Copyright (C) 2015,2016,2017 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 XAPIAN_INCLUDED_RSET_H
      23                 :            : #define XAPIAN_INCLUDED_RSET_H
      24                 :            : 
      25                 :            : #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
      26                 :            : # error "Never use <xapian/rset.h> directly; include <xapian.h> instead."
      27                 :            : #endif
      28                 :            : 
      29                 :            : #include <xapian/attributes.h>
      30                 :            : #include <xapian/intrusive_ptr.h>
      31                 :            : #include <xapian/mset.h>
      32                 :            : #include <xapian/types.h>
      33                 :            : #include <xapian/visibility.h>
      34                 :            : 
      35                 :            : namespace Xapian {
      36                 :            : 
      37                 :            : class ESetIterator;
      38                 :            : 
      39                 :            : /// Class representing a set of documents judged as relevant.
      40                 :        204 : class XAPIAN_VISIBILITY_DEFAULT RSet {
      41                 :            :   public:
      42                 :            :     /// Class representing the RSet internals.
      43                 :            :     class Internal;
      44                 :            :     /// @private @internal Reference counted internals.
      45                 :            :     Xapian::Internal::intrusive_ptr<Internal> internal;
      46                 :            : 
      47                 :            :     /** Copying is allowed.
      48                 :            :      *
      49                 :            :      *  The internals are reference counted, so copying is cheap.
      50                 :            :      */
      51                 :            :     RSet(const RSet & o);
      52                 :            : 
      53                 :            :     /** Copying is allowed.
      54                 :            :      *
      55                 :            :      *  The internals are reference counted, so assignment is cheap.
      56                 :            :      */
      57                 :            :     RSet & operator=(const RSet & o);
      58                 :            : 
      59                 :            :     /// Move constructor.
      60                 :            :     RSet(RSet && o);
      61                 :            : 
      62                 :            :     /// Move assignment operator.
      63                 :            :     RSet & operator=(RSet && o);
      64                 :            : 
      65                 :            :     /** Default constructor.
      66                 :            :      *
      67                 :            :      *  Creates an empty RSet.
      68                 :            :      */
      69                 :            :     RSet();
      70                 :            : 
      71                 :            :     /** @private @internal Wrap an existing Internal. */
      72                 :            :     XAPIAN_VISIBILITY_INTERNAL
      73                 :            :     explicit RSet(Internal* internal_);
      74                 :            : 
      75                 :            :     /// Destructor.
      76                 :            :     ~RSet();
      77                 :            : 
      78                 :            :     /** Return number of documents in this RSet object. */
      79                 :            :     Xapian::doccount size() const;
      80                 :            : 
      81                 :            :     /** Return true if this RSet object is empty. */
      82                 :        432 :     bool empty() const { return size() == 0; }
      83                 :            : 
      84                 :            :     /** Efficiently swap this RSet object with another. */
      85                 :            :     void swap(RSet & o) { internal.swap(o.internal); }
      86                 :            : 
      87                 :            :     /** Mark a document as relevant.
      88                 :            :      *
      89                 :            :      *  If @a did is already marked as relevant, nothing happens.
      90                 :            :      */
      91                 :            :     void add_document(Xapian::docid did);
      92                 :            : 
      93                 :            :     /** Mark a document as relevant.
      94                 :            :      *
      95                 :            :      *  If @a did is already marked as relevant, nothing happens.
      96                 :            :      */
      97                 :            :     void add_document(const Xapian::MSetIterator& it) {
      98                 :            :         add_document(*it);
      99                 :            :     }
     100                 :            : 
     101                 :            :     /** Unmark a document as relevant.
     102                 :            :      *
     103                 :            :      *  If @a did is not marked as relevant, nothing happens.
     104                 :            :      */
     105                 :            :     void remove_document(Xapian::docid did);
     106                 :            : 
     107                 :            :     /** Unmark a document as relevant.
     108                 :            :      *
     109                 :            :      *  If @a did is not marked as relevant, nothing happens.
     110                 :            :      */
     111                 :            :     void remove_document(const Xapian::MSetIterator& it) {
     112                 :            :         remove_document(*it);
     113                 :            :     }
     114                 :            : 
     115                 :            :     /// Check if a document is marked as relevant.
     116                 :            :     bool contains(Xapian::docid did) const;
     117                 :            : 
     118                 :            :     /// Check if a document is marked as relevant.
     119                 :            :     bool contains(const Xapian::MSetIterator& it) const {
     120                 :            :         return contains(*it);
     121                 :            :     }
     122                 :            : 
     123                 :            :     /// Return a string describing this object.
     124                 :            :     std::string get_description() const;
     125                 :            : };
     126                 :            : 
     127                 :            : }
     128                 :            : 
     129                 :            : #endif // XAPIAN_INCLUDED_RSET_H

Generated by: LCOV version 1.11