annotate data/fileio/DataFileReader.h @ 282:d9319859a4cf tip

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