]> git.tdb.fi Git - r2c2.git/blob - catalogue.h
c8b006ab42820b8b7b786e3ca494292fed7874a3
[r2c2.git] / catalogue.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBR2C2_CATALOGUE_H_
9 #define LIBR2C2_CATALOGUE_H_
10
11 #include <map>
12 #include <msp/datafile/loader.h>
13 #include "articlenumber.h"
14 #include "layout.h"
15 #include "profile.h"
16
17 namespace R2C2 {
18
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 rail_profile();
34                 void scale(float, float);
35                 void track(unsigned);
36                 void track(ArticleNumber);
37                 void vehicle(unsigned);
38                 void vehicle(ArticleNumber);
39         };
40
41         typedef std::map<ArticleNumber, TrackType *> TrackMap;
42         typedef std::map<ArticleNumber, VehicleType *> VehicleMap;
43
44         sigc::signal<void, const TrackType &> signal_track_added;
45         sigc::signal<void, const VehicleType &> signal_vehicle_added;
46
47 private:
48         float scale;
49         float gauge;
50         Profile rail_profile;
51         Profile ballast_profile;
52         Profile path_profile;
53         TrackMap tracks;
54         VehicleMap vehicles;
55         Layout layout;
56
57 public:
58         Catalogue();
59         ~Catalogue();
60
61         float get_scale() const { return scale; }
62         float get_gauge() const { return gauge; }
63         float get_rail_elevation() const;
64         const Profile &get_rail_profile() const { return rail_profile; }
65         const Profile &get_ballast_profile() const { return ballast_profile; }
66         const Profile &get_path_profile() const { return path_profile; }
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         Layout &get_layout() { return layout; }
77 };
78
79 } // namespace R2C2
80
81 #endif