]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/catalogue.cpp
Fix memory leaks and other bad stuff
[r2c2.git] / source / libmarklin / catalogue.cpp
index 55a5a440a3903efbff54e86b61dc8fa7382e654d..cce5ef04ee564d3b2bd7f8b78278e89a0ccab3ff 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of the MSP Märklin suite
-Copyright © 2006-2009  Mikkosoft Productions, Mikko Rasa
+Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -16,6 +16,12 @@ using namespace Msp;
 
 namespace Marklin {
 
+Catalogue::Catalogue():
+       scale(1),
+       gauge(1.524),
+       layout(*this)
+{ }
+
 Catalogue::~Catalogue()
 {
        for(map<unsigned, TrackType *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
@@ -46,10 +52,30 @@ LocoType &Catalogue::get_locomotive(unsigned art_nr) const
 Catalogue::Loader::Loader(Catalogue &c):
        DataFile::BasicLoader<Catalogue>(c)
 {
+       add("ballast_profile", &Loader::ballast_profile);
+       add("gauge", &Loader::gauge);
+       add("layout", &Loader::layout);
        add("locomotive", &Loader::locomotive);
+       add("rail_profile", &Loader::rail_profile);
+       add("scale", &Loader::scale);
        add("track", &Loader::track);
 }
 
+void Catalogue::Loader::ballast_profile()
+{
+       load_sub(obj.ballast_profile);
+}
+
+void Catalogue::Loader::gauge(float g)
+{
+       obj.gauge = g/1000;
+}
+
+void Catalogue::Loader::layout()
+{
+       load_sub(obj.layout);
+}
+
 void Catalogue::Loader::locomotive(unsigned art_nr)
 {
        if(obj.locos.count(art_nr))
@@ -60,6 +86,16 @@ void Catalogue::Loader::locomotive(unsigned art_nr)
        obj.locos[art_nr] = loco.release();
 }
 
+void Catalogue::Loader::rail_profile()
+{
+       load_sub(obj.rail_profile);
+}
+
+void Catalogue::Loader::scale(float n, float d)
+{
+       obj.scale = n/d;
+}
+
 void Catalogue::Loader::track(unsigned art_nr)
 {
        if(obj.tracks.count(art_nr))