[2280] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Damian 'Mozork' Frick |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[2911] | 29 | /** |
---|
[3196] | 30 | @file |
---|
[2911] | 31 | @brief Definition of the NotificationManager class. |
---|
| 32 | */ |
---|
| 33 | |
---|
[2280] | 34 | #ifndef _NotificationManager_H__ |
---|
| 35 | #define _NotificationManager_H__ |
---|
| 36 | |
---|
[5722] | 37 | #include "questsystem/QuestsystemPrereqs.h" |
---|
[2280] | 38 | |
---|
[3196] | 39 | #include <ctime> |
---|
[2911] | 40 | #include <map> |
---|
[2280] | 41 | #include <string> |
---|
[3370] | 42 | |
---|
[5648] | 43 | #include "util/ScopedSingleton.h" |
---|
[3196] | 44 | #include "core/OrxonoxClass.h" |
---|
[2280] | 45 | |
---|
[2435] | 46 | namespace orxonox |
---|
| 47 | { |
---|
[2280] | 48 | |
---|
| 49 | /** |
---|
| 50 | @brief |
---|
[5619] | 51 | The Singleton NotificationManager functions as a gateway between Notifications and NotificationListeners. |
---|
| 52 | It receives, organizes Notifications and the redistributes them to the specific NotificationListeners. |
---|
[2280] | 53 | @author |
---|
| 54 | Damian 'Mozork' Frick |
---|
| 55 | */ |
---|
[5722] | 56 | class _QuestsystemExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass |
---|
[2280] | 57 | { |
---|
[5648] | 58 | friend class ScopedSingleton<NotificationManager, ScopeID::GSLevel>; |
---|
[2911] | 59 | public: |
---|
| 60 | NotificationManager(); |
---|
| 61 | virtual ~NotificationManager(); |
---|
[3034] | 62 | |
---|
[2911] | 63 | static const std::string ALL; |
---|
| 64 | static const std::string NONE; |
---|
[3034] | 65 | |
---|
[2911] | 66 | bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. |
---|
[5619] | 67 | bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager. |
---|
[3034] | 68 | |
---|
[5619] | 69 | bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe. |
---|
[3034] | 70 | |
---|
[2911] | 71 | /** |
---|
[5619] | 72 | @brief Fetches the Notifications for a specific NotificationListener starting at a specified time. |
---|
| 73 | @param listener The NotificationListener the Notifications are fetched for. |
---|
[2911] | 74 | @param map A multimap, in which the notifications are stored. |
---|
| 75 | @param timeFrameStart The start time the Notifications are fetched from. |
---|
| 76 | @return Returns true if successful. |
---|
| 77 | */ |
---|
[5619] | 78 | bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart) |
---|
| 79 | { return this->getNotifications(listener, map, timeFrameStart, std::time(0)); } |
---|
[2911] | 80 | /** |
---|
[5619] | 81 | @brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now. |
---|
| 82 | @param listener The NotificationListener the Notifications are fetched for. |
---|
[2911] | 83 | @param map A multimap, in which the notifications are stored. |
---|
| 84 | @param timeDelay The timespan. |
---|
| 85 | @return Returns true if successful. |
---|
| 86 | */ |
---|
[5619] | 87 | bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay) |
---|
| 88 | { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); } |
---|
[3034] | 89 | |
---|
[2911] | 90 | private: |
---|
[3370] | 91 | static NotificationManager* singletonPtr_s; |
---|
[2911] | 92 | |
---|
| 93 | int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice. |
---|
[3034] | 94 | |
---|
[2911] | 95 | std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps). |
---|
[5619] | 96 | std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier. |
---|
| 97 | std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored. |
---|
[2280] | 98 | |
---|
[3034] | 99 | |
---|
[2280] | 100 | }; |
---|
| 101 | |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | #endif /* _NotificationManager_H__ */ |
---|