]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/driver.h
d9d11270eb697c5d4155d6eb87026c535b1839b6
[r2c2.git] / source / libr2c2 / driver.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBR2C2_DRIVER_H_
9 #define LIBR2C2_DRIVER_H_
10
11 #include <string>
12 #include <sigc++/signal.h>
13
14 namespace R2C2 {
15
16 class Driver
17 {
18 public:
19         sigc::signal<void, bool> signal_power;
20         sigc::signal<void, bool> signal_halt;
21         sigc::signal<void, unsigned, unsigned, bool> signal_loco_speed;
22         sigc::signal<void, unsigned, unsigned, bool> signal_loco_function;
23         sigc::signal<void, unsigned, bool> signal_turnout;
24         sigc::signal<void, unsigned, bool> signal_sensor;
25
26 protected:
27         Driver() { }
28 public:
29         virtual ~Driver() { }
30
31         virtual void set_power(bool) = 0;
32         virtual bool get_power() const = 0;
33         virtual void halt(bool) = 0;
34         virtual bool is_halted() const = 0;
35
36         virtual const char *enumerate_protocols(unsigned) const = 0;
37         virtual unsigned get_protocol_speed_steps(const std::string &) const = 0;
38         virtual void add_loco(unsigned, const std::string &) = 0;
39         virtual void set_loco_speed(unsigned, unsigned) = 0;
40         virtual void set_loco_reverse(unsigned, bool) = 0;
41         virtual void set_loco_function(unsigned, unsigned, bool) = 0;
42
43         virtual void add_turnout(unsigned) = 0;
44         virtual void set_turnout(unsigned, bool) = 0;
45         virtual bool get_turnout(unsigned) const = 0;
46
47         virtual void add_sensor(unsigned) = 0;
48         virtual void set_sensor(unsigned, bool) = 0;
49         virtual bool get_sensor(unsigned) const = 0;
50
51         virtual void tick() = 0;
52         virtual void flush() = 0;
53
54         static Driver *create(const std::string &);
55 };
56
57 } // namespace R2C2
58
59 #endif