]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/vehicletype.h
Full vehicle unification
[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 function(unsigned, const std::string &);
26                 void height(float);
27                 void length(float);
28                 void width(float);
29         };
30
31         struct Axle
32         {
33                 class Loader: public Msp::DataFile::ObjectLoader<Axle>
34                 {
35                 public:
36                         Loader(Axle &);
37                 private:
38                         void position(float);
39                         void wheel_diameter(float);
40                 };
41
42                 float position;
43                 float wheel_dia;
44                 bool powered;
45
46                 Axle();
47         };
48
49         struct Bogie
50         {
51                 class Loader: public Msp::DataFile::ObjectLoader<Bogie>
52                 {
53                 public:
54                         Loader(Bogie &);
55                 private:
56                         void axle();
57                         void position(float);
58                 };
59
60                 float position;
61                 std::vector<Axle> axles;
62                 std::string object;
63                 bool rotate_object;
64
65                 Bogie();
66         };
67
68 private:
69         unsigned art_nr;
70         std::string name;
71         bool locomotive;
72         std::map<unsigned, std::string> functions;
73         float length;
74         float width;
75         float height;
76         std::vector<Axle> axles;
77         std::vector<Bogie> bogies;
78         std::string object;
79
80 public:
81         VehicleType(unsigned);
82
83         unsigned get_article_number() const { return art_nr; }
84         const std::string &get_name() const { return name; }
85         bool is_locomotive() const { return locomotive; }
86         unsigned get_max_function() const;
87         const std::map<unsigned, std::string> &get_functions() const { return functions; }
88         float get_length() const { return length; }
89         float get_width() const { return width; }
90         float get_height() const { return height; }
91         const std::vector<Axle> &get_axles() const { return axles; }
92         const std::vector<Bogie> &get_bogies() const { return bogies; }
93         const std::string &get_object() const { return object; }
94 };
95
96 } // namespace Marklin
97
98 #endif