Index: code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h	(revision 2777)
+++ code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h	(revision 2779)
@@ -27,51 +27,152 @@
  */
 
+/**
+    @file NotificationQueue.h
+    @brief Definition of the NotificationQueue class.
+*/
+
 #ifndef _NotificationOueue_H__
 #define _NotificationOueue_H__
 
 #include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <set>
+#include <OgreOverlayManager.h>
 #include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+#include <map>
+#include <ctime>
 
-#include "orxonox/overlays/OverlayText.h"
+#include "orxonox/overlays/OverlayGroup.h"
 #include "orxonox/objects/Tickable.h"
 
-#include <string>
+#include "NotificationManager.h"
 
 namespace orxonox
 {
+
+    //! Container to allow easy handling.
+    struct NotificationOverlayContainer
+    {
+        NotificationOverlay* overlay; //!< Pointer to the NotificationOverlay, everything is about.
+        Notification* notification; //!< The Notification displayed by the overlay.
+        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
+            { return a->time < b->time; } //!< Ordered by time.
+    };
+
     /**
     @brief
-
+        Displays Notifications from specific senders.
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport NotificationQueue : public OverlayText, public Tickable
+
+    class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable
     {
-    public:
-        NotificationQueue(BaseObject* creator);
-        virtual ~NotificationQueue();
-
-        static NotificationQueue* queue_s; //TDO Singleton? oder im level.
-
-        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
-
-        virtual void tick(float dt);
-
-        void update(void);
-
-        int getLength(void) const
-                { return this->length_; }
-        int getWidth(void) const
-                { return this->width_; }
-
-        void setQueueText(const std::string & text);
-        bool setLength(int length);
-        bool setWidth(int width);
-
-    private:
-        Ogre::UTFString queueText_;
-        int length_;
-        int width_;
-
+    
+        public:
+            NotificationQueue(BaseObject* creator);
+            virtual ~NotificationQueue();
+            
+            virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
+            
+            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.
+            
+            /**
+            @brief Returns the maximum number of Notifications displayed.
+            @return Returns maximum size.
+            */
+            inline 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_; }
+            /**
+            @brief Returns the time interval the Notification is displayed.
+            @return Returns the display time.
+            */
+            inline int getDisplayTime() const
+                { return this->displayTime_; }
+                
+            /**
+            @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.
+            */
+            inline const std::set<std::string> & getTargetsSet()
+                { return this->targets_; }
+            const std::string & getTargets() const; //!< Returns a string consisting of teh concatination of the targets.
+            
+            /**
+            @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_; }
+            
+        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 Notifications displayed.
+            static const int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
+            static const float DEFAULT_FONT_SIZE = 0.02; //!< The default font size.
+            static const std::string DEFAULT_FONT; //!< The default font.
+        
+            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.
+            
+            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.
+            
+            void initialize(void); //!< Initializes the object.
+            void setDefaults(void); //!< Helper method to set the default values.
+            
+            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.
+            
+            bool setTargets(const std::string & targets); //!< Set the targets of this queue.
+            
+            bool setFontSize(float size); //!< Set the font size.
+            bool setFont(const std::string & font); //!< Set the font.
+            
+            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 clear(void); //!< Clear the queue.
+    
     };
 
