annotate data/fileio/CSVFormat.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 001db550bd48
rev   line source
Chris@392 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@392 2
Chris@392 3 /*
Chris@392 4 Sonic Visualiser
Chris@392 5 An audio file viewer and annotation editor.
Chris@392 6 Centre for Digital Music, Queen Mary, University of London.
Chris@392 7 This file copyright 2006 Chris Cannam.
Chris@392 8
Chris@392 9 This program is free software; you can redistribute it and/or
Chris@392 10 modify it under the terms of the GNU General Public License as
Chris@392 11 published by the Free Software Foundation; either version 2 of the
Chris@392 12 License, or (at your option) any later version. See the file
Chris@392 13 COPYING included with this distribution for more information.
Chris@392 14 */
Chris@392 15
Chris@392 16 #ifndef _CSV_FORMAT_H_
Chris@392 17 #define _CSV_FORMAT_H_
Chris@392 18
Chris@392 19 #include <QString>
Chris@392 20 #include <QStringList>
Chris@392 21
Chris@392 22 class CSVFormat
Chris@392 23 {
Chris@392 24 public:
Chris@392 25 enum ModelType {
Chris@392 26 OneDimensionalModel,
Chris@392 27 TwoDimensionalModel,
Chris@392 28 ThreeDimensionalModel
Chris@392 29 };
Chris@392 30
Chris@392 31 enum TimingType {
Chris@392 32 ExplicitTiming,
Chris@392 33 ImplicitTiming
Chris@392 34 };
Chris@392 35
Chris@392 36 enum TimeUnits {
Chris@392 37 TimeSeconds,
Chris@392 38 TimeAudioFrames,
Chris@392 39 TimeWindows
Chris@392 40 };
Chris@392 41
Chris@392 42 CSVFormat(QString path); // guess format
Chris@392 43
Chris@392 44 CSVFormat() : // arbitrary defaults
Chris@392 45 m_modelType(TwoDimensionalModel),
Chris@392 46 m_timingType(ExplicitTiming),
Chris@392 47 m_timeUnits(TimeSeconds),
Chris@392 48 m_separator(","),
Chris@392 49 m_sampleRate(44100),
Chris@392 50 m_windowSize(1024),
Chris@392 51 m_behaviour(QString::KeepEmptyParts)
Chris@392 52 { }
Chris@392 53
Chris@392 54 ModelType getModelType() const { return m_modelType; }
Chris@392 55 TimingType getTimingType() const { return m_timingType; }
Chris@392 56 TimeUnits getTimeUnits() const { return m_timeUnits; }
Chris@392 57 QString getSeparator() const { return m_separator; }
Chris@392 58 size_t getSampleRate() const { return m_sampleRate; }
Chris@392 59 size_t getWindowSize() const { return m_windowSize; }
Chris@392 60
Chris@392 61 QString::SplitBehavior getSplitBehaviour() const { return m_behaviour; }
Chris@392 62
Chris@392 63 void setModelType(ModelType t) { m_modelType = t; }
Chris@392 64 void setTimingType(TimingType t) { m_timingType = t; }
Chris@392 65 void setTimeUnits(TimeUnits t) { m_timeUnits = t; }
Chris@392 66 void setSeparator(QString s) { m_separator = s; }
Chris@392 67 void setSampleRate(size_t r) { m_sampleRate = r; }
Chris@392 68 void setWindowSize(size_t s) { m_windowSize = s; }
Chris@392 69
Chris@392 70 void setSplitBehaviour(QString::SplitBehavior b) { m_behaviour = b; }
Chris@392 71
Chris@392 72 // only valid if constructor that guesses format was used:
Chris@392 73 QList<QStringList> getExample() const { return m_example; }
Chris@392 74 int getMaxExampleCols() const { return m_maxExampleCols; }
Chris@392 75
Chris@392 76 protected:
Chris@392 77 ModelType m_modelType;
Chris@392 78 TimingType m_timingType;
Chris@392 79 TimeUnits m_timeUnits;
Chris@392 80 QString m_separator;
Chris@392 81 size_t m_sampleRate;
Chris@392 82 size_t m_windowSize;
Chris@392 83
Chris@392 84 QString::SplitBehavior m_behaviour;
Chris@392 85
Chris@392 86 QList<QStringList> m_example;
Chris@392 87 int m_maxExampleCols;
Chris@392 88 };
Chris@392 89
Chris@392 90 #endif