Gaia
distancefunction.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_DISTANCEFUNCTION_H
21 #define GAIA_DISTANCEFUNCTION_H
22 
23 #include "layoutawarefactory.h"
24 #include "parameter.h"
25 #include "point.h"
26 
27 namespace gaia2 {
28 
29 
38  public:
39 
44  QString name;
45 
46  DistanceFunction(const PointLayout& layout, const ParameterMap& params);
47  virtual ~DistanceFunction() {}
48 
54  virtual Real operator()(const Point& p1, const Point& p2,
55  int seg1 = 0, int seg2 = 0) const = 0;
56 
57  const PointLayout& layout() const { return _layout; }
58 
64  const Region& checkFixedLength(const Region& region) const;
65 
71  QStringList validParams;
72 
73  protected:
74  PointLayout _layout;
75  ParameterMap _params;
76  Region _region;
77 
78 
79 };
80 
81 
83 typedef MetricFactory DistanceFunctionFactory;
84 
85 typedef QPair<int, Real> DimWeight;
86 
87 void registerMetrics();
88 
89 
90 } // namespace gaia2
91 
92 #endif // GAIA_DISTANCEFUNCTION_H
const Region & checkFixedLength(const Region &region) const
Checks that the given Region only contains fixed-length descriptors and throws an exception if not...
Definition: distancefunction.cpp:94
QStringList validParams
List of valid parameters this analyzer accepts.
Definition: distancefunction.h:71
A region is a physical location in the point layout which consists in a list of segments.
Definition: region.h:125
void registerMetrics()
Registers all the metrics available inside the MetricFactory.
Definition: distancefunction.cpp:56
This class describes the layout of a point.
Definition: pointlayout.h:60
virtual Real operator()(const Point &p1, const Point &p2, int seg1=0, int seg2=0) const =0
This function computes the distance between the two given points.
Main Gaia namespace, which contains all the library functions.
Definition: addfield.cpp:22
Definition: distancefunction.h:37
Definition: parameter.h:34
QString name
Name for the metric, usually the key that was used to instantiate it from the factory.
Definition: distancefunction.h:44
A tuned implementation of a factory.
Definition: layoutawarefactory.h:39
Definition: point.h:106