Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2011, 10:20:45 AM (14 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).

Location:
code/branches/tutoriallevel2/src/modules/notifications
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel2/src/modules/notifications/Notification.cc

    r7489 r8374  
    3535
    3636#include "core/CoreIncludes.h"
    37 #include "NotificationManager.h"
     37#include "interfaces/NotificationListener.h"
    3838
    3939namespace orxonox
     
    7272    {
    7373        this->message_.clear();
    74         this->sender_ = NotificationManager::NONE;
     74        this->sender_ = NotificationListener::NONE;
    7575    }
    7676
  • code/branches/tutoriallevel2/src/modules/notifications/Notification.h

    r7655 r8374  
    8080
    8181            void initialize(void); //!< Registers the object and sets some default values.
    82             void registerVariables(void) {}
    8382
    8483    };
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationDispatcher.cc

    r7552 r8374  
    4141
    4242#include "infos/PlayerInfo.h"
     43#include "interfaces/NotificationListener.h"
    4344#include "interfaces/PlayerTrigger.h"
    4445#include "worldentities/pawns/Pawn.h"
    45 
    46 #include "NotificationManager.h"
    4746
    4847namespace orxonox
     
    6160        RegisterObject(NotificationDispatcher);
    6261
    63         this->sender_ = NotificationManager::NONE;
     62        this->sender_ = NotificationListener::NONE;
    6463        this->registerVariables();
    6564    }
     
    114113        {
    115114            const std::string message = this->createNotificationMessage();
    116             NotificationManager::sendNotification(message, clientId, this->getSender());
     115            NotificationListener::sendNotification(message, clientId, this->getSender());
    117116        }
    118117        else if(GameMode::isServer())
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc

    r8371 r8374  
    3636#include "core/command/ConsoleCommand.h"
    3737#include "core/CoreIncludes.h"
     38#include "core/GameMode.h"
    3839#include "core/GUIManager.h"
    3940#include "core/LuaState.h"
    40 #include "network/Host.h"
    41 #include "network/NetworkFunction.h"
    4241#include "util/Convert.h"
    4342#include "util/ScopedSingletonManager.h"
     
    5352{
    5453
    55     const std::string NotificationManager::ALL("all");
    56     const std::string NotificationManager::NONE("none");
    57 
    5854    // Register tolua_open function when loading the library.
    5955    DeclareToluaInterface(Notifications);
     
    6460    SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);
    6561
    66     registerStaticNetworkFunction(NotificationManager::sendNotification);
    67 
    6862    /**
    6963    @brief
     
    7367    {
    7468        RegisterRootObject(NotificationManager);
    75 
    76         this->highestIndex_ = 0;
    7769
    7870        ModifyConsoleCommand("enterEditMode").setObject(this);
     
    113105        this->queues_.clear();
    114106    }
    115 
    116     /**
    117     @brief
    118         Sends a Notification with the specified message to the specified client from the specified sender.
    119     @param message
    120         The message that should be sent.
    121     @param clientId
    122         The id of the client the notification should be sent to.
    123     @param sender
    124         The sender that sent the notification.
    125     @param isLocal
    126         If this is set to true (false is default), then the Notification is sent to the client where this function is executed, meaning the Notification is sent locally.
    127     */
    128     /*static*/ void NotificationManager::sendNotification(const std::string& message, unsigned int clientId, const std::string& sender, bool isLocal)
    129     {
    130         // If we're in standalone mode or we're already no the right client we create and send the Notification.
    131         if(GameMode::isStandalone() || isLocal || Host::getPlayerID() == clientId)
    132         {
    133             Notification* notification = new Notification(message, sender);
    134             if(NotificationManager::getInstance().registerNotification(notification))
    135                 COUT(3) << "Notification \"" << notification->getMessage() << "\" sent." << std::endl;
    136         }
    137         // If we're on the server (and the server is not the intended recipient of the Notification) we send it over the network.
    138         else if(GameMode::isServer())
    139         {
    140             callStaticNetworkFunction(NotificationManager::sendNotification, clientId, message, clientId, sender);
    141         }
    142     }
    143 
    144     /**
    145     @brief
    146         Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender.
     107   
     108    bool NotificationManager::registerNotification(const std::string& message, const std::string& sender)
     109    {
     110        Notification* notification = new Notification(message, sender);
     111        return this->registerNotification(notification);
     112    }
     113
     114    /**
     115    @brief
     116        Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender.
    147117    @param notification
    148118        The Notification to be registered.
     
    159129        this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification));
    160130
    161         if(notification->getSender() == NotificationManager::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
     131        if(notification->getSender() == NotificationListener::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
    162132            return true;
    163133
    164134        bool all = false;
    165         if(notification->getSender() == NotificationManager::ALL) // If all are the sender, then the Notifications is added to every NotificationListener.
     135        if(notification->getSender() == NotificationListener::ALL) // If all are the sender, then the Notifications is added to every NotificationQueue.
    166136            all = true;
    167137
    168         // Insert the Notification in all NotificationListeners that have its sender as target.
    169         for(std::map<NotificationListener*, unsigned int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all NotificationListeners.
    170         {
    171             const std::set<std::string>& set = it->first->getTargetsSet();
    172             bool bAll = set.find(NotificationManager::ALL) != set.end();
    173             // If either the Notification has as sender 'all', the NotificationListener displays all Notifications or the NotificationListener has the sender of the Notification as target.
     138        // Insert the Notification in all NotificationQueues that have its sender as target.
     139        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
     140        {
     141            const std::set<std::string>& set = it->second->getTargetsSet();
     142            bool bAll = set.find(NotificationListener::ALL) != set.end();
     143            // If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target.
    174144            if(all || bAll || set.find(notification->getSender()) != set.end())
    175145            {
    176146                if(!bAll)
    177                     this->notificationLists_[it->second]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationListener.
    178                 it->first->update(notification, time); // Update the NotificationListener.
     147                    this->notificationLists_[it->second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue.
     148                it->second->update(notification, time); // Update the NotificationQueue.
    179149            }
    180150        }
     
    187157    /**
    188158    @brief
    189         Unregisters a Notification within the NotificationManager for a given NotificationListener.
     159        Unregisters a Notification within the NotificationManager for a given NotificationQueue.
    190160    @param notification
    191161        A pointer to the Notification to be unregistered.
    192     @param listener
    193         A pointer to the NotificationListener the Notification is unregistered for.
    194     */
    195     void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener)
     162    @param queue
     163        A pointer to the NotificationQueue the Notification is unregistered for.
     164    */
     165    void NotificationManager::unregisterNotification(Notification* notification, NotificationQueue* queue)
    196166    {
    197167        assert(notification);
    198         assert(listener);
    199 
    200         // Remove the Notification from the list of Notifications of the input NotificationListener.
    201         this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second));
    202 
    203         COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;
     168        assert(queue);
     169
     170        // Remove the Notification from the list of Notifications of the input NotificationQueue.
     171        this->removeNotification(notification, *(this->notificationLists_.find(queue->getName())->second));
     172
     173        COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << std::endl;
    204174    }
    205175
     
    231201    /**
    232202    @brief
    233         Registers a NotificationListener within the NotificationManager.
    234     @param listener
    235         The NotificationListener to be registered.
    236     @return
    237         Returns true if successful.  Fales if the NotificationListener is already registered.
    238     */
    239     bool NotificationManager::registerListener(NotificationListener* listener)
    240     {
    241         assert(listener);
    242 
    243         // If the NotificationListener is already registered.
    244         if(this->listenerList_.find(listener) != this->listenerList_.end())
    245             return false;
    246 
    247         this->highestIndex_ += 1;
    248         unsigned int index = this->highestIndex_; // An identifier that identifies each registered NotificationListener uniquely.
    249 
    250         this->listenerList_[listener] = index; // Add the NotificationListener to the list of NotificationListeners.
    251 
    252         const std::set<std::string>& set = listener->getTargetsSet();
    253 
    254         // If all senders are the target of the NotificationListener, then the list of Notifications for that specific NotificationListener is the same as the list of all Notifications.
    255         bool bAll = set.find(NotificationManager::ALL) != set.end();
    256         std::multimap<std::time_t, Notification*>* map = NULL;
    257         if(bAll)
    258             this->notificationLists_[index] = &this->allNotificationsList_;
    259         // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationListeners.
    260         else
    261         {
    262             this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>;
    263             map = this->notificationLists_[index];
    264         }
    265 
    266         // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
    267         for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
    268         {
    269             if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
    270                 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
    271         }
    272 
    273         listener->update(); // Update the listener.
    274 
    275         COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl;
    276 
    277         return true;
    278     }
    279 
    280     /**
    281     @brief
    282         Unregisters a NotificationListener within the NotificationManager.
    283     @param listener
    284         The NotificationListener to be unregistered.
    285     */
    286     void NotificationManager::unregisterListener(NotificationListener* listener)
    287     {
    288         assert(listener);
    289 
    290         unsigned int identifier = this->listenerList_.find(listener)->second;
    291         std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second;
    292 
    293         // If the map is not the map of all Notifications, make sure all Notifications are unregistered.
    294         std::multimap<std::time_t, Notification*>::iterator it = map->begin();
    295         if(map != &this->allNotificationsList_)
    296         {
    297             while(it != map->end())
    298             {
    299                 this->unregisterNotification(it->second, listener);
    300                 it = map->begin();
    301             }
    302             delete map;
    303         }
    304 
    305         COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl;
    306 
    307         // Remove the NotificationListener from the list of NotificationListeners.
    308         this->listenerList_.erase(listener);
    309         // Remove the Notifications list that was associated with the input NotificationListener.
    310         this->notificationLists_.erase(identifier);
    311     }
    312 
    313     /**
    314     @brief
    315         Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map.
    316     @param listener
    317         The NotificationListener the Notifications are fetched for.
     203        Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map.
     204    @param queue
     205        The NotificationQueue the Notifications are fetched for.
    318206    @param map
    319207        A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
     
    325213        Returns true if successful.
    326214    */
    327     void NotificationManager::getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
    328     {
    329         assert(listener);
     215    void NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
     216    {
     217        assert(queue);
    330218        assert(map);
    331219
    332         std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.
     220        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue.
    333221
    334222        std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
     
    343231    /**
    344232    @brief
    345         Fetches the newest Notifications for a specific NotificationListener and stores them in the input map.
    346     @param listener
    347         The NotificationListener the Notifications are fetched for.
     233        Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.
     234    @param queue
     235        The NotificationQueue the Notifications are fetched for.
    348236    @param map
    349237        A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
     
    353241        Returns true if successful.
    354242    */
    355     void NotificationManager::getNewestNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications)
    356     {
    357         assert(listener);
     243    void NotificationManager::getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications)
     244    {
     245        assert(queue);
    358246        assert(map);
    359247
    360         std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.
     248        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue.
    361249
    362250        if(!notifications->empty()) // If the list of Notifications is not empty.
     
    390278    @brief
    391279        Registers a NotificationQueue.
    392         This makes sure that the NotificationQueue can be attained through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.
     280        This makes sure that the NotificationQueue can be accessed through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.
    393281    @param queue
    394282        A pointer to the NotificationQueue to be registered.
     
    398286    bool NotificationManager::registerQueue(NotificationQueue* queue)
    399287    {
     288        assert(queue);
     289
     290        // If the NotificationQueue is already registered.
     291        if(this->queues_.find(queue->getName()) != this->queues_.end())
     292            return false;
     293
     294        this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)); // Add the NotificationQueue to the list of NotificationQueues.
     295
     296        const std::set<std::string>& set = queue->getTargetsSet();
     297
     298        // If all senders are the target of the NotificationQueue, then the list of Notifications for that specific NotificationQueue is the same as the list of all Notifications.
     299        bool bAll = set.find(NotificationListener::ALL) != set.end();
     300        std::multimap<std::time_t, Notification*>* map = NULL;
     301        if(bAll)
     302            this->notificationLists_[queue->getName()] = &this->allNotificationsList_;
     303        // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationQueues.
     304        else
     305        {
     306            this->notificationLists_[queue->getName()] = new std::multimap<std::time_t, Notification*>;
     307            map = this->notificationLists_[queue->getName()];
     308        }
     309
     310        // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue.
     311        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
     312        {
     313            if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
     314                map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
     315        }
     316
     317        queue->update(); // Update the queue.
     318       
    400319        COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl;
    401         return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;
     320        return true;
    402321    }
    403322
     
    410329    void NotificationManager::unregisterQueue(NotificationQueue* queue)
    411330    {
     331        assert(queue);
     332
     333        std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(queue->getName())->second;
     334
     335        // If the map is not the map of all Notifications, make sure all Notifications are unregistered.
     336        std::multimap<std::time_t, Notification*>::iterator it = map->begin();
     337        if(map != &this->allNotificationsList_)
     338        {
     339            while(it != map->end())
     340            {
     341                this->unregisterNotification(it->second, queue);
     342                it = map->begin();
     343            }
     344            delete map;
     345        }
     346
     347        // Remove the NotificationQueue from the list of NotificationQueues.
     348        this->queues_.erase(queue->getName());
     349        // Remove the Notifications list that was associated with the input NotificationQueue.
     350        this->notificationLists_.erase(queue->getName());
     351       
    412352        COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl;
    413         this->queues_.erase(queue->getName());
    414353    }
    415354
     
    424363        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)");
    425364
    426         NotificationQueue* infoQueue = new NotificationQueue("info", NotificationManager::ALL, 1, -1);
     365        NotificationQueue* infoQueue = new NotificationQueue("info", NotificationListener::ALL, 1, -1);
    427366        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"FFFFFF00\")");
    428367        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")");
  • 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.
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc

    r8371 r8374  
    9090        this->create(); // Creates the NotificationQueue in lua.
    9191
    92         // Register the NotificationQueue as NotificationListener with the NotificationManager.
    93         bool listenerRegistered = NotificationManager::getInstance().registerListener(this);
    94         if(!listenerRegistered) // If the registration has failed.
    95         {
    96             this->registered_ = false;
    97             // Remove the NotificationQueue in lua.
    98             if(GameMode::showsGraphics())
    99                 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    100             NotificationManager::getInstance().unregisterQueue(this);
    101             COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;
    102             return;
    103         }
    104 
    10592        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
    10693    }
     
    119106
    120107            // Unregister with the NotificationManager.
    121             NotificationManager::getInstance().unregisterListener(this);
    122108            NotificationManager::getInstance().unregisterQueue(this);
    123109        }
     
    181167        Updates the NotificationQueue.
    182168        Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting them into the queue.
     169        This is called by the NotificationManager when the Notifications have changed so much, that the NotificationQueue may have to re-initialize his operations.
    183170    */
    184171    void NotificationQueue::update(void)
     
    418405            this->targets_.insert(string[i]);
    419406
     407        // TODO: Why?
    420408        if(this->registered_)
    421409        {
    422             NotificationManager::getInstance().unregisterListener(this);
    423             NotificationManager::getInstance().registerListener(this);
     410            NotificationManager::getInstance().unregisterQueue(this);
     411            NotificationManager::getInstance().registerQueue(this);
    424412        }
    425413    }
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h

    r8371 r8374  
    4646
    4747#include "tools/interfaces/Tickable.h"
    48 #include "interfaces/NotificationListener.h"
    4948
    5049namespace orxonox // tolua_export
     
    9089    */
    9190    class _NotificationsExport NotificationQueue // tolua_export
    92         : public Tickable, public NotificationListener
     91        : public Tickable
    9392    { // tolua_export
    9493
Note: See TracChangeset for help on using the changeset viewer.