3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBMARKLIN_LAYOUT_H_
9 #define LIBMARKLIN_LAYOUT_H_
12 #include <sigc++/sigc++.h>
13 #include <msp/datafile/loader.h>
14 #include <msp/time/timestamp.h>
30 class Loader: public Msp::DataFile::BasicLoader<Layout>
38 virtual void finish();
40 void route(const std::string &);
42 void track(ArticleNumber);
43 void train(unsigned, unsigned);
44 void train(ArticleNumber, unsigned);
48 sigc::signal<void, Track &> signal_track_added;
49 sigc::signal<void, Track &> signal_track_removed;
50 sigc::signal<void, Route &> signal_route_added;
51 sigc::signal<void, Route &> signal_route_removed;
52 sigc::signal<void, Train &> signal_train_added;
53 sigc::signal<void, Train &> signal_train_removed;
54 sigc::signal<void, Vehicle &> signal_vehicle_added;
55 sigc::signal<void, Vehicle &> signal_vehicle_removed;
56 sigc::signal<void, Block &, Train *> signal_block_reserved;
57 sigc::signal<void, const std::string &> signal_emergency;
63 std::set<Track *> tracks;
64 std::set<Route *> routes;
65 std::set<Block *> blocks;
66 std::map<unsigned, Train *> trains;
67 std::set<Vehicle *> vehicles;
68 Msp::Time::TimeStamp last_tick;
69 unsigned next_turnout_id;
72 Layout(Catalogue &, Driver * = 0);
75 Catalogue &get_catalogue() const { return catalogue; }
76 bool has_driver() const { return driver; }
77 Driver &get_driver() const;
78 const std::string &get_base() const { return base; }
80 void add_track(Track &);
81 const std::set<Track *> &get_tracks() const { return tracks; }
82 void remove_track(Track &);
83 unsigned allocate_turnout_id(bool);
85 void add_block(Block &);
86 Block &get_block(unsigned) const;
87 const std::set<Block *> &get_blocks() const { return blocks; }
89 void create_blocks(Track &);
90 void remove_block(Block &);
92 void add_route(Route &);
93 const std::set<Route *> &get_routes() const { return routes; }
94 Route &get_route(const std::string &) const;
96 void remove_route(Route &);
98 void add_train(Train &);
99 Train &get_train(unsigned) const;
100 const std::map<unsigned, Train *> &get_trains() const { return trains; }
101 void remove_train(Train &);
103 void add_vehicle(Vehicle &);
104 void remove_vehicle(Vehicle &);
107 void emergency(const std::string &);
109 void save(const std::string &);
110 void save_trains(const std::string &);
112 void sensor_event(unsigned, bool);
115 } // namespace Marklin