changeset 4:149bb02a41ba

* Session file save, and the skeleton of session file load.
author Chris Cannam
date Fri, 13 Jan 2006 18:05:07 +0000
parents 581f67f370f3
children 31c4ed2d5da6
files base/Layer.cpp base/Model.cpp base/View.cpp base/XmlExportable.cpp base/XmlExportable.h
diffstat 5 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/base/Layer.cpp	Thu Jan 12 17:19:08 2006 +0000
+++ b/base/Layer.cpp	Fri Jan 13 18:05:07 2006 +0000
@@ -41,12 +41,12 @@
     
     s += indent;
 
-    s += QString("<layer type=\"%1\" id=\"%2\" name=\"%3\" model=\"%4\" %5/>\n")
+    s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n")
 	.arg(LayerFactory::instance()->getLayerTypeName
 	     (LayerFactory::instance()->getLayerType(this)))
-	.arg((intptr_t)this)
+	.arg(getObjectExportId(this))
 	.arg(objectName())
-	.arg((intptr_t)getModel())
+	.arg(getObjectExportId(getModel()))
 	.arg(extraAttributes);
 
     return s;
--- a/base/Model.cpp	Thu Jan 12 17:19:08 2006 +0000
+++ b/base/Model.cpp	Fri Jan 13 18:05:07 2006 +0000
@@ -18,9 +18,12 @@
     
     s += indent;
 
-    s += QString("<model id=\"%1\" name=\"%2\" %3/>\n")
-	.arg((intptr_t)this)
+    s += QString("<model id=\"%1\" name=\"%2\" sampleRate=\"%3\" start=\"%4\" end=\"%5\" %6/>\n")
+	.arg(getObjectExportId(this))
 	.arg(objectName())
+	.arg(getSampleRate())
+	.arg(getStartFrame())
+	.arg(getEndFrame())
 	.arg(extraAttributes);
 
     return s;
--- a/base/View.cpp	Thu Jan 12 17:19:08 2006 +0000
+++ b/base/View.cpp	Fri Jan 13 18:05:07 2006 +0000
@@ -980,7 +980,7 @@
 	s += m_layers[i]->toXmlString(indent + "  ");
     }
 
-    s += indent + "</view>";
+    s += indent + "</view>\n";
 
     return s;
 }
--- a/base/XmlExportable.cpp	Thu Jan 12 17:19:08 2006 +0000
+++ b/base/XmlExportable.cpp	Fri Jan 13 18:05:07 2006 +0000
@@ -8,6 +8,7 @@
 */
 
 #include "XmlExportable.h"
+#include <map>
 
 QString
 XmlExportable::encodeEntities(QString s)
@@ -39,3 +40,17 @@
     return "#" + r + g + b;
 }
 
+int
+XmlExportable::getObjectExportId(const void * object)
+{
+    static std::map<const void *, int> idMap;
+    static int maxId = 0;
+    
+    if (idMap.find(object) == idMap.end()) {
+	idMap[object] = maxId++;
+    }
+
+    return idMap[object];
+}
+
+
--- a/base/XmlExportable.h	Thu Jan 12 17:19:08 2006 +0000
+++ b/base/XmlExportable.h	Fri Jan 13 18:05:07 2006 +0000
@@ -22,6 +22,8 @@
     static QString encodeEntities(QString);
 
     static QString encodeColour(QColor);
+
+    static int getObjectExportId(const void *); // not thread-safe
 };
 
 #endif