annotate data/fileio/DataFileReaderFactory.h @ 1624:dcd510bd89db single-point

Try out Qt containers
author Chris Cannam
date Mon, 11 Mar 2019 11:17:30 +0000
parents 1dc64d3d323c
children
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@1491 16 #ifndef SV_DATA_FILE_READER_FACTORY_H
Chris@1491 17 #define SV_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@1491 26 class ProgressReporter;
Chris@148 27
Chris@148 28 class DataFileReaderFactory
Chris@148 29 {
Chris@148 30 public:
Chris@308 31 enum Exception { ImportCancelled };
Chris@308 32
Chris@148 33 /**
Chris@148 34 * Return the file extensions that we have data file readers for,
Chris@148 35 * in a format suitable for use with QFileDialog. For example,
Chris@148 36 * "*.csv *.xml".
Chris@148 37 */
Chris@148 38 static QString getKnownExtensions();
Chris@148 39
Chris@148 40 /**
Chris@148 41 * Return a data file reader initialised to the file at the
Chris@148 42 * given path, or NULL if no suitable reader for this path is
Chris@148 43 * available or the file cannot be opened.
Chris@392 44 *
Chris@148 45 * Caller owns the returned object and must delete it after use.
Chris@392 46 *
Chris@392 47 * Note that this function is non-interactive -- the user is not
Chris@392 48 * asked for file format preferences.
Chris@148 49 */
Chris@148 50 static DataFileReader *createReader(QString path,
Chris@392 51 MIDIFileImportPreferenceAcquirer *,
Chris@1491 52 sv_samplerate_t mainModelSampleRate,
Chris@1491 53 ProgressReporter *reporter = 0);
Chris@148 54
Chris@148 55 /**
Chris@148 56 * Read the given path, if a suitable reader is available.
Chris@148 57 * Return NULL if no reader succeeded in reading this file.
Chris@392 58 *
Chris@392 59 * Note that this function is non-interactive -- the user is not
Chris@392 60 * asked for file format preferences. If the CSV file reader is
Chris@392 61 * used, it is with default format.
Chris@148 62 */
Chris@392 63 static Model *load(QString path,
Chris@392 64 MIDIFileImportPreferenceAcquirer *acquirer,
Chris@1491 65 sv_samplerate_t mainModelSampleRate,
Chris@1491 66 ProgressReporter *reporter = 0);
Chris@392 67
Chris@392 68 /**
Chris@392 69 * Read the given path, if a suitable reader is available.
Chris@392 70 * Return NULL if no reader succeeded in reading this file.
Chris@392 71 * Do not attempt the general CSV reader.
Chris@392 72 */
Chris@392 73 static Model *loadNonCSV(QString path,
Chris@392 74 MIDIFileImportPreferenceAcquirer *acquirer,
Chris@1491 75 sv_samplerate_t mainModelSampleRate,
Chris@1491 76 ProgressReporter *reporter = 0);
Chris@392 77
Chris@392 78 /**
Chris@392 79 * Read the given path using the CSV reader with the given format.
Chris@392 80 * Return NULL if it failed in reading this file.
Chris@392 81 */
Chris@392 82 static Model *loadCSV(QString path,
Chris@392 83 CSVFormat format,
Chris@1491 84 sv_samplerate_t mainModelSampleRate,
Chris@1491 85 ProgressReporter *reporter = 0);
Chris@392 86
Chris@392 87 protected:
Chris@392 88 static DataFileReader *createReader(QString path, bool csv,
Chris@392 89 MIDIFileImportPreferenceAcquirer *,
Chris@392 90 CSVFormat format,
Chris@1491 91 sv_samplerate_t mainModelSampleRate,
Chris@1491 92 ProgressReporter *reporter = 0);
Chris@148 93 };
Chris@148 94
Chris@148 95 #endif
Chris@148 96