From eeaafdf4ee012df99b5f4d0ea5b394ad81e1e23c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 25 Jul 2009 01:00:47 +0000 Subject: Moved ArtificialEventSource to common/events.h. svn-id: r42726 --- common/events.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/common/events.h b/common/events.h index 484ccec5f0..4f060a6da7 100644 --- a/common/events.h +++ b/common/events.h @@ -158,6 +158,36 @@ public: virtual bool allowMapping() const { return true; } }; +/** + * An artificial event source. This is class is used as an event source, which is + * made up by client specific events. + * + * Example usage cases for this are the Keymapper or the DefaultEventManager. + */ +class ArtificialEventSource : public EventSource { +protected: + Common::Queue _artificialEventQueue; +public: + void addEvent(const Common::Event &ev) { + _artificialEventQueue.push(ev); + } + + bool pollEvent(Common::Event &ev) { + if (!_artificialEventQueue.empty()) { + ev = _artificialEventQueue.pop(); + return true; + } else { + return false; + } + } + + /** + * By default an artificial event source prevents its events + * from being mapped. + */ + virtual bool allowMapping() const { return false; } +}; + /** * Object which catches and processes Events. * -- cgit v1.2.3