svcore  1.9
MatchFileReader.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2007 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _MATCH_FILE_READER_H_
00017 #define _MATCH_FILE_READER_H_
00018 
00019 #include <vector>
00020 #include <QString>
00021 #include "base/Debug.h"
00022 
00023 class QFile;
00024 class Model;
00025 
00026 class Alignment
00027 {
00028 public:
00029     Alignment();
00030 
00031     typedef std::vector<int> FrameArray;
00032 
00033     double thisHopTime;
00034     double refHopTime;
00035 
00036     FrameArray thisIndex;
00037     FrameArray refIndex;
00038 
00039     double fromReference(double) const;
00040     double toReference(double) const;
00041 
00043     void setMainModel(Model *m) { m_mainModel = m; }
00044     bool isMainModel(Model *m) const { return m == m_mainModel; }
00045 
00046     int search(const FrameArray &arr, int val) const;
00047 
00048 protected:
00049     Model *m_mainModel;
00050 };
00051 
00052 class MatchFileReader
00053 {
00054 public:
00055     MatchFileReader(QString path);
00056     virtual ~MatchFileReader();
00057 
00058     virtual bool isOK() const;
00059     virtual QString getError() const;
00060     virtual Alignment load() const;
00061 
00062 protected:
00063     QFile *m_file;
00064     QString m_error;
00065 };
00066 
00067 #endif
00068