[Scummvm-cvs-logs] SF.net SVN: scummvm:[42728] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Jul 25 03:01:22 CEST 2009


Revision: 42728
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42728&view=rev
Author:   lordhoto
Date:     2009-07-25 01:01:22 +0000 (Sat, 25 Jul 2009)

Log Message:
-----------
- EventDispatcher is no longer a singleton.
- Add "getEventDispatcher" method to EventManager.

Modified Paths:
--------------
    scummvm/trunk/backends/events/default/default-events.cpp
    scummvm/trunk/common/events.cpp
    scummvm/trunk/common/events.h

Modified: scummvm/trunk/backends/events/default/default-events.cpp
===================================================================
--- scummvm/trunk/backends/events/default/default-events.cpp	2009-07-25 01:01:05 UTC (rev 42727)
+++ scummvm/trunk/backends/events/default/default-events.cpp	2009-07-25 01:01:22 UTC (rev 42728)
@@ -101,10 +101,10 @@
 
 	assert(boss);
 
-	g_eventDispatcher.registerSource(boss, false);
-	g_eventDispatcher.registerSource(&_artificialEventSource, false);
+	_dispatcher.registerSource(boss, false);
+	_dispatcher.registerSource(&_artificialEventSource, false);
 
-	g_eventDispatcher.registerObserver(this, 0, false);
+	_dispatcher.registerObserver(this, 0, false);
 
 	_recordFile = NULL;
 	_recordTimeFile = NULL;
@@ -207,7 +207,7 @@
 #ifdef ENABLE_KEYMAPPER
 	_keymapper = new Common::Keymapper(this);
 	// EventDispatcher will automatically free the keymapper
-	g_eventDispatcher.registerMapper(_keymapper);
+	_dispatcher.registerMapper(_keymapper);
 	_remap = false;
 #endif
 }
@@ -383,7 +383,7 @@
 	uint32 time = g_system->getMillis();
 	bool result = false;
 
-	g_eventDispatcher.dispatch();
+	_dispatcher.dispatch();
 	if (!_eventQueue.empty()) {
 		event = _eventQueue.pop();
 		result = true;

Modified: scummvm/trunk/common/events.cpp
===================================================================
--- scummvm/trunk/common/events.cpp	2009-07-25 01:01:05 UTC (rev 42727)
+++ scummvm/trunk/common/events.cpp	2009-07-25 01:01:22 UTC (rev 42728)
@@ -25,8 +25,6 @@
 
 #include "common/events.h"
 
-DECLARE_SINGLETON(Common::EventDispatcher);
-
 namespace Common {
 
 EventDispatcher::EventDispatcher() : _mapper(0) {

Modified: scummvm/trunk/common/events.h
===================================================================
--- scummvm/trunk/common/events.h	2009-07-25 01:01:05 UTC (rev 42727)
+++ scummvm/trunk/common/events.h	2009-07-25 01:01:22 UTC (rev 42728)
@@ -236,9 +236,11 @@
  * mapper will be processed before an event is sent to the
  * observers. 
  */
-class EventDispatcher : public Singleton<EventDispatcher> {
-	friend class Singleton<SingletonBaseType>;
+class EventDispatcher {
 public:
+	EventDispatcher();
+	~EventDispatcher();
+
 	/**
 	 * Tries to catch events from the registered event
 	 * sources and dispatch them to the observers.
@@ -289,9 +291,6 @@
 	 */
 	void unregisterObserver(EventObserver *obs);
 private:
-	EventDispatcher();
-	~EventDispatcher();
-
 	EventMapper *_mapper;
 
 	struct Entry {
@@ -314,8 +313,6 @@
 	void dispatchEvent(const Event &event);
 };
 
-#define g_eventDispatcher (Common::EventDispatcher::instance())
-
 class Keymapper;
 
 /**
@@ -398,6 +395,14 @@
 #ifdef ENABLE_KEYMAPPER
 	virtual Common::Keymapper *getKeymapper() = 0;
 #endif
+
+	/**
+	 * Returns the underlying EventDispatcher.
+	 */
+	EventDispatcher *getEventDispatcher() { return &_dispatcher; }
+
+protected:
+	EventDispatcher _dispatcher;
 };
 
 } // End of namespace Common


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list