Make TradWeight a simple subclass and deprecate
[xapian.git] / xapian-core / backends / multi / multi_termlist.h
blobbaaf678de49e96dab243fc9771265e9463f09a7b
1 /** @file
2 * @brief Adapter class for a TermList in a multidatabase
3 */
4 /* Copyright (C) 2007,2010,2013,2017,2024 Olly Betts
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.
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.
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
21 #ifndef XAPIAN_INCLUDED_MULTI_TERMLIST_H
22 #define XAPIAN_INCLUDED_MULTI_TERMLIST_H
24 #include "api/termlist.h"
26 #include <xapian/database.h>
28 using Xapian::Internal::intrusive_ptr_nonnull;
30 /** Adapter class for a TermList in a multidatabase.
32 * Most methods just forward to @a real_termlist, but @a get_termfreq()
33 * fetches the combined term frequency from the multidatabase.
35 class MultiTermList : public TermList {
36 /// Don't allow assignment.
37 void operator=(const MultiTermList &) = delete;
39 /// Don't allow copying.
40 MultiTermList(const MultiTermList &) = delete;
42 /// The TermList in the subdatabase.
43 TermList* real_termlist;
45 /// The multidatabase.
46 intrusive_ptr_nonnull<const Xapian::Database::Internal> db;
48 public:
49 /// Constructor.
50 MultiTermList(const Xapian::Database::Internal* db_, TermList* real_termlist_);
52 /// Destructor.
53 ~MultiTermList();
55 /// Return approximate size of this termlist.
56 Xapian::termcount get_approx_size() const;
58 /// Return the wdf for the term at the current position.
59 Xapian::termcount get_wdf() const;
61 /// Return the term frequency for the term at the current position.
62 Xapian::doccount get_termfreq() const;
64 /** Advance the current position to the next term in the termlist.
66 * The list starts before the first term in the list, so next(), skip_to()
67 * or check() must be called before any methods which need the context of
68 * the current position.
70 * @return If a non-NULL pointer is returned, then the caller should
71 * substitute the returned pointer for its pointer to us, and then
72 * delete us. This "pruning" can only happen for a non-leaf
73 * subclass of this class.
75 Internal * next();
77 /** Skip forward to the specified term.
79 * If the specified term isn't in the list, position ourselves on the
80 * first term after tname (or at_end() if no terms after tname exist).
82 Internal* skip_to(std::string_view term);
84 /// Return the length of the position list for the current position.
85 Xapian::termcount positionlist_count() const;
87 /// Return a PositionIterator for the current position.
88 PositionList* positionlist_begin() const;
91 #endif // XAPIAN_INCLUDED_MULTI_TERMLIST_H