]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/sensor.h
Add a virtual get_block function to Sensor
[r2c2.git] / source / libr2c2 / sensor.h
1 #ifndef LIBR2C2_SENSOR_H_
2 #define LIBR2C2_SENSOR_H_
3
4 #include <sigc++/signal.h>
5 #include <msp/time/timedelta.h>
6
7 namespace R2C2 {
8
9 class Block;
10 class Layout;
11
12 class Sensor: public sigc::trackable
13 {
14 public:
15         enum State
16         {
17                 INACTIVE,
18                 MAYBE_INACTIVE,
19                 MAYBE_ACTIVE,
20                 ACTIVE
21         };
22
23         sigc::signal<void, State> signal_state_changed;
24
25 protected:
26         Layout &layout;
27         unsigned address;
28         State state;
29         Msp::Time::TimeDelta state_confirm_timeout;
30
31         Sensor(Layout &);
32 public:
33         virtual ~Sensor();
34
35         unsigned get_address() const { return address; }
36         State get_state() const { return state; }
37         virtual Block *get_block() const { return 0; }
38
39         void tick(const Msp::Time::TimeDelta &);
40
41 private:
42         void event(unsigned, bool);
43 };
44
45 } // namespace R2C2
46
47 #endif