diff options
Diffstat (limited to 'lib/urlfilter/filtertree.h')
-rw-r--r-- | lib/urlfilter/filtertree.h | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/urlfilter/filtertree.h b/lib/urlfilter/filtertree.h index 004cf5a..3da82e0 100644 --- a/lib/urlfilter/filtertree.h +++ b/lib/urlfilter/filtertree.h @@ -9,22 +9,26 @@ #ifndef SMOLBOTE_FILTERTREE_H #define SMOLBOTE_FILTERTREE_H +#include "domain.h" +#include "filterleaf.h" +#include <QIODevice> #include <QObject> #include <QVector> #include <vector> -#include <QIODevice> -#include "filterleaf.h" -#include "domain.h" +#include <QMutex> /** FilterTree: B+ tree of filter rules - * The root of the tree contains branches that represent domains, on which their rules are to be applied. - * Each branch contains leaves - rules + * The tree contains branches that represent domains + * Each domain-branch contains leaves (rules) that are to be applied to it. + * Rules may be applied to multiple branches. */ class FilterTree : public QObject { Q_OBJECT public: + ~FilterTree(); + const QStringList branches() const; QVector<const FilterLeaf *> match(const QString &domain, const QString &requestUrl) const; @@ -32,19 +36,23 @@ public: private: struct Branch { - explicit Branch(const QString &host) : domain(host) {} + explicit Branch(const QString &host) + : domain(host) + { + } explicit Branch(Branch &&other) : domain(std::move(other.domain)) , leaves(std::move(other.leaves)) - {} - ~Branch() { qDeleteAll(leaves); } + { + } - // TODO: replace domain type with domain-matching class Domain domain; - //std::string domain; std::vector<FilterLeaf *> leaves; }; + Branch& branch(const QString &domain); + + QMutex branchLock; std::vector<Branch> m_branches; }; |