- Timestamp:
- May 20, 2011, 3:58:29 AM (14 years ago)
- Location:
- code/branches/unity_build/src/libraries/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/unity_build/src/libraries/util/OutputHandler.cc
r8515 r8516 231 231 void OutputHandler::registerOutputListener(OutputListener* listener) 232 232 { 233 for (std:: list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)233 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 234 234 { 235 235 if ((*it)->name_ == listener->name_) … … 240 240 } 241 241 this->listeners_.push_back(listener); 242 // Update global soft debug level 243 this->setSoftDebugLevel(listener->getOutputListenerName(), listener->getSoftDebugLevel()); 242 this->updateGlobalDebugLevel(); 244 243 } 245 244 246 245 void OutputHandler::unregisterOutputListener(OutputListener* listener) 247 246 { 248 this->listeners_.remove(listener); 247 for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 248 { 249 if ((*it)->name_ == listener->name_) 250 { 251 this->listeners_.erase(it); 252 break; 253 } 254 } 255 this->updateGlobalDebugLevel(); 249 256 } 250 257 … … 278 285 int OutputHandler::getSoftDebugLevel(const std::string& name) const 279 286 { 280 for (std:: list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)287 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 281 288 { 282 289 if ((*it)->name_ == name) … … 288 295 void OutputHandler::setSoftDebugLevel(const std::string& name, int level) 289 296 { 290 int globalSoftDebugLevel = -1; 291 for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 297 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 292 298 { 293 299 if ((*it)->name_ == name) 294 300 (*it)->softDebugLevel_ = level; 295 if ((*it)->softDebugLevel_ > globalSoftDebugLevel) 296 globalSoftDebugLevel = (*it)->softDebugLevel_; 297 } 298 // Update global soft debug level 301 } 302 this->updateGlobalDebugLevel(); 303 } 304 305 void OutputHandler::updateGlobalDebugLevel() 306 { 307 int globalSoftDebugLevel = -1; 308 std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); 309 for (; it != this->listeners_.end(); ++it) 310 globalSoftDebugLevel = std::max(globalSoftDebugLevel, (*it)->softDebugLevel_); 311 299 312 OutputHandler::softDebugLevel_s = globalSoftDebugLevel; 300 313 } -
code/branches/unity_build/src/libraries/util/OutputHandler.h
r8515 r8516 39 39 #include "UtilPrereqs.h" 40 40 41 #include <list>42 41 #include <ostream> 43 42 #include <string> … … 221 220 OutputHandler(const OutputHandler& rhs); //!< Copy-constructor: Unused and undefined 222 221 223 std::list<OutputListener*> listeners_; //!< Array with all registered output listeners 224 int outputLevel_; //!< The level of the incoming output 225 LogFileWriter* logFile_; //!< Listener that writes to the log file 226 ConsoleWriter* consoleWriter_; //!< Listener for std::cout (just program beginning) 227 MemoryLogWriter* memoryBuffer_; //!< Writes to memory as a buffer (can/must be stopped at some time) 228 static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access 222 /// Evaluates the maximum global log level 223 void updateGlobalDebugLevel(); 224 225 std::vector<OutputListener*> listeners_; //!< Array with all registered output listeners 226 int outputLevel_; //!< The level of the incoming output 227 LogFileWriter* logFile_; //!< Writes output to the log file 228 ConsoleWriter* consoleWriter_; //!< Writes to std::cout (can be disabled) 229 MemoryLogWriter* memoryBuffer_; //!< Writes to memory as a buffer (can/must be stopped at some time) 230 static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access 229 231 }; 230 232 … … 271 273 inline OutputHandler& OutputHandler::output(const T& output) 272 274 { 273 for (std:: list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)275 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 274 276 { 275 277 if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
Note: See TracChangeset
for help on using the changeset viewer.