]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/catalogue.h
Support trains with multiple vehicles
[r2c2.git] / source / libmarklin / catalogue.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_CATALOGUE_H_
9 #define LIBMARKLIN_CATALOGUE_H_
10
11 #include <map>
12 #include <msp/datafile/loader.h>
13 #include "layout.h"
14 #include "profile.h"
15
16 namespace Marklin {
17
18 class LocoType;
19 class TrackType;
20 class VehicleType;
21
22 class Catalogue
23 {
24 public:
25         class Loader: public Msp::DataFile::BasicLoader<Catalogue>
26         {
27         public:
28                 Loader(Catalogue &);
29         private:
30                 void ballast_profile();
31                 void gauge(float);
32                 void layout();
33                 void locomotive(unsigned);
34                 void rail_profile();
35                 void scale(float, float);
36                 void track(unsigned);
37                 void vehicle(unsigned);
38         };
39
40         sigc::signal<void, const TrackType &> signal_track_added;
41         sigc::signal<void, const VehicleType &> signal_vehicle_added;
42
43 private:
44         float scale;
45         float gauge;
46         Profile rail_profile;
47         Profile ballast_profile;
48         Profile path_profile;
49         std::map<unsigned, TrackType *> tracks;
50         std::map<unsigned, VehicleType *> vehicles;
51         Layout layout;
52
53 public:
54         Catalogue();
55         ~Catalogue();
56
57         float get_scale() const { return scale; }
58         float get_gauge() const { return gauge; }
59         const Profile &get_rail_profile() const { return rail_profile; }
60         const Profile &get_ballast_profile() const { return ballast_profile; }
61         const Profile &get_path_profile() const { return path_profile; }
62
63         void add_track(TrackType &);
64         const TrackType &get_track(unsigned) const;
65         const std::map<unsigned, TrackType *> &get_tracks() const { return tracks; }
66
67         void add_vehicle(VehicleType &);
68         const VehicleType &get_vehicle(unsigned) const;
69         const LocoType &get_locomotive(unsigned) const;
70         const std::map<unsigned, VehicleType *> &get_vehicles() const { return vehicles; }
71
72         Layout &get_layout() { return layout; }
73 };
74
75 } // namespace Marklin
76
77 #endif