Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2010, 10:20:44 AM (14 years ago)
Author:
dafrick
Message:

Merged notifications branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/notifications/NotificationManager.h

    r7164 r7403  
    2828
    2929/**
    30     @file
     30    @file NotificationManager.h
    3131    @brief Definition of the NotificationManager class.
    3232*/
     
    4444#include "core/OrxonoxClass.h"
    4545
    46 namespace orxonox
    47 {
     46namespace orxonox // tolua_export
     47{ // tolua_export
     48
    4849    /**
    4950    @brief
     
    5354        Damian 'Mozork' Frick
    5455    */
    55     class _NotificationsExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
    56     {
     56    class _NotificationsExport NotificationManager // tolua_export
     57        : public Singleton<NotificationManager>, public OrxonoxClass
     58    { // tolua_export
    5759            friend class Singleton<NotificationManager>;
    5860        public:
     
    6062            virtual ~NotificationManager();
    6163
     64            virtual void preDestroy(void); //!< Is called before the object is destroyed.
     65
     66            static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export
     67
    6268            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
    6369            static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
    6470
    6571            bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
    66             void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager.
     72            void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager for a given NotificationListener.
    6773            bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
    6874            void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager.
    6975
    70             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.
     76            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.
    7177
    7278            /**
    73             @brief Fetches the Notifications for a specific NotificationListener starting at a specified time.
     79            @brief Fetches the Notifications for a specific NotificationListener in a timeframe from now-timeDelay to now and stores them in the input map.
    7480            @param listener The NotificationListener the Notifications are fetched for.
    75             @param map A multimap, in which the notifications are stored.
    76             @param timeFrameStart The start time the Notifications are fetched from.
    77             @return Returns true if successful.
    78             */
    79             bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart)
    80                 { return this->getNotifications(listener, map, timeFrameStart, std::time(0)); }
    81             /**
    82             @brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now.
    83             @param listener The NotificationListener the Notifications are fetched for.
    84             @param map A multimap, in which the notifications are stored.
     81            @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
    8582            @param timeDelay The timespan.
    8683            @return Returns true if successful.
    8784            */
    88             bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay)
    89                 { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
     85            void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)
     86                { this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
     87
     88            void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer.
     89
     90            bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue.
     91            void unregisterQueue(NotificationQueue* queue); //!< Unregisters a NotificationQueue.
     92
     93            // tolua_begin
     94            void loadQueues(void); //!< Loads all the NotificationQueues that should exist.
     95            void createQueue(const std::string& name); //!< Creates a new NotificationQueue.
     96            orxonox::NotificationQueue* getQueue(const std::string & name); //!< Get the NotificationQueue with the input name.
     97            // tolua_end
    9098
    9199        private:
    92100            static NotificationManager* singletonPtr_s;
    93101
    94             int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
     102            unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
    95103
    96             std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored.
    97             std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
    98             std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
    99             std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with.
     104            std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all Notifications are stored.
     105            std::map<NotificationListener*, unsigned int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
     106            std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
    100107
    101             bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map.
     108            std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
    102109
    103     };
     110            bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input Notification form an input map.
    104111
    105 }
     112    }; // tolua_export
     113
     114} // tolua_export
    106115
    107116#endif /* _NotificationManager_H__ */
Note: See TracChangeset for help on using the changeset viewer.