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