eventdispatcher.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef EVENTDISPATCHER_H__
00015 #define EVENTDISPATCHER_H__
00016
00017 #include "event.h"
00018
00019 #include <map>
00020 #include <string>
00021
00022 namespace gloox
00023 {
00024
00025 class EventHandler;
00026
00033 class EventDispatcher
00034 {
00035
00036 public:
00040 EventDispatcher();
00041
00045 virtual ~EventDispatcher();
00046
00055 void dispatch( const Event& event, const std::string& context, bool remove );
00056
00061 void dispatch( const Event& event );
00062
00069 void registerEventHandler( EventHandler* eh, const std::string& context );
00070
00075 void removeEventHandler( EventHandler* eh );
00076
00077 private:
00078 typedef std::multimap<const std::string, EventHandler*> ContextHandlerMap;
00079 typedef std::multimap<Event::EventType, EventHandler*> TypeHandlerMap;
00080
00081 ContextHandlerMap m_contextHandlers;
00082 TypeHandlerMap m_typeHandlers;
00083
00084 };
00085
00086 }
00087
00088 #endif // EVENTDISPATCHER_H__