gloox 1.0
eventdispatcher.h
00001 /*
00002   Copyright (c) 2008-2009 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
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__