/** * @file Common/eventqueue.h * @brief Event queue interface implementation * @author Enar Vaikene * * Copyright (c) 2011-2019 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * * This file can be used under the terms of the GNU General Public License * version 3.0 as published by the Free Software Foundation and appearing in * the file LICENSE included in the packaging of this file. Please review the * the following information to ensure the GNU General Public License version * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. * * Alternatively, this file may be used in accordance with the Commercial License * Agreement provided with the Software. */ #ifndef __COMMON_EVENTQUEUE_H #define __COMMON_EVENTQUEUE_H #include "ieventqueue.h" #include #include #include #include namespace eVaf { namespace Common { namespace Internal { /** * iEventQueue interface implementation */ class EventQueue : public iEventQueue { Q_OBJECT public: EventQueue(); virtual ~EventQueue(); /// Qt event handler virtual bool event(QEvent * e); /* iEventQueue interface */ virtual uint registerEvent(QString const & name); virtual uint queryEvent(QString const & name) const; virtual void unregisterEvent(uint id); virtual uint subscribeEvent(uint id, QObject * obj); virtual void unsubscribeEvent(uint id, QObject * obj); virtual void broadcastEvent(Event * event); private: // Members /// ID of the next event uint mNextEventId; /// List of registered events typedef QHash Events; Events mEvents; /// List of subscribers typedef QHash > Subscribers; Subscribers mSubscribers; private slots: /// One of the subscribers is destroyed /// We need to remove it from the list of subscribers. void subscriberDestroyed(QObject * obj = nullptr); }; } // namespace evaf::Common::Internal } // namespace eVaf::Common } // namespace eVaf #endif // eventqueue.h