Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 28, 2011, 4:21:14 PM (13 years ago)
Author:
dafrick
Message:

Making NotificationQueue XML-loadable. Adding notifications to all levels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel3/src/modules/notifications/NotificationQueue.h

    r8453 r8636  
    4545#include "NotificationManager.h"
    4646
     47#include "core/BaseObject.h"
    4748#include "tools/interfaces/Tickable.h"
    4849
     
    8889    @ingroup Notifications
    8990    */
    90     class _NotificationsExport NotificationQueue : public Tickable
     91    class _NotificationsExport NotificationQueue : public BaseObject, public Tickable
    9192    {
    9293
    9394        public:
    94             NotificationQueue(const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
     95            NotificationQueue(BaseObject* creator);
     96            NotificationQueue(BaseObject* creator, const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
    9597            virtual ~NotificationQueue();
    9698
    97             virtual void tick(float dt); //!< To update from time to time.
    98 
    99             void update(void); //!< Updates the NotificationQueue.
    100             void update(Notification* notification, const std::time_t & time); //!< Updates the NotificationQueue by adding an new Notification.
     99            virtual void tick(float dt); // To update from time to time.
     100            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     101
     102            void update(void); // Updates the NotificationQueue.
     103            void update(Notification* notification, const std::time_t & time); // Updates the NotificationQueue by adding an new Notification.
    101104
    102105            // tolua_begin
     
    105108            @return Returns the name.
    106109            */
    107             inline const std::string& getName() const
    108                 { return this->name_; }
    109 
    110             void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
     110            inline const std::string& getName(void) const
     111                { return this->BaseObject::getName(); }
     112
     113            void setMaxSize(unsigned int size); // Sets the maximum number of displayed Notifications.
    111114            /**
    112115            @brief Returns the maximum number of Notifications displayed.
    113116            @return Returns maximum size.
    114117            */
    115             inline unsigned int getMaxSize() const
     118            inline unsigned int getMaxSize(void) const
    116119                { return this->maxSize_; }
    117120
    118             void setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
     121            void setDisplayTime(int time); // Sets the maximum number of seconds a Notification is displayed.
    119122            /**
    120123            @brief Returns the time interval the Notification is displayed.
    121124            @return Returns the display time.
    122125            */
    123             inline int getDisplayTime() const
     126            inline int getDisplayTime(void) const
    124127                { return this->displayTime_; }
    125128            // tolua_end
     
    129132            @return Returns the size of the NotificationQueue.
    130133            */
    131             inline unsigned int getSize() const
     134            inline unsigned int getSize(void) const
    132135                { return this->size_; }
    133136
     
    136139            @return Returns a set of strings holding the different targets.
    137140            */
    138             inline const std::set<std::string> & getTargetsSet()
     141            inline const std::set<std::string> & getTargetsSet(void)
    139142                { return this->targets_; }
    140143
    141             void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    142             const std::string& getTargets(void) const; //!< Returns a string consisting of the concatenation of the targets.
     144            void setTargets(const std::string & targets); // Set the targets of this NotificationQueue.
     145            const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets.
     146
     147            /**
     148            @brief Check whether the NotificationQueue is registered with the NotificationManager.
     149            @return Returns true if it is registered, false if not.
     150            */
     151            inline bool isRegistered(void)
     152                { return this->registered_; }
    143153
    144154            bool tidy(void); // Pops all Notifications from the NotificationQueue.
     
    160170            virtual void notificationRemoved(unsigned int index) {}
    161171           
    162             virtual void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
     172            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
    163173
    164174        protected:
     
    167177            static const int INF = -1; //!< Constant denoting infinity.
    168178
     179            virtual void create(void); // Creates the NotificationQueue.
     180
    169181        private:
    170             std::string name_; //!< The name of the NotificationQueue.
    171 
     182            void initialize(void); // Initializes the NotificationQueue.
     183
     184            time_t creationTime_; // The time this NotificationQueue was created.
     185           
    172186            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    173187            unsigned int size_; //!< The number of Notifications displayed.
     
    186200            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    187201
    188             void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue.
    189             void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue.
    190             void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer.
     202            void push(Notification* notification, const std::time_t & time); // Adds (pushes) a Notification to the NotificationQueue.
     203            void pop(void); // Removes (pops) the least recently added Notification form the NotificationQueue.
     204            void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); // Removes the Notification that is stored in the input NotificationContainer.
    191205
    192206    };
Note: See TracChangeset for help on using the changeset viewer.