Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7413 for code/trunk


Ignore:
Timestamp:
Sep 11, 2010, 5:05:47 PM (14 years ago)
Author:
dafrick
Message:

Removing some TODO comments.
Better handling of duplicate name in Notificationlayer.lua.
Moving StringCompare object from NotificationListener to StringUtils.

Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/gui/scripts/NotificationLayer.lua

    r7403 r7413  
    426426    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
    427427    local name = window:getText()
     428
     429    local queue = P.queueList[name]
     430    -- Test if a queue with that name already exists.
     431    if queue ~= nil then
     432        window:setText("Queue with that name already exists.")
     433        return
     434    end
     435
    428436    -- Creates the new queue.
    429437    orxonox.NotificationManager:getInstance():createQueue(name)
    430438
    431     local queue = P.queueList[name]
     439    queue = P.queueList[name]
    432440    if queue == nil then
    433441        return
  • code/trunk/src/libraries/util/StringUtils.h

    r7401 r7413  
    4747{
    4848    extern _UtilExport std::string BLANKSTRING;
     49
     50    //!< Struct that can be used as a comparison object for strings in stl containers.
     51    _UtilExport struct StringCompare
     52    {
     53        bool operator() (const std::string& lhs, const std::string& rhs) const
     54            { return lhs.compare(rhs) < 0; }
     55    };
     56
    4957    _UtilExport std::string getUniqueNumberString();
    5058
  • code/trunk/src/modules/notifications/Notification.cc

    r7410 r7413  
    104104    @brief
    105105        Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
    106     @param clientID
     106    @param clientId
    107107        The id of the client that this Notification is sent to.
    108108    @param sender
  • code/trunk/src/modules/notifications/NotificationManager.cc

    r7403 r7413  
    129129        for(std::map<NotificationListener*, unsigned int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all NotificationListeners.
    130130        {
    131             std::set<std::string, NotificationListenerStringCompare> set = it->first->getTargetsSet();
     131            std::set<std::string, StringCompare> set = it->first->getTargetsSet();
    132132            bool bAll = set.find(NotificationManager::ALL) != set.end();
    133133            // If either the Notification has as sender 'all', the NotificationListener displays all Notifications or the NotificationListener has the sender of the Notification as target.
     
    210210        this->listenerList_[listener] = index; // Add the NotificationListener to the list of NotificationListeners.
    211211
    212         std::set<std::string, NotificationListenerStringCompare> set = listener->getTargetsSet();
     212        std::set<std::string, StringCompare> set = listener->getTargetsSet();
    213213
    214214        // 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.
     
    248248        assert(listener);
    249249
    250         //TODO: Make unsigned int.
    251250        unsigned int identifier = this->listenerList_.find(listener)->second;
    252251        std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second;
  • code/trunk/src/modules/notifications/NotificationQueue.cc

    r7412 r7413  
    6969        // Initialize.
    7070        this->size_ = 0;
    71         this->tickTime_ = 0.0;
     71        this->tickTime_ = 0.0f;
    7272
    7373        // Sets the input values.
     
    7777        this->setDisplayTime(displayTime);
    7878
    79         //TODO: Destroy if registration fails?
    80 
    8179        // Register the NotificationQueue with the NotificationManager.
    8280        bool queueRegistered = NotificationManager::getInstance().registerQueue(this);
     
    8583        {
    8684            this->registered_ = false;
    87             COUT(1) << "Error: Notification Queue '" << this->getName() << "' could not be registered." << std::endl;
     85            COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;
    8886            return;
    8987        }
     
    9997            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    10098            NotificationManager::getInstance().unregisterQueue(this);
    101             COUT(1) << "Error: Notification Queue '" << this->getName() << "' could not be registered." << std::endl;
     99            COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;
    102100            return;
    103101        }
     
    358356        bool first = true;
    359357        // Iterate through the set of targets.
    360         for(std::set<std::string, NotificationListenerStringCompare>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
     358        for(std::set<std::string, StringCompare>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
    361359        {
    362360            if(!first)
  • code/trunk/src/modules/notifications/NotificationQueue.h

    r7412 r7413  
    124124            @return Returns a set of strings holding the different targets.
    125125            */
    126             inline const std::set<std::string, NotificationListenerStringCompare> & getTargetsSet()
     126            inline const std::set<std::string, StringCompare> & getTargetsSet()
    127127                { return this->targets_; }
    128128
     
    144144            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
    145145
    146             std::set<std::string, NotificationListenerStringCompare> targets_; //!< The targets the NotificationQueue displays Notifications of.
     146            std::set<std::string, StringCompare> targets_; //!< The targets the NotificationQueue displays Notifications of.
    147147
    148148            std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< The NotificationContainers ordered by the time they were registered.
  • code/trunk/src/orxonox/interfaces/NotificationListener.h

    r7403 r7413  
    4141#include <string>
    4242
     43#include "util/StringUtils.h"
     44
    4345#include "core/OrxonoxClass.h"
    4446
     
    4648{
    4749    class Notification;
    48 
    49     /**
    50     @brief
    51         Struct that overloads the compare operation between two PickupIdentifier pointers.
    52     */
    53     //TODO:
    54     struct NotificationListenerStringCompare
    55     {
    56         bool operator() (const std::string& lhs, const std::string& rhs) const
    57             { return lhs.compare(rhs) < 0; }
    58     };
    5950
    6051    /**
     
    7061            virtual ~NotificationListener() {}
    7162
    72             virtual const std::set<std::string, NotificationListenerStringCompare> & getTargetsSet() = 0;
     63            virtual const std::set<std::string, StringCompare> & getTargetsSet() = 0;
    7364            virtual void update(void) = 0;
    7465            virtual void update(Notification* notification, const std::time_t & time) = 0;
Note: See TracChangeset for help on using the changeset viewer.