]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/locomotive.h
Style fixes, including:
[r2c2.git] / source / libmarklin / locomotive.h
1 #ifndef LIBMARKLIN_LOCOMOTIVE_H_
2 #define LIBMARKLIN_LOCOMOTIVE_H_
3
4 #include <list>
5 #include <string>
6 #include <sigc++/signal.h>
7 #include "constants.h"
8
9 namespace Marklin {
10
11 class Control;
12
13 class Locomotive
14 {
15 private:
16         Control  &control;
17         unsigned addr;
18         unsigned speed;
19         bool     reverse;
20         unsigned funcs;
21
22 public:
23         sigc::signal<void, unsigned> signal_speed_changed;
24
25         Locomotive(Control &, unsigned);
26
27         void     set_speed(unsigned);
28         void     set_reverse(bool);
29         void     set_function(unsigned, bool);
30         unsigned get_address() const   { return addr; }
31         unsigned get_speed() const     { return speed; }
32         bool     get_reverse() const   { return reverse; }
33         bool     get_function(unsigned f) const { return (funcs>>f)&1; }
34         void     refresh_status();
35 private:
36         void     send_command(bool);
37         void     status_reply(Error, const std::string &);
38         bool     reverse_timeout();
39 };
40
41 } // namespace Marklin
42
43 #endif