Gaia
frozendataset.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_FROZENDATASET_H
21 #define GAIA_FROZENDATASET_H
22 
23 #include <QString>
24 #include <QVector>
25 #include "types.h"
26 
27 namespace gaia2 {
28 
29 class DataSet;
30 class FrozenDataSet;
31 class FrozenSearchPoint;
32 class FrozenDistance;
33 
34 template <typename DataSetType, typename PointType, typename SearchPointType, typename DistanceType>
35 class BaseView;
36 
37 typedef BaseView<FrozenDataSet, FrozenPoint, FrozenSearchPoint, FrozenDistance> FrozenView;
38 
39 
49 class FrozenDataSet : public MatrixRXf, public QObject {
50 public:
51  FrozenDataSet();
52  FrozenDataSet(int npoints, int dimension);
53 
57  void load(const QString& filename);
58 
62  void save(const QString& filename) const;
63 
67  int size() const;
68 
72  int dimension() const;
73 
74 
75  QStringList pointNames() const;
76 
80  const QString& pointName(int i) const;
81 
86  int pointIndex(const QString& name) const;
87 
88  FrozenPoint point(const QString& name) const;
89 
95  QPair<int, int> descriptorLocation(const QString& descriptorName) const;
96 
97  QStringList descriptorNames() const;
98 
107  void fromDataSet(const DataSet& dataset);
108 
114  static void checkValidFrozenDataSet(const DataSet& dataset);
115 
122  void setReferenceDataSet(DataSet* dataset = 0);
123 
128  const DataSet* referenceDataSet() const;
129 
131 
132  void addView(FrozenView* view) { Q_UNUSED(view); }
133  void removeView(FrozenView* view) { Q_UNUSED(view); }
134 
135 protected:
140  QVector<QString> _names;
141 
142  // map of desc -> (start, end) indices
143  QMap<QString, QPair<int, int> > _layout;
144 
145  DataSet* _referenceDataSet;
146 
147 };
148 
149 
150 } // namespace gaia2
151 
152 #endif // GAIA_FROZENDATASET_H
int dimension() const
Return the number of dimensions of this dataset.
Definition: frozendataset.cpp:36
const QString & pointName(int i) const
Return the name of the point with the given index.
Definition: frozendataset.cpp:47
This class represents a dataset and all related information.
Definition: dataset.h:91
QVector< QString > _names
This variable records the names of the points.
Definition: frozendataset.h:140
static void checkValidFrozenDataSet(const DataSet &dataset)
Checks whether the given dataset would make a valid FrozenDataSet.
Definition: frozendataset.cpp:197
void fromDataSet(const DataSet &dataset)
Note: this method is not made static as a named-constructor, because then we would have to return the...
Definition: frozendataset.cpp:157
Main Gaia namespace, which contains all the library functions.
Definition: addfield.cpp:22
QPair< int, int > descriptorLocation(const QString &descriptorName) const
Return the column indices of beginning and end fo the region spanning the descriptor.
Definition: frozendataset.cpp:181
void setReferenceDataSet(DataSet *dataset=0)
Set the reference dataset, ie: the one used for fetching the values when doing filtered queries...
Definition: frozendataset.cpp:218
int pointIndex(const QString &name) const
Return the index of the point with the given name.
Definition: frozendataset.cpp:51
A FrozenDataSet is a dataset that has been flagged as immutable.
Definition: frozendataset.h:49
int size() const
Return the number of points contained in this dataset.
Definition: frozendataset.cpp:32
const DataSet * referenceDataSet() const
Return the reference dataset.
Definition: frozendataset.cpp:242
void save(const QString &filename) const
Save this dataset to disk.
Definition: frozendataset.cpp:118
void load(const QString &filename)
Load a dataset from disk.
Definition: frozendataset.cpp:67