Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 26, 2009, 9:45:23 PM (16 years ago)
Author:
dafrick
Message:

Done some documenting, and resolved some (possible) issues. So the Notifications are about finished…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.cc

    r2788 r2858  
    174174    @param queue
    175175        The NotificationQueue the Notifications are fetched for.
     176    @param map
     177        A multimap, in which the notifications are stored.
    176178    @param timeFrameStart
    177179        The start time of the timeframe.
     
    179181        The end time of the timeframe.
    180182    @return
    181         Returns a time-ordered list of Notifications.
    182     @todo
    183         Make sure the map is deleted.
    184     */
    185     std::multimap<std::time_t,Notification*>* NotificationManager::getNotifications(NotificationQueue* queue, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
    186     {
    187         std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->queueList_[queue]];
    188        
    189         if(notifications == NULL)
    190             return NULL;
     183        Returns true if successful.
     184    */
     185    bool NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
     186    {
     187        if(queue == NULL || map == NULL)
     188            return false;
     189
     190        std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->queueList_[queue]]; //!< The Notifications for the input NotificationQueue.
     191       
     192        if(notifications == NULL) //!< Returns NULL, if there are no Notifications.
     193            return true;
    191194   
    192195        std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
     
    194197        itHighest = notifications->upper_bound(timeFrameStart);
    195198       
    196         std::multimap<std::time_t,Notification*>* map = new std::multimap<std::time_t,Notification*>();
    197        
    198         for(it = itLowest; it != itHighest; it++)
    199         {
    200             map->insert(std::pair<std::time_t,Notification*>(it->first,it->second));
    201         }
    202        
    203         if(map->size() == 0)
    204         {
    205             delete map;
    206             return NULL;
    207         }
    208        
    209         return map;
     199        for(it = itLowest; it != itHighest; it++) //!< Iterate through the Notifications from the start of the time Frame to the end of it.
     200        {
     201            map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); //!< Add the found Notifications to the map.
     202        }
     203       
     204        return true;
    210205    }
    211206
Note: See TracChangeset for help on using the changeset viewer.