annotate data/fileio/DataFileReaderFactory.h @ 558:1d7ebc05157e

* Some fairly simplistic code to set up layer type properties based on RDF data about feature types (both when running transforms and when importing features from RDF files).
author Chris Cannam
date Thu, 12 Feb 2009 15:26:43 +0000
parents 183ee2a55fc7
children 59e7fe1b1003
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_FACTORY_H_
Chris@148 17 #define _DATA_FILE_READER_FACTORY_H_
Chris@148 18
Chris@148 19 #include <QString>
Chris@148 20
Chris@392 21 #include "CSVFormat.h"
Chris@392 22 #include "MIDIFileReader.h"
Chris@392 23
Chris@148 24 class DataFileReader;
Chris@148 25 class Model;
Chris@148 26
Chris@148 27 class DataFileReaderFactory
Chris@148 28 {
Chris@148 29 public:
Chris@308 30 enum Exception { ImportCancelled };
Chris@308 31
Chris@148 32 /**
Chris@148 33 * Return the file extensions that we have data file readers for,
Chris@148 34 * in a format suitable for use with QFileDialog. For example,
Chris@148 35 * "*.csv *.xml".
Chris@148 36 */
Chris@148 37 static QString getKnownExtensions();
Chris@148 38
Chris@148 39 /**
Chris@148 40 * Return a data file reader initialised to the file at the
Chris@148 41 * given path, or NULL if no suitable reader for this path is
Chris@148 42 * available or the file cannot be opened.
Chris@392 43 *
Chris@148 44 * Caller owns the returned object and must delete it after use.
Chris@392 45 *
Chris@392 46 * Note that this function is non-interactive -- the user is not
Chris@392 47 * asked for file format preferences.
Chris@148 48 */
Chris@148 49 static DataFileReader *createReader(QString path,
Chris@392 50 MIDIFileImportPreferenceAcquirer *,
Chris@148 51 size_t mainModelSampleRate);
Chris@148 52
Chris@148 53 /**
Chris@148 54 * Read the given path, if a suitable reader is available.
Chris@148 55 * Return NULL if no reader succeeded in reading this file.
Chris@392 56 *
Chris@392 57 * Note that this function is non-interactive -- the user is not
Chris@392 58 * asked for file format preferences. If the CSV file reader is
Chris@392 59 * used, it is with default format.
Chris@148 60 */
Chris@392 61 static Model *load(QString path,
Chris@392 62 MIDIFileImportPreferenceAcquirer *acquirer,
Chris@392 63 size_t mainModelSampleRate);
Chris@392 64
Chris@392 65 /**
Chris@392 66 * Read the given path, if a suitable reader is available.
Chris@392 67 * Return NULL if no reader succeeded in reading this file.
Chris@392 68 * Do not attempt the general CSV reader.
Chris@392 69 */
Chris@392 70 static Model *loadNonCSV(QString path,
Chris@392 71 MIDIFileImportPreferenceAcquirer *acquirer,
Chris@392 72 size_t mainModelSampleRate);
Chris@392 73
Chris@392 74 /**
Chris@392 75 * Read the given path using the CSV reader with the given format.
Chris@392 76 * Return NULL if it failed in reading this file.
Chris@392 77 */
Chris@392 78 static Model *loadCSV(QString path,
Chris@392 79 CSVFormat format,
Chris@392 80 size_t mainModelSampleRate);
Chris@392 81
Chris@392 82 protected:
Chris@392 83 static DataFileReader *createReader(QString path, bool csv,
Chris@392 84 MIDIFileImportPreferenceAcquirer *,
Chris@392 85 CSVFormat format,
Chris@392 86 size_t mainModelSampleRate);
Chris@148 87 };
Chris@148 88
Chris@148 89 #endif
Chris@148 90