Add i8042 back
[qemupp.git] / include / pin.hpp
blob3120d002a18d5605579bf8c9c3c08e7d7658c222
1 #ifndef PIN_HPP
2 #define PIN_HPP
4 #include "notify.hpp"
5 #include "marshal.hpp"
7 class Pin : public Notifiable
9 public:
10 Pin(bool value=false) : value(value) {
13 enum Event {
14 RISING_EDGE,
15 FALLING_EDGE,
18 NotifierHandle connect(Event type, Notifier notifier) {
19 return Notifiable::connect(type, notifier);
22 bool get(void) const {
23 return this->value;
26 void set(bool value) {
27 if (value && !this->value) {
28 this->value = value;
29 this->notify(RISING_EDGE);
30 } else if (!value && this->value) {
31 this->value = value;
32 this->notify(FALLING_EDGE);
36 void lower(void) {
37 this->set(false);
40 void raise(void) {
41 this->set(true);
44 void pickle(Marshaller *m, const char *name) {
45 bool value = this->get();
46 m->start_struct("Pin", name);
47 marshal(m, "value", &value);
48 m->end_struct();
49 this->set(this->value);
52 private:
53 bool value;
56 #endif