openMSX
Event.hh
Go to the documentation of this file.
1 #ifndef EVENT_HH
2 #define EVENT_HH
3 
4 #include <string>
5 
6 namespace openmsx {
7 
8 class TclObject;
9 
11 {
34  OPENMSX_BOOT_EVENT, // sent when the MSX resets or power ups
35 
38 
44 
47 
50 
53 
56 
59 
64 
68 
71 
77 
78  NUM_EVENT_TYPES // must be last
79 };
80 
81 class Event
82 {
83 public:
84  Event(const Event&) = delete;
85  Event& operator=(const Event&) = delete;
86 
87  EventType getType() const { return type; }
88 
90  std::string toString() const;
91 
93  virtual TclObject toTclList() const = 0;
94 
95  bool operator< (const Event& other) const;
96  bool operator> (const Event& other) const;
97  bool operator<=(const Event& other) const;
98  bool operator>=(const Event& other) const;
99  bool operator==(const Event& other) const;
100  bool operator!=(const Event& other) const;
101 
105  virtual bool isRepeatStopper(const Event& /*other*/) const {
106  return true;
107  }
108 
112  virtual bool matches(const Event& other) const {
113  return *this == other;
114  }
115 
116 protected:
117  explicit Event(EventType type_) : type(type_) {}
118  ~Event() = default;
119 
120 private:
121  virtual bool lessImpl(const Event& other) const = 0;
122 
123  const EventType type;
124 };
125 
126 // implementation for events that don't need additional data
127 class SimpleEvent final : public Event
128 {
129 public:
130  explicit SimpleEvent(EventType type_) : Event(type_) {}
131  TclObject toTclList() const override;
132  bool lessImpl(const Event& other) const override;
133 };
134 
135 } // namespace openmsx
136 
137 #endif
bool operator>=(const Event &other) const
Definition: Event.cc:27
Sent when a OPENMSX_FINISH_FRAME_EVENT caused a redraw of the screen.
Definition: Event.hh:43
Send when a (new) machine configuration is loaded.
Definition: Event.hh:58
SimpleEvent(EventType type_)
Definition: Event.hh:130
Send when a machine is (de)activated.
Definition: Event.hh:62
bool operator>(const Event &other) const
Definition: Event.cc:19
~Event()=default
Command received on CliComm connection.
Definition: Event.hh:52
Used to schedule &#39;taking reverse snapshots&#39; between Z80 instructions.
Definition: Event.hh:49
bool operator==(const Event &other) const
Definition: Event.cc:32
Send when an after-emutime command should be executed.
Definition: Event.hh:55
bool operator<(const Event &other) const
Definition: Event.cc:13
Sent when VDP (V99x8 or V9990) reaches the end of a frame.
Definition: Event.hh:37
virtual TclObject toTclList() const =0
Similar to toString(), but retains the structure of the event.
virtual bool isRepeatStopper(const Event &) const
Should &#39;bind -repeat&#39; be stopped by &#39;other&#39; event.
Definition: Event.hh:105
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
Event(const Event &)=delete
Send when (part of) the openMSX window gets exposed, and thus should be repainted.
Definition: Event.hh:67
EventType
Definition: Event.hh:10
virtual bool matches(const Event &other) const
Does this event &#39;match&#39; the given event.
Definition: Event.hh:112
Event(EventType type_)
Definition: Event.hh:117
Delete old MSXMotherboards.
Definition: Event.hh:70
Event & operator=(const Event &)=delete
EventType getType() const
Definition: Event.hh:87
bool operator!=(const Event &other) const
Definition: Event.cc:36
std::string toString() const
Get a string representation of this event.
Definition: Event.cc:8
bool operator<=(const Event &other) const
Definition: Event.cc:23