Gaia
filterwrapper.h
1 /*
2  * Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Gaia
5  *
6  * Gaia is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License as published by the Free
8  * Software Foundation (FSF), either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the Affero GNU General Public License
17  * version 3 along with this program. If not, see http://www.gnu.org/licenses/
18  */
19 
20 #ifndef GAIA_PARSER_FILTERWRAPPER_H
21 #define GAIA_PARSER_FILTERWRAPPER_H
22 
23 #include "filter.h"
24 #include "convert.h"
25 
26 namespace gaia2 {
27 namespace filter {
28 
35 class FilterWrapper : public Filter {
36  void initValueList(const QString& varname, const QString& op, const QList<Real>& values);
37  void initLabelList(const QString& varname, const QString& op, const QList<QString>& labels);
38 
39  public:
40  FilterWrapper(const QString& varname, const QString& op, Real value);
41  FilterWrapper(const QString& varname, const QString& op, const QList<Real>& values);
42 
43  FilterWrapper(const QString& varname, const QString& op, const QString& label);
44  FilterWrapper(const QString& varname, const QString& op, const QList<QString>& labels);
45 
46  FilterWrapper(const std::string& varname, const std::string& op, Real value);
47  FilterWrapper(const std::string& varname, const std::string& op, const std::vector<Real>& values);
48 
49  FilterWrapper(const std::string& varname, const std::string& op, const std::string& label);
50  FilterWrapper(const std::string& varname, const std::string& op, const std::vector<std::string>& labels);
51 
52 };
53 
54 
55 class AndFilter : public Filter {
56  void init(const QList<Filter*>& preds);
57 
58  public:
59  AndFilter(const QList<Filter*>& preds) { init(preds); }
60  AndFilter(const std::vector<Filter*>& preds) { init(convert::Vector_to_QList(preds)); }
61 
62 };
63 
64 class OrFilter : public Filter {
65  void init(const QList<Filter*>& preds);
66 
67  public:
68  OrFilter(const QList<Filter*>& preds) { init(preds); }
69  OrFilter(const std::vector<Filter*>& preds) { init(convert::Vector_to_QList(preds)); }
70 };
71 
72 class NotFilter : public Filter {
73  public:
74  NotFilter(const Filter* pred);
75 };
76 
77 
78 } // namespace filter
79 } // namespace gaia2
80 
81 
82 #endif // GAIA_PARSER_FILTERWRAPPER_H
QList< T > Vector_to_QList(const std::vector< T > &v)
Converts a std::vector of something into a QList of the same objects.
Definition: convert.h:91
Definition: filterwrapper.h:64
The Filter class allows to check whether a predicate is true for a given Point.
Definition: filter.h:73
Main Gaia namespace, which contains all the library functions.
Definition: addfield.cpp:22
void init()
Init function that makes sure that all the factories have correctly registered all the types they can...
Definition: gaia.cpp:53
The FilterWrapper class serves as an easy wrapper for a subset of all possible filters, but with a much more intuitive API that allows filters to be constructed programatically on the fly instead of being parsed from a string representation.
Definition: filterwrapper.h:35
Definition: filterwrapper.h:72
Definition: filterwrapper.h:55