Changeset 1586 for code/branches/core3/src/util
- Timestamp:
- Jun 10, 2008, 3:35:50 PM (16 years ago)
- Location:
- code/branches/core3/src/util
- Files:
-
- 4 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/util/CMakeLists.txt
r1505 r1586 7 7 MultiTypeString.cc 8 8 MultiTypeMath.cc 9 OutputBuffer.cc 10 OutputHandler.cc 9 11 String.cc 10 12 SubString.cc -
code/branches/core3/src/util/Convert.h
r1505 r1586 41 41 42 42 #include "Math.h" 43 #include "Debug.h" 43 44 #include "SubString.h" 44 45 #include "MultiTypeMath.h" … … 74 75 enum { specialized = false }; 75 76 static bool convert(ToType* output, const FromType& input) 76 { return false; } 77 { 78 COUT(2) << "Warning: Couldn't convert a value." << std::endl; 79 return false; 80 } 77 81 }; 78 82 … … 139 143 static bool convert(ToType* output, const FromType& input) 140 144 { 145 COUT(2) << "Warning: Couldn't convert a value." << std::endl; 141 146 return false; 142 147 } -
code/branches/core3/src/util/Debug.h
r1585 r1586 37 37 #define _Debug_H__ 38 38 39 #include " CorePrereqs.h"39 #include "UtilPrereqs.h" 40 40 41 41 #include <stdio.h> … … 43 43 #include "OutputHandler.h" 44 44 45 extern "C" _CoreExport int getSoftDebugLevel(); 45 46 /** 47 @brief Returns the soft debug level, stored in the only existing instance of the OutputHandler class, configured in the config-file. 48 @return The soft debug level 49 */ 50 static inline int getSoftDebugLevel() 51 { 52 return orxonox::OutputHandler::getSoftDebugLevel(); 53 } 54 46 55 47 56 // DEFINE ERROR MODES -
code/branches/core3/src/util/OutputBuffer.h
r1574 r1586 34 34 #include <iostream> 35 35 36 #include " CorePrereqs.h"36 #include "UtilPrereqs.h" 37 37 38 38 namespace orxonox 39 39 { 40 class _ CoreExport OutputBufferListener40 class _UtilExport OutputBufferListener 41 41 { 42 42 friend class OutputBuffer; … … 49 49 }; 50 50 51 class _ CoreExport OutputBuffer51 class _UtilExport OutputBuffer 52 52 { 53 53 public: … … 59 59 { 60 60 this->stream_ << object; 61 this->callListeners(); 62 return *this; 63 } 64 65 template <const OutputBuffer&> 66 inline OutputBuffer& operator<<(const OutputBuffer& object) 67 { 68 this->stream_ << object.stream_; 61 69 this->callListeners(); 62 70 return *this; … … 97 105 void unregisterListener(OutputBufferListener* listener); 98 106 107 inline std::stringstream& getStream() 108 { return this->stream_; } 109 99 110 private: 100 111 void callListeners(); -
code/branches/core3/src/util/OutputHandler.cc
r1574 r1586 33 33 34 34 #include "OutputHandler.h" 35 #include "Core.h"36 #include "ConsoleCommand.h"37 #include "Shell.h"38 35 39 36 namespace orxonox 40 37 { 41 SetConsoleCommandShortcutGeneric(log, createConsoleCommand(createFunctor(&OutputHandler::log), "log" ));42 SetConsoleCommandShortcutGeneric(error, createConsoleCommand(createFunctor(&OutputHandler::error), "error" ));43 SetConsoleCommandShortcutGeneric(warning, createConsoleCommand(createFunctor(&OutputHandler::warning), "warning"));44 SetConsoleCommandShortcutGeneric(info, createConsoleCommand(createFunctor(&OutputHandler::info), "info" ));45 SetConsoleCommandShortcutGeneric(debug, createConsoleCommand(createFunctor(&OutputHandler::debug), "debug" ));46 47 38 /** 48 39 @brief Constructor: Opens the logfile and writes the first line. … … 51 42 OutputHandler::OutputHandler(const std::string& logfilename) 52 43 { 44 this->outputBuffer_ = &this->fallbackBuffer_; 45 this->softDebugLevel_[0] = this->softDebugLevel_[1] = this->softDebugLevel_[2] = this->softDebugLevel_[3] = 2; 53 46 this->logfilename_ = logfilename; 54 47 this->logfile_.open(this->logfilename_.c_str(), std::fstream::out); … … 77 70 78 71 /** 72 @brief Sets the soft debug level for a given output device. 73 @param device The output device 74 @param level The debug level 75 */ 76 void OutputHandler::setSoftDebugLevel(OutputHandler::OutputDevice device, int level) 77 { 78 OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device] = level; 79 } 80 81 /** 79 82 @brief Returns the soft debug level for a given output device. 80 83 @param device The output device … … 83 86 int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device) 84 87 { 85 return Core::getSoftDebugLevel(device);88 return OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device]; 86 89 } 87 90 88 91 /** 89 @brief Returns the Shell's OutputBuffer. This is mere placed here to avoid 90 recompiling the entire project when Shell.h changes. 91 @return The OutputBuffer of the Shell 92 @brief Sets the OutputBuffer, representing the third output stream. 93 @param buffer The OutputBuffer 92 94 */ 93 OutputBuffer& OutputHandler::getShellOutputBuffer()95 void OutputHandler::setOutputBuffer(OutputBuffer& buffer) 94 96 { 95 return Shell::getInstance().getOutputBuffer(); 97 buffer.getStream() >> this->outputBuffer_->getStream().rdbuf(); 98 this->outputBuffer_ = &buffer; 96 99 } 97 100 … … 113 116 114 117 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_) 115 Shell::getInstance().getOutputBuffer() << sb;118 (*this->outputBuffer_) << sb; 116 119 117 120 return *this; … … 135 138 136 139 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_) 137 Shell::getInstance().getOutputBuffer() << manipulator;140 (*this->outputBuffer_) << manipulator; 138 141 139 142 return *this; … … 157 160 158 161 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_) 159 Shell::getInstance().getOutputBuffer() << manipulator;162 (*this->outputBuffer_) << manipulator; 160 163 161 164 return *this; … … 179 182 180 183 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_) 181 Shell::getInstance().getOutputBuffer() << manipulator;184 (*this->outputBuffer_) << manipulator; 182 185 183 186 return *this; -
code/branches/core3/src/util/OutputHandler.h
r1574 r1586 38 38 #define _OutputHandler_H__ 39 39 40 #include " CorePrereqs.h"40 #include "UtilPrereqs.h" 41 41 42 42 #include <iostream> … … 49 49 { 50 50 //! The OutputHandler acts like std::cout, but redirects output to the console AND the logfile. 51 class _ CoreExport OutputHandler51 class _UtilExport OutputHandler 52 52 { 53 53 public: 54 54 enum OutputDevice 55 55 { 56 LD_All ,57 LD_Console ,58 LD_Logfile ,59 LD_Shell 56 LD_All = 0, 57 LD_Console = 1, 58 LD_Logfile = 2, 59 LD_Shell = 3 60 60 }; 61 61 … … 86 86 { return this->logfile_; } 87 87 88 /** @brief Returns a pointer to the OutputBuffer. @return The OutputBuffer */ 89 inline OutputBuffer* getOutputBuffer() 90 { return this->outputBuffer_; } 91 88 92 /** @brief Sets the level of the incoming output. @param level The level of the incoming output @return The OutputHandler itself */ 89 93 inline OutputHandler& setOutputLevel(int level) … … 94 98 { return this->outputLevel_; } 95 99 96 static int getSoftDebugLevel(OutputHandler::OutputDevice device); 97 98 OutputBuffer& getShellOutputBuffer(); 100 static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); 101 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 102 103 void setOutputBuffer(OutputBuffer& buffer); 99 104 100 105 template <class T> … … 136 141 OutputHandler(const OutputHandler& oh); // don't copy 137 142 virtual ~OutputHandler(); 138 std::ofstream logfile_; //!< The logfile where the output is logged 139 std::string logfilename_; //!< The name of the logfile 140 int outputLevel_; //!< The level of the incoming output 143 144 std::ofstream logfile_; //!< The logfile where the output is logged 145 std::string logfilename_; //!< The name of the logfile 146 OutputBuffer fallbackBuffer_; //!< The OutputBuffer that gets used if there is no other OutputBuffer 147 OutputBuffer* outputBuffer_; //!< The OutputBuffer to put output in (usually used by the Shell) 148 int outputLevel_; //!< The level of the incoming output 149 int softDebugLevel_[4]; //!< The soft debug level for each OutputDevice - the configurable maximal output level 141 150 }; 142 151 … … 159 168 160 169 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_) 161 OutputHandler::getOutStream().getShellOutputBuffer() << output;170 (*this->outputBuffer_) << output; 162 171 163 172 return *this; … … 183 192 184 193 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= out.getOutputLevel()) 185 OutputHandler::getOutStream().getShellOutputBuffer() << output;194 (*out.getOutputBuffer()) << output; 186 195 187 196 return out; 188 197 } 189 190 198 } 191 199 -
code/branches/core3/src/util/String.h
r1505 r1586 129 129 std::string input = "3.14"; 130 130 float f; 131 bool success = string2Number(&f, input);131 bool success = FromString(&f, input); 132 132 */ 133 133 template <typename T> … … 151 151 std::string input = "3.14"; 152 152 float f; 153 bool success = string2Number(&f, input, 0.000000);153 bool success = FromString(&f, input, 0.000000); 154 154 */ 155 155 template <typename T> -
code/branches/core3/src/util/UtilPrereqs.h
r1505 r1586 65 65 class MultiTypeString; 66 66 class MultiTypeMath; 67 template <class T> 68 class String2Number; 67 class OutputHandler; 69 68 class SubString; 70 69 70 namespace orxonox 71 { 72 class OutputBuffer; 73 class OutputBufferListener; 74 } 75 71 76 #endif /* _UtilPrereqs_H__ */
Note: See TracChangeset
for help on using the changeset viewer.