comparison data/fileio/DataFileReader.h @ 148:1a42221a1522

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 11:49:58 +0000
parents
children 084ae1c213ee
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 #ifndef _DATA_FILE_READER_H_
17 #define _DATA_FILE_READER_H_
18
19 #include <QString>
20
21 class Model;
22
23 class DataFileReader
24 {
25 public:
26 /**
27 * Return true if the file appears to be of the correct type.
28 *
29 * The DataFileReader will be constructed by passing a file path
30 * to its constructor. If the file can at that time be determined
31 * to be not of a type that this reader can read, it should return
32 * false in response to any subsequent call to isOK().
33 *
34 * If the file is apparently of the correct type, isOK() should
35 * return true; if it turns out that the file cannot after all be
36 * read (because it's corrupted or the detection misfired), then
37 * the read() function may return NULL.
38 */
39 virtual bool isOK() const = 0;
40
41 virtual QString getError() const { return ""; }
42
43 /**
44 * Read the file and return the corresponding data model. This
45 * function is not expected to be thread-safe or reentrant. This
46 * function may be interactive (i.e. it's permitted to pop up
47 * dialogs and windows and ask the user to specify any details
48 * that can't be automatically extracted from the file).
49 *
50 * Return NULL if the file cannot be parsed at all (although it's
51 * preferable to return a partial model and warn the user).
52 *
53 * Caller owns the returned model and must delete it after use.
54 */
55 virtual Model *load() const = 0;
56 };
57
58 #endif