Changeset 8515 for code/branches/unity_build/src
- Timestamp:
- May 20, 2011, 3:53:21 AM (14 years ago)
- Location:
- code/branches/unity_build/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/unity_build/src/libraries/core/command/Shell.cc
r8079 r8515 84 84 85 85 // Get the previous output and add it to the Shell 86 for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin();87 it != OutputHandler::getInstance().getOutputVectorEnd(); ++it)86 OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin(); 87 for (;it != OutputHandler::getInstance().getOutput().end(); ++it) 88 88 { 89 89 if (it->first <= this->getSoftDebugLevel()) -
code/branches/unity_build/src/libraries/util/OutputHandler.cc
r7401 r8515 147 147 OutputListener that writes all the output piece by piece to an array 148 148 associated with the corresponding output level. 149 Used as buffer until all output devices have been initialised. 149 150 @note 150 Only output below or equal to the current soft debug level is written151 to minimise huge arrays for the normal run.151 At some point, OutputHandler::disableMemoryLog() has to be called in 152 order to avoid large memory footprints of this class. 152 153 */ 153 154 class MemoryLogWriter : public OutputListener … … 156 157 friend class OutputHandler; 157 158 158 /**159 @brief160 Sets the right soft debug level and registers itself161 */162 159 MemoryLogWriter() 163 160 : OutputListener("memoryLog") … … 166 163 } 167 164 168 //! Push edthe just written output to the internal array165 //! Push the just written output to the internal array 169 166 void outputChanged(int level) 170 167 { … … 180 177 181 178 private: 182 std::ostringstream 183 std::vector<std::pair<int, std::string> >output_; //!< Vector containing ALL output179 std::ostringstream buffer_; //!< Stream object used to process the output 180 OutputHandler::OutputVector output_; //!< Vector containing ALL output 184 181 }; 185 182 … … 212 209 this->registerOutputListener(this->consoleWriter_); 213 210 214 this-> output_ = new MemoryLogWriter();215 // W e capture as much input as the listener with the highest level216 this-> output_->softDebugLevel_ = getSoftDebugLevel();217 this->registerOutputListener(this-> output_);211 this->memoryBuffer_ = new MemoryLogWriter(); 212 // Write everything, e.g. use hardDebugLevel 213 this->memoryBuffer_->softDebugLevel_ = hardDebugLevel; 214 this->registerOutputListener(this->memoryBuffer_); 218 215 } 219 216 … … 223 220 delete this->logFile_; 224 221 delete this->consoleWriter_; 225 delete this-> output_;222 delete this->memoryBuffer_; // Might already be NULL 226 223 } 227 224 … … 267 264 } 268 265 269 OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorBegin() const 270 { 271 return this->output_->output_.begin(); 272 } 273 274 OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorEnd() const 275 { 276 return this->output_->output_.end(); 266 void OutputHandler::disableMemoryLog() 267 { 268 this->unregisterOutputListener(this->memoryBuffer_); 269 // Only clear the buffer so we can still reference the vector 270 this->memoryBuffer_->output_.clear(); 271 } 272 273 const OutputHandler::OutputVector& OutputHandler::getOutput() const 274 { 275 return this->memoryBuffer_->output_; 277 276 } 278 277 -
code/branches/unity_build/src/libraries/util/OutputHandler.h
r7401 r8515 103 103 { return OutputHandler::getInstance().setOutputLevel(level); } 104 104 105 typedef std::vector<std::pair<int, std::string> >::const_iterator OutputVectorIterator; 106 //! Returns an iterator to the beginning of the all-output vector 107 OutputVectorIterator getOutputVectorBegin() const; 108 //! Returns an iterator to the end of the all-output vector 109 OutputVectorIterator getOutputVectorEnd() const; 105 typedef std::vector<std::pair<int, std::string> > OutputVector; 106 //! Returns all output written so far (empty if disableMemoryLog() was called) 107 const OutputVector& getOutput() const; 110 108 111 109 //! Writes to all output devices … … 140 138 //! Enables the std::cout stream for output (startup behaviour) 141 139 void enableCout(); 140 //! Stop writing to the memory buffer (call this as soon as possible to minimise memory usage) 141 void disableMemoryLog(); 142 142 143 143 //! Sets the level of the incoming output and returns the OutputHandler … … 225 225 LogFileWriter* logFile_; //!< Listener that writes to the log file 226 226 ConsoleWriter* consoleWriter_; //!< Listener for std::cout (just program beginning) 227 MemoryLogWriter* output_; //!< Listener that Stores ALL output below the current soft debug level227 MemoryLogWriter* memoryBuffer_; //!< Writes to memory as a buffer (can/must be stopped at some time) 228 228 static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access 229 229 }; -
code/branches/unity_build/src/orxonox/overlays/InGameConsole.cc
r8079 r8515 91 91 this->setConfigValues(); 92 92 this->initialise(); 93 94 // Output buffering is not anymore needed. Not the best solution to do 95 // this here, but there isn't much of another way. 96 OutputHandler::getInstance().disableMemoryLog(); 93 97 } 94 98
Note: See TracChangeset
for help on using the changeset viewer.