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>
39 void signal(const std::string &);
40 void terrain(const std::string &);
41 void track(const std::string &);
42 void train(const std::string &, unsigned, const std::string &);
43 void turnout(unsigned, unsigned);
53 mutable std::list<Msp::Variant> caches;
61 const std::set<B *> &get() const { return base; }
64 const std::set<T *> &get() const;
71 typedef std::vector<Zone *> ZoneArray;
73 sigc::signal<void, Object &> signal_object_added;
74 sigc::signal<void, Object &> signal_object_removed;
75 sigc::signal<void, TrackChain &> signal_track_chain_added;
76 sigc::signal<void, TrackChain &> signal_track_chain_removed;
77 sigc::signal<void, Train &> signal_train_added;
78 sigc::signal<void, Train &> signal_train_removed;
79 sigc::signal<void, Block &, Train *> signal_block_reserved;
80 sigc::signal<void, Sensor &, Sensor::State> signal_sensor_state_changed;
81 sigc::signal<void, Block *, const std::string &> signal_emergency;
88 Storage<Object> objects;
89 Storage<TrackChain> track_chains;
90 Storage<Sensor> sensors;
91 std::map<unsigned, Train *> trains;
92 Msp::Time::TimeStamp last_tick;
93 unsigned next_turnout_addr;
96 Layout(Catalogue &, Driver * = 0);
99 Catalogue &get_catalogue() const { return catalogue; }
100 bool has_driver() const { return driver; }
101 Driver &get_driver() const;
102 Clock &get_clock() { return clock; }
103 const std::string &get_base() const { return base; }
107 void add(TrackChain &);
110 void add(BeamGate &);
113 const std::set<T *> &get_all() const;
116 T *pick(const Ray &);
118 void remove(Object &);
119 void remove(Track &);
120 void remove(TrackChain &);
121 void remove(Sensor &);
122 void remove(BeamGate &);
124 unsigned allocate_turnout_address();
126 Block &get_block(unsigned) const;
127 void create_blocks();
128 void create_blocks(Track &);
130 Route &get_route(const std::string &) const;
131 void update_routes();
133 ZoneArray get_zones(const std::string &) const;
134 Zone &get_zone(const std::string &, unsigned) const;
136 void add_train(Train &);
137 Train &get_train(unsigned) const;
138 const std::map<unsigned, Train *> &get_trains() const { return trains; }
139 void remove_train(Train &);
142 void emergency(Block *, const std::string &);
144 void save(const std::string &) const;
145 void save_dynamic(const std::string &) const;
147 void sensor_state_changed(Sensor &, Sensor::State);