/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Damian 'Mozork' Frick * Co-authors: * ... * */ /** @file NotificationManager.h @brief Definition of the NotificationManager class. @ingroup Notifications */ #ifndef _NotificationManager_H__ #define _NotificationManager_H__ #include "notifications/NotificationsPrereqs.h" #include #include #include #include "util/Singleton.h" #include "core/OrxonoxClass.h" namespace orxonox // tolua_export { // tolua_export /** @brief The Singleton NotificationManager functions as a gateway between Notifications and NotificationListeners. It receives, organizes Notifications and the redistributes them to the specific NotificationListeners. @author Damian 'Mozork' Frick */ class _NotificationsExport NotificationManager // tolua_export : public Singleton, public OrxonoxClass { // tolua_export friend class Singleton; public: NotificationManager(); virtual ~NotificationManager(); virtual void preDestroy(void); //!< Is called before the object is destroyed. static NotificationManager& getInstance() { return Singleton::getInstance(); } // tolua_export static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners. static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener. bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager for a given NotificationListener. bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager. void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager. void getNotifications(NotificationListener* listener, std::multimap* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map. /** @brief Fetches the Notifications for a specific NotificationListener in a timeframe from now-timeDelay to now and stores them in the input map. @param listener The NotificationListener the Notifications are fetched for. @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. @param timeDelay The timespan. @return Returns true if successful. */ void getNotifications(NotificationListener* listener, std::multimap* map, int timeDelay) { this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); } void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer. bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue. void unregisterQueue(NotificationQueue* queue); //!< Unregisters a NotificationQueue. // tolua_begin void loadQueues(void); //!< Loads all the NotificationQueues that should exist. void createQueue(const std::string& name); //!< Creates a new NotificationQueue. orxonox::NotificationQueue* getQueue(const std::string & name); //!< Get the NotificationQueue with the input name. // tolua_end private: static NotificationManager* singletonPtr_s; unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice. std::multimap allNotificationsList_; //!< Container where all Notifications are stored. std::map listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier. std::map*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored. std::map queues_; //!< The list of NotificationQueues created by the NotificationManager. bool removeNotification(Notification* notification, std::multimap& map); //!< Helper method that removes an input Notification form an input map. }; // tolua_export } // tolua_export #endif /* _NotificationManager_H__ */