Changeset 8524
- Timestamp:
- May 21, 2011, 4:23:19 AM (13 years ago)
- Location:
- code/branches/unity_build/src/libraries
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/unity_build/src/libraries/core/ConfigValueIncludes.h
r7401 r8524 255 255 ModifyConfigValueGeneric(this, &varname, #varname, modifier, __VA_ARGS__) 256 256 257 /** Modifies a runtime configurable value by using a modifier and some arguments. 258 If the container for the value doesn't yet exist, a warning is displayed. 259 Also, the @a variable argument will be modified and set to the current value. 260 @param variable 261 Pointer to the variable where the value should be written to 262 @param entryName 263 Name of the entry in the ini file (e.g. [MySection] myValue) 264 @param modifier 265 On of these functions: set, tset, add, remove, reset, update 266 @param ... 267 Arguments for the modifier function 268 */ 269 #define ModifyConfigValueExternal(variable, entryName, modifier, ...) \ 270 ModifyConfigValueGeneric(this, &variable, entryName, modifier, __VA_ARGS__) 271 257 272 #endif /* _ConfigValueIncludes_H__ */ -
code/branches/unity_build/src/libraries/core/Core.cc
r8520 r8524 69 69 #include "Language.h" 70 70 #include "LuaState.h" 71 #include "ObjectList.h" 71 72 #include "command/ConsoleCommand.h" 72 73 #include "command/IOConsole.h" … … 229 230 } 230 231 231 namespace DefaultLogLevels 232 { 233 struct List 234 { 235 OutputLevel::Value logFile; 236 OutputLevel::Value ioConsole; 237 OutputLevel::Value inGameConsole; 238 }; 239 240 using namespace OutputLevel; 241 static const List Dev = { Debug, Info, Info }; 242 static const List User = { Info, Error, Error }; 232 namespace DefaultLevelLogFile 233 { 234 const OutputLevel::Value Dev = OutputLevel::Debug; 235 const OutputLevel::Value User = OutputLevel::Info; 243 236 } 244 237 … … 246 239 void Core::setConfigValues() 247 240 { 248 // Choose the default level saccording to the path Orxonox was started (build directory or not)249 DefaultLogLevels::List defaultLogLevels = (PathConfig::buildDirectoryRun() ? DefaultLogLevels::Dev : DefaultLogLevels::User);250 251 SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile _", defaultLogLevels.logFile)241 // Choose the default level according to the path Orxonox was started (build directory or not) 242 OutputLevel::Value defaultLogLevel = (PathConfig::buildDirectoryRun() ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User); 243 244 SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile", defaultLogLevel) 252 245 .description("The maximum level of debug output written to the log file"); 253 246 OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_); 254 255 SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelIOConsole_", defaultLogLevels.ioConsole)256 .description("The maximum level of debug output shown in the IO console");257 OutputHandler::getInstance().setSoftDebugLevel("IOConsole", debugLevelIOConsole_);258 // In case we don't start the IOConsole, also configure that simple listener259 OutputHandler::getInstance().setSoftDebugLevel("Console", debugLevelIOConsole_);260 261 SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelInGameConsole_", defaultLogLevels.inGameConsole)262 .description("The maximum level of debug output shown in the in-game console");263 OutputHandler::getInstance().setSoftDebugLevel("InGameConsole", debugLevelInGameConsole_);264 247 265 248 SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun()) … … 290 273 immediately change the debug levels to predefined values which can be 291 274 reconfigured with \c tconfig. 275 @note 276 The debug levels for the IOConsole and the InGameConsole can be found 277 in the Shell class. The same rules apply. 292 278 */ 293 279 void Core::devModeChanged() … … 296 282 if (isNormal) 297 283 { 298 ModifyConfigValue(debugLevelLogFile_, update); 299 ModifyConfigValue(debugLevelIOConsole_, update); 300 ModifyConfigValue(debugLevelInGameConsole_, update); 284 ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update); 301 285 } 302 286 else 303 287 { 304 DefaultLogLevels::List levels = (bDevMode_ ? DefaultLogLevels::Dev : DefaultLogLevels::User); 305 ModifyConfigValue(debugLevelLogFile_, tset, levels.logFile); 306 ModifyConfigValue(debugLevelIOConsole_, tset, levels.ioConsole); 307 ModifyConfigValue(debugLevelInGameConsole_, tset, levels.inGameConsole); 308 } 288 OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User); 289 ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level); 290 } 291 292 // Inform listeners 293 ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin(); 294 for (; it != ObjectList<DevModeListener>::end(); ++it) 295 it->devModeChanged(bDevMode_); 309 296 } 310 297 … … 491 478 ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL))); 492 479 } 480 481 482 DevModeListener::DevModeListener() 483 { 484 RegisterRootObject(DevModeListener); 485 } 493 486 } -
code/branches/unity_build/src/libraries/core/Core.h
r8519 r8524 53 53 namespace orxonox 54 54 { 55 //! Informs about changes in the Development Mode. 56 class DevModeListener : virtual public OrxonoxClass 57 { 58 public: 59 DevModeListener(); 60 virtual ~DevModeListener() {} 61 virtual void devModeChanged(bool value) = 0; 62 }; 63 55 64 /** 56 65 @brief … … 130 139 bool bGraphicsLoaded_; 131 140 int debugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler) 132 int debugLevelIOConsole_; //!< The debug level for the IO console (belongs to OutputHandler)133 int debugLevelInGameConsole_; //!< The debug level for the in game console (belongs to OutputHandler)134 141 std::string language_; //!< The language 135 142 bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called -
code/branches/unity_build/src/libraries/core/command/Shell.cc
r8518 r8524 40 40 #include "core/ConfigFileManager.h" 41 41 #include "core/ConfigValueIncludes.h" 42 #include "core/PathConfig.h" 42 43 #include "CommandExecutor.h" 43 44 #include "ConsoleCommand.h" … … 87 88 for (;it != OutputHandler::getInstance().getOutput().end(); ++it) 88 89 { 89 if (it->first <= this->getSoftDebugLevel())90 if (it->first <= debugLevel_) 90 91 { 91 92 this->outputBuffer_ << it->second; … … 96 97 // Register the shell as output listener 97 98 OutputHandler::getInstance().registerOutputListener(this); 99 OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_); 98 100 } 99 101 … … 105 107 OutputHandler::getInstance().unregisterOutputListener(this); 106 108 this->inputBuffer_->destroy(); 109 } 110 111 namespace DefaultLogLevel 112 { 113 const OutputLevel::Value Dev = OutputLevel::Info; 114 const OutputLevel::Value User = OutputLevel::Error; 107 115 } 108 116 … … 118 126 setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>()); 119 127 SetConfigValue(cacheSize_s, 32); 128 129 // Choose the default level according to the path Orxonox was started (build directory or not) 130 OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User); 131 SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel) 132 .description("The maximum level of debug output shown in the " + consoleName_); 133 OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_); 120 134 } 121 135 … … 141 155 this->commandHistory_.erase(this->commandHistory_.begin() + index); 142 156 ModifyConfigValue(commandHistory_, remove, index); 157 } 158 } 159 160 /** Called upon changes in the development mode (by Core) 161 Behaviour details see Core::devModeChanged. 162 */ 163 void Shell::devModeChanged(bool value) 164 { 165 bool isNormal = (value == PathConfig::buildDirectoryRun()); 166 if (isNormal) 167 { 168 ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, update); 169 } 170 else 171 { 172 OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User); 173 ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level); 143 174 } 144 175 } -
code/branches/unity_build/src/libraries/core/command/Shell.h
r8522 r8524 49 49 50 50 #include "util/OutputHandler.h" 51 #include "core/Core.h" 51 52 #include "core/OrxonoxClass.h" 52 53 #include "core/input/InputBuffer.h" … … 85 86 Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole. 86 87 */ 87 class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener 88 class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener, public DevModeListener 88 89 { 89 90 public: … … 148 149 Shell(const Shell& other); 149 150 151 // DevModeListener 152 void devModeChanged(bool value); 153 150 154 void addToHistory(const std::string& command); 151 155 const std::string& getFromHistory() const; … … 198 202 unsigned int historyOffset_; ///< The command history is a circular buffer, this variable defines the current write-offset 199 203 std::vector<std::string> commandHistory_; ///< The history of commands that were entered by the user 204 int debugLevel_; //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output) 200 205 static unsigned int cacheSize_s; ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass 201 206 }; -
code/branches/unity_build/src/libraries/util/OutputHandler.h
r8522 r8524 256 256 //! Returns the name of this output listener 257 257 const std::string& getOutputListenerName() const { return this->name_; } 258 //! Returns the soft debug level of the listener259 int getSoftDebugLevel() const { return this->softDebugLevel_; }260 258 261 259 protected:
Note: See TracChangeset
for help on using the changeset viewer.