annotate data/fileio/DataFileReader.h @ 299:576be0d0d218

* Merge transform directory from sv-match-alignment branch (the previous comment included notes for this stuff, but I missed it in the actual merge) * Fix crash when a transform fails to create an output model and the thread that created the transform then deletes its input model thinking it's no longer needed, even though the transform run thread is still using it -- fix is to wait() on the transform before returning the null output model
author Chris Cannam
date Fri, 28 Sep 2007 16:15:06 +0000
parents 084ae1c213ee
children ad5f892c0c4d
rev   line source
Chris@148 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@148 2
Chris@148 3 /*
Chris@148 4 Sonic Visualiser
Chris@148 5 An audio file viewer and annotation editor.
Chris@148 6 Centre for Digital Music, Queen Mary, University of London.
Chris@148 7 This file copyright 2006 Chris Cannam.
Chris@148 8
Chris@148 9 This program is free software; you can redistribute it and/or
Chris@148 10 modify it under the terms of the GNU General Public License as
Chris@148 11 published by the Free Software Foundation; either version 2 of the
Chris@148 12 License, or (at your option) any later version. See the file
Chris@148 13 COPYING included with this distribution for more information.
Chris@148 14 */
Chris@148 15
Chris@148 16 #ifndef _DATA_FILE_READER_H_
Chris@148 17 #define _DATA_FILE_READER_H_
Chris@148 18
Chris@148 19 #include <QString>
Chris@248 20 #include <QObject>
Chris@148 21
Chris@148 22 class Model;
Chris@148 23
Chris@248 24 class DataFileReader : public QObject
Chris@148 25 {
Chris@148 26 public:
Chris@148 27 /**
Chris@148 28 * Return true if the file appears to be of the correct type.
Chris@148 29 *
Chris@148 30 * The DataFileReader will be constructed by passing a file path
Chris@148 31 * to its constructor. If the file can at that time be determined
Chris@148 32 * to be not of a type that this reader can read, it should return
Chris@148 33 * false in response to any subsequent call to isOK().
Chris@148 34 *
Chris@148 35 * If the file is apparently of the correct type, isOK() should
Chris@148 36 * return true; if it turns out that the file cannot after all be
Chris@148 37 * read (because it's corrupted or the detection misfired), then
Chris@148 38 * the read() function may return NULL.
Chris@148 39 */
Chris@148 40 virtual bool isOK() const = 0;
Chris@148 41
Chris@148 42 virtual QString getError() const { return ""; }
Chris@148 43
Chris@148 44 /**
Chris@148 45 * Read the file and return the corresponding data model. This
Chris@148 46 * function is not expected to be thread-safe or reentrant. This
Chris@148 47 * function may be interactive (i.e. it's permitted to pop up
Chris@148 48 * dialogs and windows and ask the user to specify any details
Chris@148 49 * that can't be automatically extracted from the file).
Chris@148 50 *
Chris@148 51 * Return NULL if the file cannot be parsed at all (although it's
Chris@148 52 * preferable to return a partial model and warn the user).
Chris@148 53 *
Chris@148 54 * Caller owns the returned model and must delete it after use.
Chris@148 55 */
Chris@148 56 virtual Model *load() const = 0;
Chris@148 57 };
Chris@148 58
Chris@148 59 #endif