Gaia
parameter.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_PARAMETER_H
21 #define GAIA_PARAMETER_H
22 
23 #include <QVariant>
24 #include "types.h"
25 #include "gaia.h"
26 #include "descriptor.h"
27 #include "yamlcpp.h"
28 #include "Eigen/Core"
29 
30 namespace gaia2 {
31 
32 class Parameter;
33 
34 class ParameterMap : public GaiaMap<QString, Parameter, GaiaException> {
35 public:
37 };
38 
39 // forward declarations (for faster compilation)
40 class Transformation;
41 class TransfoChain;
42 class PointLayout;
43 
48 class Parameter : public QVariant {
49  public:
50  Parameter() : QVariant() {}
51 
52  template <typename T>
53  Parameter(const T& val) : QVariant(val) {}
54 
55  // automatic coercion to QString
56  operator QString() const {
57  return this->toString();
58  }
59 
60  // starting with Qt 4.6, a new QVariant type got introduced: float
61  // This is a very stupid idea as it breaks BC, and we want to avoid it
62  Parameter(float x) : QVariant((double)x) {}
63 
64  // type: Array<Real>
65  Parameter(const Array<Real>& val);
66  Array<Real> toArrayReal() const;
67 
68  // type: RealDescriptor
69  Parameter(const RealDescriptor& val);
70  RealDescriptor toRealDescriptor() const;
71 
72  // type: StringDescriptor
73  Parameter(const StringDescriptor& val);
74  StringDescriptor toStringDescriptor() const;
75 
76  // type: ParameterMap
77  Parameter(const ParameterMap& parameterMap);
78  ParameterMap toParameterMap() const;
79 
80  // type: Eigen::MatrixXf
81  Parameter(const Eigen::MatrixXf& matrix);
82  Eigen::MatrixXf toMatrix() const;
83 
84  // type: Transformation
85  Parameter(const Transformation& transfo);
86  Transformation toTransformation() const;
87 
88  // type: TransfoChain (history)
89  Parameter(const TransfoChain& history);
90  TransfoChain toHistory() const;
91 
92  // type: QList<QPointF> (coordinates, for BPF)
93  Parameter(const QList<QPointF>& coords);
94  QList<QPointF> toCoords() const;
95 
96  // type: PointLayout
97  Parameter(const PointLayout& layout);
98  PointLayout toPointLayout() const;
99 
100 };
101 
102 // convenience empty ParameterMap
103 extern const ParameterMap noParams;
104 
105 
106 ParameterMap toParameterMap(const yaml::Node& node);
107 
108 } // namespace gaia2
109 
110 #endif // GAIA_PARAMETER_H
Class containing all info pertaining to a specific transformation, ie: the name of the analyzer class...
Definition: transformation.h:41
Map class (derived from QMap) but that throws a custom Exception instead of returning a default const...
Definition: types.h:143
Definition: parameter.h:48
This class describes the layout of a point.
Definition: pointlayout.h:60
Main Gaia namespace, which contains all the library functions.
Definition: addfield.cpp:22
Definition: parameter.h:34
Definition: transformation.h:106
Definition: yamlcpp.h:77