Chris@148: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@148: Chris@148: /* Chris@148: Sonic Visualiser Chris@148: An audio file viewer and annotation editor. Chris@148: Centre for Digital Music, Queen Mary, University of London. Chris@148: This file copyright 2006 Chris Cannam. Chris@148: Chris@148: This program is free software; you can redistribute it and/or Chris@148: modify it under the terms of the GNU General Public License as Chris@148: published by the Free Software Foundation; either version 2 of the Chris@148: License, or (at your option) any later version. See the file Chris@148: COPYING included with this distribution for more information. Chris@148: */ Chris@148: Chris@148: #ifndef _DATA_FILE_READER_H_ Chris@148: #define _DATA_FILE_READER_H_ Chris@148: Chris@148: #include Chris@248: #include Chris@148: Chris@148: class Model; Chris@148: Chris@248: class DataFileReader : public QObject Chris@148: { Chris@148: public: Chris@148: /** Chris@148: * Return true if the file appears to be of the correct type. Chris@148: * Chris@148: * The DataFileReader will be constructed by passing a file path Chris@148: * to its constructor. If the file can at that time be determined Chris@148: * to be not of a type that this reader can read, it should return Chris@148: * false in response to any subsequent call to isOK(). Chris@148: * Chris@148: * If the file is apparently of the correct type, isOK() should Chris@148: * return true; if it turns out that the file cannot after all be Chris@148: * read (because it's corrupted or the detection misfired), then Chris@148: * the read() function may return NULL. Chris@148: */ Chris@148: virtual bool isOK() const = 0; Chris@148: Chris@148: virtual QString getError() const { return ""; } Chris@148: Chris@148: /** Chris@148: * Read the file and return the corresponding data model. This Chris@148: * function is not expected to be thread-safe or reentrant. This Chris@148: * function may be interactive (i.e. it's permitted to pop up Chris@148: * dialogs and windows and ask the user to specify any details Chris@148: * that can't be automatically extracted from the file). Chris@148: * Chris@148: * Return NULL if the file cannot be parsed at all (although it's Chris@148: * preferable to return a partial model and warn the user). Chris@148: * Chris@148: * Caller owns the returned model and must delete it after use. Chris@148: */ Chris@148: virtual Model *load() const = 0; Chris@148: }; Chris@148: Chris@148: #endif