Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 28, 2011, 5:10:01 PM (13 years ago)
Author:
dafrick
Message:

Merging tutoriallevel3 branch into presentation branch.

Location:
code/branches/presentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/modules/notifications/NotificationQueue.h

    r7552 r8637  
    4545#include "NotificationManager.h"
    4646
     47#include "core/BaseObject.h"
    4748#include "tools/interfaces/Tickable.h"
    48 #include "interfaces/NotificationListener.h"
    49 
    50 namespace orxonox // tolua_export
    51 { // tolua_export
     49
     50namespace orxonox
     51{
    5252
    5353    /**
     
    7878        Displays @ref orxonox::Notification "Notifications" from specific senders.
    7979
    80         There are quite some parameters that influence the behaviour of the NotificationQueue:
     80        There are quite some parameters that influence the behavior of the NotificationQueue:
    8181        - @b name The name of the NotificationQueue. It needs to be unique.
    8282        - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.
     
    8989    @ingroup Notifications
    9090    */
    91     class _NotificationsExport NotificationQueue // tolua_export
    92         : public Tickable, public NotificationListener
    93     { // tolua_export
     91    class _NotificationsExport NotificationQueue : public BaseObject, public Tickable
     92    {
    9493
    9594        public:
    96             NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::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);
    9797            virtual ~NotificationQueue();
    9898
    99             //! Destroys the NotificationQueue.
    100             void destroy(bool noGraphics = false); // tolua_export
    101 
    102             virtual void tick(float dt); //!< To update from time to time.
    103 
    104             void update(void); //!< Updates the NotificationQueue.
    105             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.
    106104
    107105            // tolua_begin
     
    110108            @return Returns the name.
    111109            */
    112             inline const std::string& getName() const
    113                 { return this->name_; }
    114 
    115             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.
    116114            /**
    117115            @brief Returns the maximum number of Notifications displayed.
    118116            @return Returns maximum size.
    119117            */
    120             inline unsigned int getMaxSize() const
     118            inline unsigned int getMaxSize(void) const
    121119                { return this->maxSize_; }
    122120
    123             void setDisplayTime(unsigned 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.
    124122            /**
    125123            @brief Returns the time interval the Notification is displayed.
    126124            @return Returns the display time.
    127125            */
    128             inline unsigned int getDisplayTime() const
     126            inline int getDisplayTime(void) const
    129127                { return this->displayTime_; }
    130128            // tolua_end
     
    134132            @return Returns the size of the NotificationQueue.
    135133            */
    136             inline unsigned int getSize() const
     134            inline unsigned int getSize(void) const
    137135                { return this->size_; }
    138136
     
    141139            @return Returns a set of strings holding the different targets.
    142140            */
    143             inline const std::set<std::string> & getTargetsSet()
     141            inline const std::set<std::string> & getTargetsSet(void)
    144142                { return this->targets_; }
    145143
    146             // tolua_begin
    147             void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    148             const std::string& getTargets(void) const; //!< Returns a string consisting of the concatination of the targets.
    149             // tolua_end
    150 
    151         private:
     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_; }
     153
     154            bool tidy(void); // Pops all Notifications from the NotificationQueue.
     155           
     156        protected:
     157            /**
     158            @brief Is called when a notification was pushed.
     159            @param notification The Notification that was pushed.
     160            */
     161            virtual void notificationPushed(Notification* notification) {}
     162            /**
     163            @brief Is called when a notification was popped.
     164            */
     165            virtual void notificationPopped(void) {}
     166            /**
     167            @brief Is called when a notification was removed.
     168            @param index The index the removed notification was at.
     169            */
     170            virtual void notificationRemoved(unsigned int index) {}
     171           
     172            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
     173
     174        protected:
    152175            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    153176            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    154 
    155             std::string name_; //!< The name of the NotificationQueue.
    156 
     177            static const int INF = -1; //!< Constant denoting infinity.
     178
     179            virtual void create(void); // Creates the NotificationQueue.
     180
     181        private:
     182            void initialize(void); // Initializes the NotificationQueue.
     183
     184            time_t creationTime_; // The time this NotificationQueue was created.
     185           
    157186            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    158187            unsigned int size_; //!< The number of Notifications displayed.
    159             unsigned int displayTime_; //!< The time a Notification is displayed.
     188            int displayTime_; //!< The time a Notification is displayed.
    160189
    161190            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
     
    169198            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    170199
    171             void create(void); //!< Creates the NotificationQueue in lua.
    172 
    173200            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    174201
    175             void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue.
    176             void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue.
    177             void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer.
    178 
    179             void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
    180 
    181     }; // tolua_export
    182 
    183 } // tolua_export
    184 
    185 #endif /* _NotificationOverlay_H__ */
     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.
     205
     206    };
     207
     208}
     209
     210#endif /* _NotificationQueue_H__ */
Note: See TracChangeset for help on using the changeset viewer.