[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 | |
---|
[2779] | 29 | /** |
---|
| 30 | @file NotificationManager.h |
---|
| 31 | @brief Definition of the NotificationManager class. |
---|
| 32 | */ |
---|
| 33 | |
---|
[2280] | 34 | #ifndef _NotificationManager_H__ |
---|
| 35 | #define _NotificationManager_H__ |
---|
| 36 | |
---|
| 37 | #include "OrxonoxPrereqs.h" |
---|
| 38 | |
---|
[2788] | 39 | #include "core/OrxonoxClass.h" |
---|
[2280] | 40 | |
---|
[2779] | 41 | #include <map> |
---|
[2280] | 42 | #include <string> |
---|
[2779] | 43 | #include <ctime> |
---|
[2280] | 44 | |
---|
[2779] | 45 | #include "NotificationOverlay.h" |
---|
| 46 | |
---|
[2435] | 47 | namespace orxonox |
---|
| 48 | { |
---|
[2280] | 49 | |
---|
| 50 | /** |
---|
| 51 | @brief |
---|
[2785] | 52 | The Singleton NotificationManager functions as a gateway between Notifications and NotificationQueues. |
---|
[2779] | 53 | It receives, organizes Notifications and the redistributes them to the specific NotificationQueues. |
---|
[2280] | 54 | @author |
---|
| 55 | Damian 'Mozork' Frick |
---|
| 56 | */ |
---|
[2788] | 57 | class _OrxonoxExport NotificationManager : public OrxonoxClass |
---|
[2280] | 58 | { |
---|
[2786] | 59 | public: |
---|
[2785] | 60 | NotificationManager(); |
---|
[2779] | 61 | virtual ~NotificationManager(); |
---|
| 62 | |
---|
| 63 | static const std::string ALL; |
---|
| 64 | static const std::string NONE; |
---|
| 65 | |
---|
[2785] | 66 | static NotificationManager & getInstance(); //! Returns a reference to the single instance of the NotificationManager. |
---|
| 67 | |
---|
| 68 | bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. |
---|
| 69 | bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue within the NotificationManager. |
---|
[2779] | 70 | |
---|
[2858] | 71 | bool getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationQueue in a specified timeframe. |
---|
[2779] | 72 | |
---|
| 73 | /** |
---|
| 74 | @brief Fetches the Notifications for a specific NotificationQueue starting at a specified time. |
---|
| 75 | @param queue The NotificationQueue the Notifications are fetched for. |
---|
[2858] | 76 | @param map A multimap, in which the notifications are stored. |
---|
[2779] | 77 | @param timeFrameStart The start time the Notifications are fetched from. |
---|
[2858] | 78 | @return Returns true if successful. |
---|
[2779] | 79 | */ |
---|
[2858] | 80 | bool getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart) |
---|
| 81 | { return this->getNotifications(queue, map, timeFrameStart, std::time(0)); } |
---|
[2779] | 82 | /** |
---|
| 83 | @brief Fetches the Notifications for a specific NotificationQueue starting at a specified timespan before now. |
---|
| 84 | @param queue The NotificationQueue the Notifications are fetched for. |
---|
[2858] | 85 | @param map A multimap, in which the notifications are stored. |
---|
[2779] | 86 | @param timeDelay The timespan. |
---|
[2858] | 87 | @return Returns true if successful. |
---|
[2779] | 88 | */ |
---|
[2858] | 89 | bool getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, int timeDelay) |
---|
| 90 | { return this->getNotifications(queue, map, std::time(0)-timeDelay, std::time(0)); } |
---|
[2779] | 91 | |
---|
[2785] | 92 | private: |
---|
| 93 | static NotificationManager* singletonRef_s; |
---|
| 94 | |
---|
| 95 | int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice. |
---|
[2435] | 96 | |
---|
[2785] | 97 | std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps). |
---|
| 98 | std::map<NotificationQueue*,int> queueList_; //!< Container where all NotificationQueues are stored with a number as identifier. |
---|
| 99 | std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored. |
---|
[2779] | 100 | |
---|
[2280] | 101 | |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | #endif /* _NotificationManager_H__ */ |
---|