]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/vehicletype.cpp
Add vehicles
[r2c2.git] / source / libmarklin / vehicletype.cpp
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 #include "vehicletype.h"
9
10 using namespace Msp;
11
12 namespace Marklin {
13
14 VehicleType::VehicleType(unsigned n):
15         art_nr(n),
16         length(0),
17         width(0),
18         height(0)
19 { }
20
21
22 VehicleType::Loader::Loader(VehicleType &vt):
23         DataFile::ObjectLoader<VehicleType>(vt)
24 {
25         add("axle",   &Loader::axle);
26         add("bogie",  &Loader::bogie);
27         add("height", &Loader::height);
28         add("length", &Loader::length);
29         add("name",   &VehicleType::name);
30         add("width",  &Loader::width);
31 }
32
33 void VehicleType::Loader::axle()
34 {
35         Axle axl;
36         load_sub(axl);
37         obj.axles.push_back(axl);
38 }
39
40 void VehicleType::Loader::bogie()
41 {
42         Bogie bog;
43         load_sub(bog);
44         obj.bogies.push_back(bog);
45 }
46
47 void VehicleType::Loader::height(float h)
48 {
49         obj.height = h/1000;
50 }
51
52 void VehicleType::Loader::length(float l)
53 {
54         obj.length = l/1000;
55 }
56
57 void VehicleType::Loader::width(float w)
58 {
59         obj.width = w/1000;
60 }
61
62
63 VehicleType::Axle::Loader::Loader(Axle &a):
64         DataFile::ObjectLoader<Axle>(a)
65 {
66         add("position",       &Loader::position);
67         add("wheel_diameter", &Loader::wheel_diameter);
68         add("powered",        &Axle::powered);
69 }
70
71 void VehicleType::Axle::Loader::position(float p)
72 {
73         obj.position = p/1000;
74 }
75
76 void VehicleType::Axle::Loader::wheel_diameter(float d)
77 {
78         obj.wheel_dia = d/1000;
79 }
80
81
82 VehicleType::Bogie::Loader::Loader(Bogie &b):
83         DataFile::ObjectLoader<Bogie>(b)
84 {
85         add("position", &Loader::position);
86         add("axle",     &Loader::axle);
87 }
88
89 void VehicleType::Bogie::Loader::axle()
90 {
91         Axle axl;
92         load_sub(axl);
93         obj.axles.push_back(axl);
94 }
95
96 void VehicleType::Bogie::Loader::position(float p)
97 {
98         obj.position = p/1000;
99 }
100
101 } // namespace Marklin