[ci] Try to get .gitignore check to work
[xapian.git] / xapian-core / matcher / spymaster.h
bloba9d4a1f6967a7ba3dc6494facb703b4087b7835e
1 /** @file spymaster.h
2 * @brief Class for managing MatchSpy objects during the match
3 */
4 /* Copyright 2017 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_SPYMASTER_H
22 #define XAPIAN_INCLUDED_SPYMASTER_H
24 #include <xapian/intrusive_ptr.h>
25 #include <xapian/matchspy.h>
27 #include <vector>
29 class SpyMaster {
30 typedef Xapian::Internal::opt_intrusive_ptr<Xapian::MatchSpy> opt_ptr_spy;
32 /// The MatchSpy objects to apply.
33 const std::vector<opt_ptr_spy>* spies;
35 public:
36 explicit SpyMaster(const std::vector<opt_ptr_spy>* spies_)
37 : spies(spies_->empty() ? NULL : spies_)
40 operator bool() const { return spies != NULL; }
42 void operator()(const Xapian::Document& doc,
43 double weight) {
44 if (spies != NULL) {
45 for (auto spy : *spies) {
46 (*spy)(doc, weight);
52 #endif // XAPIAN_INCLUDED_SPYMASTER_H