annotate data/fileio/DataFileReader.h @ 228:f02989f7e160

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