annotate base/Model.cpp @ 147:3a13b0d4934e

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 11:44:37 +0000
parents f90fad823cea
children
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@3 2
Chris@3 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@3 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@3 14 */
Chris@0 15
Chris@0 16 #include "Model.h"
Chris@30 17 #include "PlayParameterRepository.h"
Chris@0 18
Chris@146 19 #include <QTextStream>
Chris@146 20
Chris@43 21 #include <iostream>
Chris@43 22
Chris@0 23 const int Model::COMPLETION_UNKNOWN = -1;
Chris@0 24
Chris@30 25 Model::~Model()
Chris@30 26 {
Chris@117 27 // std::cerr << "Model::~Model(" << this << ")" << std::endl;
Chris@43 28
Chris@30 29 // Subclasses have to handle adding themselves to the repository,
Chris@30 30 // if they want to be played. We can't do it from here because
Chris@30 31 // the repository would be unable to tell whether we were playable
Chris@30 32 // or not (because dynamic_cast won't work from the base class ctor)
Chris@145 33 PlayParameterRepository::getInstance()->removeModel(this);
Chris@30 34 }
Chris@30 35
Chris@146 36 void
Chris@146 37 Model::toXml(QTextStream &stream, QString indent,
Chris@146 38 QString extraAttributes) const
Chris@146 39 {
Chris@146 40 stream << indent;
Chris@146 41 stream << QString("<model id=\"%1\" name=\"%2\" sampleRate=\"%3\" start=\"%4\" end=\"%5\" %6/>\n")
Chris@146 42 .arg(getObjectExportId(this))
Chris@146 43 .arg(encodeEntities(objectName()))
Chris@146 44 .arg(getSampleRate())
Chris@146 45 .arg(getStartFrame())
Chris@146 46 .arg(getEndFrame())
Chris@146 47 .arg(extraAttributes);
Chris@146 48 }
Chris@146 49
Chris@3 50 QString
Chris@3 51 Model::toXmlString(QString indent, QString extraAttributes) const
Chris@3 52 {
Chris@3 53 QString s;
Chris@3 54
Chris@3 55 s += indent;
Chris@3 56
Chris@4 57 s += QString("<model id=\"%1\" name=\"%2\" sampleRate=\"%3\" start=\"%4\" end=\"%5\" %6/>\n")
Chris@4 58 .arg(getObjectExportId(this))
Chris@77 59 .arg(encodeEntities(objectName()))
Chris@4 60 .arg(getSampleRate())
Chris@4 61 .arg(getStartFrame())
Chris@4 62 .arg(getEndFrame())
Chris@3 63 .arg(extraAttributes);
Chris@3 64
Chris@3 65 return s;
Chris@3 66 }
Chris@3 67
Chris@0 68 #ifdef INCLUDE_MOCFILES
Chris@0 69 #include "Model.moc.cpp"
Chris@0 70 #endif
Chris@0 71