Changeset 8706 for code/trunk/src/modules/notifications/NotificationQueue.h
- Timestamp:
- Jun 14, 2011, 8:53:28 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/notifications/NotificationQueue.h
r7552 r8706 45 45 #include "NotificationManager.h" 46 46 47 #include "core/BaseObject.h" 47 48 #include "tools/interfaces/Tickable.h" 48 #include " interfaces/NotificationListener.h"49 50 namespace orxonox // tolua_export51 { // tolua_export49 #include "network/synchronisable/Synchronisable.h" 50 51 namespace orxonox 52 { 52 53 53 54 /** … … 78 79 Displays @ref orxonox::Notification "Notifications" from specific senders. 79 80 80 There are quite some parameters that influence the behavio ur of the NotificationQueue:81 There are quite some parameters that influence the behavior of the NotificationQueue: 81 82 - @b name The name of the NotificationQueue. It needs to be unique. 82 83 - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays. … … 89 90 @ingroup Notifications 90 91 */ 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 { 94 94 95 95 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); 97 97 virtual ~NotificationQueue(); 98 98 99 //! Destroys the NotificationQueue.100 v oid destroy(bool noGraphics = false); // tolua_export101 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. 106 106 107 107 // tolua_begin … … 110 110 @return Returns the name. 111 111 */ 112 inline const std::string& getName( ) const113 { 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. 116 116 /** 117 117 @brief Returns the maximum number of Notifications displayed. 118 118 @return Returns maximum size. 119 119 */ 120 inline unsigned int getMaxSize( ) const120 inline unsigned int getMaxSize(void) const 121 121 { return this->maxSize_; } 122 122 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. 124 124 /** 125 125 @brief Returns the time interval the Notification is displayed. 126 126 @return Returns the display time. 127 127 */ 128 inline unsigned int getDisplayTime() const128 inline int getDisplayTime(void) const 129 129 { return this->displayTime_; } 130 130 // tolua_end 131 void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed. 132 void displayTimeChanged(void); 131 133 132 134 /** … … 134 136 @return Returns the size of the NotificationQueue. 135 137 */ 136 inline unsigned int getSize( ) const138 inline unsigned int getSize(void) const 137 139 { return this->size_; } 138 140 … … 141 143 @return Returns a set of strings holding the different targets. 142 144 */ 143 inline const std::set<std::string> & getTargetsSet( )145 inline const std::set<std::string> & getTargetsSet(void) 144 146 { return this->targets_; } 145 147 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: 152 182 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 153 183 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 157 191 unsigned int maxSize_; //!< The maximal number of Notifications displayed. 158 192 unsigned int size_; //!< The number of Notifications displayed. 159 unsignedint displayTime_; //!< The time a Notification is displayed.193 int displayTime_; //!< The time a Notification is displayed. 160 194 161 195 bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already. … … 169 203 NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 170 204 171 void create(void); //!< Creates the NotificationQueue in lua.172 173 205 void setName(const std::string& name); //!< Sets the name of the NotificationQueue. 174 206 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.