]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/catalogue.h
Return null from Route::find if a route can't be found
[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 TrackType;
19 class VehicleType;
20
21 class Catalogue
22 {
23 public:
24         class Loader: public Msp::DataFile::BasicLoader<Catalogue>
25         {
26         public:
27                 Loader(Catalogue &);
28         private:
29                 void ballast_profile();
30                 void gauge(float);
31                 void layout();
32                 void rail_profile();
33                 void scale(float, float);
34                 void track(unsigned);
35                 void vehicle(unsigned);
36         };
37
38         sigc::signal<void, const TrackType &> signal_track_added;
39         sigc::signal<void, const VehicleType &> signal_vehicle_added;
40
41 private:
42         float scale;
43         float gauge;
44         Profile rail_profile;
45         Profile ballast_profile;
46         Profile path_profile;
47         std::map<unsigned, TrackType *> tracks;
48         std::map<unsigned, VehicleType *> vehicles;
49         Layout layout;
50
51 public:
52         Catalogue();
53         ~Catalogue();
54
55         float get_scale() const { return scale; }
56         float get_gauge() const { return gauge; }
57         float get_rail_elevation() const;
58         const Profile &get_rail_profile() const { return rail_profile; }
59         const Profile &get_ballast_profile() const { return ballast_profile; }
60         const Profile &get_path_profile() const { return path_profile; }
61
62         void add_track(TrackType &);
63         const TrackType &get_track(unsigned) const;
64         const std::map<unsigned, TrackType *> &get_tracks() const { return tracks; }
65
66         void add_vehicle(VehicleType &);
67         const VehicleType &get_vehicle(unsigned) const;
68         const std::map<unsigned, VehicleType *> &get_vehicles() const { return vehicles; }
69
70         Layout &get_layout() { return layout; }
71 };
72
73 } // namespace Marklin
74
75 #endif