X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fvehicletype.cpp;h=dd15b48f964794b2291775f98fae9cb6dadc8d44;hb=77f8c0e033b9b5e7085de5d22a62128a996a5b2a;hp=0c057e26203b79075eb1207f2c4b6c4b7bbda2f3;hpb=7ff28ec88dedc3a2327feb4a507ae622cb953113;p=r2c2.git diff --git a/source/libmarklin/vehicletype.cpp b/source/libmarklin/vehicletype.cpp index 0c057e2..dd15b48 100644 --- a/source/libmarklin/vehicletype.cpp +++ b/source/libmarklin/vehicletype.cpp @@ -7,6 +7,7 @@ Distributed under the GPL #include "vehicletype.h" +using namespace std; using namespace Msp; namespace Marklin { @@ -18,6 +19,13 @@ VehicleType::VehicleType(unsigned n): height(0) { } +unsigned VehicleType::get_max_function() const +{ + if(functions.empty()) + return 0; + return (--functions.end())->first; +} + VehicleType::Axle::Axle(): position(0), @@ -35,13 +43,15 @@ VehicleType::Bogie::Bogie(): VehicleType::Loader::Loader(VehicleType &vt): DataFile::ObjectLoader(vt) { - add("axle", &Loader::axle); - add("bogie", &Loader::bogie); - add("height", &Loader::height); - add("length", &Loader::length); - add("object", &VehicleType::object); - add("name", &VehicleType::name); - add("width", &Loader::width); + add("axle", &Loader::axle); + add("bogie", &Loader::bogie); + add("function", &Loader::function); + add("height", &Loader::height); + add("length", &Loader::length); + add("locomotive", &VehicleType::locomotive); + add("object", &VehicleType::object); + add("name", &VehicleType::name); + add("width", &Loader::width); } void VehicleType::Loader::axle() @@ -58,6 +68,11 @@ void VehicleType::Loader::bogie() obj.bogies.push_back(bog); } +void VehicleType::Loader::function(unsigned i, const string &f) +{ + obj.functions[i] = f; +} + void VehicleType::Loader::height(float h) { obj.height = h/1000;