SVFileReader Class Reference

#include <SVFileReader.h>

Collaboration diagram for SVFileReader:

Collaboration graph
[legend]
List of all members.

Detailed Description

SVFileReader loads Sonic Visualiser XML files.

(The SV file format is bzipped XML.)

Some notes about the SV XML format follow. We're very lazy with our XML: there's no schema or DTD, and we depend heavily on elements being in a particular order.


    <sv>

    <data>

      <!-- The data section contains definitions of both models and
           visual layers.  Layers are considered data in the document;
           the structure of views that displays the layers is not. -->

      <!-- id numbers are unique within the data type (i.e. no two
           models can have the same id, but a model can have the same
           id as a layer, etc).  SV generates its id numbers just for
           the purpose of cross-referencing within the current file;
           they don't necessarily have any meaning once the file has
           been loaded. -->

      <model id="0" name="..." type="..." ... />
      <model id="1" name="..." type="..." ... />

      <!-- Models that have data associated with them store it
           in a neighbouring dataset element.  The dataset must follow
           the model and precede any derivation or layer elements that
           refer to the model. -->

      <model id="2" name="..." type="..." dataset="0" ... />

      <dataset id="0" type="..."> 
        <point frame="..." value="..." ... />
      </dataset>

      <!-- Where one model is derived from another via a transform,
           it has an associated derivation element.  This must follow
           both the source and target model elements.  The source and
           model attributes give the source model id and target model
           id respectively.  A model can have both dataset and
           derivation elements; if it does, dataset must appear first. 
           If the model's data are not stored, but instead the model
           is to be regenerated completely from the transform when 
           the session is reloaded, then the model should have _only_
           a derivation element, and no model element should appear
           for it at all. -->

      <derivation type="transform" source="0" model="2" channel="-1">
        <transform id="vamp:soname:pluginid:output" ... />
      </derivation>

      <!-- Note that the derivation element just described replaces
           this earlier formulation, which had more attributes in the
           derivation element and a plugin element describing plugin
           parameters and properties.  What we actually read and
           write these days is a horrid composite of the two formats,
           for backward compatibility reasons. -->

      <derivation source="0" model="2" transform="vamp:soname:pluginid:output" ...>
        <plugin id="pluginid" ... />
      </derivation>

      <!-- The playparameters element lists playback settings for
           a model. -->

      <playparameters mute="false" pan="0" gain="1" model="1" ... />

      <!-- Layer elements.  The models must have already been defined.
           The same model may appear in more than one layer (of more
           than one type). -->

      <layer id="1" type="..." name="..." model="0" ... />
      <layer id="2" type="..." name="..." model="1" ... />

    </data>


    <display>

      <!-- The display element contains visual structure for the
           layers.  It's simpler than the data section. -->

      <!-- Overall preferred window size for this session. -->

      <window width="..." height="..."/>

      <!-- List of view elements to stack up.  Each one contains
           a list of layers in stacking order, back to front. -->

      <view type="pane" ...>
        <layer id="1"/>
        <layer id="2"/>
      </view>

      <!-- The layer elements just refer to layers defined in the
           data section, so they don't have to have any attributes
           other than the id.  For sort-of-historical reasons SV
           actually does repeat the other attributes here, but
           it doesn't need to. -->

      <view type="pane" ...>
        <layer id="2"/>
      <view>

    </display>


    <!-- List of selected regions by audio frame extents. -->

    <selections>
      <selection start="..." end="..."/>
    </selections>


    </sv>
 

Definition at line 164 of file SVFileReader.h.

Signals

void modelRegenerationFailed (QString layerName, QString transformName, QString message)
void modelRegenerationWarning (QString layerName, QString transformName, QString message)

Public Member Functions

 SVFileReader (Document *document, SVFileReaderPaneCallback &callback, QString location="")
virtual ~SVFileReader ()
void parse (const QString &xmlData)
void parse (QXmlInputSource &source)
bool isOK ()
QString getErrorString () const
void setCurrentPane (Pane *pane)
virtual bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
virtual bool characters (const QString &)
virtual bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName)
bool error (const QXmlParseException &exception)
bool fatalError (const QXmlParseException &exception)

Protected Member Functions

bool readWindow (const QXmlAttributes &)
bool readModel (const QXmlAttributes &)
bool readView (const QXmlAttributes &)
bool readLayer (const QXmlAttributes &)
bool readDatasetStart (const QXmlAttributes &)
bool addBinToDataset (const QXmlAttributes &)
bool addPointToDataset (const QXmlAttributes &)
bool addRowToDataset (const QXmlAttributes &)
bool readRowData (const QString &)
bool readDerivation (const QXmlAttributes &)
bool readPlayParameters (const QXmlAttributes &)
bool readPlugin (const QXmlAttributes &)
bool readTransform (const QXmlAttributes &)
bool readParameter (const QXmlAttributes &)
bool readSelection (const QXmlAttributes &)
bool readMeasurement (const QXmlAttributes &)
void addUnaddedModels ()
bool haveModel (int id)

Protected Attributes

Documentm_document
SVFileReaderPaneCallbackm_paneCallback
QString m_location
Panem_currentPane
std::map< int, Layer * > m_layers
std::map< int, Model * > m_models
std::set< Model * > m_addedModels
std::map< int, int > m_awaitingDatasets
Layerm_currentLayer
Modelm_currentDataset
Modelm_currentDerivedModel
int m_currentDerivedModelId
PlayParametersm_currentPlayParameters
Transform m_currentTransform
Modelm_currentTransformSource
int m_currentTransformChannel
bool m_currentTransformIsNewStyle
QString m_datasetSeparator
bool m_inRow
bool m_inLayer
bool m_inView
bool m_inData
bool m_inSelections
int m_rowNumber
QString m_errorString
bool m_ok


Constructor & Destructor Documentation

SVFileReader::SVFileReader ( Document document,
SVFileReaderPaneCallback callback,
QString  location = "" 
)

Definition at line 47 of file SVFileReader.cpp.

SVFileReader::~SVFileReader (  )  [virtual]

Definition at line 91 of file SVFileReader.cpp.

References m_addedModels, m_awaitingDatasets, and m_models.


Member Function Documentation

void SVFileReader::parse ( const QString &  xmlData  ) 

Definition at line 69 of file SVFileReader.cpp.

void SVFileReader::parse ( QXmlInputSource &  source  ) 

Definition at line 77 of file SVFileReader.cpp.

References m_ok.

bool SVFileReader::isOK (  ) 

Definition at line 86 of file SVFileReader.cpp.

References m_ok.

QString SVFileReader::getErrorString (  )  const [inline]

Definition at line 178 of file SVFileReader.h.

References m_errorString.

void SVFileReader::setCurrentPane ( Pane pane  )  [inline]

Definition at line 181 of file SVFileReader.h.

References m_currentPane.

bool SVFileReader::startElement ( const QString &  namespaceURI,
const QString &  localName,
const QString &  qName,
const QXmlAttributes &  atts 
) [virtual]

Definition at line 120 of file SVFileReader.cpp.

References addBinToDataset(), addPointToDataset(), addRowToDataset(), addUnaddedModels(), m_inData, m_inSelections, m_inView, readDatasetStart(), readDerivation(), readLayer(), readMeasurement(), readModel(), readParameter(), readPlayParameters(), readPlugin(), readSelection(), readTransform(), readView(), and readWindow().

bool SVFileReader::characters ( const QString &   )  [virtual]

Definition at line 245 of file SVFileReader.cpp.

References m_inRow, m_rowNumber, and readRowData().

bool SVFileReader::endElement ( const QString &  namespaceURI,
const QString &  localName,
const QString &  qName 
) [virtual]

Definition at line 260 of file SVFileReader.cpp.

References Document::addDerivedModel(), addUnaddedModels(), Transform::getIdentifier(), haveModel(), m_addedModels, m_awaitingDatasets, m_currentDataset, m_currentDerivedModel, m_currentDerivedModelId, m_currentPlayParameters, m_currentTransform, m_currentTransformChannel, m_currentTransformSource, m_document, m_inData, m_inLayer, m_inRow, m_inSelections, m_inView, m_models, modelRegenerationFailed(), and modelRegenerationWarning().

bool SVFileReader::error ( const QXmlParseException &  exception  ) 

Definition at line 352 of file SVFileReader.cpp.

References m_errorString.

bool SVFileReader::fatalError ( const QXmlParseException &  exception  ) 

Definition at line 364 of file SVFileReader.cpp.

References m_errorString.

void SVFileReader::modelRegenerationFailed ( QString  layerName,
QString  transformName,
QString  message 
) [signal]

Referenced by endElement().

void SVFileReader::modelRegenerationWarning ( QString  layerName,
QString  transformName,
QString  message 
) [signal]

Referenced by endElement().

bool SVFileReader::readWindow ( const QXmlAttributes &   )  [protected]

Definition at line 384 of file SVFileReader.cpp.

References m_paneCallback, READ_MANDATORY, and SVFileReaderPaneCallback::setWindowSize().

Referenced by startElement().

bool SVFileReader::readModel ( const QXmlAttributes &   )  [protected]

Definition at line 415 of file SVFileReader.cpp.

References FileFinder::AudioFile, FileFinder::find(), FileSource::getErrorString(), FileFinder::getInstance(), haveModel(), FileSource::isAvailable(), WaveFileModel::isOK(), FileSource::isOK(), m_addedModels, m_awaitingDatasets, m_document, m_location, m_models, FileSource::ProgressDialog, READ_MANDATORY, Document::setMainModel(), EditableDenseThreeDimensionalModel::setMaximumLevel(), EditableDenseThreeDimensionalModel::setMinimumLevel(), SparseValueModel< PointType >::setScaleUnits(), NoteModel::setValueQuantization(), FileSource::waitForData(), and FileSource::waitForStatus().

Referenced by startElement().

bool SVFileReader::readView ( const QXmlAttributes &   )  [protected]

Definition at line 610 of file SVFileReader.cpp.

References SVFileReaderPaneCallback::addPane(), m_currentPane, m_paneCallback, PlaybackIgnore, PlaybackScrollContinuous, PlaybackScrollPage, READ_MANDATORY, View::setCentreFrame(), Pane::setCentreLineVisible(), View::setFollowGlobalPan(), View::setFollowGlobalZoom(), View::setPlaybackFollow(), and View::setZoomLevel().

Referenced by startElement().

bool SVFileReader::readLayer ( const QXmlAttributes &   )  [protected]

Definition at line 665 of file SVFileReader.cpp.

References Document::addLayerToView(), Document::createLayer(), LayerFactory::getInstance(), haveModel(), m_currentLayer, m_currentPane, m_document, m_inData, m_inLayer, m_layers, m_models, Layer::setLayerDormant(), Document::setModel(), Layer::setObjectName(), Layer::setPresentationName(), and Layer::setProperties().

Referenced by startElement().

bool SVFileReader::readDatasetStart ( const QXmlAttributes &   )  [protected]

Definition at line 790 of file SVFileReader.cpp.

References haveModel(), m_awaitingDatasets, m_currentDataset, m_datasetSeparator, m_models, and READ_MANDATORY.

Referenced by startElement().

bool SVFileReader::addBinToDataset ( const QXmlAttributes &   )  [protected]

Definition at line 923 of file SVFileReader.cpp.

References m_currentDataset, and EditableDenseThreeDimensionalModel::setBinName().

Referenced by startElement().

bool SVFileReader::addPointToDataset ( const QXmlAttributes &   )  [protected]

Definition at line 846 of file SVFileReader.cpp.

References SparseValueModel< PointType >::addPoint(), SparseModel< PointType >::addPoint(), m_currentDataset, and READ_MANDATORY.

Referenced by startElement().

bool SVFileReader::addRowToDataset ( const QXmlAttributes &   )  [protected]

Definition at line 952 of file SVFileReader.cpp.

References m_inRow, and m_rowNumber.

Referenced by startElement().

bool SVFileReader::readRowData ( const QString &   )  [protected]

Definition at line 972 of file SVFileReader.cpp.

References EditableDenseThreeDimensionalModel::getHeight(), m_currentDataset, m_datasetSeparator, m_rowNumber, and EditableDenseThreeDimensionalModel::setColumn().

Referenced by characters().

bool SVFileReader::readDerivation ( const QXmlAttributes &   )  [protected]

Definition at line 1016 of file SVFileReader.cpp.

References RealTime::frame2RealTime(), Document::getMainModel(), Model::getSampleRate(), haveModel(), m_currentDerivedModel, m_currentDerivedModelId, m_currentTransform, m_currentTransformChannel, m_currentTransformIsNewStyle, m_currentTransformSource, m_document, m_models, Transform::setBlockSize(), Transform::setDuration(), Transform::setIdentifier(), Transform::setStartTime(), Transform::setStepSize(), and Transform::setWindowType().

Referenced by startElement().

bool SVFileReader::readPlayParameters ( const QXmlAttributes &   )  [protected]

Definition at line 1106 of file SVFileReader.cpp.

References PlayParameterRepository::getInstance(), haveModel(), m_currentPlayParameters, m_models, PlayParameters::setPlayGain(), PlayParameters::setPlayMuted(), PlayParameters::setPlayPan(), and PlayParameters::setPlayPluginId().

Referenced by startElement().

bool SVFileReader::readPlugin ( const QXmlAttributes &   )  [protected]

Definition at line 1161 of file SVFileReader.cpp.

References XmlExportable::encodeEntities(), TransformFactory::getInstance(), m_currentDerivedModelId, m_currentPlayParameters, m_currentTransform, m_currentTransformIsNewStyle, and PlayParameters::setPlayPluginConfiguration().

Referenced by startElement().

bool SVFileReader::readTransform ( const QXmlAttributes &   )  [protected]

Definition at line 1194 of file SVFileReader.cpp.

References m_currentDerivedModelId, m_currentTransform, and Transform::setFromXmlAttributes().

Referenced by startElement().

bool SVFileReader::readParameter ( const QXmlAttributes &   )  [protected]

Definition at line 1207 of file SVFileReader.cpp.

References m_currentDerivedModelId, m_currentTransform, and Transform::setParameter().

Referenced by startElement().

bool SVFileReader::readSelection ( const QXmlAttributes &   )  [protected]

Definition at line 1228 of file SVFileReader.cpp.

References SVFileReaderPaneCallback::addSelection(), m_paneCallback, and READ_MANDATORY.

Referenced by startElement().

bool SVFileReader::readMeasurement ( const QXmlAttributes &   )  [protected]

Definition at line 1241 of file SVFileReader.cpp.

References Layer::addMeasurementRect(), m_currentLayer, and m_inLayer.

Referenced by startElement().

void SVFileReader::addUnaddedModels (  )  [protected]

Definition at line 396 of file SVFileReader.cpp.

References Document::addImportedModel(), m_addedModels, m_document, and m_models.

Referenced by endElement(), and startElement().

bool SVFileReader::haveModel ( int  id  )  [inline, protected]

Definition at line 222 of file SVFileReader.h.

References m_models.

Referenced by endElement(), readDatasetStart(), readDerivation(), readLayer(), readModel(), and readPlayParameters().


Member Data Documentation

Document* SVFileReader::m_document [protected]

Definition at line 226 of file SVFileReader.h.

Referenced by addUnaddedModels(), endElement(), readDerivation(), readLayer(), and readModel().

SVFileReaderPaneCallback& SVFileReader::m_paneCallback [protected]

Definition at line 227 of file SVFileReader.h.

Referenced by readSelection(), readView(), and readWindow().

QString SVFileReader::m_location [protected]

Definition at line 228 of file SVFileReader.h.

Referenced by readModel().

Pane* SVFileReader::m_currentPane [protected]

Definition at line 229 of file SVFileReader.h.

Referenced by readLayer(), readView(), and setCurrentPane().

std::map<int, Layer *> SVFileReader::m_layers [protected]

Definition at line 230 of file SVFileReader.h.

Referenced by readLayer().

std::map<int, Model *> SVFileReader::m_models [protected]

Definition at line 231 of file SVFileReader.h.

Referenced by addUnaddedModels(), endElement(), haveModel(), readDatasetStart(), readDerivation(), readLayer(), readModel(), readPlayParameters(), and ~SVFileReader().

std::set<Model *> SVFileReader::m_addedModels [protected]

Definition at line 232 of file SVFileReader.h.

Referenced by addUnaddedModels(), endElement(), readModel(), and ~SVFileReader().

std::map<int, int> SVFileReader::m_awaitingDatasets [protected]

Definition at line 233 of file SVFileReader.h.

Referenced by endElement(), readDatasetStart(), readModel(), and ~SVFileReader().

Layer* SVFileReader::m_currentLayer [protected]

Definition at line 234 of file SVFileReader.h.

Referenced by readLayer(), and readMeasurement().

Model* SVFileReader::m_currentDataset [protected]

Definition at line 235 of file SVFileReader.h.

Referenced by addBinToDataset(), addPointToDataset(), endElement(), readDatasetStart(), and readRowData().

Model* SVFileReader::m_currentDerivedModel [protected]

Definition at line 236 of file SVFileReader.h.

Referenced by endElement(), and readDerivation().

int SVFileReader::m_currentDerivedModelId [protected]

Definition at line 237 of file SVFileReader.h.

Referenced by endElement(), readDerivation(), readParameter(), readPlugin(), and readTransform().

PlayParameters* SVFileReader::m_currentPlayParameters [protected]

Definition at line 238 of file SVFileReader.h.

Referenced by endElement(), readPlayParameters(), and readPlugin().

Transform SVFileReader::m_currentTransform [protected]

Definition at line 239 of file SVFileReader.h.

Referenced by endElement(), readDerivation(), readParameter(), readPlugin(), and readTransform().

Model* SVFileReader::m_currentTransformSource [protected]

Definition at line 240 of file SVFileReader.h.

Referenced by endElement(), and readDerivation().

int SVFileReader::m_currentTransformChannel [protected]

Definition at line 241 of file SVFileReader.h.

Referenced by endElement(), and readDerivation().

bool SVFileReader::m_currentTransformIsNewStyle [protected]

Definition at line 242 of file SVFileReader.h.

Referenced by readDerivation(), and readPlugin().

QString SVFileReader::m_datasetSeparator [protected]

Definition at line 243 of file SVFileReader.h.

Referenced by readDatasetStart(), and readRowData().

bool SVFileReader::m_inRow [protected]

Definition at line 244 of file SVFileReader.h.

Referenced by addRowToDataset(), characters(), and endElement().

bool SVFileReader::m_inLayer [protected]

Definition at line 245 of file SVFileReader.h.

Referenced by endElement(), readLayer(), and readMeasurement().

bool SVFileReader::m_inView [protected]

Definition at line 246 of file SVFileReader.h.

Referenced by endElement(), and startElement().

bool SVFileReader::m_inData [protected]

Definition at line 247 of file SVFileReader.h.

Referenced by endElement(), readLayer(), and startElement().

bool SVFileReader::m_inSelections [protected]

Definition at line 248 of file SVFileReader.h.

Referenced by endElement(), and startElement().

int SVFileReader::m_rowNumber [protected]

Definition at line 249 of file SVFileReader.h.

Referenced by addRowToDataset(), characters(), and readRowData().

QString SVFileReader::m_errorString [protected]

Definition at line 250 of file SVFileReader.h.

Referenced by error(), fatalError(), and getErrorString().

bool SVFileReader::m_ok [protected]

Definition at line 251 of file SVFileReader.h.

Referenced by isOK(), and parse().


The documentation for this class was generated from the following files:
Generated on Wed Feb 20 15:45:36 2008 for SonicVisualiser by  doxygen 1.5.1