]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/catalogue.h
Add basic support for signals
[r2c2.git] / source / libr2c2 / catalogue.h
1 #ifndef LIBR2C2_CATALOGUE_H_
2 #define LIBR2C2_CATALOGUE_H_
3
4 #include <map>
5 #include <msp/datafile/objectloader.h>
6 #include "articlenumber.h"
7 #include "layout.h"
8 #include "profile.h"
9
10 namespace R2C2 {
11
12 class SignalType;
13 class TrackType;
14 class VehicleType;
15
16 class Catalogue
17 {
18 public:
19         class Loader: public Msp::DataFile::ObjectLoader<Catalogue>
20         {
21         public:
22                 Loader(Catalogue &);
23         private:
24                 void ballast_profile();
25                 void gauge(float);
26                 void layout();
27                 void rail_profile();
28                 void scale(float, float);
29                 void signal(ArticleNumber);
30                 void track(unsigned);
31                 void track(ArticleNumber);
32                 void vehicle(unsigned);
33                 void vehicle(ArticleNumber);
34         };
35
36         typedef std::map<ArticleNumber, TrackType *> TrackMap;
37         typedef std::map<ArticleNumber, VehicleType *> VehicleMap;
38         typedef std::map<ArticleNumber, SignalType *> SignalMap;
39
40         sigc::signal<void, const TrackType &> signal_track_added;
41         sigc::signal<void, const VehicleType &> signal_vehicle_added;
42         sigc::signal<void, const SignalType &> signal_signal_added;
43
44 private:
45         float scale;
46         float gauge;
47         Profile rail_profile;
48         Profile ballast_profile;
49         Profile path_profile;
50         std::string track_technique;
51         TrackMap tracks;
52         VehicleMap vehicles;
53         SignalMap signals;
54         Layout layout;
55
56 public:
57         Catalogue();
58         ~Catalogue();
59
60         float get_scale() const { return scale; }
61         float get_gauge() const { return gauge; }
62         float get_rail_elevation() const;
63         const Profile &get_rail_profile() const { return rail_profile; }
64         const Profile &get_ballast_profile() const { return ballast_profile; }
65         const Profile &get_path_profile() const { return path_profile; }
66         const std::string &get_track_technique() const { return track_technique; }
67
68         void add_track(TrackType &);
69         const TrackType &get_track(const ArticleNumber &) const;
70         const TrackMap &get_tracks() const { return tracks; }
71
72         void add_vehicle(VehicleType &);
73         const VehicleType &get_vehicle(const ArticleNumber &) const;
74         const VehicleMap &get_vehicles() const { return vehicles; }
75
76         void add_signal(SignalType &);
77         const SignalType &get_signal(const ArticleNumber &) const;
78         const SignalMap &get_signals() const { return signals; }
79
80         Layout &get_layout() { return layout; }
81 };
82
83 } // namespace R2C2
84
85 #endif