]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/vehicletype.h
Add vehicles
[r2c2.git] / source / libmarklin / vehicletype.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_VEHICLETYPE_H_
9 #define LIBMARKLIN_VEHICLETYPE_H_
10
11 #include <msp/datafile/objectloader.h>
12
13 namespace Marklin {
14
15 class VehicleType
16 {
17 public:
18         class Loader: public Msp::DataFile::ObjectLoader<VehicleType>
19         {
20         public:
21                 Loader(VehicleType &);
22         private:
23                 void axle();
24                 void bogie();
25                 void height(float);
26                 void length(float);
27                 void width(float);
28         };
29
30         struct Axle
31         {
32                 class Loader: public Msp::DataFile::ObjectLoader<Axle>
33                 {
34                 public:
35                         Loader(Axle &);
36                 private:
37                         void position(float);
38                         void wheel_diameter(float);
39                 };
40
41                 float position;
42                 float wheel_dia;
43                 bool powered;
44         };
45
46         struct Bogie
47         {
48                 class Loader: public Msp::DataFile::ObjectLoader<Bogie>
49                 {
50                 public:
51                         Loader(Bogie &);
52                 private:
53                         void axle();
54                         void position(float);
55                 };
56
57                 float position;
58                 std::vector<Axle> axles;
59         };
60
61 private:
62         unsigned art_nr;
63         std::string name;
64         float length;
65         float width;
66         float height;
67         std::vector<Axle> axles;
68         std::vector<Bogie> bogies;
69
70 public:
71         VehicleType(unsigned);
72
73         unsigned get_article_number() const { return art_nr; }
74         const std::string &get_name() const { return name; }
75         float get_length() const { return length; }
76         float get_width() const { return width; }
77         float get_height() const { return height; }
78         const std::vector<Axle> &get_axles() const { return axles; }
79         const std::vector<Bogie> &get_bogies() const { return bogies; }
80 };
81
82 } // namespace Marklin
83
84 #endif