]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/trafficmanager.h
Forgot to add the new files
[r2c2.git] / source / libmarklin / trafficmanager.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_TRAFFICMANAGER_H_
9 #define LIBMARKLIN_TRAFFICMANAGER_H_
10
11 #include "block.h"
12 #include "train.h"
13
14 namespace Marklin {
15
16 class Control;
17 class Layout;
18 class Turnout;
19
20 class TrafficManager
21 {
22 public:
23         class Loader: public Msp::DataFile::BasicLoader<TrafficManager>
24         {
25         public:
26                 Loader(TrafficManager &);
27         private:
28                 void train(unsigned, unsigned);
29         };
30
31         sigc::signal<void, Train &> signal_train_added;
32         sigc::signal<void, const Block &, const Train *> signal_block_reserved;
33
34 private:
35         Control &control;
36         Layout &layout;
37         std::list<Block *> blocks;
38         std::list<Train *> trains;
39         Msp::Time::TimeStamp last_tick;
40
41 public:
42         TrafficManager(Control &, Layout &);
43         ~TrafficManager();
44
45         Control &get_control() const { return control; }
46         Layout &get_layout() const { return layout; }
47         const std::list<Block *> &get_blocks() const { return blocks; }
48         Block &get_block(unsigned) const;
49         Block &get_block_by_track(const Track &) const;
50         const std::list<Train *> &get_trains() const { return trains; }
51         Train &get_train_by_locomotive(const Locomotive &) const;
52         void add_train(Train *);
53         void tick();
54         void save(const std::string &) const;
55 private:
56         void turnout_path_changed(unsigned, Turnout *);
57 };
58
59 } // namespace Marklin
60
61 #endif