Essentia  2.1-beta6-dev
range.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Essentia
5  *
6  * Essentia 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 ESSENTIA_RANGE_H
21 #define ESSENTIA_RANGE_H
22 
23 #include "parameter.h"
24 #include <set>
25 
26 namespace essentia {
27 
28 class ESSENTIA_API Range {
29  public:
30  virtual ~Range() {}
31  static Range* create(const std::string& s);
32  virtual bool contains(const Parameter& param) const = 0;
33 };
34 
35 class Everything : public Range {
36  public:
37  virtual bool contains(const Parameter& param) const;
38 };
39 
40 class Interval : public Range {
41  public:
42  Interval(const std::string& s);
43  virtual ~Interval() {}
44  virtual bool contains(const Parameter& param) const;
45 
46  protected:
47  bool _lbound, _ubound; // whether we have a lower/upper bound (ie: not infinite)
48  bool _lincluded, _uincluded; // whether these bounds are inclusive or exclusive
49  Real _lvalue, _uvalue; // the boundary values
50 };
51 
52 class Set : public Range {
53  public:
54  Set(const std::string& s);
55  virtual ~Set() {}
56  virtual bool contains(const Parameter& param) const;
57  void test() const;
58 
59  protected:
60  std::set<std::string> _elements;
61  std::string s;
62 };
63 
64 } // namespace essentia
65 
66 #endif // ESSENTIA_RANGE_H
Definition: range.h:35
virtual bool contains(const Parameter &param) const
Definition: range.h:40
virtual bool contains(const Parameter &param) const
bool _uincluded
Definition: range.h:48
Real _lvalue
Definition: range.h:49
bool _lbound
Definition: range.h:47
bool _ubound
Definition: range.h:47
Interval(const std::string &s)
Real _uvalue
Definition: range.h:49
virtual ~Interval()
Definition: range.h:43
bool _lincluded
Definition: range.h:48
Definition: parameter.h:30
Definition: range.h:28
virtual bool contains(const Parameter &param) const =0
static Range * create(const std::string &s)
virtual ~Range()
Definition: range.h:30
Definition: range.h:52
std::set< std::string > _elements
Definition: range.h:60
void test() const
virtual ~Set()
Definition: range.h:55
Set(const std::string &s)
virtual bool contains(const Parameter &param) const
std::string s
Definition: range.h:61
Definition: algorithm.h:28
float Real
Definition: types.h:69