eVaf
eventqueue.h
Go to the documentation of this file.
1 
20 #ifndef __COMMON_EVENTQUEUE_H
21 #define __COMMON_EVENTQUEUE_H
22 
23 #include "ieventqueue.h"
24 
25 #include <QObject>
26 #include <QString>
27 #include <QHash>
28 #include <QVector>
29 
30 
31 namespace eVaf {
32 namespace Common {
33 namespace Internal {
34 
38 class EventQueue : public iEventQueue
39 {
40  Q_OBJECT
41 
42 public:
43 
44  EventQueue();
45 
46  virtual ~EventQueue();
47 
49  virtual bool event(QEvent * e);
50 
51  /*
52  iEventQueue interface
53  */
54 
55  virtual uint registerEvent(QString const & name);
56 
57  virtual uint queryEvent(QString const & name) const;
58 
59  virtual void unregisterEvent(uint id);
60 
61  virtual uint subscribeEvent(uint id, QObject * obj);
62 
63  virtual void unsubscribeEvent(uint id, QObject * obj);
64 
65  virtual void broadcastEvent(Event * event);
66 
67 
68 private: // Members
69 
71  uint mNextEventId;
72 
74  typedef QHash<uint, QString> Events;
75  Events mEvents;
76 
78  typedef QHash<uint, QVector<QObject *> > Subscribers;
79  Subscribers mSubscribers;
80 
81 
82 private slots:
83 
86  void subscriberDestroyed(QObject * obj = 0);
87 
88 };
89 
90 } // namespace evaf::Common::Internal
91 } // namespace eVaf::Common
92 } // namespace eVaf
93 
94 #endif // eventqueue.h
Event class for all the eVaf events.
Definition: event.h:39
virtual uint registerEvent(QString const &name)
Registers an event.
Event queue interface.
virtual uint subscribeEvent(uint id, QObject *obj)
Subscribes to an event.
virtual bool event(QEvent *e)
Qt event handler.
virtual uint queryEvent(QString const &name) const
Queries for an existing event.
iEventQueue interface implementation
Definition: eventqueue.h:38
virtual void unsubscribeEvent(uint id, QObject *obj)
Unsubscribes from an event.
The eVaf event queue interface.
Definition: ieventqueue.h:41
Global eVaf namespace.
Definition: engine.h:37
virtual void broadcastEvent(Event *event)
Sends the event to all the subscribers.
virtual void unregisterEvent(uint id)
Unregisters an event.