1 #ifndef LIBR2C2_LAYOUT_H_
2 #define LIBR2C2_LAYOUT_H_
5 #include <sigc++/sigc++.h>
6 #include <msp/datafile/objectloader.h>
7 #include <msp/time/timestamp.h>
31 class Loader: public Msp::DataFile::ObjectLoader<Layout>
38 void signal(ArticleNumber);
39 void terrain(ArticleNumber);
40 void track(ArticleNumber);
41 void train(ArticleNumber, unsigned, const std::string &);
42 void turnout(unsigned, unsigned);
52 mutable std::list<Msp::Variant> caches;
60 const std::set<B *> &get() const { return base; }
63 const std::set<T *> &get() const;
70 typedef std::vector<Zone *> ZoneArray;
72 sigc::signal<void, Object &> signal_object_added;
73 sigc::signal<void, Object &> signal_object_removed;
74 sigc::signal<void, TrackChain &> signal_track_chain_added;
75 sigc::signal<void, TrackChain &> signal_track_chain_removed;
76 sigc::signal<void, Train &> signal_train_added;
77 sigc::signal<void, Train &> signal_train_removed;
78 sigc::signal<void, Block &, Train *> signal_block_reserved;
79 sigc::signal<void, Sensor &, Sensor::State> signal_sensor_state_changed;
80 sigc::signal<void, const std::string &> signal_emergency;
87 Storage<Object> objects;
88 Storage<TrackChain> track_chains;
89 Storage<Sensor> sensors;
90 std::map<unsigned, Train *> trains;
91 Msp::Time::TimeStamp last_tick;
92 unsigned next_turnout_addr;
95 Layout(Catalogue &, Driver * = 0);
98 Catalogue &get_catalogue() const { return catalogue; }
99 bool has_driver() const { return driver; }
100 Driver &get_driver() const;
101 const Clock &get_clock() const { return clock; }
102 const std::string &get_base() const { return base; }
106 void add(TrackChain &);
109 void add(BeamGate &);
112 const std::set<T *> &get_all() const;
115 T *pick(const Ray &);
117 void remove(Object &);
118 void remove(Track &);
119 void remove(TrackChain &);
120 void remove(Sensor &);
121 void remove(BeamGate &);
123 unsigned allocate_turnout_address();
125 Block &get_block(unsigned) const;
126 void create_blocks();
127 void create_blocks(Track &);
129 Route &get_route(const std::string &) const;
130 void update_routes();
132 ZoneArray get_zones(const std::string &) const;
133 Zone &get_zone(const std::string &, unsigned) const;
135 void add_train(Train &);
136 Train &get_train(unsigned) const;
137 const std::map<unsigned, Train *> &get_trains() const { return trains; }
138 void remove_train(Train &);
141 void emergency(const std::string &);
143 void save(const std::string &) const;
144 void save_dynamic(const std::string &) const;
146 void sensor_state_changed(Sensor &, Sensor::State);