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
openmsx::Event::operator==
bool operator==(const Event &other) const
Definition: Event.cc:32
openmsx::OPENMSX_KEY_GROUP_EVENT
Definition: Event.hh:14
openmsx::OPENMSX_MOUSE_WHEEL_EVENT
Definition: Event.hh:20
openmsx::OPENMSX_JOY_AXIS_MOTION_EVENT
Definition: Event.hh:22
openmsx::OPENMSX_QUIT_EVENT
Definition: Event.hh:31
openmsx::OPENMSX_AFTER_TIMED_EVENT
Send when an after-emutime command should be executed.
Definition: Event.hh:55
openmsx::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
Definition: Event.hh:34
openmsx::Event
Definition: Event.hh:81
openmsx::Event::operator=
Event & operator=(const Event &)=delete
openmsx::OPENMSX_JOY_HAT_EVENT
Definition: Event.hh:24
openmsx::OPENMSX_BREAK_EVENT
Definition: Event.hh:45
openmsx::Event::toString
std::string toString() const
Get a string representation of this event.
Definition: Event.cc:8
openmsx::OPENMSX_MACHINE_DEACTIVATED
Definition: Event.hh:63
openmsx::OPENMSX_OSD_CONTROL_PRESS_EVENT
Definition: Event.hh:33
openmsx::Event::isRepeatStopper
virtual bool isRepeatStopper(const Event &) const
Should 'bind -repeat' be stopped by 'other' event.
Definition: Event.hh:105
openmsx::OPENMSX_KEY_DOWN_EVENT
Definition: Event.hh:13
openmsx::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
Definition: Event.hh:73
openmsx::OPENMSX_MOUSE_WHEEL_GROUP_EVENT
Definition: Event.hh:21
openmsx::OPENMSX_SWITCH_RENDERER_EVENT
Definition: Event.hh:46
openmsx::Event::Event
Event(EventType type_)
Definition: Event.hh:117
openmsx::SimpleEvent::lessImpl
bool lessImpl(const Event &other) const override
Definition: Event.cc:46
openmsx::OPENMSX_TAKE_REVERSE_SNAPSHOT
Used to schedule 'taking reverse snapshots' between Z80 instructions.
Definition: Event.hh:49
openmsx::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
Definition: Event.hh:16
openmsx::Event::getType
EventType getType() const
Definition: Event.hh:87
openmsx::OPENMSX_FRAME_DRAWN_EVENT
Sent when a OPENMSX_FINISH_FRAME_EVENT caused a redraw of the screen.
Definition: Event.hh:43
openmsx::OPENMSX_MACHINE_ACTIVATED
Send when a machine is (de)activated.
Definition: Event.hh:62
openmsx::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
Definition: Event.hh:28
openmsx::OPENMSX_CLICOMMAND_EVENT
Command received on CliComm connection.
Definition: Event.hh:52
openmsx::OPENMSX_JOY_AXIS_MOTION_GROUP_EVENT
Definition: Event.hh:23
openmsx::OPENMSX_EXPOSE_EVENT
Send when (part of) the openMSX window gets exposed, and thus should be repainted.
Definition: Event.hh:67
openmsx::OPENMSX_FOCUS_EVENT
Definition: Event.hh:29
openmsx::SimpleEvent::SimpleEvent
SimpleEvent(EventType type_)
Definition: Event.hh:130
openmsx::OPENMSX_MACHINE_LOADED_EVENT
Send when a (new) machine configuration is loaded.
Definition: Event.hh:58
openmsx::SimpleEvent
Definition: Event.hh:127
openmsx::EventType
EventType
Definition: Event.hh:10
openmsx::OPENMSX_MOUSE_BUTTON_DOWN_EVENT
Definition: Event.hh:18
openmsx::OPENMSX_MIDI_IN_COREMIDI_EVENT
Definition: Event.hh:74
openmsx::Event::operator<
bool operator<(const Event &other) const
Definition: Event.cc:13
openmsx::OPENMSX_MIDI_IN_READER_EVENT
Definition: Event.hh:72
openmsx::OPENMSX_JOY_HAT_GROUP_EVENT
Definition: Event.hh:25
openmsx::TclObject
Definition: TclObject.hh:21
openmsx::OPENMSX_RS232_TESTER_EVENT
Definition: Event.hh:76
openmsx::OPENMSX_KEY_UP_EVENT
Definition: Event.hh:12
openmsx::OPENMSX_JOY_BUTTON_DOWN_EVENT
Definition: Event.hh:27
openmsx::OPENMSX_FINISH_FRAME_EVENT
Sent when VDP (V99x8 or V9990) reaches the end of a frame.
Definition: Event.hh:37
openmsx::NUM_EVENT_TYPES
Definition: Event.hh:78
openmsx::OPENMSX_DELETE_BOARDS
Delete old MSXMotherboards.
Definition: Event.hh:70
openmsx::Event::Event
Event(const Event &)=delete
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::OPENMSX_MIDI_IN_COREMIDI_VIRTUAL_EVENT
Definition: Event.hh:75
openmsx::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:112
openmsx::Event::~Event
~Event()=default
openmsx::OPENMSX_OSD_CONTROL_RELEASE_EVENT
Definition: Event.hh:32