annotate document/SVFileReader.h @ 62:75ce271d0edb

* (Temporarily?) restore layer hierarchy window
author Chris Cannam
date Tue, 17 Oct 2006 18:53:08 +0000
parents ca1e3f5657d5
children bedc7517b6e8
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@30 21 #include "transform/PluginTransform.h"
Chris@0 22
Chris@0 23 #include <QXmlDefaultHandler>
Chris@0 24
Chris@0 25 #include <map>
Chris@0 26
Chris@0 27 class Pane;
Chris@0 28 class Model;
Chris@0 29 class Document;
Chris@0 30 class PlayParameters;
Chris@0 31
Chris@0 32 class SVFileReaderPaneCallback
Chris@0 33 {
Chris@0 34 public:
Chris@0 35 virtual Pane *addPane() = 0;
Chris@0 36 virtual void setWindowSize(int width, int height) = 0;
Chris@0 37 virtual void addSelection(int start, int end) = 0;
Chris@0 38 };
Chris@0 39
Chris@0 40 class SVFileReader : public QXmlDefaultHandler
Chris@0 41 {
Chris@0 42 public:
Chris@0 43 SVFileReader(Document *document,
Chris@0 44 SVFileReaderPaneCallback &callback);
Chris@0 45 virtual ~SVFileReader();
Chris@0 46
Chris@0 47 void parse(const QString &xmlData);
Chris@0 48 void parse(QXmlInputSource &source);
Chris@0 49
Chris@0 50 bool isOK();
Chris@0 51 QString getErrorString() const { return m_errorString; }
Chris@0 52
Chris@0 53 // For loading a single layer onto an existing pane
Chris@0 54 void setCurrentPane(Pane *pane) { m_currentPane = pane; }
Chris@0 55
Chris@0 56 virtual bool startElement(const QString &namespaceURI,
Chris@0 57 const QString &localName,
Chris@0 58 const QString &qName,
Chris@0 59 const QXmlAttributes& atts);
Chris@0 60
Chris@0 61 virtual bool characters(const QString &);
Chris@0 62
Chris@0 63 virtual bool endElement(const QString &namespaceURI,
Chris@0 64 const QString &localName,
Chris@0 65 const QString &qName);
Chris@0 66
Chris@0 67 bool error(const QXmlParseException &exception);
Chris@0 68 bool fatalError(const QXmlParseException &exception);
Chris@0 69
Chris@0 70 protected:
Chris@0 71 bool readWindow(const QXmlAttributes &);
Chris@0 72 bool readModel(const QXmlAttributes &);
Chris@0 73 bool readView(const QXmlAttributes &);
Chris@0 74 bool readLayer(const QXmlAttributes &);
Chris@0 75 bool readDatasetStart(const QXmlAttributes &);
Chris@0 76 bool addBinToDataset(const QXmlAttributes &);
Chris@0 77 bool addPointToDataset(const QXmlAttributes &);
Chris@0 78 bool addRowToDataset(const QXmlAttributes &);
Chris@0 79 bool readRowData(const QString &);
Chris@0 80 bool readDerivation(const QXmlAttributes &);
Chris@0 81 bool readPlayParameters(const QXmlAttributes &);
Chris@0 82 bool readPlugin(const QXmlAttributes &);
Chris@0 83 bool readSelection(const QXmlAttributes &);
Chris@0 84 void addUnaddedModels();
Chris@0 85
Chris@0 86 Document *m_document;
Chris@0 87 SVFileReaderPaneCallback &m_paneCallback;
Chris@0 88 Pane *m_currentPane;
Chris@0 89 std::map<int, Layer *> m_layers;
Chris@0 90 std::map<int, Model *> m_models;
Chris@0 91 std::set<Model *> m_addedModels;
Chris@0 92 std::map<int, int> m_awaitingDatasets; // map dataset id -> model id
Chris@0 93 Model *m_currentDataset;
Chris@0 94 Model *m_currentDerivedModel;
Chris@55 95 int m_currentDerivedModelId;
Chris@0 96 PlayParameters *m_currentPlayParameters;
Chris@0 97 QString m_currentTransform;
Chris@55 98 Model *m_currentTransformSource;
Chris@30 99 PluginTransform::ExecutionContext m_currentTransformContext;
Chris@0 100 QString m_currentTransformConfiguration;
Chris@0 101 QString m_datasetSeparator;
Chris@0 102 bool m_inRow;
Chris@0 103 bool m_inView;
Chris@0 104 bool m_inData;
Chris@0 105 bool m_inSelections;
Chris@0 106 int m_rowNumber;
Chris@0 107 QString m_errorString;
Chris@0 108 bool m_ok;
Chris@0 109 };
Chris@0 110
Chris@0 111 #endif