comparison data/fileio/DataFileReaderFactory.cpp @ 148:1a42221a1522

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 11:49:58 +0000
parents
children 4b2ea82fd0ed
comparison
equal deleted inserted replaced
147:3a13b0d4934e 148:1a42221a1522
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #include "DataFileReaderFactory.h"
17 #include "MIDIFileReader.h"
18 #include "CSVFileReader.h"
19
20 #include "base/Model.h"
21
22 #include <QString>
23
24 QString
25 DataFileReaderFactory::getKnownExtensions()
26 {
27 return "*.svl *.csv *.lab *.mid *.txt";
28 }
29
30 DataFileReader *
31 DataFileReaderFactory::createReader(QString path, size_t mainModelSampleRate)
32 {
33 QString err;
34
35 DataFileReader *reader = 0;
36
37 reader = new MIDIFileReader(path, mainModelSampleRate);
38 if (reader->isOK()) return reader;
39 if (reader->getError() != "") err = reader->getError();
40 delete reader;
41
42 reader = new CSVFileReader(path, mainModelSampleRate);
43 if (reader->isOK()) return reader;
44 if (reader->getError() != "") err = reader->getError();
45 delete reader;
46
47 return 0;
48 }
49
50 Model *
51 DataFileReaderFactory::load(QString path, size_t mainModelSampleRate)
52 {
53 DataFileReader *reader = createReader(path, mainModelSampleRate);
54 if (!reader) return NULL;
55
56 Model *model = reader->load();
57 delete reader;
58
59 return model;
60 }
61