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 {
36  OPENMSX_BOOT_EVENT, // sent when the MSX resets or power ups
37 
40 
46 
49 
52 
55 
58 
61 
66 
70 
73 
79 
80  NUM_EVENT_TYPES // must be last
81 };
82 
83 class Event
84 {
85 public:
86  Event(const Event&) = delete;
87  Event& operator=(const Event&) = delete;
88 
89  EventType getType() const { return type; }
90 
92  std::string toString() const;
93 
95  virtual TclObject toTclList() const = 0;
96 
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  bool operator==(const Event& other) const;
102  bool operator!=(const Event& other) const;
103 
107  virtual bool isRepeatStopper(const Event& /*other*/) const {
108  return true;
109  }
110 
114  virtual bool matches(const Event& other) const {
115  return *this == other;
116  }
117 
118 protected:
119  explicit Event(EventType type_) : type(type_) {}
120  ~Event() = default;
121 
122 private:
123  virtual bool lessImpl(const Event& other) const = 0;
124 
125  const EventType type;
126 };
127 
128 // implementation for events that don't need additional data
129 class SimpleEvent final : public Event
130 {
131 public:
132  explicit SimpleEvent(EventType type_) : Event(type_) {}
133  TclObject toTclList() const override;
134  bool lessImpl(const Event& other) const override;
135 };
136 
137 } // namespace openmsx
138 
139 #endif
openmsx::Event::operator==
bool operator==(const Event &other) const
Definition: Event.cc:32
openmsx::OPENMSX_KEY_GROUP_EVENT
@ OPENMSX_KEY_GROUP_EVENT
Definition: Event.hh:14
openmsx::OPENMSX_MOUSE_WHEEL_EVENT
@ OPENMSX_MOUSE_WHEEL_EVENT
Definition: Event.hh:20
openmsx::OPENMSX_JOY_AXIS_MOTION_EVENT
@ OPENMSX_JOY_AXIS_MOTION_EVENT
Definition: Event.hh:22
openmsx::OPENMSX_QUIT_EVENT
@ OPENMSX_QUIT_EVENT
Definition: Event.hh:33
openmsx::OPENMSX_AFTER_TIMED_EVENT
@ OPENMSX_AFTER_TIMED_EVENT
Send when an after-emutime command should be executed.
Definition: Event.hh:57
openmsx::OPENMSX_MOUSE_MOTION_EVENT
@ OPENMSX_MOUSE_MOTION_EVENT
Definition: Event.hh:15
openmsx::Event::toTclList
virtual TclObject toTclList() const =0
Similar to toString(), but retains the structure of the event.
openmsx::OPENMSX_BOOT_EVENT
@ OPENMSX_BOOT_EVENT
Definition: Event.hh:36
openmsx::Event
Definition: Event.hh:84
openmsx::OPENMSX_FILEDROP_GROUP_EVENT
@ OPENMSX_FILEDROP_GROUP_EVENT
Definition: Event.hh:32
openmsx::Event::operator=
Event & operator=(const Event &)=delete
openmsx::OPENMSX_JOY_HAT_EVENT
@ OPENMSX_JOY_HAT_EVENT
Definition: Event.hh:24
openmsx::OPENMSX_BREAK_EVENT
@ OPENMSX_BREAK_EVENT
Definition: Event.hh:47
openmsx::Event::toString
std::string toString() const
Get a string representation of this event.
Definition: Event.cc:8
openmsx::OPENMSX_MACHINE_DEACTIVATED
@ OPENMSX_MACHINE_DEACTIVATED
Definition: Event.hh:65
openmsx::OPENMSX_OSD_CONTROL_PRESS_EVENT
@ OPENMSX_OSD_CONTROL_PRESS_EVENT
Definition: Event.hh:35
openmsx::Event::isRepeatStopper
virtual bool isRepeatStopper(const Event &) const
Should 'bind -repeat' be stopped by 'other' event.
Definition: Event.hh:107
openmsx::OPENMSX_KEY_DOWN_EVENT
@ OPENMSX_KEY_DOWN_EVENT
Definition: Event.hh:13
openmsx::OPENMSX_MOUSE_BUTTON_GROUP_EVENT
@ OPENMSX_MOUSE_BUTTON_GROUP_EVENT
Definition: Event.hh:19
openmsx::Event::operator>=
bool operator>=(const Event &other) const
Definition: Event.cc:27
openmsx::OPENMSX_MIDI_IN_WINDOWS_EVENT
@ OPENMSX_MIDI_IN_WINDOWS_EVENT
Definition: Event.hh:75
openmsx::OPENMSX_MOUSE_WHEEL_GROUP_EVENT
@ OPENMSX_MOUSE_WHEEL_GROUP_EVENT
Definition: Event.hh:21
openmsx::OPENMSX_SWITCH_RENDERER_EVENT
@ OPENMSX_SWITCH_RENDERER_EVENT
Definition: Event.hh:48
openmsx::Event::Event
Event(EventType type_)
Definition: Event.hh:119
openmsx::SimpleEvent::lessImpl
bool lessImpl(const Event &other) const override
Definition: Event.cc:46
openmsx::OPENMSX_TAKE_REVERSE_SNAPSHOT
@ OPENMSX_TAKE_REVERSE_SNAPSHOT
Used to schedule 'taking reverse snapshots' between Z80 instructions.
Definition: Event.hh:51
openmsx::OPENMSX_MOUSE_BUTTON_UP_EVENT
@ OPENMSX_MOUSE_BUTTON_UP_EVENT
Definition: Event.hh:17
openmsx::Event::operator!=
bool operator!=(const Event &other) const
Definition: Event.cc:36
openmsx::Event::operator>
bool operator>(const Event &other) const
Definition: Event.cc:19
openmsx::OPENMSX_MOUSE_MOTION_GROUP_EVENT
@ OPENMSX_MOUSE_MOTION_GROUP_EVENT
Definition: Event.hh:16
openmsx::Event::getType
EventType getType() const
Definition: Event.hh:89
openmsx::OPENMSX_FRAME_DRAWN_EVENT
@ OPENMSX_FRAME_DRAWN_EVENT
Sent when a OPENMSX_FINISH_FRAME_EVENT caused a redraw of the screen.
Definition: Event.hh:45
openmsx::OPENMSX_MACHINE_ACTIVATED
@ OPENMSX_MACHINE_ACTIVATED
Send when a machine is (de)activated.
Definition: Event.hh:64
openmsx::OPENMSX_RESIZE_EVENT
@ OPENMSX_RESIZE_EVENT
Definition: Event.hh:30
openmsx::Event::operator<=
bool operator<=(const Event &other) const
Definition: Event.cc:23
openmsx::SimpleEvent::toTclList
TclObject toTclList() const override
Similar to toString(), but retains the structure of the event.
Definition: Event.cc:41
openmsx::OPENMSX_JOY_BUTTON_GROUP_EVENT
@ OPENMSX_JOY_BUTTON_GROUP_EVENT
Definition: Event.hh:28
openmsx::OPENMSX_CLICOMMAND_EVENT
@ OPENMSX_CLICOMMAND_EVENT
Command received on CliComm connection.
Definition: Event.hh:54
openmsx::OPENMSX_JOY_AXIS_MOTION_GROUP_EVENT
@ OPENMSX_JOY_AXIS_MOTION_GROUP_EVENT
Definition: Event.hh:23
openmsx::OPENMSX_FILEDROP_EVENT
@ OPENMSX_FILEDROP_EVENT
Definition: Event.hh:31
openmsx::OPENMSX_EXPOSE_EVENT
@ OPENMSX_EXPOSE_EVENT
Send when (part of) the openMSX window gets exposed, and thus should be repainted.
Definition: Event.hh:69
openmsx::OPENMSX_FOCUS_EVENT
@ OPENMSX_FOCUS_EVENT
Definition: Event.hh:29
openmsx::SimpleEvent::SimpleEvent
SimpleEvent(EventType type_)
Definition: Event.hh:132
openmsx::OPENMSX_MACHINE_LOADED_EVENT
@ OPENMSX_MACHINE_LOADED_EVENT
Send when a (new) machine configuration is loaded.
Definition: Event.hh:60
openmsx::SimpleEvent
Definition: Event.hh:130
openmsx::EventType
EventType
Definition: Event.hh:11
openmsx::OPENMSX_MOUSE_BUTTON_DOWN_EVENT
@ OPENMSX_MOUSE_BUTTON_DOWN_EVENT
Definition: Event.hh:18
openmsx::OPENMSX_MIDI_IN_COREMIDI_EVENT
@ OPENMSX_MIDI_IN_COREMIDI_EVENT
Definition: Event.hh:76
openmsx::Event::operator<
bool operator<(const Event &other) const
Definition: Event.cc:13
openmsx::OPENMSX_MIDI_IN_READER_EVENT
@ OPENMSX_MIDI_IN_READER_EVENT
Definition: Event.hh:74
openmsx::OPENMSX_JOY_HAT_GROUP_EVENT
@ OPENMSX_JOY_HAT_GROUP_EVENT
Definition: Event.hh:25
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::OPENMSX_RS232_TESTER_EVENT
@ OPENMSX_RS232_TESTER_EVENT
Definition: Event.hh:78
openmsx::OPENMSX_KEY_UP_EVENT
@ OPENMSX_KEY_UP_EVENT
Definition: Event.hh:12
openmsx::OPENMSX_JOY_BUTTON_DOWN_EVENT
@ OPENMSX_JOY_BUTTON_DOWN_EVENT
Definition: Event.hh:27
openmsx::OPENMSX_FINISH_FRAME_EVENT
@ OPENMSX_FINISH_FRAME_EVENT
Sent when VDP (V99x8 or V9990) reaches the end of a frame.
Definition: Event.hh:39
openmsx::NUM_EVENT_TYPES
@ NUM_EVENT_TYPES
Definition: Event.hh:80
openmsx::OPENMSX_DELETE_BOARDS
@ OPENMSX_DELETE_BOARDS
Delete old MSXMotherboards.
Definition: Event.hh:72
openmsx::Event::Event
Event(const Event &)=delete
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::OPENMSX_MIDI_IN_COREMIDI_VIRTUAL_EVENT
@ OPENMSX_MIDI_IN_COREMIDI_VIRTUAL_EVENT
Definition: Event.hh:77
openmsx::OPENMSX_JOY_BUTTON_UP_EVENT
@ OPENMSX_JOY_BUTTON_UP_EVENT
Definition: Event.hh:26
openmsx::Event::matches
virtual bool matches(const Event &other) const
Does this event 'match' the given event.
Definition: Event.hh:114
openmsx::Event::~Event
~Event()=default
openmsx::OPENMSX_OSD_CONTROL_RELEASE_EVENT
@ OPENMSX_OSD_CONTROL_RELEASE_EVENT
Definition: Event.hh:34