]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/catalogue.h
dcde9f38f9600dfac5a2a7f761e72ec0c54738c5
[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 ObjectType;
13
14 class Catalogue
15 {
16 public:
17         class Loader: public Msp::DataFile::ObjectLoader<Catalogue>
18         {
19         public:
20                 Loader(Catalogue &);
21         private:
22                 void ballast_profile();
23                 void gauge(float);
24                 void layout();
25                 void rail_profile();
26                 void scale(float, float);
27                 void signal(ArticleNumber);
28                 void track(ArticleNumber);
29                 void vehicle(ArticleNumber);
30         };
31
32         typedef std::map<ArticleNumber, ObjectType *> ObjectMap;
33
34         sigc::signal<void, const ObjectType &> signal_object_added;
35
36 private:
37         float scale;
38         float gauge;
39         Profile rail_profile;
40         Profile ballast_profile;
41         std::string track_technique;
42         ObjectMap objects;
43         Layout layout;
44
45 public:
46         Catalogue();
47         ~Catalogue();
48
49         float get_scale() const { return scale; }
50         float get_gauge() const { return gauge; }
51         float get_rail_elevation() const;
52         const Profile &get_rail_profile() const { return rail_profile; }
53         const Profile &get_ballast_profile() const { return ballast_profile; }
54         const std::string &get_track_technique() const { return track_technique; }
55
56         void add(ObjectType &);
57         const ObjectType &get(const ArticleNumber &) const;
58         const ObjectMap &get_all() const { return objects; }
59
60         template<typename T>
61         const T &get(const ArticleNumber &an) const
62         { return dynamic_cast<const T &>(get(an)); }
63
64         Layout &get_layout() { return layout; }
65 };
66
67 } // namespace R2C2
68
69 #endif