annotate document/SVFileReader.h @ 3:e764bbf2b090 last-cc-copyright

* Move the current DenseThreeDimensionalModel to EditableDenseThreeDimensionalModel (wow!), and make DTDM an abstract base * Move FFTFuzzyAdapter to FFTModel as a new subclass of DTDM
author Chris Cannam
date Mon, 31 Jul 2006 17:05:18 +0000
parents cd5d7ff8ef38
children 56e1d4242bb4
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 Sonic Visualiser
Chris@0 5 An audio file viewer and annotation editor.
Chris@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@0 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@0 9 This program is free software; you can redistribute it and/or
Chris@0 10 modify it under the terms of the GNU General Public License as
Chris@0 11 published by the Free Software Foundation; either version 2 of the
Chris@0 12 License, or (at your option) any later version. See the file
Chris@0 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _SV_FILE_READER_H_
Chris@0 17 #define _SV_FILE_READER_H_
Chris@0 18
Chris@0 19 #include "layer/LayerFactory.h"
Chris@0 20 #include "transform/Transform.h"
Chris@0 21
Chris@0 22 #include <QXmlDefaultHandler>
Chris@0 23
Chris@0 24 #include <map>
Chris@0 25
Chris@0 26 class Pane;
Chris@0 27 class Model;
Chris@0 28 class Document;
Chris@0 29 class PlayParameters;
Chris@0 30
Chris@0 31 class SVFileReaderPaneCallback
Chris@0 32 {
Chris@0 33 public:
Chris@0 34 virtual Pane *addPane() = 0;
Chris@0 35 virtual void setWindowSize(int width, int height) = 0;
Chris@0 36 virtual void addSelection(int start, int end) = 0;
Chris@0 37 };
Chris@0 38
Chris@0 39 class SVFileReader : public QXmlDefaultHandler
Chris@0 40 {
Chris@0 41 public:
Chris@0 42 SVFileReader(Document *document,
Chris@0 43 SVFileReaderPaneCallback &callback);
Chris@0 44 virtual ~SVFileReader();
Chris@0 45
Chris@0 46 void parse(const QString &xmlData);
Chris@0 47 void parse(QXmlInputSource &source);
Chris@0 48
Chris@0 49 bool isOK();
Chris@0 50 QString getErrorString() const { return m_errorString; }
Chris@0 51
Chris@0 52 // For loading a single layer onto an existing pane
Chris@0 53 void setCurrentPane(Pane *pane) { m_currentPane = pane; }
Chris@0 54
Chris@0 55 virtual bool startElement(const QString &namespaceURI,
Chris@0 56 const QString &localName,
Chris@0 57 const QString &qName,
Chris@0 58 const QXmlAttributes& atts);
Chris@0 59
Chris@0 60 virtual bool characters(const QString &);
Chris@0 61
Chris@0 62 virtual bool endElement(const QString &namespaceURI,
Chris@0 63 const QString &localName,
Chris@0 64 const QString &qName);
Chris@0 65
Chris@0 66 bool error(const QXmlParseException &exception);
Chris@0 67 bool fatalError(const QXmlParseException &exception);
Chris@0 68
Chris@0 69 protected:
Chris@0 70 bool readWindow(const QXmlAttributes &);
Chris@0 71 bool readModel(const QXmlAttributes &);
Chris@0 72 bool readView(const QXmlAttributes &);
Chris@0 73 bool readLayer(const QXmlAttributes &);
Chris@0 74 bool readDatasetStart(const QXmlAttributes &);
Chris@0 75 bool addBinToDataset(const QXmlAttributes &);
Chris@0 76 bool addPointToDataset(const QXmlAttributes &);
Chris@0 77 bool addRowToDataset(const QXmlAttributes &);
Chris@0 78 bool readRowData(const QString &);
Chris@0 79 bool readDerivation(const QXmlAttributes &);
Chris@0 80 bool readPlayParameters(const QXmlAttributes &);
Chris@0 81 bool readPlugin(const QXmlAttributes &);
Chris@0 82 bool readSelection(const QXmlAttributes &);
Chris@0 83 void addUnaddedModels();
Chris@0 84
Chris@0 85 Document *m_document;
Chris@0 86 SVFileReaderPaneCallback &m_paneCallback;
Chris@0 87 Pane *m_currentPane;
Chris@0 88 std::map<int, Layer *> m_layers;
Chris@0 89 std::map<int, Model *> m_models;
Chris@0 90 std::set<Model *> m_addedModels;
Chris@0 91 std::map<int, int> m_awaitingDatasets; // map dataset id -> model id
Chris@0 92 Model *m_currentDataset;
Chris@0 93 Model *m_currentDerivedModel;
Chris@0 94 PlayParameters *m_currentPlayParameters;
Chris@0 95 QString m_currentTransform;
Chris@0 96 int m_currentTransformChannel;
Chris@0 97 QString m_currentTransformConfiguration;
Chris@0 98 QString m_datasetSeparator;
Chris@0 99 bool m_inRow;
Chris@0 100 bool m_inView;
Chris@0 101 bool m_inData;
Chris@0 102 bool m_inSelections;
Chris@0 103 int m_rowNumber;
Chris@0 104 QString m_errorString;
Chris@0 105 bool m_ok;
Chris@0 106 };
Chris@0 107
Chris@0 108 #endif