gloox  1.0
eventdispatcher.h
1 /*
2  Copyright (c) 2008-2009 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef EVENTDISPATCHER_H__
15 #define EVENTDISPATCHER_H__
16 
17 #include "event.h"
18 
19 #include <map>
20 #include <string>
21 
22 namespace gloox
23 {
24 
25  class EventHandler;
26 
34  {
35 
36  public:
41 
45  virtual ~EventDispatcher();
46 
55  void dispatch( const Event& event, const std::string& context, bool remove );
56 
61  void dispatch( const Event& event );
62 
69  void registerEventHandler( EventHandler* eh, const std::string& context );
70 
75  void removeEventHandler( EventHandler* eh );
76 
77  private:
78  typedef std::multimap<const std::string, EventHandler*> ContextHandlerMap;
79  typedef std::multimap<Event::EventType, EventHandler*> TypeHandlerMap;
80 
81  ContextHandlerMap m_contextHandlers;
82  TypeHandlerMap m_typeHandlers;
83 
84  };
85 
86 }
87 
88 #endif // EVENTDISPATCHER_H__