Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2011, 10:20:45 AM (13 years ago)
Author:
dafrick
Message:

Changes in notifications module structure. Notifications can now be sent through the NotificationListener, meaning, they can be sent from anywhere within orxonox (and the modules of course).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h

    r8371 r8374  
    4343
    4444#include "util/Singleton.h"
    45 #include "core/OrxonoxClass.h"
     45#include "interfaces/NotificationListener.h"
    4646
    4747namespace orxonox // tolua_export
     
    6060    */
    6161    class _NotificationsExport NotificationManager // tolua_export
    62         : public Singleton<NotificationManager>, public OrxonoxClass
     62        : public Singleton<NotificationManager>, public NotificationListener
    6363    { // tolua_export
    6464            friend class Singleton<NotificationManager>;
     
    7575            static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export
    7676
    77             static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
    78             static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
    79 
    80             //! Sends a Notification with the specified message to the specified client from the specified sender.
    81             static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationManager::NONE, bool isLocal = false);
     77            virtual bool registerNotification(const std::string& message, const std::string& sender);
    8278
    8379            bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
    84             void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager for a given NotificationListener.
    85             bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
    86             void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager.
     80            void unregisterNotification(Notification* notification, NotificationQueue* queue); //!< Unregisters a Notification within the NotificationManager for a given NotificationQueue.
    8781
    88             void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* 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.
     82            void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map.
    8983
    9084            /**
    91             @brief Fetches the Notifications for a specific NotificationListener in a timeframe from now-timeDelay to now and stores them in the input map.
    92             @param listener The NotificationListener the Notifications are fetched for.
     85            @brief Fetches the Notifications for a specific NotificationQueue in a timeframe from now-timeDelay to now and stores them in the input map.
     86            @param listener The NotificationQueue the Notifications are fetched for.
    9387            @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
    9488            @param timeDelay The timespan.
    9589            @return Returns true if successful.
    9690            */
    97             void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)
    98                 { this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
     91            void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int timeDelay)
     92                { this->getNotifications(queue, map, std::time(0)-timeDelay, std::time(0)); }
    9993
    100             void getNewestNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); //!< Fetches the newest Notifications for a specific NotificationListener and stores them in the input map.
     94            void getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); //!< Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.
    10195
    10296            void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer.
     
    114108            static NotificationManager* singletonPtr_s;
    115109
    116             unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
    117 
    118110            std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all Notifications are stored.
    119             std::map<NotificationListener*, unsigned int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
    120             std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
     111            std::map<const std::string, std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored.
    121112
    122113            std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
Note: See TracChangeset for help on using the changeset viewer.