diff options
author | RJ Ryan <rryan@mixxx.org> | 2013-06-19 00:46:54 -0400 |
---|---|---|
committer | RJ Ryan <rryan@mixxx.org> | 2013-06-19 00:46:54 -0400 |
commit | 25d57b59dff3947212909634864dd82365c9606b (patch) | |
tree | f0d0f8a048f8ed2f45c5ff015fc96891662f72f1 /src/library/dao/analysisdao.h | |
parent | e50f9f168fa08f2be6d0f13e8a225bbcc9de09bb (diff) |
Moving mixxx/* to the root. A new era begins!
Diffstat (limited to 'src/library/dao/analysisdao.h')
-rw-r--r-- | src/library/dao/analysisdao.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/library/dao/analysisdao.h b/src/library/dao/analysisdao.h new file mode 100644 index 0000000000..bfd56f8437 --- /dev/null +++ b/src/library/dao/analysisdao.h @@ -0,0 +1,70 @@ +#ifndef ANALYSISDAO_H +#define ANALYSISDAO_H + +#include <QObject> +#include <QSqlDatabase> + +#include "configobject.h" +#include "library/dao/dao.h" +#include "trackinfoobject.h" + +class AnalysisDao : public DAO { + public: + static const QString s_analysisTableName; + + enum AnalysisType { + TYPE_UNKNOWN = 0, + TYPE_WAVEFORM, + TYPE_WAVESUMMARY + }; + + struct AnalysisInfo { + AnalysisInfo() + : analysisId(-1), + trackId(-1), + type(TYPE_UNKNOWN) { + } + int analysisId; + int trackId; + AnalysisType type; + QString description; + QString version; + QByteArray data; + }; + + AnalysisDao(QSqlDatabase& database, ConfigObject<ConfigValue>* pConfig); + virtual ~AnalysisDao(); + + virtual void initialize(); + void setDatabase(QSqlDatabase& database); + + bool getWaveform(TrackInfoObject& tio); + bool saveWaveform(const TrackInfoObject& tio); + bool removeWaveform(const TrackInfoObject& tio); + + QList<AnalysisInfo> getAnalysesForTrackByType(int trackId, AnalysisType type); + QList<AnalysisInfo> getAnalysesForTrack(int trackId); + bool saveAnalysis(AnalysisInfo* analysis); + bool deleteAnalysis(int analysisId); + void deleteAnalysises(QList<int> ids); + bool deleteAnalysesForTrack(int trackId); + + void saveTrackAnalyses(TrackInfoObject* pTrack); + + private: + bool saveWaveform(const TrackInfoObject& tio, + const Waveform& waveform, + AnalysisType type); + bool loadWaveform(const TrackInfoObject& tio, + Waveform* waveform, AnalysisType type); + QDir getAnalysisStoragePath() const; + QByteArray loadDataFromFile(QString fileName) const; + bool saveDataToFile(QString fileName, QByteArray data) const; + bool deleteFile(QString filename) const; + QList<AnalysisInfo> loadAnalysesFromQuery(int trackId, QSqlQuery& query); + + ConfigObject<ConfigValue>* m_pConfig; + QSqlDatabase m_db; +}; + +#endif // ANALYSISDAO_H |