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