Changeset 8729 for code/trunk/src
- Timestamp:
- Jul 4, 2011, 2:47:44 AM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 90 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/CMakeLists.txt
r8420 r8729 65 65 REMOVE_LINKER_FLAGS("-INCREMENTAL:YES" Debug) 66 66 ADD_LINKER_FLAGS ("-INCREMENTAL:NO" Debug) 67 ENDIF()68 IF(NOT DISABLE_COMPILATIONS)69 # Compilations seem to generate 'memory leaks' with static variables70 MESSAGE("Warning: You should disable Compilations when using VLD!")71 67 ENDIF() 72 68 ENDIF() … … 149 145 ################### Tolua Bind ################## 150 146 151 # Create directory because the tolua application doesn't work otherwise 152 IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) 153 FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) 154 ENDIF() 155 156 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) 147 # Add hook script to the lua code that generates the bindings 148 SET(TOLUA_PARSER_HOOK_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/ToluaInterfaceHook.lua) 149 SET(TOLUA_PARSER_DEPENDENCIES ${TOLUA_PARSER_DEPENDENCIES} ${TOLUA_PARSER_HOOK_SCRIPT}) 157 150 158 151 ################ Sub Directories ################ -
code/trunk/src/OrxonoxConfig.cmake
r8412 r8729 34 34 ENDIF() 35 35 36 # Global switch to disable multiple file compilations 37 OPTION(DISABLE_COMPILATIONS "Global multi-file compilation switch" FALSE) 36 # Global option to steer building muliple files as a single one 37 # off/false: Turn off completely 38 # partial: Only combine files explicitly specified with BUILD_UNIT 39 # full##: Use ## source files per orxonox library and use manual build units 40 # for external dependencies. Example: full8 will in general use 8 41 # source files per library, but more specifically tries to occupy 42 # 8 CPU threads. 43 # This is configured manually in BuildUnitsConfig.cmake 44 SET(ENABLE_BUILD_UNITS "partial" CACHE STRING "Enables building multiple source files as one.") 45 IF(ENABLE_BUILD_UNITS) 46 IF(NOT "${ENABLE_BUILD_UNITS}" STREQUAL "partial") 47 STRING(REGEX REPLACE "^full([1-9][0-9]?)$" "\\1" _nr_of_units "${ENABLE_BUILD_UNITS}") 48 IF("${_nr_of_units}" STREQUAL "${ENABLE_BUILD_UNITS}") # Regex match failed 49 MESSAGE(FATAL_ERROR "Unrecognised option for ENABLE_BUILD_UNITS: ${ENABLE_BUILD_UNITS}") 50 ELSE() 51 SET(NR_OF_BUILD_UNITS ${_nr_of_units}) 52 IF(NOT HAVE_COUNTER_MACRO) 53 MESSAGE(WARNING "Your compiler doesn't support the __COUNTER__ macro. Full build units might not work!") 54 ENDIF() 55 ENDIF() 56 ENDIF() 57 IF(CMAKE_COMPILER_IS_GNU) 58 INCLUDE(BuildUnitsConfigGCC.cmake) 59 ELSEIF(MSVC) 60 INCLUDE(BuildUnitsConfigMSVC.cmake) 61 ENDIF() 62 ENDIF() 38 63 39 64 # Use WinMain() or main()? -
code/trunk/src/external/bullet/BulletCollision/CMakeLists.txt
r8393 r8729 1 1 ADD_SOURCE_FILES(BULLET_FILES 2 3 COMPILATION_BEGIN BulletCollisionCompilation.cpp4 2 5 3 BroadphaseCollision/btAxisSweep3.cpp … … 84 82 NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp 85 83 NarrowPhaseCollision/btPersistentManifold.cpp 84 NarrowPhaseCollision/btPolyhedralContactClipping.cpp 86 85 NarrowPhaseCollision/btRaycastCallback.cpp 87 86 NarrowPhaseCollision/btSubSimplexConvexCast.cpp 88 87 NarrowPhaseCollision/btVoronoiSimplexSolver.cpp 89 88 90 COMPILATION_END91 92 # Raises compiler errors when compiled inside the compilation93 NarrowPhaseCollision/btPolyhedralContactClipping.cpp94 89 95 90 # Headers -
code/trunk/src/external/bullet/BulletDynamics/CMakeLists.txt
r8351 r8729 1 1 ADD_SOURCE_FILES(BULLET_FILES 2 3 COMPILATION_BEGIN BulletDynamicsCompilation.cpp4 2 5 3 Character/btKinematicCharacterController.cpp … … 25 23 Vehicle/btRaycastVehicle.cpp 26 24 Vehicle/btWheelInfo.cpp 27 28 COMPILATION_END29 25 30 26 # Headers -
code/trunk/src/external/bullet/CMakeLists.txt
r8393 r8729 32 32 VERSION 33 33 2.78 34 EXCLUDE_FROM_BUILD_UNITS 35 BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp 34 36 SOURCE_FILES 35 37 ${BULLET_FILES} -
code/trunk/src/external/bullet/LinearMath/CMakeLists.txt
r8393 r8729 1 1 ADD_SOURCE_FILES(BULLET_FILES 2 2 3 COMPILATION_BEGIN BulletLinearMathCompilation.cpp4 3 btAlignedAllocator.cpp 5 4 btConvexHull.cpp 6 5 btConvexHullComputer.cpp 7 6 btGeometryUtil.cpp 8 7 btQuickprof.cpp 9 8 btSerializer.cpp 10 COMPILATION_END11 9 12 10 # Headers … … 15 13 btAlignedObjectArray.h 16 14 btConvexHull.h 17 15 btConvexHullComputer.h 18 16 btDefaultMotionState.h 19 17 btGeometryUtil.h -
code/trunk/src/external/enet/CMakeLists.txt
r8351 r8729 29 29 win32.h 30 30 31 COMPILATION_BEGIN ENetCompilation.c32 31 callbacks.c 33 32 compress.c … … 39 38 unix.c 40 39 win32.c 41 COMPILATION_END42 40 ) 43 41 -
code/trunk/src/external/ogreceguirenderer/CMakeLists.txt
r8351 r8729 23 23 OgreCEGUITexture.h 24 24 25 COMPILATION_BEGIN OgreCEGUIRendererCompilation.cpp26 25 OgreCEGUIRenderer.cpp 27 26 OgreCEGUIResourceProvider.cpp 28 27 OgreCEGUITexture.cpp 29 COMPILATION_END30 28 ) 31 29 -
code/trunk/src/external/ois/CMakeLists.txt
r8351 r8729 35 35 OISPrereqs.h 36 36 37 #COMPILATION_BEGIN OISCompilation.cpp38 37 OISEffect.cpp 39 38 OISException.cpp … … 43 42 OISKeyboard.cpp 44 43 OISObject.cpp 45 #COMPILATION_END46 44 ) 45 47 46 IF(WIN32) 48 47 ADD_SUBDIRECTORY(win32) … … 56 55 IF(MINGW) 57 56 INCLUDE_DIRECTORIES(${WMI_INCLUDE_DIR}) 57 ENDIF() 58 59 # Apple has problems with OIS and build units 60 IF(APPLE) 61 SET(USE_BUILD_UNITS NO_BUILD_UNITS) 58 62 ENDIF() 59 63 … … 72 76 LINK_LIBS_LINUX 73 77 X11 78 ${USE_BUILD_UNITS} 74 79 SOURCE_FILES 75 80 ${OIS_FILES} -
code/trunk/src/external/ois/linux/CMakeLists.txt
r5929 r8729 8 8 LinuxPrereqs.h 9 9 10 COMPILATION_BEGIN OISLinuxCompilation.cpp11 10 EventHelpers.cpp 12 11 LinuxForceFeedback.cpp … … 15 14 LinuxKeyboard.cpp 16 15 LinuxMouse.cpp 17 COMPILATION_END18 16 ) -
code/trunk/src/external/ois/mac/CMakeLists.txt
r8351 r8729 8 8 MacPrereqs.h 9 9 10 #COMPILATION_BEGIN OISMacCompilation.cpp11 10 MacHelpers.cpp 12 11 MacHIDManager.cpp … … 15 14 MacKeyboard.cpp 16 15 MacMouse.cpp 17 #COMPILATION_END18 16 ) -
code/trunk/src/external/ois/win32/CMakeLists.txt
r5929 r8729 7 7 Win32Prereqs.h 8 8 9 COMPILATION_BEGIN OISWin32Compilation.cpp10 9 Win32ForceFeedback.cpp 11 10 Win32InputManager.cpp … … 13 12 Win32KeyBoard.cpp 14 13 Win32Mouse.cpp 15 COMPILATION_END16 14 ) -
code/trunk/src/external/tinyxml/CMakeLists.txt
r8351 r8729 24 24 tinyxml.h 25 25 26 COMPILATION_BEGIN TicppCompilation.cpp27 26 ticpp.cpp 28 27 tinystr.cpp … … 30 29 tinyxmlerror.cpp 31 30 tinyxmlparser.cpp 32 COMPILATION_END33 31 ) 34 32 -
code/trunk/src/external/tolua/lua/basic.lua
r5738 r8729 354 354 end 355 355 356 356 -- called after all the required C++ includes have been written 357 function post_include_hook(package_name) 358 end -
code/trunk/src/external/tolua/lua/package.lua
r8363 r8729 135 135 i = i+1 136 136 end 137 138 post_include_hook(self.name) 137 139 138 140 output('\n') -
code/trunk/src/libraries/core/CMakeLists.txt
r8351 r8729 19 19 20 20 SET_SOURCE_FILES(CORE_SRC_FILES 21 22 #BUILD_UNIT CoreStableBuildUnit.cc 23 ClassTreeMask.cc 21 24 CommandLineParser.cc 22 25 ConfigValueContainer.cc 23 Core.cc24 26 DynLib.cc 25 27 DynLibManager.cc … … 28 30 GameMode.cc 29 31 GameState.cc 30 GraphicsManager.cc 31 GUIManager.cc 32 Identifier.cc 32 33 Language.cc 34 Loader.cc 33 35 LuaState.cc 36 MetaObjectList.cc 37 Namespace.cc 38 NamespaceNode.cc 34 39 ObjectListBase.cc 35 40 OrxonoxClass.cc 36 Resource.cc37 38 # hierarchy39 Identifier.cc40 MetaObjectList.cc41 42 # level43 BaseObject.cc44 ClassTreeMask.cc45 Loader.cc46 Namespace.cc47 NamespaceNode.cc48 41 Template.cc 49 XMLPort.cc50 51 COMPILATION_BEGIN ListenerCompilation.cc52 42 ViewportEventListener.cc 53 43 WindowEventListener.cc 54 44 XMLNameListener.cc 55 COMPILATION_END 45 XMLPort.cc 46 #END_BUILD_UNIT 56 47 57 COMPILATION_BEGIN FilesystemCompilation.cc 48 BaseObject.cc 49 Core.cc 50 51 BUILD_UNIT OgreBuildUnit.cc 52 GraphicsManager.cc 53 GUIManager.cc 54 Resource.cc 55 END_BUILD_UNIT 56 57 BUILD_UNIT FilesystemBuildUnit.cc 58 58 command/ArgumentCompletionFunctions.cc 59 59 ConfigFileManager.cc 60 60 PathConfig.cc 61 COMPILATION_END 61 END_BUILD_UNIT 62 62 63 # multithreading 64 ThreadPool.cc 65 COMPILATION_BEGIN ThreadCompilation.cc 63 BUILD_UNIT ThreadBuildUnit.cc 66 64 command/TclThreadManager.cc 67 65 Thread.cc 68 COMPILATION_END 66 ThreadPool.cc 67 END_BUILD_UNIT 69 68 ) 70 69 -
code/trunk/src/libraries/core/CommandLineParser.cc
r7401 r8729 41 41 namespace orxonox 42 42 { 43 SetCommandLineOnlyArgument(optionsFile, "start.ini").shortcut("o");44 45 43 /** 46 44 @brief … … 50 48 so that you can have simple command line switches. 51 49 */ 52 void CommandLineArgument::parse(const std::string& value, bool bParsingFile) 53 { 54 if (bParsingFile && this->bCommandLineOnly_) 55 ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files."); 50 void CommandLineArgument::parse(const std::string& value) 51 { 56 52 if (value_.getType() == MT_Type::Bool) 57 53 { … … 116 112 } 117 113 118 /** 119 @brief 120 Reads the command line parses the values of each argument. 121 It is then stored in the corresponding CommandLineArgument. 114 /** Parses the command line string for arguments and stores these. 122 115 @note 123 116 The reason that you have to provide the string to be parsed as 124 space separ ted list is because of argc and argv. If you only have117 space separated list is because of argc and argv. If you only have 125 118 a whole string, simply use getAllStrings() of SubString. 126 @param arguments 127 Vector of space separated strings. 128 @param bParsingFile 129 Parsing a file or the command line itself 130 */ 131 void CommandLineParser::_parse(const std::vector<std::string>& arguments, bool bParsingFile) 132 { 119 @param cmdLine 120 Command line string WITHOUT the execution path. 121 */ 122 void CommandLineParser::_parse(const std::string& cmdLine) 123 { 124 std::vector<std::string> arguments; 125 SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false); 126 for (unsigned i = 0; i < tokens.size(); ++i) 127 arguments.push_back(tokens[i]); 128 133 129 try 134 130 { … … 177 173 if (!name.empty()) 178 174 { 179 checkFullArgument(name, value , bParsingFile);175 checkFullArgument(name, value); 180 176 name.clear(); 181 177 assert(shortcut.empty()); … … 183 179 else if (!shortcut.empty()) 184 180 { 185 checkShortcut(shortcut, value , bParsingFile);181 checkShortcut(shortcut, value); 186 182 shortcut.clear(); 187 183 assert(name.empty()); … … 222 218 if (!name.empty()) 223 219 { 224 checkFullArgument(name, value , bParsingFile);220 checkFullArgument(name, value); 225 221 assert(shortcut.empty()); 226 222 } 227 223 else if (!shortcut.empty()) 228 224 { 229 checkShortcut(shortcut, value , bParsingFile);225 checkShortcut(shortcut, value); 230 226 assert(name.empty()); 231 227 } … … 233 229 catch (const ArgumentException& ex) 234 230 { 235 COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl;231 COUT(0) << "Could not parse command line: " << ex.what() << std::endl; 236 232 COUT(0) << CommandLineParser::getUsageInformation() << std::endl; 237 233 throw GeneralException(""); … … 249 245 Parsing a file or the command line itself 250 246 */ 251 void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value , bool bParsingFile)247 void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value) 252 248 { 253 249 std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name); … … 255 251 ThrowException(Argument, "Command line argument '" + name + "' does not exist."); 256 252 257 it->second->parse(value , bParsingFile);253 it->second->parse(value); 258 254 } 259 255 … … 268 264 Parsing a file or the command line itself 269 265 */ 270 void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value , bool bParsingFile)266 void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value) 271 267 { 272 268 std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut); … … 274 270 ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist."); 275 271 276 it->second->parse(value , bParsingFile);272 it->second->parse(value); 277 273 } 278 274 … … 342 338 } 343 339 } 344 345 /**346 @brief347 Parses only the command line for CommandLineArguments.348 */349 void CommandLineParser::_parseCommandLine(const std::string& cmdLine)350 {351 std::vector<std::string> args;352 SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);353 for (unsigned i = 0; i < tokens.size(); ++i)354 args.push_back(tokens[i]);355 this->_parse(args, false);356 }357 358 /**359 @brief360 Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.361 */362 void CommandLineParser::_parseFile()363 {364 const std::string& filename = CommandLineParser::getValue("optionsFile").getString();365 366 // look for additional arguments in given file or start.ini as default367 // They will not overwrite the arguments given directly368 std::ifstream file;369 file.open((PathConfig::getConfigPathString() + filename).c_str());370 std::vector<std::string> args;371 if (file)372 {373 while (!file.eof())374 {375 std::string line;376 std::getline(file, line);377 line = removeTrailingWhitespaces(line);378 //if (!(line[0] == '#' || line[0] == '%'))379 //{380 SubString tokens(line, " ", " ", false, '\\', true, '"', true, '\0', '\0', false, '#');381 for (unsigned i = 0; i < tokens.size(); ++i)382 if (tokens[i][0] != '#')383 args.push_back(tokens[i]);384 //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());385 //}386 }387 file.close();388 }389 390 _parse(args, true);391 }392 340 } -
code/trunk/src/libraries/core/CommandLineParser.h
r7401 r8729 51 51 #define SetCommandLineArgument(name, defaultValue) \ 52 52 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 53 = orxonox::CommandLineParser::addArgument(#name, defaultValue, false) 54 #define SetCommandLineOnlyArgument(name, defaultValue) \ 55 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 56 = orxonox::CommandLineParser::addArgument(#name, defaultValue, true) 53 = orxonox::CommandLineParser::addArgument(#name, defaultValue) 57 54 #define SetCommandLineSwitch(name) \ 58 55 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 59 = orxonox::CommandLineParser::addArgument(#name, false, false) 60 #define SetCommandLineOnlySwitch(name) \ 61 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 62 = orxonox::CommandLineParser::addArgument(#name, false, true) 63 56 = orxonox::CommandLineParser::addArgument(#name, false) 64 57 65 58 namespace orxonox … … 106 99 107 100 //! Returns the actual value of the argument. Can be equal to default value. 108 MultiTypegetValue() const { return value_; }101 const MultiType& getValue() const { return value_; } 109 102 //! Returns the given default value as type T. 110 MultiTypegetDefaultValue() const { return defaultValue_; }103 const MultiType& getDefaultValue() const { return defaultValue_; } 111 104 112 105 private: 113 106 //! Constructor initialises both value_ and defaultValue_ with defaultValue. 114 CommandLineArgument(const std::string& name, const MultiType& defaultValue , bool bCommandLineOnly)107 CommandLineArgument(const std::string& name, const MultiType& defaultValue) 115 108 : bHasDefaultValue_(true) 116 109 , name_(name) 117 110 , value_(defaultValue) 118 111 , defaultValue_(defaultValue) 119 , bCommandLineOnly_(bCommandLineOnly)120 112 { } 121 113 … … 125 117 126 118 //! Parses the value string of a command line argument. 127 void parse(const std::string& value , bool bParsingFile);119 void parse(const std::string& value); 128 120 129 121 //! Tells whether the value has been changed by the command line. … … 137 129 MultiType value_; //!< The actual value 138 130 MultiType defaultValue_; //!< Default value. Should not be changed. 139 bool bCommandLineOnly_; //!< Whether you cannot specify the value in a text file140 131 }; 141 132 … … 155 146 156 147 //! Parse redirection to internal member method. 157 static void parse CommandLine(const std::string& cmdLine) { _getInstance()._parseCommandLine(cmdLine); }158 static void parseFile() { _getInstance()._parseFile(); }148 static void parse(const std::string& cmdLine) 149 { _getInstance()._parse(cmdLine); } 159 150 160 151 static std::string getUsageInformation(); … … 165 156 static void getValue(const std::string& name, T* value) 166 157 { *value = (T)(getArgument(name)->getValue()); } 167 static MultiTypegetValue(const std::string& name)158 static const MultiType& getValue(const std::string& name) 168 159 { return getArgument(name)->getValue(); } 169 160 template <class T> 170 static CommandLineArgument& addArgument(const std::string& name, T defaultValue , bool bCommandLineOnly);161 static CommandLineArgument& addArgument(const std::string& name, T defaultValue); 171 162 172 163 static bool existsArgument(const std::string& name) … … 189 180 static CommandLineParser& _getInstance(); 190 181 191 void _parseCommandLine(const std::string& cmdLine); 192 void _parseFile(); 193 void _parse(const std::vector<std::string>& arguments, bool bParsingFile); 194 void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile); 195 void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile); 182 void _parse(const std::string& cmdLine); 183 void checkFullArgument(const std::string& name, const std::string& value); 184 void checkShortcut(const std::string& shortcut, const std::string& value); 196 185 197 186 /** … … 222 211 @param defaultValue 223 212 Default value that is used when argument was not given. 224 @param bCommandLineOnly225 Parsing a file or the command line itself226 213 */ 227 214 template <class T> 228 CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue , bool bCommandLineOnly)215 CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue) 229 216 { 230 217 OrxAssert(!_getInstance().existsArgument(name), … … 234 221 << "Please use SetCommandLineSwitch and adjust your argument: " << name); 235 222 236 return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue , bCommandLineOnly));223 return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue)); 237 224 } 238 225 } -
code/trunk/src/libraries/core/ConfigValueIncludes.h
r7401 r8729 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/trunk/src/libraries/core/Core.cc
r8505 r8729 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" … … 131 132 132 133 // Parse command line arguments AFTER the modules have been loaded (static code!) 133 CommandLineParser::parse CommandLine(cmdLine);134 CommandLineParser::parse(cmdLine); 134 135 135 136 // Set configurable paths like log, config and media … … 143 144 // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used 144 145 OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString()); 145 146 // Parse additional options file now that we know its path147 CommandLineParser::parseFile();148 146 149 147 #ifdef ORXONOX_PLATFORM_WINDOWS … … 168 166 RegisterRootObject(Core); 169 167 this->setConfigValues(); 168 // Rewrite the log file with the correct log levels 169 OutputHandler::getInstance().rewriteLogFile(); 170 170 171 171 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN) … … 230 230 } 231 231 232 namespace DefaultLevelLogFile 233 { 234 const OutputLevel::Value Dev = OutputLevel::Debug; 235 const OutputLevel::Value User = OutputLevel::Info; 236 } 237 232 238 //! Function to collect the SetConfigValue-macro calls. 233 239 void Core::setConfigValues() 234 240 { 235 #ifdef ORXONOX_RELEASE 236 const unsigned int defaultLevelLogFile = 3; 237 #else 238 const unsigned int defaultLevelLogFile = 4; 239 #endif 240 SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile) 241 .description("The maximum level of debug output shown in the log file"); 242 OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_); 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) 245 .description("The maximum level of debug output written to the log file"); 246 OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_); 243 247 244 248 SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun()) 245 .description("Developer mode. If not set, hides some things from the user to not confuse him."); 249 .description("Developer mode. If not set, hides some things from the user to not confuse him.") 250 .callback(this, &Core::devModeChanged); 246 251 SetConfigValue(language_, Language::getInstance().defaultLanguage_) 247 252 .description("The language of the in game text") … … 258 263 } 259 264 265 /** Callback function for changes in the dev mode that affect debug levels. 266 The function behaves according to these rules: 267 - 'normal' mode is defined based on where the program was launched: if 268 the launch path was the build directory, development mode \c on is 269 normal, otherwise normal means development mode \c off. 270 - Debug levels should not be hard configured (\c config instead of 271 \c tconfig) in non 'normal' mode to avoid strange behaviour. 272 - Changing the development mode from 'normal' to the other state will 273 immediately change the debug levels to predefined values which can be 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. 278 */ 279 void Core::devModeChanged() 280 { 281 bool isNormal = (bDevMode_ == PathConfig::buildDirectoryRun()); 282 if (isNormal) 283 { 284 ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update); 285 } 286 else 287 { 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_); 296 } 297 260 298 //! Callback function if the language has changed. 261 299 void Core::languageChanged() … … 440 478 ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL))); 441 479 } 480 481 482 DevModeListener::DevModeListener() 483 { 484 RegisterRootObject(DevModeListener); 485 } 442 486 } -
code/trunk/src/libraries/core/Core.h
r8423 r8729 45 45 46 46 #include <string> 47 #include <loki/ScopeGuard.h>48 49 47 #include "util/DestructionHelper.h" 50 48 #include "util/Singleton.h" … … 53 51 namespace orxonox 54 52 { 53 //! Informs about changes in the Development Mode. 54 class DevModeListener : virtual public OrxonoxClass 55 { 56 public: 57 DevModeListener(); 58 virtual ~DevModeListener() {} 59 virtual void devModeChanged(bool value) = 0; 60 }; 61 55 62 /** 56 63 @brief … … 101 108 Core(const Core&); //!< Don't use (undefined symbol) 102 109 110 void devModeChanged(); 103 111 void languageChanged(); 104 112 void initRandomNumberGenerator(); … … 128 136 129 137 bool bGraphicsLoaded_; 130 int softDebugLevelLogFile_;//!< The debug level for the log file (belongs to OutputHandler)138 int debugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler) 131 139 std::string language_; //!< The language 132 140 bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called -
code/trunk/src/libraries/core/CoreIncludes.h
r8706 r8729 80 80 #include "util/Debug.h" 81 81 #include "Identifier.h" 82 #include "SubclassIdentifier.h"83 82 #include "ClassFactory.h" 84 83 #include "ObjectList.h" -
code/trunk/src/libraries/core/EventIncludes.h
r7401 r8729 37 37 38 38 #include "CorePrereqs.h" 39 40 #include "Event.h" 39 41 #include "XMLPort.h" 40 42 #include "command/Executor.h" -
code/trunk/src/libraries/core/GUIManager.cc
r8706 r8729 490 490 } 491 491 492 const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showCursor, TriBool::ValueuseKeyboard, bool bBlockJoyStick)492 const std::string& GUIManager::createInputState(const std::string& name, tribool showCursor, tribool useKeyboard, bool bBlockJoyStick) 493 493 { 494 494 InputState* state = InputManager::getInstance().createInputState(name); … … 506 506 #ifdef ORXONOX_PLATFORM_APPLE 507 507 // There is no non exclusive mode on OS X yet 508 state->setMouseExclusive( TriBool::True);509 #else 510 if (showCursor == TriBool::Dontcare)511 state->setMouseExclusive( TriBool::Dontcare);512 else if (GraphicsManager::getInstance().isFullScreen() || showCursor == TriBool::False)513 state->setMouseExclusive( TriBool::True);508 state->setMouseExclusive(true); 509 #else 510 if (showCursor == dontcare) 511 state->setMouseExclusive(dontcare); 512 else if (GraphicsManager::getInstance().isFullScreen() || showCursor == false) 513 state->setMouseExclusive(true); 514 514 else 515 state->setMouseExclusive( TriBool::False);516 #endif 517 518 if (showCursor == TriBool::True)515 state->setMouseExclusive(false); 516 #endif 517 518 if (showCursor == true) 519 519 state->setMouseHandler(this); 520 else if (showCursor == TriBool::False)520 else if (showCursor == false) 521 521 state->setMouseHandler(&InputHandler::EMPTY); 522 522 523 if (useKeyboard == TriBool::True)523 if (useKeyboard == true) 524 524 state->setKeyHandler(this); 525 else if (useKeyboard == TriBool::False)525 else if (useKeyboard == false) 526 526 state->setKeyHandler(&InputHandler::EMPTY); 527 527 … … 717 717 } 718 718 719 /** Helper method to get the developer's mode without having to export Core.h. 720 @see Core::inDevMode 721 */ 722 /*static*/ bool GUIManager::inDevMode() 723 { 724 return Core::getInstance().inDevMode(); 725 } 726 719 727 /** 720 728 @brief Callback of window event listener, called if the window is resized. Sets the display size of CEGUI. -
code/trunk/src/libraries/core/GUIManager.h
r8706 r8729 39 39 40 40 #include <map> 41 #include <set>42 41 #include <string> 43 42 #include <CEGUIForwardRefs.h> … … 47 46 #include "util/DestructionHelper.h" 48 47 #include "util/OgreForwardRefs.h" 49 #include "util/ TriBool.h"48 #include "util/tribool.h" 50 49 #include "util/Singleton.h" 51 50 #include "input/InputHandler.h" 52 #include "Core.h"53 51 #include "OrxonoxClass.h" 54 52 #include "WindowEventListener.h" 55 56 // Tolua includes (have to be relative to the current directory)57 /*58 $cfile "../util/TriBool.h" // tolua_export59 */60 53 61 54 #if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7 … … 66 59 { // tolua_export 67 60 class PlayerInfo; // Forward declaration 61 62 // Acquaint Tolua with tribool 63 /* tolua_begin 64 struct dontcare_keyword_t 65 { 66 dontcare_keyword_t(); 67 }; 68 class tribool 69 { 70 tribool(bool value); 71 tribool(dontcare_keyword_t); 72 bool operator==(tribool); 73 }; 74 tolua_end */ 68 75 69 76 /** … … 104 111 void setBackgroundImage(const std::string& image); 105 112 106 /** 107 @brief Helper method to get the developer's mode without having to export Core.h. 108 @see Core::inDevMode 109 */ 110 static bool inDevMode(void) { return Core::getInstance().inDevMode(); } // tolua_export 113 static bool inDevMode(void); // tolua_export 111 114 112 115 //! Creates a new InputState to be used with a GUI Sheet 113 const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export116 const std::string& createInputState(const std::string& name, tribool showCursor = tribool(true), tribool useKeyboard = tribool(true), bool bBlockJoyStick = false); // tolua_export 114 117 LuaState* getLuaState(void) 115 118 { return this->luaState_; } -
code/trunk/src/libraries/core/Game.cc
r8706 r8729 109 109 110 110 // Do this after the Core creation! 111 ClassIdentifier<Game>::getIdentifier("Game")->initialiseObject(this, "Game", true);111 RegisterRootObject(Game); 112 112 this->setConfigValues(); 113 113 -
code/trunk/src/libraries/core/LuaState.cc
r8351 r8729 40 40 #include "util/Exception.h" 41 41 #include "Resource.h" 42 #include "ToluaBindCore.h"43 42 #include "command/IOConsole.h" 44 43 45 44 namespace orxonox 46 45 { 47 LuaState::ToluaInterfaceMap LuaState::toluaInterfaces_s;48 std::vector<LuaState*> LuaState::instances_s;49 50 46 const std::string LuaState::ERROR_HANDLER_NAME = "errorHandler"; 51 52 // Do this after declaring toluaInterfaces_s and instances_s to avoid larger problems53 DeclareToluaInterface(Core);54 47 55 48 LuaState::LuaState() … … 277 270 } 278 271 272 /*static*/ LuaState::ToluaInterfaceMap& LuaState::getToluaInterfaces() 273 { 274 static ToluaInterfaceMap p; 275 return p; 276 } 277 278 /*static*/ std::vector<LuaState*>& LuaState::getInstances() 279 { 280 static std::vector<LuaState*> p; 281 return p; 282 } 283 279 284 /*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name) 280 285 { 281 for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)286 for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it) 282 287 { 283 288 if (it->first == name || it->second == function) … … 287 292 } 288 293 } 289 toluaInterfaces_s[name] = function;294 getToluaInterfaces()[name] = function; 290 295 291 296 // Open interface in all LuaStates 292 for (std::vector<LuaState*>::const_iterator it = instances_s.begin(); it != instances_s.end(); ++it)297 for (std::vector<LuaState*>::const_iterator it = getInstances().begin(); it != getInstances().end(); ++it) 293 298 (*function)((*it)->luaState_); 294 299 … … 299 304 /*static*/ bool LuaState::removeToluaInterface(const std::string& name) 300 305 { 301 ToluaInterfaceMap::iterator it = toluaInterfaces_s.find(name);302 if (it == toluaInterfaces_s.end())306 ToluaInterfaceMap::iterator it = getToluaInterfaces().find(name); 307 if (it == getToluaInterfaces().end()) 303 308 { 304 309 COUT(2) << "Warning: Cannot remove Tolua interface '" << name << "': Not found" << std::endl; … … 307 312 308 313 // Close interface in all LuaStates 309 for (std::vector<LuaState*>::const_iterator itState = instances_s.begin(); itState != instances_s.end(); ++itState)314 for (std::vector<LuaState*>::const_iterator itState = getInstances().begin(); itState != getInstances().end(); ++itState) 310 315 { 311 316 lua_pushnil((*itState)->luaState_); … … 314 319 315 320 // Remove entry 316 toluaInterfaces_s.erase(it);321 getToluaInterfaces().erase(it); 317 322 318 323 // Return dummy bool … … 322 327 /*static*/ void LuaState::openToluaInterfaces(lua_State* state) 323 328 { 324 for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)329 for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it) 325 330 (*it->second)(state); 326 331 } … … 328 333 /*static*/ void LuaState::closeToluaInterfaces(lua_State* state) 329 334 { 330 for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)335 for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it) 331 336 { 332 337 lua_pushnil(state); -
code/trunk/src/libraries/core/LuaState.h
r8351 r8729 48 48 #include <vector> 49 49 #include <boost/shared_ptr.hpp> 50 #include <loki/ScopeGuard.h>51 52 #include "ToluaInterface.h"53 50 54 51 namespace orxonox // tolua_export … … 121 118 122 119 typedef std::map<std::string, int (*)(lua_State *L)> ToluaInterfaceMap; 123 static ToluaInterfaceMap toluaInterfaces_s;124 static std::vector<LuaState*> instances_s;120 static ToluaInterfaceMap& getToluaInterfaces(); 121 static std::vector<LuaState*>& getInstances(); 125 122 }; // tolua_export 123 124 125 //! Helper class that registers/unregisters tolua bindings 126 class ToluaBindingsHelper 127 { 128 public: 129 ToluaBindingsHelper(int (*function)(lua_State*), const std::string& libraryName) 130 : libraryName_(libraryName) 131 { 132 LuaState::addToluaInterface(function, libraryName_); 133 } 134 ~ToluaBindingsHelper() 135 { 136 LuaState::removeToluaInterface(libraryName_); 137 } 138 private: 139 std::string libraryName_; 140 }; 126 141 } // tolua_export 127 142 -
code/trunk/src/libraries/core/ObjectListBase.h
r7401 r8729 41 41 42 42 #include "CorePrereqs.h" 43 44 43 #include <vector> 45 #include "OrxonoxClass.h"46 44 47 45 namespace orxonox -
code/trunk/src/libraries/core/OrxonoxClass.h
r8351 r8729 45 45 46 46 #include "CorePrereqs.h" 47 #include "Super.h"48 47 49 48 #include <set> 50 49 #include <vector> 50 #include "Super.h" 51 51 52 52 /** -
code/trunk/src/libraries/core/PathConfig.cc
r8366 r8729 74 74 75 75 SetCommandLineArgument(externalDataPath, "").information("Path to the external data files"); 76 SetCommandLine OnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");76 SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files"); 77 77 78 78 PathConfig::PathConfig() -
code/trunk/src/libraries/core/Super.h
r8706 r8729 73 73 74 74 #include "CorePrereqs.h" 75 76 75 #include "util/Debug.h" 77 #include "Event.h"78 76 79 77 /////////////////////// -
code/trunk/src/libraries/core/ViewportEventListener.h
r8079 r8729 30 30 #define _ViewportEventListener_H__ 31 31 32 #include "CorePrereqs.h" 33 32 34 #include "util/OgreForwardRefs.h" 33 34 #include "CorePrereqs.h"35 35 #include "OrxonoxClass.h" 36 36 -
code/trunk/src/libraries/core/command/Functor.h
r8706 r8729 114 114 #define _Functor_H__ 115 115 116 #include "core/CorePrereqs.h" 117 116 118 #include <typeinfo> 117 118 #include "core/CorePrereqs.h"119 119 120 120 #include "util/Debug.h" -
code/trunk/src/libraries/core/command/IOConsolePOSIX.cc
r7422 r8729 236 236 void IOConsole::printOutputLine(const std::string& text, Shell::LineType type) 237 237 { 238 /*239 238 // Colour line 240 239 switch (type) 241 240 { 242 case Shell::None: this->cout_ << "\033[37m"; break;243 241 case Shell::Error: this->cout_ << "\033[91m"; break; 244 case Shell::Warning: this->cout_ << "\033[31m"; break; 245 case Shell::Info: this->cout_ << "\033[34m"; break; 246 case Shell::Debug: this->cout_ << "\033[36m"; break; 247 case Shell::Verbose: this->cout_ << "\033[35m"; break; 248 case Shell::Ultra: this->cout_ << "\033[37m"; break; 242 case Shell::Warning: this->cout_ << "\033[93m"; break; 243 case Shell::Info: this->cout_ << "\033[90m"; break; 244 case Shell::Debug: this->cout_ << "\033[90m"; break; 245 case Shell::Verbose: this->cout_ << "\033[90m"; break; 246 case Shell::Ultra: this->cout_ << "\033[90m"; break; 247 case Shell::Command: this->cout_ << "\033[36m"; break; 248 case Shell::Hint: this->cout_ << "\033[33m"; break; 249 case Shell::TDebug: this->cout_ << "\033[95m"; break; 249 250 default: break; 250 251 } 251 */252 252 253 253 // Print output line 254 254 this->cout_ << text; 255 255 256 // Reset colour to white257 // this->cout_ << "\033[37m";256 // Reset colour atributes 257 this->cout_ << "\033[0m"; 258 258 } 259 259 -
code/trunk/src/libraries/core/command/IOConsoleWindows.cc
r7287 r8729 208 208 case Shell::Command: colour = FOREGROUND_GREEN | FOREGROUND_BLUE; break; 209 209 case Shell::Hint: colour = FOREGROUND_GREEN | FOREGROUND_RED ; break; 210 case Shell::TDebug: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE; break; 210 211 default: colour = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break; 211 212 } -
code/trunk/src/libraries/core/command/IOConsoleWindows.h
r7401 r8729 39 39 #include <sstream> 40 40 #include <string> 41 #include <vector>42 41 #include "util/Singleton.h" 43 42 #include "Shell.h" -
code/trunk/src/libraries/core/command/Shell.cc
r8706 r8729 34 34 #include "Shell.h" 35 35 36 #include "util/Math.h" 36 37 #include "util/OutputHandler.h" 37 38 #include "util/StringUtils.h" … … 40 41 #include "core/ConfigFileManager.h" 41 42 #include "core/ConfigValueIncludes.h" 43 #include "core/PathConfig.h" 44 #include "core/input/InputBuffer.h" 42 45 #include "CommandExecutor.h" 43 46 #include "ConsoleCommand.h" … … 84 87 85 88 // Get the previous output and add it to the Shell 86 for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin();87 it != OutputHandler::getInstance().getOutputVectorEnd(); ++it)88 { 89 if (it->first <= this->getSoftDebugLevel())89 OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin(); 90 for (;it != OutputHandler::getInstance().getOutput().end(); ++it) 91 { 92 if (it->first <= debugLevel_) 90 93 { 91 94 this->outputBuffer_ << it->second; … … 96 99 // Register the shell as output listener 97 100 OutputHandler::getInstance().registerOutputListener(this); 101 OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_); 98 102 } 99 103 … … 105 109 OutputHandler::getInstance().unregisterOutputListener(this); 106 110 this->inputBuffer_->destroy(); 111 } 112 113 namespace DefaultLogLevel 114 { 115 const OutputLevel::Value Dev = OutputLevel::Info; 116 const OutputLevel::Value User = OutputLevel::Error; 107 117 } 108 118 … … 119 129 SetConfigValue(cacheSize_s, 32); 120 130 121 #ifdef ORXONOX_RELEASE 122 const unsigned int defaultLevel = 1; 123 #else 124 const unsigned int defaultLevel = 3; 125 #endif 126 SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel) 127 .description("The maximal level of debug output shown in the Shell"); 128 this->setSoftDebugLevel(this->softDebugLevel_); 131 // Choose the default level according to the path Orxonox was started (build directory or not) 132 OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User); 133 SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel) 134 .description("The maximum level of debug output shown in the " + consoleName_); 135 OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_); 129 136 } 130 137 … … 150 157 this->commandHistory_.erase(this->commandHistory_.begin() + index); 151 158 ModifyConfigValue(commandHistory_, remove, index); 159 } 160 } 161 162 /** Called upon changes in the development mode (by Core) 163 Behaviour details see Core::devModeChanged. 164 */ 165 void Shell::devModeChanged(bool value) 166 { 167 bool isNormal = (value == PathConfig::buildDirectoryRun()); 168 if (isNormal) 169 { 170 ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, update); 171 } 172 else 173 { 174 OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User); 175 ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level); 152 176 } 153 177 } … … 215 239 } 216 240 241 /// Returns the current position of the cursor in the input buffer. 242 unsigned int Shell::getCursorPosition() const 243 { 244 return this->inputBuffer_->getCursorPosition(); 245 } 246 247 /// Returns the current content of the input buffer (the text which was entered by the user) 248 const std::string& Shell::getInput() const 249 { 250 return this->inputBuffer_->get(); 251 } 252 217 253 /** 218 254 @brief Sends output to the internal output buffer. -
code/trunk/src/libraries/core/command/Shell.h
r7401 r8729 49 49 50 50 #include "util/OutputHandler.h" 51 #include "core/Core.h" 51 52 #include "core/OrxonoxClass.h" 52 #include "core/input/InputBuffer.h"53 53 54 54 namespace orxonox … … 85 85 Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole. 86 86 */ 87 class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener87 class _CoreExport Shell : public OutputListener, public DevModeListener 88 88 { 89 89 public: … … 91 91 enum LineType 92 92 { 93 TDebug = OutputLevel::TDebug, 93 94 None = OutputLevel::None, 94 95 Warning = OutputLevel::Warning, … … 118 119 119 120 void setCursorPosition(unsigned int cursor); 120 /// Returns the current position of the cursor in the input buffer. 121 inline unsigned int getCursorPosition() const 122 { return this->inputBuffer_->getCursorPosition(); } 123 124 /// Returns the current content of the input buffer (the text which was entered by the user) 125 inline const std::string& getInput() const 126 { return this->inputBuffer_->get(); } 121 unsigned int getCursorPosition() const; 122 123 const std::string& getInput() const; 127 124 128 125 typedef std::list<std::pair<std::string, LineType> > LineList; … … 146 143 private: 147 144 Shell(const Shell& other); 145 146 // DevModeListener 147 void devModeChanged(bool value); 148 148 149 149 void addToHistory(const std::string& command); … … 197 197 unsigned int historyOffset_; ///< The command history is a circular buffer, this variable defines the current write-offset 198 198 std::vector<std::string> commandHistory_; ///< The history of commands that were entered by the user 199 int softDebugLevel_; ///< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)199 int debugLevel_; //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output) 200 200 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 201 }; -
code/trunk/src/libraries/core/input/InputHandler.h
r6746 r8729 31 31 32 32 #include "InputPrereqs.h" 33 #include "util/Math.h"34 33 35 34 namespace orxonox 36 35 { 36 /// A Vector class containing two integers @a x and @a y. 37 class IntVector2 38 { 39 public: 40 IntVector2() : x(0), y(0) { } 41 IntVector2(int _x, int _y) : x(_x), y(_y) { } 42 int x; 43 int y; 44 }; 45 37 46 namespace ButtonEvent 38 47 { -
code/trunk/src/libraries/core/input/InputManager.cc
r8351 r8729 94 94 , oisInputManager_(0) 95 95 , devices_(2) 96 , exclusiveMouse_( TriBool::False)96 , exclusiveMouse_(false) 97 97 , emptyState_(0) 98 98 , calibratorCallbackHandler_(0) … … 108 108 109 109 if (GraphicsManager::getInstance().isFullScreen()) 110 exclusiveMouse_ = TriBool::True;110 exclusiveMouse_ = true; 111 111 this->loadDevices(); 112 112 … … 161 161 paramList.insert(StringPair("w32_keyboard", "DISCL_FOREGROUND")); 162 162 paramList.insert(StringPair("w32_mouse", "DISCL_FOREGROUND")); 163 if (exclusiveMouse_ == TriBool::True|| GraphicsManager::getInstance().isFullScreen())163 if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen()) 164 164 { 165 165 // Disable Windows key plus special keys (like play, stop, next, etc.) … … 174 174 paramList.insert(StringPair("XAutoRepeatOn", "true")); 175 175 176 if (exclusiveMouse_ == TriBool::True|| GraphicsManager::getInstance().isFullScreen())176 if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen()) 177 177 { 178 178 if (CommandLineParser::getValue("keyboard_no_grab").getBool()) … … 447 447 448 448 // Check whether we have to change the mouse mode 449 TriBool::Value requestedMode = TriBool::Dontcare;449 tribool requestedMode = dontcare; 450 450 std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef(); 451 451 if (mouseStates.empty()) 452 requestedMode = TriBool::False;452 requestedMode = false; 453 453 else 454 454 requestedMode = mouseStates.front()->getMouseExclusive(); 455 if (requestedMode != TriBool::Dontcare && exclusiveMouse_ != requestedMode) 456 { 457 exclusiveMouse_ = requestedMode; 455 if (requestedMode != dontcare && exclusiveMouse_ != requestedMode) 456 { 457 assert(requestedMode != dontcare); 458 exclusiveMouse_ = (requestedMode == true); 458 459 if (!GraphicsManager::getInstance().isFullScreen()) 459 460 this->reloadInternal(); … … 644 645 } 645 646 646 bool InputManager::setMouseExclusive(const std::string& name, TriBool::Valuevalue)647 bool InputManager::setMouseExclusive(const std::string& name, tribool value) 647 648 { 648 649 if (name == "empty") -
code/trunk/src/libraries/core/input/InputManager.h
r8079 r8729 33 33 34 34 #include <map> 35 #include <set>36 35 #include <string> 37 36 #include <vector> … … 39 38 40 39 #include "util/Singleton.h" 41 #include "util/ TriBool.h"40 #include "util/tribool.h" 42 41 #include "core/WindowEventListener.h" 43 42 … … 169 168 True if the call was successful, fals if the name was not found 170 169 */ 171 bool setMouseExclusive(const std::string& name, TriBool::Valuevalue); // tolua_export170 bool setMouseExclusive(const std::string& name, tribool value); // tolua_export 172 171 173 172 //------------------------------- … … 215 214 OIS::InputManager* oisInputManager_; //!< OIS input manager 216 215 std::vector<InputDevice*> devices_; //!< List of all input devices (keyboard, mouse, joy sticks) 217 TriBool::ValueexclusiveMouse_; //!< Currently applied mouse mode216 bool exclusiveMouse_; //!< Currently applied mouse mode 218 217 219 218 // some internally handled states and handlers -
code/trunk/src/libraries/core/input/InputPrereqs.h
r6746 r8729 41 41 #include <ois/OISKeyboard.h> 42 42 #include <ois/OISMouse.h> 43 #include <ois/OISJoyStick.h>44 43 #include "util/OrxEnum.h" 45 44 -
code/trunk/src/libraries/core/input/InputState.cc
r7284 r8729 37 37 , bAlwaysGetsInput_(bAlwaysGetsInput) 38 38 , bTransparent_(bTransparent) 39 , exclusiveMouse_( TriBool::Dontcare)39 , exclusiveMouse_(dontcare) 40 40 , bExpired_(true) 41 41 , handlers_(2) -
code/trunk/src/libraries/core/input/InputState.h
r8351 r8729 38 38 #include <boost/bind.hpp> 39 39 40 #include "util/ TriBool.h"40 #include "util/tribool.h" 41 41 #include "InputHandler.h" 42 42 #include "InputManager.h" … … 112 112 void setHandler (InputHandler* handler); 113 113 114 void setMouseExclusive( TriBool::Valuevalue) { exclusiveMouse_ = value; this->bExpired_ = true; }115 TriBool::ValuegetMouseExclusive() const { return exclusiveMouse_; }114 void setMouseExclusive(tribool value) { exclusiveMouse_ = value; this->bExpired_ = true; } 115 tribool getMouseExclusive() const { return exclusiveMouse_; } 116 116 117 117 //! Returns the name of the state (which is unique!) … … 166 166 const bool bAlwaysGetsInput_; //!< See class declaration for explanation 167 167 const bool bTransparent_; //!< See class declaration for explanation 168 TriBool::ValueexclusiveMouse_; //!< See class declaration for explanation168 tribool exclusiveMouse_; //!< See class declaration for explanation 169 169 int priority_; //!< Current priority (might change) 170 170 bool bExpired_; //!< See hasExpired() -
code/trunk/src/libraries/core/input/JoyStick.h
r7809 r8729 34 34 #include <string> 35 35 #include <vector> 36 #include <ois/OISJoyStick.h> 36 37 #include "InputDevice.h" 37 38 -
code/trunk/src/libraries/core/input/JoyStickQuantityListener.h
r6417 r8729 36 36 37 37 #include "InputPrereqs.h" 38 39 #include <vector> 38 40 #include "core/OrxonoxClass.h" 39 41 -
code/trunk/src/libraries/core/input/KeyBinderManager.h
r7284 r8729 34 34 #include <map> 35 35 #include <string> 36 #include <boost/shared_ptr.hpp>37 36 38 37 #include "util/Singleton.h" -
code/trunk/src/libraries/core/input/KeyDetector.h
r7284 r8729 32 32 #include "InputPrereqs.h" 33 33 34 #include <boost/shared_ptr.hpp>35 34 #include "util/Singleton.h" 36 35 #include "KeyBinder.h" -
code/trunk/src/libraries/core/input/Keyboard.h
r8079 r8729 31 31 32 32 #include "InputPrereqs.h" 33 34 #include "InputHandler.h"35 33 #include "InputDevice.h" 36 34 -
code/trunk/src/libraries/core/input/Mouse.cc
r7284 r8729 37 37 // include this as last, X11 seems to define some macros... 38 38 #include <ois/linux/LinuxMouse.h> 39 #undef Success 39 40 #endif 40 41 -
code/trunk/src/libraries/network/WANDiscoverable.h
r8351 r8729 28 28 29 29 #include "NetworkPrereqs.h" 30 //#include "core/OrxonoxClass.h"30 #include "core/OrxonoxClass.h" 31 31 #include "core/CoreIncludes.h" 32 32 #include "MasterServerComm.h" -
code/trunk/src/libraries/network/packet/CMakeLists.txt
r7314 r8729 1 1 ADD_SOURCE_FILES(NETWORK_SRC_FILES 2 COMPILATION_BEGIN PacketCompilation.cc 2 3 BUILD_UNIT PacketBuildUnit.cc 3 4 Acknowledgement.cc 4 5 Chat.cc … … 10 11 Packet.cc 11 12 Welcome.cc 12 COMPILATION_END 13 END_BUILD_UNIT 14 13 15 ServerInformation.cc 14 16 ) -
code/trunk/src/libraries/tools/CMakeLists.txt
r8351 r8729 1 1 SET_SOURCE_FILES(TOOLS_SRC_FILES 2 COMPILATION_BEGIN ResourceCompilation.cc 2 3 BUILD_UNIT ResourceBuildUnit.cc 3 4 ResourceCollection.cc 4 5 ResourceLocation.cc 5 COMPILATION_END 6 END_BUILD_UNIT 7 6 8 TextureGenerator.cc 7 9 Timer.cc 8 COMPILATION_BEGIN OgreCompilation.cc 10 11 BUILD_UNIT OgreBuildUnit.cc 9 12 BillboardSet.cc 10 13 DynamicLines.cc … … 13 16 ParticleInterface.cc 14 17 Shader.cc 15 COMPILATION_END 18 END_BUILD_UNIT 16 19 ) 20 17 21 #ADD_SUBDIRECTORY(bsp) 18 22 ADD_SUBDIRECTORY(interfaces) -
code/trunk/src/libraries/tools/Shader.h
r8079 r8729 32 32 #include "tools/ToolsPrereqs.h" 33 33 34 #include < map>34 #include <list> 35 35 #include <string> 36 #include <vector>37 38 36 #include <OgreCompositorInstance.h> 39 37 40 38 #include "util/MultiType.h" 41 #include "util/OgreForwardRefs.h"42 39 #include "core/ViewportEventListener.h" 43 40 -
code/trunk/src/libraries/tools/Timer.cc
r8079 r8729 42 42 #include "core/command/ConsoleCommand.h" 43 43 #include "core/command/CommandExecutor.h" 44 #include "core/command/Executor.h" 44 45 #include "core/command/Functor.h" 45 46 #include "tools/interfaces/TimeFactorListener.h" … … 175 176 { 176 177 return TimeFactorListener::getTimeFactor(); 178 } 179 180 /** 181 @brief Initializes and starts the timer, which will call an executor after some time. 182 @param interval The timer-interval in seconds 183 @param bLoop If true, the executor gets called every @a interval seconds 184 @param executor The executor that will be called 185 @param bKillAfterCall If true, the timer will be deleted after the executor was called 186 */ 187 void Timer::setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall) 188 { 189 this->setInterval(interval); 190 this->bLoop_ = bLoop; 191 this->executor_ = executor; 192 this->bActive_ = true; 193 194 this->time_ = this->interval_; 195 this->bKillAfterCall_ = bKillAfterCall; 196 197 executor->getFunctor()->setSafeMode(true); 177 198 } 178 199 -
code/trunk/src/libraries/tools/Timer.h
r8079 r8729 80 80 81 81 #include "core/OrxonoxClass.h" 82 #include "core/command/Executor .h"82 #include "core/command/ExecutorPtr.h" 83 83 84 84 namespace orxonox … … 109 109 Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 110 110 111 /** 112 @brief Initializes and starts the timer, which will call an executor after some time. 113 @param interval The timer-interval in seconds 114 @param bLoop If true, the executor gets called every @a interval seconds 115 @param executor The executor that will be called 116 @param bKillAfterCall If true, the timer will be deleted after the executor was called 117 */ 118 void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false) 119 { 120 this->setInterval(interval); 121 this->bLoop_ = bLoop; 122 this->executor_ = executor; 123 this->bActive_ = true; 124 125 this->time_ = this->interval_; 126 this->bKillAfterCall_ = bKillAfterCall; 127 128 executor->getFunctor()->setSafeMode(true); 129 } 111 void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 130 112 131 113 void run(); -
code/trunk/src/libraries/util/CMakeLists.txt
r8351 r8729 19 19 20 20 SET_SOURCE_FILES(UTIL_SRC_FILES 21 COMPILATION_BEGIN StableCompilation.cc 21 22 BUILD_UNIT StableBuildUnit.cc 22 23 Clipboard.cc 23 24 Clock.cc … … 32 33 SmallObjectAllocator.cc 33 34 SubString.cc 34 COMPILATION_END 35 END_BUILD_UNIT 35 36 36 37 MultiType.cc … … 40 41 StringUtils.cc 41 42 ) 42 43 IF(MSVC)44 # Simply using #pragma warning(disable:4244) doesn't really disable it45 # if the warning occurs in a template in another file46 # Hence promote it manually to a higher warning level (4)47 SET_SOURCE_FILES_PROPERTIES(MultiType.cc PROPERTIES COMPILE_FLAGS "-w44244")48 ENDIF()49 43 50 44 ORXONOX_ADD_LIBRARY(util -
code/trunk/src/libraries/util/Convert.h
r8706 r8729 133 133 #include "ImplicitConversion.h" 134 134 135 // disable warnings about possible loss of data 136 #ifdef ORXONOX_COMPILER_MSVC 137 # pragma warning(push) 138 # pragma warning(disable:4244) 139 #endif 140 135 141 namespace orxonox 136 142 { … … 471 477 } 472 478 479 // Reinstate warnings 480 #ifdef ORXONOX_COMPILER_MSVC 481 # pragma warning(pop) 482 #endif 483 473 484 #endif /* _Convert_H__ */ -
code/trunk/src/libraries/util/Debug.h
r7401 r8729 83 83 #ifdef ORXONOX_RELEASE 84 84 const int hardDebugLevel = OutputLevel::Verbose; 85 #elif defined(NDEBUG)86 const int hardDebugLevel = OutputLevel::Verbose;87 85 #else 88 86 //! Maximum level for debug output that should be even processed at run time … … 125 123 orxonox::OutputHandler::getOutStream(level) 126 124 125 /** Logs debug output: You can use DOUT exactly like @c std::cout. 126 Use this macro to produce temporary debug output that will be removed later on. 127 The console output shall have a special colour if available. 128 */ 129 #define DOUT orxonox::OutputHandler::getOutStream(-1) << "+++ " 130 127 131 #endif /* _Util_Debug_H__ */ -
code/trunk/src/libraries/util/Math.h
r8706 r8729 299 299 300 300 _UtilExport unsigned long getUniqueNumber(); 301 302 /**303 @brief A Vector class containing two integers @a x and @a y.304 */305 class IntVector2306 {307 public:308 IntVector2() : x(0), y(0) { }309 IntVector2(int _x, int _y) : x(_x), y(_y) { }310 int x;311 int y;312 };313 314 /**315 @brief A Vector class containing three integers @a x, @a y, and @a z.316 */317 class IntVector3318 {319 public:320 IntVector3() : x(0), y(0), z(0) { }321 IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }322 int x;323 int y;324 int z;325 };326 301 } 327 302 -
code/trunk/src/libraries/util/OutputHandler.cc
r7401 r8729 69 69 */ 70 70 LogFileWriter() 71 : OutputListener( OutputHandler::logFileOutputListenerName_s)71 : OutputListener("LogFile") 72 72 { 73 73 // Get path for a temporary file … … 85 85 timeinfo = localtime(&rawtime); 86 86 87 this->logFile_.open(this->logFilename_.c_str(), std::fstream::out); 88 this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl; 89 this->logFile_.flush(); 90 91 this->outputStream_ = &this->logFile_; 87 this->openFile(); 88 if (this->logFile_.is_open()) 89 { 90 this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl; 91 this->logFile_.flush(); 92 } 92 93 } 93 94 … … 95 96 ~LogFileWriter() 96 97 { 97 this->logFile_ << "Closed log" << std::endl; 98 this->logFile_.close(); 98 if (this->logFile_.is_open()) 99 { 100 this->logFile_ << "Closed log" << std::endl; 101 this->logFile_.close(); 102 } 99 103 } 100 104 … … 102 106 void setLogPath(const std::string& path) 103 107 { 104 this->logFile_.close(); 105 // Read old file into a buffer 106 std::ifstream old(this->logFilename_.c_str()); 108 if (this->logFile_.is_open()) 109 this->logFile_.close(); 110 111 // Open the new file 107 112 this->logFilename_ = path + logFileBaseName_g; 108 // Open the new file and feed it the content of the old one 113 this->openFile(); 114 } 115 116 //! Erases the log file 117 void clearFile() 118 { 119 if (this->logFile_.is_open()) 120 { 121 this->logFile_.close(); 122 this->openFile(); 123 } 124 } 125 126 private: 127 void openFile() 128 { 109 129 this->logFile_.open(this->logFilename_.c_str(), std::fstream::out); 110 this->logFile_ << old.rdbuf(); 111 this->logFile_.flush(); 112 old.close(); 113 } 114 115 private: 130 131 if (this->logFile_.is_open()) 132 this->outputStream_ = &this->logFile_; 133 else 134 { 135 COUT(2) << "Warning: Failed to open log file. File logging disabled." << std::endl; 136 this->outputStream_ = NULL; 137 } 138 } 139 116 140 std::ofstream logFile_; //!< File handle for the log file 117 141 std::string logFilename_; //!< Filename of the log file … … 133 157 //! Only assigns the output stream with std::cout 134 158 ConsoleWriter() 135 : OutputListener(" consoleLog")159 : OutputListener("Console") 136 160 { 137 161 this->outputStream_ = &std::cout; … … 147 171 OutputListener that writes all the output piece by piece to an array 148 172 associated with the corresponding output level. 173 Used as buffer until all output devices have been initialised. 149 174 @note 150 Only output below or equal to the current soft debug level is written151 to minimise huge arrays for the normal run.175 At some point, OutputHandler::disableMemoryLog() has to be called in 176 order to avoid large memory footprints of this class. 152 177 */ 153 178 class MemoryLogWriter : public OutputListener … … 156 181 friend class OutputHandler; 157 182 158 /**159 @brief160 Sets the right soft debug level and registers itself161 */162 183 MemoryLogWriter() 163 184 : OutputListener("memoryLog") … … 166 187 } 167 188 168 //! Push edthe just written output to the internal array189 //! Push the just written output to the internal array 169 190 void outputChanged(int level) 170 191 { … … 180 201 181 202 private: 182 std::ostringstream 183 std::vector<std::pair<int, std::string> >output_; //!< Vector containing ALL output203 std::ostringstream buffer_; //!< Stream object used to process the output 204 OutputHandler::OutputVector output_; //!< Vector containing ALL output 184 205 }; 185 206 … … 188 209 ///// OutputHandler ///// 189 210 ///////////////////////// 190 const std::string OutputHandler::logFileOutputListenerName_s = "logFile"; 191 int OutputHandler::softDebugLevel_s = hardDebugLevel; 211 int OutputHandler::softDebugLevel_s = hardDebugLevel; 192 212 193 213 //! Creates the LogFileWriter and the MemoryLogWriter … … 195 215 : outputLevel_(OutputLevel::Verbose) 196 216 { 217 // Note: These levels only concern startup before orxonox.ini is read. 197 218 #ifdef ORXONOX_RELEASE 198 const OutputLevel::Value defaultLevelConsole = OutputLevel::Error; 199 const OutputLevel::Value defaultLevelLogFile = OutputLevel::Info; 219 const OutputLevel::Value initialLevelConsole = OutputLevel::Error; 200 220 #else 201 const OutputLevel::Value defaultLevelConsole = OutputLevel::Info; 202 const OutputLevel::Value defaultLevelLogFile = OutputLevel::Debug; 221 const OutputLevel::Value initialLevelConsole = OutputLevel::Info; 203 222 #endif 223 // Use high log level because we rewrite the log file anyway with the 224 // correct level. But if Orxonox were to crash before that, we might be 225 // grateful to have a high debug level, esp. for releases. 226 const OutputLevel::Value intialLevelLogFile = OutputLevel::Debug; 204 227 205 228 this->logFile_ = new LogFileWriter(); 206 229 // Use default level until we get the configValue from the Core 207 this->logFile_->softDebugLevel_ = defaultLevelLogFile;230 this->logFile_->softDebugLevel_ = intialLevelLogFile; 208 231 this->registerOutputListener(this->logFile_); 209 232 210 233 this->consoleWriter_ = new ConsoleWriter(); 211 this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;234 this->consoleWriter_->softDebugLevel_ = initialLevelConsole; 212 235 this->registerOutputListener(this->consoleWriter_); 213 236 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_);237 this->memoryBuffer_ = new MemoryLogWriter(); 238 // Write everything, e.g. use hardDebugLevel 239 this->memoryBuffer_->softDebugLevel_ = hardDebugLevel; 240 this->registerOutputListener(this->memoryBuffer_); 218 241 } 219 242 … … 223 246 delete this->logFile_; 224 247 delete this->consoleWriter_; 225 delete this-> output_;248 delete this->memoryBuffer_; // Might already be NULL 226 249 } 227 250 … … 234 257 void OutputHandler::registerOutputListener(OutputListener* listener) 235 258 { 236 for (std:: list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)259 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 237 260 { 238 261 if ((*it)->name_ == listener->name_) … … 243 266 } 244 267 this->listeners_.push_back(listener); 245 // Update global soft debug level 246 this->setSoftDebugLevel(listener->getOutputListenerName(), listener->getSoftDebugLevel()); 268 this->updateGlobalDebugLevel(); 247 269 } 248 270 249 271 void OutputHandler::unregisterOutputListener(OutputListener* listener) 250 272 { 251 this->listeners_.remove(listener); 273 for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 274 { 275 if ((*it)->name_ == listener->name_) 276 { 277 this->listeners_.erase(it); 278 break; 279 } 280 } 281 this->updateGlobalDebugLevel(); 252 282 } 253 283 … … 255 285 { 256 286 this->logFile_->setLogPath(path); 287 this->rewriteLogFile(); 288 } 289 290 void OutputHandler::rewriteLogFile() 291 { 292 logFile_->clearFile(); 293 294 if (logFile_->outputStream_ == NULL) 295 return; 296 297 for (OutputVector::const_iterator it = this->getOutput().begin(); it != this->getOutput().end(); ++it) 298 { 299 if (it->first <= logFile_->softDebugLevel_) 300 (*logFile_->outputStream_) << it->second; 301 } 302 logFile_->outputStream_->flush(); 257 303 } 258 304 … … 267 313 } 268 314 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(); 315 void OutputHandler::disableMemoryLog() 316 { 317 this->unregisterOutputListener(this->memoryBuffer_); 318 // Only clear the buffer so we can still reference the vector 319 this->memoryBuffer_->output_.clear(); 320 } 321 322 const OutputHandler::OutputVector& OutputHandler::getOutput() const 323 { 324 return this->memoryBuffer_->output_; 277 325 } 278 326 279 327 int OutputHandler::getSoftDebugLevel(const std::string& name) const 280 328 { 281 for (std:: list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)329 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 282 330 { 283 331 if ((*it)->name_ == name) … … 289 337 void OutputHandler::setSoftDebugLevel(const std::string& name, int level) 290 338 { 291 int globalSoftDebugLevel = -1; 292 for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 339 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 293 340 { 294 341 if ((*it)->name_ == name) 295 342 (*it)->softDebugLevel_ = level; 296 if ((*it)->softDebugLevel_ > globalSoftDebugLevel) 297 globalSoftDebugLevel = (*it)->softDebugLevel_; 298 } 299 // Update global soft debug level 343 } 344 this->updateGlobalDebugLevel(); 345 } 346 347 void OutputHandler::updateGlobalDebugLevel() 348 { 349 int globalSoftDebugLevel = -1; 350 std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); 351 for (; it != this->listeners_.end(); ++it) 352 globalSoftDebugLevel = std::max(globalSoftDebugLevel, (*it)->softDebugLevel_); 353 300 354 OutputHandler::softDebugLevel_s = globalSoftDebugLevel; 301 355 } -
code/trunk/src/libraries/util/OutputHandler.h
r7401 r8729 39 39 #include "UtilPrereqs.h" 40 40 41 #include <list>42 41 #include <ostream> 43 42 #include <string> … … 63 62 enum Value 64 63 { 64 TDebug = -1, 65 65 None = 0, 66 66 Error = 1, … … 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 … … 136 134 //! Set the log path once the program has been properly initialised 137 135 void setLogPath(const std::string& path); 136 /** Rewrites the log file (completely respects the current debug level). 137 Once disableMemoryLog() has been called, this function will do nothing. 138 */ 139 void rewriteLogFile(); 140 138 141 //! Disables the std::cout stream for output 139 142 void disableCout(); 140 143 //! Enables the std::cout stream for output (startup behaviour) 141 144 void enableCout(); 145 //! Stop writing to the memory buffer (call this as soon as possible to minimise memory usage) 146 void disableMemoryLog(); 142 147 143 148 //! Sets the level of the incoming output and returns the OutputHandler … … 213 218 inline operator int() const { return 0; } 214 219 215 //! Name of the OutputListener that writes to the log file216 static const std::string logFileOutputListenerName_s;217 218 220 private: 219 221 OutputHandler(); … … 221 223 OutputHandler(const OutputHandler& rhs); //!< Copy-constructor: Unused and undefined 222 224 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* output_; //!< Listener that Stores ALL output below the current soft debug level 228 static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access 225 /// Evaluates the maximum global log level 226 void updateGlobalDebugLevel(); 227 228 std::vector<OutputListener*> listeners_; //!< Array with all registered output listeners 229 int outputLevel_; //!< The level of the incoming output 230 LogFileWriter* logFile_; //!< Writes output to the log file 231 ConsoleWriter* consoleWriter_; //!< Writes to std::cout (can be disabled) 232 MemoryLogWriter* memoryBuffer_; //!< Writes to memory as a buffer (can/must be stopped at some time) 233 static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access 229 234 }; 230 235 … … 251 256 //! Returns the name of this output listener 252 257 const std::string& getOutputListenerName() const { return this->name_; } 253 //! Returns the soft debug level of the listener254 int getSoftDebugLevel() const { return this->softDebugLevel_; }255 //! Sets the soft debug level of the listener256 void setSoftDebugLevel(int level)257 {258 this->softDebugLevel_ = level;259 OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);260 }261 258 262 259 protected: … … 271 268 inline OutputHandler& OutputHandler::output(const T& output) 272 269 { 273 for (std:: list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)270 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 274 271 { 275 272 if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL) -
code/trunk/src/libraries/util/UtilPrereqs.h
r8351 r8729 87 87 class Exception; 88 88 class ExprParser; 89 class IntVector2;90 class IntVector3;91 89 class MultiType; 92 90 class OutputHandler; -
code/trunk/src/modules/docking/Dock.cc
r8706 r8729 44 44 #include "worldentities/pawns/Pawn.h" 45 45 46 #include "ToluaBindDocking.h"47 48 46 namespace orxonox 49 47 { 50 // Register tolua_open function when loading the library51 DeclareToluaInterface(Docking);52 53 48 CreateFactory(Dock); 54 49 -
code/trunk/src/modules/notifications/NotificationQueueCEGUI.cc
r8706 r8729 43 43 #include "util/Convert.h" 44 44 45 #include "ToluaBindNotifications.h"46 47 45 namespace orxonox 48 46 { 49 47 50 48 CreateFactory(NotificationQueueCEGUI); 51 52 // Register tolua_open function when loading the library.53 DeclareToluaInterface(Notifications);54 49 55 50 /*static*/ const std::string NotificationQueueCEGUI::NOTIFICATION_LAYER("NotificationLayer"); -
code/trunk/src/modules/objects/eventsystem/EventFilter.cc
r6417 r8729 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "core/Event.h" 32 33 #include "core/XMLPort.h" 33 34 #include "EventName.h" -
code/trunk/src/modules/objects/eventsystem/EventListener.cc
r7163 r8729 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "core/Event.h" 32 33 #include "core/XMLPort.h" 33 34 -
code/trunk/src/modules/overlays/hud/GametypeFadingMessage.h
r7163 r8729 27 27 */ 28 28 29 #ifndef _Gametype InfoMessage_H__30 #define _Gametype InfoMessage_H__29 #ifndef _GametypeFadingMessage_H__ 30 #define _GametypeFadingMessage_H__ 31 31 32 32 #include "overlays/OverlaysPrereqs.h" -
code/trunk/src/modules/pickup/PickupCollectionIdentifier.h
r7533 r8729 34 34 35 35 #ifndef _PickupCollectionIdentifier_H__ 36 #define _PickupCollectionIdentifier_H_ 36 #define _PickupCollectionIdentifier_H__ 37 37 38 38 #include "PickupPrereqs.h" … … 75 75 } 76 76 77 #endif // _PickupCollectionIdentifier_H_ 77 #endif // _PickupCollectionIdentifier_H__ -
code/trunk/src/modules/pickup/PickupManager.cc
r7801 r8729 49 49 #include "PickupRepresentation.h" 50 50 51 #include "ToluaBindPickup.h"52 53 51 namespace orxonox 54 52 { 55 // Register tolua_open function when loading the library56 DeclareToluaInterface(Pickup);57 58 53 ManageScopedSingleton(PickupManager, ScopeID::Root, false); 59 54 -
code/trunk/src/modules/pong/CMakeLists.txt
r7163 r8729 1 1 SET_SOURCE_FILES(PONG_SRC_FILES 2 COMPILATION_BEGIN PongCompilation.cc2 BUILD_UNIT PongBuildUnit.cc 3 3 Pong.cc 4 4 PongAI.cc … … 8 8 PongCenterpoint.cc 9 9 PongScore.cc 10 COMPILATION_END 10 END_BUILD_UNIT 11 11 ) 12 12 -
code/trunk/src/modules/pong/PongAI.cc
r8108 r8729 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" 38 #include "core/command/Executor.h" 38 39 #include "tools/Timer.h" 39 40 -
code/trunk/src/modules/questsystem/QuestManager.cc
r8706 r8729 47 47 #include "QuestItem.h" 48 48 49 #include "ToluaBindQuestsystem.h"50 51 49 namespace orxonox 52 50 { 53 // Register tolua_open function when loading the library54 DeclareToluaInterface(Questsystem);55 56 51 ManageScopedSingleton(QuestManager, ScopeID::Root, false); 57 52 -
code/trunk/src/modules/weapons/munitions/ReplenishingMunition.cc
r5929 r8729 28 28 29 29 #include "ReplenishingMunition.h" 30 30 31 #include "core/CoreIncludes.h" 32 #include "core/command/Executor.h" 31 33 32 34 namespace orxonox -
code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc
r6417 r8729 31 31 #include "util/Convert.h" 32 32 #include "core/CoreIncludes.h" 33 #include "core/command/Executor.h" 33 34 34 35 namespace orxonox -
code/trunk/src/orxonox/CMakeLists.txt
r8351 r8729 35 35 ChatInputHandler.cc 36 36 # Test.cc 37 COMPILATION_BEGIN SceneCompilation.cc 37 38 BUILD_UNIT SceneBuildUnit.cc 38 39 CameraManager.cc 39 40 Scene.cc 40 COMPILATION_END 41 END_BUILD_UNIT 41 42 ) 42 43 -
code/trunk/src/orxonox/Main.cc
r7801 r8729 39 39 #include "core/Game.h" 40 40 #include "core/LuaState.h" 41 #include "ToluaBindOrxonox.h"42 #include "ToluaBindNetwork.h"43 44 DeclareToluaInterface(Orxonox);45 DeclareToluaInterface(Network);46 41 47 42 namespace orxonox -
code/trunk/src/orxonox/controllers/AIController.cc
r7284 r8729 37 37 namespace orxonox 38 38 { 39 static const floatACTION_INTERVAL = 1.0f;39 const float AIController::ACTION_INTERVAL = 1.0f; 40 40 41 41 CreateFactory(AIController); -
code/trunk/src/orxonox/controllers/AIController.h
r5929 r8729 50 50 51 51 private: 52 static const float ACTION_INTERVAL; 53 52 54 Timer actionTimer_; 53 55 }; -
code/trunk/src/orxonox/controllers/DroneController.cc
r7284 r8729 43 43 CreateFactory(DroneController); 44 44 45 static const floatACTION_INTERVAL = 1.0f;45 const float DroneController::ACTION_INTERVAL = 1.0f; 46 46 47 47 DroneController::DroneController(BaseObject* creator) : ArtificialController(creator) -
code/trunk/src/orxonox/controllers/DroneController.h
r7163 r8729 69 69 70 70 private: 71 static const float ACTION_INTERVAL; 72 71 73 Timer actionTimer_; 72 74 WeakPtr<Pawn> owner_; -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r8079 r8729 77 77 { 78 78 gameInputState_ = InputManager::getInstance().createInputState("game"); 79 gameInputState_->setMouseExclusive( TriBool::True);79 gameInputState_->setMouseExclusive(true); 80 80 gameInputState_->setHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 81 81 KeyBinderManager::getInstance().setToDefault(); 82 82 83 83 guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly"); 84 guiMouseOnlyInputState_->setMouseExclusive( TriBool::True);84 guiMouseOnlyInputState_->setMouseExclusive(true); 85 85 guiMouseOnlyInputState_->setMouseHandler(&GUIManager::getInstance()); 86 86 -
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r8727 r8729 48 48 #include "util/Convert.h" 49 49 #include "core/CoreIncludes.h" 50 #include "core/command/Executor.h" 50 51 #include "network/Host.h" 51 52 #include "infos/PlayerInfo.h" -
code/trunk/src/orxonox/graphics/CMakeLists.txt
r7163 r8729 9 9 ParticleEmitter.cc 10 10 ParticleSpawner.cc 11 COMPILATION_BEGIN GraphicsCompilation.cc 11 12 BUILD_UNIT GraphicsBuildUnit.cc 12 13 Backlight.cc 13 14 Camera.cc 14 15 Light.cc 15 COMPILATION_END 16 END_BUILD_UNIT 16 17 ) -
code/trunk/src/orxonox/overlays/InGameConsole.cc
r8484 r8729 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 … … 586 590 colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 1.00f); break; 587 591 592 case Shell::TDebug: colourTop = ColourValue(0.90f, 0.00f, 0.90f, 1.00f); 593 colourBottom = ColourValue(1.00f, 0.00f, 1.00f, 1.00f); break; 594 588 595 default: colourTop = ColourValue(0.90f, 0.90f, 0.90f, 1.00f); 589 596 colourBottom = ColourValue(1.00f, 1.00f, 1.00f, 1.00f); break; -
code/trunk/src/orxonox/sound/BaseSound.cc
r8521 r8729 61 61 BaseSound::~BaseSound() 62 62 { 63 this->stop(); 63 if (this->state_ != Stopped) 64 this->stop(); 64 65 // Release buffer 65 66 if (this->soundBuffer_ != NULL) -
code/trunk/src/orxonox/weaponsystem/Munition.cc
r8706 r8729 29 29 30 30 #include "Munition.h" 31 31 32 #include "core/CoreIncludes.h" 33 #include "core/command/Executor.h" 32 34 33 35 namespace orxonox -
code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc
r7183 r8729 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "core/SubclassIdentifier.h" 32 33 #include "worldentities/pawns/Pawn.h" 33 34
Note: See TracChangeset
for help on using the changeset viewer.