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