File indexing completed on 2024-05-12 15:55:21

0001 /* SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org>
0002 
0003    SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef EXACTCATEGORYMATCHER_H
0007 #define EXACTCATEGORYMATCHER_H
0008 
0009 #include "CategoryMatcher.h"
0010 
0011 namespace DB
0012 {
0013 
0014 /**
0015    \brief Enforce exact matching for another matcher.
0016 
0017    The ExactCategoryMatcher matches, iff the sub-matcher matches and
0018    the ImageInfoPtr does not contain any other tags in the category.
0019 
0020    If no sub-matcher is set, no image is matched.
0021 
0022    Example:
0023    The sub-matcher matches images with the tags "Jesper" and "Jim" in the category "People".
0024    Then the ExactMatcher will match the same images, except those who are also tagged with
0025    any other people.
0026 
0027    This is a replacement for the NoOtherItemsCategoryMatcher.
0028 */
0029 class ExactCategoryMatcher : public CategoryMatcher
0030 {
0031 public:
0032     explicit ExactCategoryMatcher(const QString category);
0033     ~ExactCategoryMatcher() override;
0034     void setMatcher(CategoryMatcher *subMatcher);
0035     bool eval(ImageInfoPtr, QMap<QString, StringSet> &alreadyMatched) override;
0036     void debug(int level) const override;
0037     /// shouldCreateMatchedSet is _always_ set for the sub-matcher of ExactCategoryMatcher.
0038     void setShouldCreateMatchedSet(bool) override;
0039 
0040 private:
0041     const QString m_category;
0042     CategoryMatcher *m_matcher;
0043 };
0044 
0045 }
0046 
0047 #endif /* EXACTCATEGORYMATCHER_H */
0048 
0049 // vi:expandtab:tabstop=4 shiftwidth=4: