X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flibr2c2%2Fvehicletype.cpp;h=973070ceafc158fe2fddfd4fb966115c5c1ca2a6;hb=59bae8acd679127602cf35d22bcd37e316a5a056;hp=9f8814652770448aa1ae1dc84f5b4d542f4e167a;hpb=4236c30c0a7a48854e9634e9ad7d8d6e0fd243a3;p=r2c2.git diff --git a/source/libr2c2/vehicletype.cpp b/source/libr2c2/vehicletype.cpp index 9f88146..973070c 100644 --- a/source/libr2c2/vehicletype.cpp +++ b/source/libr2c2/vehicletype.cpp @@ -1,4 +1,5 @@ #include +#include #include "vehicletype.h" using namespace std; @@ -7,12 +8,13 @@ using namespace Msp; namespace R2C2 { VehicleType::VehicleType(const ArticleNumber &an): - art_nr(an), + ObjectType(an), locomotive(false), swap_direction(false), length(0), width(0), - height(0) + height(0), + rotate_object(false) { } unsigned VehicleType::get_max_function() const @@ -25,30 +27,30 @@ unsigned VehicleType::get_max_function() const const VehicleType::Axle &VehicleType::get_fixed_axle(unsigned i) const { if(i>=axles.size()) - throw InvalidParameterValue("Axle index out of range"); + throw out_of_range("VehicleType::get_fixed_axle"); return axles[i]; } const VehicleType::Bogie &VehicleType::get_bogie(unsigned i) const { if(i>=bogies.size()) - throw InvalidParameterValue("Axle index out of range"); + throw out_of_range("VehicleType::get_bogie"); return bogies[i]; } const VehicleType::Axle &VehicleType::get_bogie_axle(unsigned i, unsigned j) const { if(i>=bogies.size()) - throw InvalidParameterValue("Axle index out of range"); + throw out_of_range("VehicleType::get_bogie_axle"); if(j>=bogies[i].axles.size()) - throw InvalidParameterValue("Axle index out of range"); + throw out_of_range("VehicleType::get_bogie_axle"); return bogies[i].axles[j]; } const VehicleType::Rod &VehicleType::get_rod(unsigned i) const { if(i>=rods.size()) - throw InvalidParameterValue("Rod index out of range"); + throw out_of_range("VehicleType::get_rod"); return rods[i]; } @@ -103,7 +105,7 @@ VehicleType::Rod::Rod(): VehicleType::Loader::Loader(VehicleType &vt): - DataFile::ObjectLoader(vt) + DataFile::DerivedObjectLoader(vt) { add("axle", &Loader::axle); add("bogie", &Loader::bogie); @@ -111,9 +113,9 @@ VehicleType::Loader::Loader(VehicleType &vt): add("height", &Loader::height); add("length", &Loader::length); add("locomotive", &VehicleType::locomotive); - add("name", &VehicleType::name); add("object", &VehicleType::object); add("rod", &Loader::rod); + add("rotate_object", &VehicleType::rotate_object); add("swap_direction", &VehicleType::swap_direction); add("width", &Loader::width); } @@ -274,7 +276,7 @@ void operator>>(const LexicalConverter &c, VehicleType::Rod::Limit &l) else if(s=="SLIDE_X") l = VehicleType::Rod::SLIDE_X; else - throw LexicalError("Invalid value for Rod::Limit"); + throw lexical_error(format("conversion of '%s' to Rod::Limit", s)); } } // namespace R2C2