]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/dummy.h
Add a set_sensor function to the Driver interface
[r2c2.git] / source / libmarklin / dummy.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_DUMMY_H_
9 #define LIBMARKLIN_DUMMY_H_
10
11 #include <map>
12 #include "driver.h"
13
14 namespace Marklin {
15
16 class Dummy: public Driver
17 {
18 private:
19         struct LocoState
20         {
21                 unsigned speed;
22                 bool reverse;
23         };
24
25         bool power;
26         std::map<unsigned, bool> turnouts;
27         std::map<unsigned, LocoState> locos;
28         std::map<unsigned, bool> sensors;
29
30 public:
31         Dummy();
32
33         virtual void set_power(bool);
34         virtual bool get_power() const { return power; }
35
36         virtual void add_loco(unsigned) { }
37         virtual void set_loco_speed(unsigned, unsigned);
38         virtual void set_loco_reverse(unsigned, bool);
39         virtual void set_loco_function(unsigned, unsigned, bool);
40
41         virtual void add_turnout(unsigned);
42         virtual void set_turnout(unsigned, bool);
43         virtual bool get_turnout(unsigned) const;
44
45         virtual void add_sensor(unsigned) { }
46         virtual void set_sensor(unsigned, bool);
47         virtual bool get_sensor(unsigned) const;
48
49         virtual void tick() { }
50         virtual void flush() { }
51 };
52
53 } // namespace Marklin
54
55 #endif