Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2011, 8:53:28 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/notifications/NotificationQueue.h

    r7552 r8706  
    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#include "network/synchronisable/Synchronisable.h"
     50
     51namespace orxonox
     52{
    5253
    5354    /**
     
    7879        Displays @ref orxonox::Notification "Notifications" from specific senders.
    7980
    80         There are quite some parameters that influence the behaviour of the NotificationQueue:
     81        There are quite some parameters that influence the behavior of the NotificationQueue:
    8182        - @b name The name of the NotificationQueue. It needs to be unique.
    8283        - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.
     
    8990    @ingroup Notifications
    9091    */
    91     class _NotificationsExport NotificationQueue // tolua_export
    92         : public Tickable, public NotificationListener
    93     { // tolua_export
     92    class _NotificationsExport NotificationQueue : public BaseObject, public Tickable, public Synchronisable
     93    {
    9494
    9595        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);
     96            NotificationQueue(BaseObject* creator);
    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            virtual void changedName(void);
     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.
    106106
    107107            // tolua_begin
     
    110110            @return Returns the name.
    111111            */
    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.
     112            inline const std::string& getName(void) const
     113                { return this->BaseObject::getName(); }
     114
     115            void setMaxSize(unsigned int size); // Sets the maximum number of displayed Notifications.
    116116            /**
    117117            @brief Returns the maximum number of Notifications displayed.
    118118            @return Returns maximum size.
    119119            */
    120             inline unsigned int getMaxSize() const
     120            inline unsigned int getMaxSize(void) const
    121121                { return this->maxSize_; }
    122122
    123             void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
     123            void setDisplayTime(int time); // Sets the maximum number of seconds a Notification is displayed.
    124124            /**
    125125            @brief Returns the time interval the Notification is displayed.
    126126            @return Returns the display time.
    127127            */
    128             inline unsigned int getDisplayTime() const
     128            inline int getDisplayTime(void) const
    129129                { return this->displayTime_; }
    130130            // tolua_end
     131            void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed.
     132            void displayTimeChanged(void);
    131133
    132134            /**
     
    134136            @return Returns the size of the NotificationQueue.
    135137            */
    136             inline unsigned int getSize() const
     138            inline unsigned int getSize(void) const
    137139                { return this->size_; }
    138140
     
    141143            @return Returns a set of strings holding the different targets.
    142144            */
    143             inline const std::set<std::string> & getTargetsSet()
     145            inline const std::set<std::string> & getTargetsSet(void)
    144146                { return this->targets_; }
    145147
    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:
     148            void setTargets(const std::string & targets); // Set the targets of this NotificationQueue.
     149            const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets.
     150            void targetsChanged(void); // Is called when the NotificationQueue's targets have changed.
     151
     152            /**
     153            @brief Check whether the NotificationQueue is registered with the NotificationManager.
     154            @return Returns true if it is registered, false if not.
     155            */
     156            inline bool isRegistered(void)
     157                { return this->registered_; }
     158
     159            bool tidy(void); // Pops all Notifications from the NotificationQueue.
     160           
     161        protected:
     162            void registerVariables();
     163           
     164            /**
     165            @brief Is called when a notification was pushed.
     166            @param notification The Notification that was pushed.
     167            */
     168            virtual void notificationPushed(Notification* notification) {}
     169            /**
     170            @brief Is called when a notification was popped.
     171            */
     172            virtual void notificationPopped(void) {}
     173            /**
     174            @brief Is called when a notification was removed.
     175            @param index The index the removed notification was at.
     176            */
     177            virtual void notificationRemoved(unsigned int index) {}
     178           
     179            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
     180
     181        protected:
    152182            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    153183            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    154 
    155             std::string name_; //!< The name of the NotificationQueue.
    156 
     184            static const int INF = -1; //!< Constant denoting infinity.
     185
     186            virtual void create(void); // Creates the NotificationQueue.
     187
     188        private:
     189            time_t creationTime_; //!< The time this NotificationQueue was created.
     190           
    157191            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    158192            unsigned int size_; //!< The number of Notifications displayed.
    159             unsigned int displayTime_; //!< The time a Notification is displayed.
     193            int displayTime_; //!< The time a Notification is displayed.
    160194
    161195            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
     
    169203            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    170204
    171             void create(void); //!< Creates the NotificationQueue in lua.
    172 
    173205            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    174206
    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__ */
     207            void push(Notification* notification, const std::time_t & time); // Adds (pushes) a Notification to the NotificationQueue.
     208            void pop(void); // Removes (pops) the least recently added Notification form the NotificationQueue.
     209            void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); // Removes the Notification that is stored in the input NotificationContainer.
     210
     211    };
     212
     213}
     214
     215#endif /* _NotificationQueue_H__ */
Note: See TracChangeset for help on using the changeset viewer.