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