]> vaikene.ee Git - evaf/blob - src/libs/Common/eventqueue.h
92bcb06da4fa2e7920be2223018aaa085bd57a02
[evaf] / src / libs / Common / eventqueue.h
1 /**
2 * @file Common/eventqueue.h
3 * @brief Event queue interface implementation
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
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 <QList>
29 #include <QPointer>
30
31
32 namespace eVaf {
33 namespace Common {
34 namespace Internal {
35
36 /**
37 * iEventQueue interface implementation
38 */
39 class EventQueue : public iEventQueue
40 {
41 Q_OBJECT
42
43 public:
44
45 EventQueue();
46
47 virtual ~EventQueue();
48
49 /// Qt event handler
50 virtual bool event(QEvent * e);
51
52 /*
53 iEventQueue interface
54 */
55
56 virtual uint registerEvent(QString const & name);
57
58 virtual uint queryEvent(QString const & name) const;
59
60 virtual void unregisterEvent(uint id);
61
62 virtual uint subscribeEvent(uint id, QObject * obj);
63
64 virtual void unsubscribeEvent(uint id, QObject * obj);
65
66 virtual void broadcastEvent(Event * event);
67
68
69 private: // Members
70
71 /// ID of the next event
72 uint mNextEventId;
73
74 /// List of registered events
75 QHash<uint, QString> mEvents;
76
77 /// List of subscribers
78 QHash<uint, QList<QPointer<QObject> > > mSubscribers;
79
80 };
81
82 } // namespace evaf::Common::Internal
83 } // namespace eVaf::Common
84 } // namespace eVaf
85
86 #endif // eventqueue.h