]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/vehicletype.h
Return null from Route::find if a route can't be found
[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                 std::string object;
46
47                 Axle();
48         };
49
50         struct Bogie
51         {
52                 class Loader: public Msp::DataFile::ObjectLoader<Bogie>
53                 {
54                 public:
55                         Loader(Bogie &);
56                 private:
57                         void axle();
58                         void position(float);
59                 };
60
61                 float position;
62                 std::vector<Axle> axles;
63                 std::string object;
64                 bool rotate_object;
65
66                 Bogie();
67         };
68
69 private:
70         unsigned art_nr;
71         std::string name;
72         bool locomotive;
73         std::map<unsigned, std::string> functions;
74         float length;
75         float width;
76         float height;
77         std::vector<Axle> axles;
78         std::vector<Bogie> bogies;
79         std::string object;
80
81 public:
82         VehicleType(unsigned);
83
84         unsigned get_article_number() const { return art_nr; }
85         const std::string &get_name() const { return name; }
86         bool is_locomotive() const { return locomotive; }
87         unsigned get_max_function() const;
88         const std::map<unsigned, std::string> &get_functions() const { return functions; }
89         float get_length() const { return length; }
90         float get_width() const { return width; }
91         float get_height() const { return height; }
92         const std::vector<Axle> &get_axles() const { return axles; }
93         const std::vector<Bogie> &get_bogies() const { return bogies; }
94         float get_front_axle_offset() const;
95         float get_back_axle_offset() const;
96         const std::string &get_object() const { return object; }
97 };
98
99 } // namespace Marklin
100
101 #endif