aboutsummaryrefslogtreecommitdiff
path: root/common/EventDispatcher.cpp
diff options
context:
space:
mode:
authorAlyssa Milburn2011-08-22 20:03:05 +0200
committerAlyssa Milburn2011-08-22 20:03:05 +0200
commit84063dc9727a9f55e09d39574027beab695680e6 (patch)
treed71a9599cb550d9f7949a2d3209574064e054d85 /common/EventDispatcher.cpp
parentc6e89df3d940747a85d447f172e2323c800f5eaf (diff)
parenta39a3eda46aea108a51556f001617ad28d29e520 (diff)
downloadscummvm-rg350-84063dc9727a9f55e09d39574027beab695680e6.tar.gz
scummvm-rg350-84063dc9727a9f55e09d39574027beab695680e6.tar.bz2
scummvm-rg350-84063dc9727a9f55e09d39574027beab695680e6.zip
Merge remote-tracking branch 'origin/master' into soltys_wip2
Diffstat (limited to 'common/EventDispatcher.cpp')
-rw-r--r--common/EventDispatcher.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp
index e97068c0d0..4e3f671cfd 100644
--- a/common/EventDispatcher.cpp
+++ b/common/EventDispatcher.cpp
@@ -28,12 +28,12 @@ EventDispatcher::EventDispatcher() : _mapper(0) {
}
EventDispatcher::~EventDispatcher() {
- for (Common::List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+ for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
if (i->autoFree)
delete i->source;
}
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->autoFree)
delete i->observer;
}
@@ -43,9 +43,11 @@ EventDispatcher::~EventDispatcher() {
}
void EventDispatcher::dispatch() {
- Common::Event event;
+ Event event;
- for (Common::List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+ dispatchPoll();
+
+ for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
const bool allowMapping = i->source->allowMapping();
while (i->source->pollEvent(event)) {
@@ -83,7 +85,7 @@ void EventDispatcher::registerSource(EventSource *source, bool autoFree) {
}
void EventDispatcher::unregisterSource(EventSource *source) {
- for (Common::List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+ for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
if (i->source == source) {
if (i->autoFree)
delete source;
@@ -94,14 +96,15 @@ void EventDispatcher::unregisterSource(EventSource *source) {
}
}
-void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool autoFree) {
+void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool autoFree, bool notifyPoll) {
ObserverEntry newEntry;
newEntry.observer = obs;
newEntry.priority = priority;
newEntry.autoFree = autoFree;
+ newEntry.poll = notifyPoll;
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->priority < priority) {
_observers.insert(i, newEntry);
return;
@@ -112,7 +115,7 @@ void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool a
}
void EventDispatcher::unregisterObserver(EventObserver *obs) {
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->observer == obs) {
if (i->autoFree)
delete obs;
@@ -124,11 +127,18 @@ void EventDispatcher::unregisterObserver(EventObserver *obs) {
}
void EventDispatcher::dispatchEvent(const Event &event) {
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->observer->notifyEvent(event))
break;
}
}
-} // End of namespace Common
+void EventDispatcher::dispatchPoll() {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ if (i->poll == true)
+ if (i->observer->notifyPoll())
+ break;
+ }
+}
+} // End of namespace Common