Index: code/trunk/src/modules/notifications/NotificationQueue.h
===================================================================
--- code/trunk/src/modules/notifications/NotificationQueue.h	(revision 7401)
+++ code/trunk/src/modules/notifications/NotificationQueue.h	(revision 7403)
@@ -28,5 +28,5 @@
 
 /**
-    @file
+    @file NotificationQueue.h
     @brief Definition of the NotificationQueue class.
 */
@@ -38,28 +38,26 @@
 
 #include <ctime>
-#include <map>
 #include <set>
 #include <string>
+#include <vector>
 
-#include "util/Math.h"
 #include "tools/interfaces/Tickable.h"
-#include "overlays/OverlayGroup.h"
+
 #include "interfaces/NotificationListener.h"
+#include "NotificationManager.h"
 
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
 
     //! Container to allow easy handling.
-    struct NotificationOverlayContainer
+    struct NotificationContainer
     {
-        NotificationOverlay* overlay; //!< Pointer to the NotificationOverlay, everything is about.
-        Notification* notification; //!< The Notification displayed by the overlay.
+        Notification* notification; //!< The Notification displayed.
         time_t time; //!< The time the Notification was sent and thus first displayed.
-        std::string name; //!< The name of the overlay.
     };
 
-    //! Struct to allow ordering of NotificationOverlayContainers.
-    struct NotificationOverlayContainerCompare {
-        bool operator() (const NotificationOverlayContainer* const & a, const NotificationOverlayContainer* const & b) const
+    //! Struct to allow ordering of NotificationContainers.
+    struct NotificationContainerCompare {
+        bool operator() (const NotificationContainer* const & a, const NotificationContainer* const & b) const
             { return a->time < b->time; } //!< Ordered by time.
     };
@@ -68,149 +66,103 @@
     @brief
         Displays Notifications from specific senders.
-        Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.)
-
-        Creating a NotificationQueue through XML goes as follows:
-        Be aware that the NotificationQueue must be inside the @code <Level></Level> @endcode tags or bad things will happen.
-        
-        @code
-        <NotificationQueue
-            name = "SuperQueue" //Name of your OverlayQueue.
-            maxSize = "5" //The maximum number of Notifications displayed. (Default is 5)
-            notificationLength = "64" //The maximum number of characters of a Notification, that are displayed. (Default is 64)
-            displayTime = "30" //The time a Notification is displayed in seconds. (Default is 30)
-            targets = "target1, target2" //The senders this NotificationQueue displays Notifications from. (all, if all Notifications should be displayed.)
-            font = "VeraMono" //The font (Default is VeraMono)
-            fontSize = '0.4' //The font size. (Default is 0.025)
-            position = "0.0, 0.0" //The position of the NotificationQueue. (Default is 0.0,0.0)
-        />
-        @endcode
     @author
         Damian 'Mozork' Frick
     */
-
-    class _NotificationsExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener
-    {
+    class _NotificationsExport NotificationQueue // tolua_export
+        : public Tickable, public NotificationListener
+    { // tolua_export
 
         public:
-            NotificationQueue(BaseObject* creator);
+            NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
             virtual ~NotificationQueue();
 
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
+            /**
+            @brief Destroys the NotificationQueue.
+                   Used in lua.
+            */
+            void destroy(void) { this->OrxonoxClass::destroy(); } // tolua_export
 
             virtual void tick(float dt); //!< To update from time to time.
 
-            void update(void); //!< Updates the queue.
-            void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
+            void update(void); //!< Updates the NotificationQueue.
+            void update(Notification* notification, const std::time_t & time); //!< Updates the NotificationQueue by adding an new Notification.
 
+            // tolua_begin
+            /**
+            @brief Get the name of the NotificationQueue.
+            @return Returns the name.
+            */
+            inline const std::string& getName() const
+                { return this->name_; }
+
+            void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
             /**
             @brief Returns the maximum number of Notifications displayed.
             @return Returns maximum size.
             */
-            inline int getMaxSize() const
+            inline unsigned int getMaxSize() const
                 { return this->maxSize_; }
-            /**
-            @brief Returns the current number of Notifications displayed.
-            @return Returns the size of the queue.
-            */
-            inline int getSize() const
-                { return this->size_; }
-            /**
-            @brief Returns the maximum length in characters a Notification message is allowed to have.
-            @return Returns the maximum Notification length.
-            */
-            inline int getNotificationLength() const
-                { return this->notificationLength_; }
+
+            void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
             /**
             @brief Returns the time interval the Notification is displayed.
             @return Returns the display time.
             */
-            inline int getDisplayTime() const
+            inline float getDisplayTime() const
                 { return this->displayTime_; }
-            /**
-            @brief Returns the position of the NotificationQueue.
-            @return Returns the position.
-            */
-            inline const Vector2 & getPosition() const
-                { return this->position_; }
-            /**
-            @brief Returns the font size used to display the Notifications.
-            @return  Returns the font size.
-            */
-            inline float getFontSize() const
-                { return this->fontSize_; }
-            /**
-            @brief Returns the font used to display the Notifications.
-            @return Returns the font.
-            */
-            inline const std::string & getFont() const
-                { return this->font_; }
+            // tolua_end
 
             /**
-            @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
-            @return Retuns a set of string holding the different targets.
+            @brief Returns the current number of Notifications displayed.
+            @return Returns the size of the NotificationQueue.
             */
-            inline const std::set<std::string> & getTargetsSet()
-                { return this->targets_; }
-            bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
+            inline unsigned int getSize() const
+                { return this->size_; }
 
             /**
-            @brief Sets the position of the NotificationQueue.
-            @param pos The position.
+            @brief Returns the targets of this NotificationQueue, reps. the senders which Notifications are displayed in this NotificationQueue.
+            @return Returns a set of strings holding the different targets.
             */
-            inline void setPosition(Vector2 pos)
-                { this->position_ = pos; this->positionChanged(); }
+            inline const std::set<std::string, NotificationListenerStringCompare> & getTargetsSet()
+                { return this->targets_; }
 
-            void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
+            // tolua_begin
+            void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
+            const std::string& getTargets(void) const; //!< Returns a string consisting of the concatination of the targets.
+            // tolua_end
 
         private:
-            static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
-            static const int DEFAULT_LENGTH = 64; //!< The default maximum number of characters displayed.
-            static const int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
-            static const float DEFAULT_FONT_SIZE; //!< The default font size.
+            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
+            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
 
-            static const std::string DEFAULT_FONT; //!< The default font.
-            static const Vector2 DEFAULT_POSITION; //!< the default position.
+            std::string name_; //!< The name of the NotificationQueue.
 
-            int maxSize_; //!< The maximal number of Notifications displayed.
-            int size_; //!< The number of Notifications displayed.
-            int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
-            int displayTime_; //!< The time a Notification is displayed.
-            Vector2 position_; //!< The position of the NotificationQueue.
-
-            std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
-
-            float fontSize_; //!< The font size.
-            std::string font_; //!< The font.
-
-            std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps.
-            std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding.
-
-            float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
-            NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
+            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
+            unsigned int size_; //!< The number of Notifications displayed.
+            unsigned int displayTime_; //!< The time a Notification is displayed.
 
             bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
 
-            void initialize(void); //!< Initializes the object.
-            void setDefaults(void); //!< Helper method to set the default values.
+            std::set<std::string, NotificationListenerStringCompare> targets_; //!< The targets the NotificationQueue displays Notifications of.
 
-            bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications.
-            bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
-            bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
+            std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< The NotificationContainers ordered by the time they were registered.
+            std::vector<NotificationContainer*> notifications_; //!< The NotificationContainers in the order they were added to the NotificationQueue.
 
-            bool setTargets(const std::string & targets); //!< Set the targets of this queue.
+            float tickTime_; //!< Helper variable, to not have to check for Notifications that have been displayed too long, every tick.
+            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
 
-            bool setFontSize(float size); //!< Set the font size.
-            bool setFont(const std::string & font); //!< Set the font.
+            void create(void); //!< Creates the NotificationQueue in lua.
 
-            void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
+            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
 
-            void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
-            bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue.
+            void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue.
+            void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue.
+            void remove(NotificationContainer* container); //!< Removes the Notification that is stored in the input NotificationContainer.
 
-            void clear(void); //!< Clear the queue.
+            void clear(void); //!< Clears the NotificationQueue by removing all NotificationContainers.
 
-    };
+    }; // tolua_export
 
-}
+} // tolua_export
 
 #endif /* _NotificationOverlay_H__ */
