X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicletype.h;h=31b6992a134773c474cf1ab2868b054ccbcaca83;hb=2314cc760b726c5aa0e697c82f3a9051784e0706;hp=d8bec87a31a1ff9d47ddc2b702e26d1c190389f0;hpb=a993f204ba2cd282637814caec3ab115040fc0cc;p=r2c2.git diff --git a/source/libr2c2/vehicletype.h b/source/libr2c2/vehicletype.h index d8bec87..31b6992 100644 --- a/source/libr2c2/vehicletype.h +++ b/source/libr2c2/vehicletype.h @@ -2,15 +2,15 @@ #define LIBR2C2_VEHICLETYPE_H_ #include -#include "articlenumber.h" #include "geometry.h" +#include "objecttype.h" namespace R2C2 { -class VehicleType +class VehicleType: public ObjectType { public: - class Loader: public Msp::DataFile::ObjectLoader + class Loader: public Msp::DataFile::DerivedObjectLoader { private: std::map rod_tags; @@ -18,6 +18,7 @@ public: public: Loader(VehicleType &); private: + virtual void finish(); void axle(); void bogie(); void function(unsigned, const std::string &); @@ -27,6 +28,8 @@ public: void width(float); }; + struct Bogie; + struct Axle { class Loader: public Msp::DataFile::ObjectLoader @@ -38,6 +41,9 @@ public: void wheel_diameter(float); }; + unsigned index; + Bogie *bogie; + float local_position; float position; float wheel_dia; bool powered; @@ -46,29 +52,30 @@ public: Axle(); }; - typedef std::vector AxleArray; - struct Bogie { class Loader: public Msp::DataFile::ObjectLoader { + private: + VehicleType &parent; + public: - Loader(Bogie &); + Loader(VehicleType &, Bogie &); private: void axle(); void position(float); }; + unsigned index; float position; - AxleArray axles; + unsigned first_axle; + std::vector axles; std::string object; bool rotate_object; Bogie(); }; - typedef std::vector BogieArray; - struct Rod { enum Anchor @@ -120,13 +127,12 @@ public: Rod(); }; + typedef std::vector AxleArray; + typedef std::vector BogieArray; typedef std::vector RodArray; - typedef std::map FunctionMap; private: - ArticleNumber art_nr; - std::string name; bool locomotive; FunctionMap functions; bool swap_direction; @@ -134,6 +140,7 @@ private: float width; float height; AxleArray axles; + std::vector fixed_axles; BogieArray bogies; RodArray rods; std::string object; @@ -142,8 +149,6 @@ private: public: VehicleType(const ArticleNumber &); - const ArticleNumber &get_article_number() const { return art_nr; } - const std::string &get_name() const { return name; } bool is_locomotive() const { return locomotive; } unsigned get_max_function() const; const FunctionMap &get_functions() const { return functions; } @@ -151,7 +156,8 @@ public: float get_length() const { return length; } float get_width() const { return width; } float get_height() const { return height; } - const AxleArray &get_fixed_axles() const { return axles; } + const AxleArray &get_axles() const { return axles; } + const Axle &get_axle(unsigned) const; const Axle &get_fixed_axle(unsigned) const; const BogieArray &get_bogies() const { return bogies; } const Bogie &get_bogie(unsigned) const;