Changeset 8858 for code/trunk/src/libraries
- Timestamp:
- Aug 23, 2011, 12:45:53 AM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 5 deleted
- 129 edited
- 21 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 1 build 2 2 codeblocks 3 vs 3 4 dependencies
-
- Property svn:mergeinfo changed
/code/branches/output (added) merged: 8739-8740,8765,8771-8772,8774-8780,8787-8789,8794-8799,8801,8803-8812,8814,8816-8817,8820,8822,8825-8837,8840,8844,8846,8848-8850,8853-8854
- Property svn:ignore
-
code/trunk/src/libraries/core/BaseObject.cc
r8706 r8858 109 109 void BaseObject::registerEventListener(BaseObject* object) 110 110 { 111 COUT(4) << "New EventListener: " << object->getIdentifier()->getName() << " &(" << object << ")." << std::endl;111 orxout(verbose, context::events) << "New EventListener: " << object->getIdentifier()->getName() << " &(" << object << ")." << endl; 112 112 this->eventListeners_.insert(object); 113 113 } … … 186 186 this->addTemplate(temp); 187 187 else 188 COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl;188 orxout(internal_error) << "\"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << endl; 189 189 } 190 190 … … 312 312 if (it != this->eventStates_.end()) 313 313 { 314 COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << '.' << std::endl;314 orxout(internal_warning, context::events) << "Overwriting EventState in class " << this->getIdentifier()->getName() << '.' << endl; 315 315 delete (it->second); 316 316 } … … 379 379 this->registerEventStates(); 380 380 381 COUT(4) << this->getIdentifier()->getName() << " (&" << this << ") processing event. originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << "." << std::endl;381 orxout(verbose, context::events) << this->getIdentifier()->getName() << " (&" << this << ") processing event. originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << "." << endl; 382 382 383 383 std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(event.statename_); … … 385 385 it->second->process(event, this); 386 386 else if (!event.statename_.empty()) 387 COUT(2) << "Warning: \"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;388 else 389 COUT(2) << "Warning: Event with invalid source sent to object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;387 orxout(internal_warning, context::events) << "\"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << endl; 388 else 389 orxout(internal_warning, context::events) << "Event with invalid source sent to object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << endl; 390 390 } 391 391 … … 412 412 } 413 413 else 414 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;414 orxout(internal_warning, context::events) << "No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << endl; 415 415 } 416 416 … … 432 432 this->mainStateFunctor_ = it->second->getFunctor(); 433 433 else 434 COUT(2) << "Warning: Can't use \"" << this->mainStateName_ << "\" as MainState because it needs a second argument." << std::endl;434 orxout(internal_warning, context::events) << "Can't use \"" << this->mainStateName_ << "\" as MainState because it needs a second argument." << endl; 435 435 } 436 436 else 437 COUT(2) << "Warning: \"" << this->mainStateName_ << "\" is not a valid MainState." << std::endl;437 orxout(internal_warning, context::events) << "\"" << this->mainStateName_ << "\" is not a valid MainState." << endl; 438 438 } 439 439 } -
code/trunk/src/libraries/core/CMakeLists.txt
r8729 r8858 86 86 input/KeyBinder.h 87 87 input/KeyBinderManager.h 88 ../util/output/OutputDefinitions.h 88 89 PCH_FILE 89 90 CorePrecompiledHeaders.h -
code/trunk/src/libraries/core/ClassFactory.h
r7401 r8858 42 42 #include <string> 43 43 44 #include "util/ Debug.h"44 #include "util/Output.h" 45 45 #include "Identifier.h" 46 46 … … 73 73 ClassFactory(const std::string& name, bool bLoadable = true) 74 74 { 75 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;75 orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl; 76 76 ClassIdentifier<T>::getIdentifier(name)->addFactory(this); 77 77 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); -
code/trunk/src/libraries/core/CommandLineParser.cc
r8729 r8858 33 33 34 34 #include "util/Convert.h" 35 #include "util/ Debug.h"35 #include "util/Output.h" 36 36 #include "util/Exception.h" 37 37 #include "util/StringUtils.h" … … 229 229 catch (const ArgumentException& ex) 230 230 { 231 COUT(0) << "Could not parse command line: " << ex.what() << std::endl;232 COUT(0) << CommandLineParser::getUsageInformation() << std::endl;231 orxout(user_error) << "Could not parse command line: " << ex.what() << endl; 232 orxout(user_error) << CommandLineParser::getUsageInformation() << endl; 233 233 throw GeneralException(""); 234 234 } … … 286 286 } 287 287 288 infoStr << std::endl;289 infoStr << "Usage: orxonox [options]" << std::endl;290 infoStr << "Available options:" << std::endl;288 infoStr << endl; 289 infoStr << "Usage: orxonox [options]" << endl; 290 infoStr << "Available options:" << endl; 291 291 292 292 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin(); … … 305 305 infoStr << std::string(maxNameSize - it->second->getName().size(), ' '); 306 306 infoStr << ": " << it->second->getInformation(); 307 infoStr << std::endl;307 infoStr << endl; 308 308 } 309 309 return infoStr.str(); -
code/trunk/src/libraries/core/CommandLineParser.h
r8729 r8858 218 218 "Cannot add a command line argument with name '" + name + "' twice."); 219 219 OrxAssert(MultiType(defaultValue).getType() != MT_Type::Bool || MultiType(defaultValue).getBool() != true, 220 "Boolean command line arguments with positive default values are not supported." << std::endl220 "Boolean command line arguments with positive default values are not supported." << endl 221 221 << "Please use SetCommandLineSwitch and adjust your argument: " << name); 222 222 -
code/trunk/src/libraries/core/ConfigFileManager.cc
r7401 r8858 123 123 for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it) 124 124 if ((*it)->getName() == name) 125 if ((*it)->getIndex() > size) 126 size = (*it)->getIndex(); 127 if (size == 0) 128 return 0; 129 else 130 return (size + 1); 125 if ((*it)->getIndex() >= size) 126 size = (*it)->getIndex() + 1; 127 return size; 131 128 } 132 129 … … 274 271 { 275 272 boost::filesystem::copy_file(defaultFilepath, filepath); 276 COUT(3) << "Copied " << this->filename_ << " from the default config folder." << std::endl;273 orxout(internal_info, context::config) << "Copied " << this->filename_ << " from the default config folder." << endl; 277 274 } 278 275 catch (const boost::filesystem::filesystem_error& ex) 279 { COUT(1) << "Error in ConfigFile: " << ex.what() << std::endl; }276 { orxout(user_error, context::config) << "Error in ConfigFile: " << ex.what() << endl; } 280 277 } 281 278 } … … 375 372 file.close(); 376 373 377 COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;374 orxout(internal_info, context::config) << "Loaded config file \"" << this->filename_ << "\"." << endl; 378 375 379 376 // DO NOT save the file --> we can open supposedly read only config files … … 404 401 if (!file.is_open()) 405 402 { 406 COUT(1) << "Error: Couldn't open config-file \"" << filename << "\"." << std::endl;403 orxout(user_error, context::config) << "Couldn't open config-file \"" << filename << "\"." << endl; 407 404 return; 408 405 } … … 410 407 for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it) 411 408 { 412 file << (*it)->getFileEntry() << std::endl;409 file << (*it)->getFileEntry() << endl; 413 410 414 411 for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries) 415 file << (*it_entries)->getFileEntry() << std::endl;416 417 file << std::endl;412 file << (*it_entries)->getFileEntry() << endl; 413 414 file << endl; 418 415 } 419 416 420 417 file.close(); 421 418 422 COUT(4) << "Saved config file \"" << filename << "\"." << std::endl;419 orxout(verbose, context::config) << "Saved config file \"" << filename << "\"." << endl; 423 420 } 424 421 … … 669 666 { 670 667 if (!this->configImpl(section, entry, value, &ConfigValueContainer::set)) 671 COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl;668 orxout(user_error, context::config) << "Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << endl; 672 669 } 673 670 … … 682 679 { 683 680 if (!this->configImpl(section, entry, value, &ConfigValueContainer::tset)) 684 COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl;681 orxout(user_error, context::config) << "Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << endl; 685 682 } 686 683 -
code/trunk/src/libraries/core/ConfigValueContainer.cc
r8351 r8858 143 143 else 144 144 { 145 COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;145 orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl; 146 146 } 147 147 return false; … … 182 182 if (index > MAX_VECTOR_INDEX) 183 183 { 184 COUT(1) << "Error: Index " << index << " is too large." << std::endl;184 orxout(user_error, context::config) << "Index " << index << " is too large." << endl; 185 185 return false; 186 186 } … … 203 203 else 204 204 { 205 COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;205 orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl; 206 206 return false; 207 207 } … … 218 218 return this->set(this->valueVector_.size(), input); 219 219 220 COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;220 orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl; 221 221 return false; 222 222 } … … 241 241 return true; 242 242 } 243 COUT(1) << "Error: Invalid vector-index." << std::endl;244 } 245 246 COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;243 orxout(user_error, context::config) << "Invalid vector-index." << endl; 244 } 245 246 orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl; 247 247 return false; 248 248 } … … 312 312 if (!success) 313 313 { 314 COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is a vector." << std::endl;314 orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is a vector." << endl; 315 315 } 316 316 else 317 317 { 318 COUT(1) << "Error: Invalid vector-index." << std::endl;318 orxout(user_error, context::config) << "Invalid vector-index." << endl; 319 319 } 320 320 return false; -
code/trunk/src/libraries/core/ConfigValueIncludes.h
r8729 r8858 87 87 @code 88 88 MyObject orxonoxobject; 89 std::cout << "Name: " << orxonoxobject.getName() << std::endl;90 std::cout << "Version: " << orxonoxobject.getVersion() << std::endl;89 orxout() << "Name: " << orxonoxobject.getName() << endl; 90 orxout() << "Version: " << orxonoxobject.getVersion() << endl; 91 91 @endcode 92 92 … … 200 200 else 201 201 { 202 COUT(2) << "Warning:Couldn't reset config-value '" << entryName << "' in class '"203 << ClassIdentifier<T>::getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl;202 orxout(user_warning, context::config) << "Couldn't reset config-value '" << entryName << "' in class '" 203 << ClassIdentifier<T>::getIdentifier()->getName() << "', corresponding container doesn't exist." << endl; 204 204 } 205 205 } … … 238 238 else \ 239 239 { \ 240 COUT(2) << "Warning: Couln't modify config-value '" << entryName << "' in class '" \241 << ClassByObjectType(object)->getName() << "', corresponding container doesn't exist." << std::endl; \240 orxout(user_warning, context::config) << "Couldn't modify config-value '" << entryName << "' in class '" \ 241 << ClassByObjectType(object)->getName() << "', corresponding container doesn't exist." << endl; \ 242 242 } 243 243 -
code/trunk/src/libraries/core/Core.cc
r8729 r8858 52 52 53 53 #include "util/Clock.h" 54 #include "util/ Debug.h"54 #include "util/Output.h" 55 55 #include "util/Exception.h" 56 #include "util/output/LogWriter.h" 56 57 #include "util/Scope.h" 57 58 #include "util/ScopedSingletonManager.h" … … 111 112 , destructionHelper_(this) 112 113 { 114 orxout(internal_status) << "initializing Core object..." << endl; 115 113 116 // Set the hard coded fixed paths 114 117 this->pathConfig_ = new PathConfig(); … … 118 121 119 122 // Load modules 123 orxout(internal_info) << "Loading modules:" << endl; 120 124 const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths(); 121 125 for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it) … … 127 131 catch (...) 128 132 { 129 COUT(1) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << std::endl;133 orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl; 130 134 } 131 135 } … … 136 140 // Set configurable paths like log, config and media 137 141 this->pathConfig_->setConfigurablePaths(); 142 143 orxout(internal_info) << "Root path: " << PathConfig::getRootPathString() << endl; 144 orxout(internal_info) << "Executable path: " << PathConfig::getExecutablePathString() << endl; 145 orxout(internal_info) << "Data path: " << PathConfig::getDataPathString() << endl; 146 orxout(internal_info) << "Ext. data path: " << PathConfig::getExternalDataPathString() << endl; 147 orxout(internal_info) << "Config path: " << PathConfig::getConfigPathString() << endl; 148 orxout(internal_info) << "Log path: " << PathConfig::getLogPathString() << endl; 149 orxout(internal_info) << "Modules path: " << PathConfig::getModulePathString() << endl; 138 150 139 151 // create a signal handler (only active for Linux) … … 141 153 this->signalHandler_ = new SignalHandler(); 142 154 this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log"); 143 144 // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used145 OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());146 155 147 156 #ifdef ORXONOX_PLATFORM_WINDOWS … … 155 164 156 165 // Manage ini files and set the default settings file (usually orxonox.ini) 166 orxout(internal_info) << "Loading config:" << endl; 157 167 this->configFileManager_ = new ConfigFileManager(); 158 168 this->configFileManager_->setFilename(ConfigFileType::Settings, … … 160 170 161 171 // Required as well for the config values 172 orxout(internal_info) << "Loading language:" << endl; 162 173 this->languageInstance_ = new Language(); 163 174 … … 165 176 // possibility to configure everything below here 166 177 RegisterRootObject(Core); 178 orxout(internal_info) << "configuring Core" << endl; 167 179 this->setConfigValues(); 168 // Rewrite the log file with the correct log levels 169 OutputHandler::getInstance().rewriteLogFile(); 180 181 // Set the correct log path and rewrite the log file with the correct log levels 182 LogWriter::getInstance().setLogPath(PathConfig::getLogPathString()); 170 183 171 184 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN) … … 176 189 } 177 190 if (this->bStartIOConsole_) 191 { 192 orxout(internal_info) << "creating IO console" << endl; 178 193 this->ioConsole_ = new IOConsole(); 194 } 179 195 #endif 180 196 181 197 // creates the class hierarchy for all classes with factories 198 orxout(internal_info) << "creating class hierarchy" << endl; 182 199 Identifier::createClassHierarchy(); 183 200 184 201 // Load OGRE excluding the renderer and the render window 202 orxout(internal_info) << "creating GraphicsManager:" << endl; 185 203 this->graphicsManager_ = new GraphicsManager(false); 186 204 … … 190 208 191 209 // Create singletons that always exist (in other libraries) 210 orxout(internal_info) << "creating root scope:" << endl; 192 211 this->rootScope_ = new Scope<ScopeID::Root>(); 193 212 … … 204 223 } 205 224 else 206 COUT(0) << "Error: Could not open file for documentation writing" << endl; 207 } 225 orxout(internal_error) << "Could not open file for documentation writing" << endl; 226 } 227 228 orxout(internal_status) << "finished initializing Core object" << endl; 208 229 } 209 230 210 231 void Core::destroy() 211 232 { 233 orxout(internal_status) << "destroying Core object..." << endl; 234 212 235 // Remove us from the object lists again to avoid problems when destroying them 213 236 this->unregisterObject(); … … 228 251 safeObjectDelete(&dynLibManager_); 229 252 safeObjectDelete(&pathConfig_); 230 } 231 232 namespace DefaultLevelLogFile 233 { 234 const OutputLevel::Value Dev = OutputLevel::Debug; 235 const OutputLevel::Value User = OutputLevel::Info; 253 254 orxout(internal_status) << "finished destroying Core object" << endl; 236 255 } 237 256 … … 239 258 void Core::setConfigValues() 240 259 { 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_); 260 SetConfigValueExternal(LogWriter::getInstance().configurableMaxLevel_, 261 LogWriter::getInstance().getConfigurableSectionName(), 262 LogWriter::getInstance().getConfigurableMaxLevelName(), 263 LogWriter::getInstance().configurableMaxLevel_) 264 .description("The maximum level of output shown in the log file") 265 .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableLevel); 266 SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContextsMaxLevel_, 267 LogWriter::getInstance().getConfigurableSectionName(), 268 LogWriter::getInstance().getConfigurableAdditionalContextsMaxLevelName(), 269 LogWriter::getInstance().configurableAdditionalContextsMaxLevel_) 270 .description("The maximum level of output shown in the log file for additional contexts") 271 .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContextsLevel); 272 SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContexts_, 273 LogWriter::getInstance().getConfigurableSectionName(), 274 LogWriter::getInstance().getConfigurableAdditionalContextsName(), 275 LogWriter::getInstance().configurableAdditionalContexts_) 276 .description("Additional output contexts shown in the log file") 277 .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContexts); 247 278 248 279 SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun()) … … 279 310 void Core::devModeChanged() 280 311 { 281 bool isNormal = (bDevMode_ == PathConfig::buildDirectoryRun());282 if (isNormal)283 {284 ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update);285 }286 else287 {288 OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);289 ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level);290 }291 292 312 // Inform listeners 293 313 ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin(); … … 316 336 void Core::loadGraphics() 317 337 { 338 orxout(internal_info) << "loading graphics in Core" << endl; 339 318 340 // Any exception should trigger this, even in upgradeToGraphics (see its remarks) 319 341 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics); … … 327 349 { 328 350 // Exit the application if the Ogre config dialog was canceled 329 COUT(1) << Exception::handleMessage() << std::endl;351 orxout(user_error) << Exception::handleMessage() << endl; 330 352 exit(EXIT_FAILURE); 331 353 } … … 338 360 // and reloaded between throw and catch (access violation in MSVC). 339 361 // That's why we abort completely and only display the exception. 340 COUT(1) << "An exception occurred during upgrade to graphics. "341 << "That is unrecoverable. The message was:" << endl342 << Exception::handleMessage() << endl;362 orxout(user_error) << "An exception occurred during upgrade to graphics. " 363 << "That is unrecoverable. The message was:" << endl 364 << Exception::handleMessage() << endl; 343 365 abort(); 344 366 } … … 357 379 358 380 // Create singletons associated with graphics (in other libraries) 381 orxout(internal_info) << "creating graphics scope:" << endl; 359 382 graphicsScope_ = new Scope<ScopeID::Graphics>(); 360 383 361 384 unloader.Dismiss(); 385 386 orxout(internal_info) << "finished loading graphics in Core" << endl; 362 387 } 363 388 364 389 void Core::unloadGraphics() 365 390 { 391 orxout(internal_info) << "unloading graphics in Core" << endl; 392 366 393 safeObjectDelete(&graphicsScope_); 367 394 safeObjectDelete(&guiManager_); … … 374 401 catch (...) 375 402 { 376 COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl377 << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl378 << "Terminating the program." << std::endl;403 orxout(user_error) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << endl 404 << "Another exception might be being handled which may lead to undefined behaviour!" << endl 405 << "Terminating the program." << endl; 379 406 abort(); 380 407 } -
code/trunk/src/libraries/core/Core.h
r8729 r8858 136 136 137 137 bool bGraphicsLoaded_; 138 int debugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler)139 138 std::string language_; //!< The language 140 139 bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called -
code/trunk/src/libraries/core/CoreIncludes.h
r8729 r8858 34 34 /** 35 35 @file 36 @ingroup Object Factory 36 @ingroup Object Factory Class Identifier 37 37 @brief Defines several very important macros used to register objects, create factories, and to work with identifiers. 38 38 … … 78 78 #include "CorePrereqs.h" 79 79 80 #include "util/ Debug.h"80 #include "util/Output.h" 81 81 #include "Identifier.h" 82 82 #include "ClassFactory.h" -
code/trunk/src/libraries/core/CorePrecompiledHeaders.h
r7266 r8858 51 51 #include <set> // 50 52 52 53 #include "util/ Debug.h" // 4853 #include "util/Output.h" // 48 54 54 55 55 #include <deque> // 43 -
code/trunk/src/libraries/core/DynLib.cc
r8351 r8858 68 68 { 69 69 // Log library load 70 COUT(2) << "Loading module " << mName << std::endl;70 orxout(internal_info) << "Loading module " << mName << endl; 71 71 72 72 std::string name = mName; … … 99 99 { 100 100 // Log library unload 101 COUT(4) << "Unloading module " << mName << std::endl;101 orxout(internal_info) << "Unloading module " << mName << endl; 102 102 103 103 if (DYNLIB_UNLOAD( m_hInst )) -
code/trunk/src/libraries/core/Event.cc
r7401 r8858 49 49 if (this->bProcessingEvent_) 50 50 { 51 COUT(2) << "Warning: Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << '"' << std::endl;51 orxout(internal_warning, context::events) << "Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << '"' << endl; 52 52 return; 53 53 } … … 55 55 this->bProcessingEvent_ = true; 56 56 57 COUT(4) << "Processing event (EventState) : originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << ", object: " << object->getIdentifier()->getName() << " (&" << object << ")" << "." << std::endl;57 orxout(verbose, context::events) << "Processing event (EventState) : originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << ", object: " << object->getIdentifier()->getName() << " (&" << object << ")" << "." << endl; 58 58 59 59 // check if the originator is an instance of the requested class -
code/trunk/src/libraries/core/GUIManager.cc
r8729 r8858 73 73 #include "util/Clock.h" 74 74 #include "util/Convert.h" 75 #include "util/ Debug.h"75 #include "util/Output.h" 76 76 #include "util/Exception.h" 77 77 #include "util/Math.h" 78 78 #include "util/OrxAssert.h" 79 #include "util/output/BaseWriter.h" 79 80 #include "ConfigValueIncludes.h" 80 81 #include "Core.h" … … 101 102 void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard) 102 103 { 103 int orxonoxLevel = CEGUI::Standard;104 OutputLevel orxonoxLevel = level::debug_output; 104 105 switch (level) 105 106 { 106 case CEGUI::Errors: orxonoxLevel = 1; break;107 case CEGUI::Warnings: orxonoxLevel = 2; break;108 case CEGUI::Standard: orxonoxLevel = 4; break;109 case CEGUI::Informative: orxonoxLevel = 5; break;110 case CEGUI::Insane: orxonoxLevel = 6; break;107 case CEGUI::Errors: orxonoxLevel = level::internal_error; break; 108 case CEGUI::Warnings: orxonoxLevel = level::internal_warning; break; 109 case CEGUI::Standard: orxonoxLevel = level::verbose; break; 110 case CEGUI::Informative: orxonoxLevel = level::verbose_more; break; 111 case CEGUI::Insane: orxonoxLevel = level::verbose_ultra; break; 111 112 default: OrxAssert(false, "CEGUI log level out of range, inspect immediately!"); 112 113 } 113 OutputHandler::getOutStream(orxonoxLevel) 114 << "CEGUI: " << message << std::endl;114 115 orxout(orxonoxLevel, context::cegui) << message << endl; 115 116 116 117 CEGUI::DefaultLogger::logEvent(message, level); … … 256 257 { 257 258 RegisterRootObject(GUIManager); 259 260 orxout(internal_status) << "initializing GUIManager..." << endl; 261 258 262 this->setConfigValues(); 259 263 260 264 using namespace CEGUI; 261 265 262 COUT(3) << "Initialising CEGUI." << std::endl;266 orxout(internal_info) << "Initialising CEGUI." << endl; 263 267 264 268 this->oldCEGUI_ = false; 265 269 266 270 // Note: No SceneManager specified yet 267 271 #ifdef ORXONOX_OLD_CEGUI … … 300 304 std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); 301 305 ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log"); 302 // Set the log level according to ours (translate by subtracting 1) 303 ceguiLogger->setLoggingLevel( 304 static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1)); 306 ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_)); 305 307 this->ceguiLogger_ = ceguiLogger.release(); 306 308 … … 336 338 // Set up the sheet manager in the Lua framework 337 339 this->luaState_->doFile("SheetManager.lua"); 340 341 orxout(internal_status) << "finished initializing GUIManager" << endl; 338 342 } 339 343 340 344 void GUIManager::destroy() 341 345 { 346 orxout(internal_status) << "destroying GUIManager..." << endl; 347 342 348 using namespace CEGUI; 343 349 … … 356 362 #endif 357 363 safeObjectDelete(&luaState_); 364 365 orxout(internal_status) << "finished destroying GUIManager" << endl; 358 366 } 359 367 360 368 void GUIManager::setConfigValues(void) 361 369 { 362 SetConfigValue(guiScheme_, GUIManager::defaultScheme_) .description("Changes the current GUI scheme.").callback(this, &GUIManager::changedGUIScheme);370 SetConfigValue(guiScheme_, GUIManager::defaultScheme_).description("Changes the current GUI scheme.").callback(this, &GUIManager::changedGUIScheme); 363 371 SetConfigValue(numScrollLines_, 1).description("How many lines to scroll in a list if the scroll wheel is used"); 372 SetConfigValueExternal(outputLevelCeguiLog_, BaseWriter::getConfigurableSectionName(), "outputLevelCeguiLog", CEGUI::Standard).description("The log level of the CEGUI log file").callback(this, &GUIManager::changedCeguiOutputLevel); 364 373 } 365 374 366 375 void GUIManager::changedGUIScheme(void) 367 376 { 377 } 378 379 void GUIManager::changedCeguiOutputLevel() 380 { 381 if (this->ceguiLogger_) 382 this->ceguiLogger_->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_)); 368 383 } 369 384 … … 670 685 { 671 686 // Display the error and proceed. See @remarks why this can be dangerous. 672 COUT(1) << ex.getMessage() << std::endl;687 orxout(internal_error) << ex.getMessage() << endl; 673 688 return true; 674 689 } -
code/trunk/src/libraries/core/GUIManager.h
r8729 r8858 152 152 bool protectedCall(FunctionType function); 153 153 154 void changedCeguiOutputLevel(); 155 154 156 // keyHandler functions 155 157 void buttonPressed (const KeyEvent& evt); … … 168 170 169 171 #ifdef ORXONOX_OLD_CEGUI 170 CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine171 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider172 CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine 173 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 172 174 #else 173 CEGUI::OgreRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine174 CEGUI::OgreResourceProvider* resourceProvider_; //!< CEGUI's resource provider175 Ogre::RenderQueueListener* rqListener_; //!< RQ listener so we can draw UNDER Ogre overlays175 CEGUI::OgreRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine 176 CEGUI::OgreResourceProvider* resourceProvider_; //!< CEGUI's resource provider 177 Ogre::RenderQueueListener* rqListener_; //!< RQ listener so we can draw UNDER Ogre overlays 176 178 CEGUI::OgreImageCodec* imageCodec_; 177 179 #endif 178 LuaState* luaState_; //!< LuaState, access point to the Lua engine 179 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 180 CEGUI::System* guiSystem_; //!< CEGUI's main system 181 shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 182 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 183 CEGUI::Window* rootWindow_; //!< Root node for all windows 184 CEGUI::Window* hudRootWindow_; //!< Root node for the HUD sheets 185 CEGUI::Window* menuRootWindow_; //!< Root node for the menu sheets (used by Lua) 186 std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each GUI 187 Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI 180 LuaState* luaState_; //!< LuaState, access point to the Lua engine 181 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 182 CEGUI::System* guiSystem_; //!< CEGUI's main system 183 shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 184 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 185 int outputLevelCeguiLog_; //!< CEGUI's log level 186 CEGUI::Window* rootWindow_; //!< Root node for all windows 187 CEGUI::Window* hudRootWindow_; //!< Root node for the HUD sheets 188 CEGUI::Window* menuRootWindow_; //!< Root node for the menu sheets (used by Lua) 189 std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each GUI 190 Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI 188 191 189 192 /// Helper object that executes the surrogate destructor destroy() 190 193 DestructionHelper<GUIManager> destructionHelper_; 191 194 192 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager195 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager 193 196 194 197 // The used CEGUI scheme. … … 196 199 std::string guiScheme_; 197 200 bool oldCEGUI_; 198 201 199 202 int numScrollLines_; ///< How many lines to scroll in a list if the scroll wheel is used 200 203 -
code/trunk/src/libraries/core/Game.cc
r8729 r8858 40 40 41 41 #include "util/Clock.h" 42 #include "util/ Debug.h"42 #include "util/Output.h" 43 43 #include "util/Exception.h" 44 44 #include "util/Sleep.h" … … 60 60 SetConsoleCommand("exit", &stop_game); 61 61 static void printFPS() 62 { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }62 { orxout(message) << Game::getInstance().getAvgFPS() << endl; } 63 63 SetConsoleCommand("Stats", "printFPS", &printFPS); 64 64 static void printTickTime() 65 { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }65 { orxout(message) << Game::getInstance().getAvgTickTime() << endl; } 66 66 SetConsoleCommand("Stats", "printTickTime", &printTickTime); 67 67 … … 84 84 , destructionHelper_(this) 85 85 { 86 orxout(internal_status) << "initializing Game object..." << endl; 87 86 88 #ifdef ORXONOX_PLATFORM_WINDOWS 87 89 minimumSleepTime_ = 1000/*us*/; … … 106 108 107 109 // Create the Core 110 orxout(internal_info) << "creating Core object:" << endl; 108 111 this->core_ = new Core(cmdLine); 109 112 … … 125 128 this->loadedTopStateNode_ = this->rootStateNode_; 126 129 this->loadedStates_.push_back(this->getState(rootStateNode_->name_)); 130 131 orxout(internal_status) << "finished initializing Game object" << endl; 127 132 } 128 133 129 134 void Game::destroy() 130 135 { 136 orxout(internal_status) << "destroying Game object..." << endl; 137 131 138 // Remove us from the object lists again to avoid problems when destroying them 132 139 this->unregisterObject(); … … 139 146 safeObjectDelete(&core_); 140 147 safeObjectDelete(&gameClock_); 148 149 orxout(internal_status) << "finished destroying Game object..." << endl; 141 150 } 142 151 … … 163 172 { 164 173 if (this->requestedStateNodes_.empty()) 165 COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl; 174 orxout(user_error) << "Starting game without requesting GameState. This automatically terminates the program." << endl; 175 176 // Update the GameState stack if required. We do this already here to have a properly initialized game before entering the main loop 177 this->updateGameStateStack(); 178 179 orxout(user_status) << "Game loaded" << endl; 180 orxout(internal_status) << "--------------------------------------------------" << endl; 181 orxout(internal_status) << "starting main loop..." << endl; 166 182 167 183 // START GAME … … 189 205 catch (...) 190 206 { 191 COUT(0) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << std::endl;192 COUT(0) << "This should really never happen! Closing the program." << std::endl;207 orxout(user_error) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << endl; 208 orxout(user_error) << "This should really never happen! Closing the program." << endl; 193 209 this->stop(); 194 210 break; … … 203 219 catch (...) 204 220 { 205 COUT(0) << "An exception occurred in the Core postUpdate: " << Exception::handleMessage() << std::endl;206 COUT(0) << "This should really never happen! Closing the program." << std::endl;221 orxout(user_error) << "An exception occurred in the Core postUpdate: " << Exception::handleMessage() << endl; 222 orxout(user_error) << "This should really never happen! Closing the program." << endl; 207 223 this->stop(); 208 224 break; … … 217 233 this->updateFPSLimiter(); 218 234 } 235 236 orxout(internal_status) << "finished main loop" << endl; 237 orxout(internal_status) << "--------------------------------------------------" << endl; 219 238 220 239 // UNLOAD all remaining states … … 241 260 catch (...) 242 261 { 243 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << std::endl;262 orxout(user_error) << "Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << endl; 244 263 // All scheduled operations have now been rendered inert --> flush them and issue a warning 245 264 if (this->requestedStateNodes_.size() > 1) 246 COUT(4) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;265 orxout(internal_info) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << endl; 247 266 this->requestedStateNodes_.clear(); 248 267 break; … … 272 291 catch (...) 273 292 { 274 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << std::endl;275 COUT(1) << "This should really never happen!" << std::endl;276 COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;293 orxout(user_error) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << endl; 294 orxout(user_error) << "This should really never happen!" << endl; 295 orxout(user_error) << "Unloading all GameStates depending on the one that crashed." << endl; 277 296 shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_; 278 297 while (current->name_ != (*it)->getName() && current) … … 338 357 void Game::stop() 339 358 { 359 orxout(user_status) << "Exit" << endl; 340 360 this->bAbort_ = true; 341 361 } … … 355 375 if (!this->checkState(name)) 356 376 { 357 COUT(2) << "Warning: GameState named '" << name << "' doesn't exist!" << std::endl;377 orxout(user_warning) << "GameState named '" << name << "' doesn't exist!" << endl; 358 378 return; 359 379 } … … 361 381 if (this->bChangingState_) 362 382 { 363 COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;383 orxout(user_warning) << "Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << endl; 364 384 return; 365 385 } … … 372 392 if (name == lastRequestedNode->name_) 373 393 { 374 COUT(2) << "Warning: Requesting the currently active state! Ignoring." << std::endl;394 orxout(user_warning) << "Requesting the currently active state! Ignoring." << endl; 375 395 return; 376 396 } … … 403 423 404 424 if (requestedNodes.empty()) 405 COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;425 orxout(user_error) << "Requested GameState transition is not allowed. Ignoring." << endl; 406 426 else 407 427 this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end()); … … 425 445 this->requestState(lastRequestedNode->parent_.lock()->name_); 426 446 else 427 COUT(2) << "Warning: Can't pop the internal dummy root GameState" << std::endl;447 orxout(internal_warning) << "Can't pop the internal dummy root GameState" << endl; 428 448 } 429 449 … … 437 457 std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(name); 438 458 if (it != gameStateDeclarations_s.end()) 439 COUT(1) << "Error: GameState '" << name << "' has not yet been loaded." << std::endl;459 orxout(internal_error) << "GameState '" << name << "' has not yet been loaded." << endl; 440 460 else 441 COUT(1) << "Error: Could not find GameState '" << name << "'." << std::endl;461 orxout(internal_error) << "Could not find GameState '" << name << "'." << endl; 442 462 return shared_ptr<GameState>(); 443 463 } … … 507 527 if (!GameMode::showsGraphics()) 508 528 { 529 orxout(user_status) << "Loading graphics" << endl; 530 orxout(internal_info) << "loading graphics in Game" << endl; 531 509 532 core_->loadGraphics(); 510 533 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics); … … 524 547 } 525 548 graphicsUnloader.Dismiss(); 549 550 orxout(internal_info) << "finished loading graphics in Game" << endl; 526 551 } 527 552 } … … 531 556 if (GameMode::showsGraphics()) 532 557 { 558 orxout(user_status) << "Unloading graphics" << endl; 559 orxout(internal_info) << "unloading graphics in Game" << endl; 560 533 561 // Destroy all the GameStates that require graphics 534 562 for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();) … … 555 583 void Game::loadState(const std::string& name) 556 584 { 585 orxout(internal_status) << "loading state '" << name << "'" << endl; 586 557 587 this->bChangingState_ = true; 558 588 LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState); (void)LOKI_ANONYMOUS_VARIABLE(scopeGuard); … … 577 607 void Game::unloadState(const std::string& name) 578 608 { 609 orxout(internal_status) << "unloading state '" << name << "'" << endl; 610 579 611 this->bChangingState_ = true; 580 612 try … … 589 621 catch (...) 590 622 { 591 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << std::endl;592 COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;623 orxout(internal_warning) << "Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << endl; 624 orxout(internal_warning) << "There might be potential resource leaks involved! To avoid this, improve exception-safety." << endl; 593 625 } 594 626 // Check if graphics is still required -
code/trunk/src/libraries/core/Game.h
r8423 r8858 47 47 #include <boost/preprocessor/cat.hpp> 48 48 49 #include "util/ Debug.h"49 #include "util/Output.h" 50 50 #include "util/DestructionHelper.h" 51 51 #include "util/Singleton.h" … … 215 215 else 216 216 { 217 COUT(0) << "Error: Cannot declare two GameStates with the same name." << std::endl;218 COUT(0) << " Ignoring second one ('" << stateName << "')." << std::endl;217 orxout(internal_warning) << "Cannot declare two GameStates with the same name." << endl; 218 orxout(internal_warning) << "Ignoring second one ('" << stateName << "')." << endl; 219 219 } 220 220 -
code/trunk/src/libraries/core/GameState.cc
r6417 r8858 35 35 #include "GameState.h" 36 36 37 #include "util/Debug.h"38 37 #include "util/Exception.h" 39 38 #include "util/OrxAssert.h" -
code/trunk/src/libraries/core/GraphicsManager.cc
r8423 r8858 104 104 RegisterObject(GraphicsManager); 105 105 106 orxout(internal_status) << "initializing GraphicsManager..." << endl; 106 107 this->setConfigValues(); 107 108 … … 114 115 resources_.reset(new XMLFile("DefaultResources.oxr")); 115 116 resources_->setLuaSupport(false); 116 Loader::open(resources_.get() );117 Loader::open(resources_.get(), ClassTreeMask(), false); 117 118 118 119 // Only for runs in the build directory (not installed) … … 122 123 extResources_.reset(new XMLFile("resources.oxr")); 123 124 extResources_->setLuaSupport(false); 124 Loader::open(extResources_.get() );125 Loader::open(extResources_.get(), ClassTreeMask(), false); 125 126 126 127 if (bLoadRenderer) … … 129 130 this->upgradeToGraphics(); 130 131 } 132 133 orxout(internal_status) << "finished initializing GraphicsManager" << endl; 131 134 } 132 135 133 136 void GraphicsManager::destroy() 134 137 { 138 orxout(internal_status) << "destroying GraphicsManager..." << endl; 139 135 140 Loader::unload(debugOverlay_.get()); 136 141 … … 148 153 safeObjectDelete(&ogreLogger_); 149 154 safeObjectDelete(&ogreWindowEventListener_); 155 156 orxout(internal_status) << "finished destroying GraphicsManager" << endl; 150 157 } 151 158 … … 158 165 SetConfigValue(ogreLogFile_, "ogre.log") 159 166 .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation."); 160 SetConfigValue(ogreLogLevelTrivial_ , 5)161 .description("Corresponding orxonox debug level for ogre Trivial");162 SetConfigValue(ogreLogLevelNormal_ , 4)163 .description("Corresponding orxonox debug level for ogre Normal");164 SetConfigValue(ogreLogLevelCritical_, 2)165 .description("Corresponding orxonox debug level for ogre Critical");166 167 } 167 168 … … 179 180 return; 180 181 182 orxout(internal_info) << "GraphicsManager upgrade to graphics" << endl; 183 181 184 // load all the required plugins for Ogre 182 185 this->loadOgrePlugins(); … … 189 192 // choose another resource group. 190 193 Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 194 195 orxout(internal_info) << "GraphicsManager finished upgrade to graphics" << endl; 191 196 } 192 197 … … 197 202 void GraphicsManager::loadOgreRoot() 198 203 { 199 COUT(3) << "Setting up Ogre..." << std::endl;204 orxout(internal_info) << "Setting up Ogre..." << endl; 200 205 201 206 if (ogreConfigFile_.empty()) 202 207 { 203 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;208 orxout(internal_warning) << "Ogre config file set to \"\". Defaulting to config.cfg" << endl; 204 209 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg"); 205 210 } 206 211 if (ogreLogFile_.empty()) 207 212 { 208 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;213 orxout(internal_warning) << "Ogre log file set to \"\". Defaulting to ogre.log" << endl; 209 214 ModifyConfigValue(ogreLogFile_, tset, "ogre.log"); 210 215 } … … 216 221 // Ogre::Root will detect that we've already created a Log 217 222 ogreLogger_ = new Ogre::LogManager(); 218 COUT(4) << "Ogre LogManager created" << std::endl;223 orxout(internal_info) << "Ogre LogManager created" << endl; 219 224 220 225 // create our own log that we can listen to 221 226 Ogre::Log *myLog; 222 227 myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false); 223 COUT(4) << "Ogre Log created" << std::endl;228 orxout(internal_info) << "Ogre Log created" << endl; 224 229 225 230 myLog->setLogDetail(Ogre::LL_BOREME); 226 231 myLog->addListener(this); 227 232 228 COUT(4) << "Creating Ogre Root..." << std::endl;233 orxout(internal_info) << "Creating Ogre Root..." << endl; 229 234 230 235 // check for config file existence because Ogre displays (caught) exceptions if not … … 240 245 ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string()); 241 246 242 COUT(3) << "Ogre set up done." << std::endl;247 orxout(internal_info) << "Ogre set up done." << endl; 243 248 } 244 249 245 250 void GraphicsManager::loadOgrePlugins() 246 251 { 252 orxout(internal_info) << "loading ogre plugins" << endl; 253 247 254 // Plugin path can have many different locations... 248 255 std::string pluginPath = specialConfig::ogrePluginsDirectory; … … 277 284 void GraphicsManager::loadRenderer() 278 285 { 279 CCOUT(4) << "Configuring Renderer" << std::endl;286 orxout(internal_info) << "GraphicsManager: Configuring Renderer" << endl; 280 287 281 288 bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp(); 282 289 if (updatedConfig) 283 COUT(2) << "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << std::endl;290 orxout(user_info)<< "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << endl; 284 291 285 292 if (!ogreRoot_->restoreConfig() || updatedConfig) … … 291 298 } 292 299 293 CCOUT(4) << "Creating render window" << std::endl;300 orxout(internal_info) << "Creating render window" << endl; 294 301 295 302 this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox"); … … 317 324 { 318 325 // Load debug overlay to show info about fps and tick time 319 COUT(4) << "Loading Debug Overlay..." << std::endl;326 orxout(internal_info) << "Loading Debug Overlay..." << endl; 320 327 debugOverlay_.reset(new XMLFile("debug.oxo")); 321 Loader::open(debugOverlay_.get() );328 Loader::open(debugOverlay_.get(), ClassTreeMask(), false); 322 329 } 323 330 … … 396 403 Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName) 397 404 { 398 intorxonoxLevel;405 OutputLevel orxonoxLevel; 399 406 std::string introduction; 400 407 // Do not show caught OGRE exceptions in front 401 408 if (message.find("EXCEPTION") != std::string::npos) 402 409 { 403 orxonoxLevel = OutputLevel::Debug;410 orxonoxLevel = level::internal_error; 404 411 introduction = "Ogre, caught exception: "; 405 412 } … … 409 416 { 410 417 case Ogre::LML_TRIVIAL: 411 orxonoxLevel = this->ogreLogLevelTrivial_;418 orxonoxLevel = level::verbose_more; 412 419 break; 413 420 case Ogre::LML_NORMAL: 414 orxonoxLevel = this->ogreLogLevelNormal_;421 orxonoxLevel = level::verbose; 415 422 break; 416 423 case Ogre::LML_CRITICAL: 417 orxonoxLevel = this->ogreLogLevelCritical_;424 orxonoxLevel = level::internal_warning; 418 425 break; 419 426 default: 420 orxonoxLevel = 0;427 orxonoxLevel = level::debug_output; 421 428 } 422 429 introduction = "Ogre: "; 423 430 } 424 OutputHandler::getOutStream(orxonoxLevel) 425 << introduction << message << std::endl;431 432 orxout(orxonoxLevel, context::ogre) << introduction << message << endl; 426 433 } 427 434 -
code/trunk/src/libraries/core/GraphicsManager.h
r8706 r8858 134 134 std::string ogrePlugins_; //!< Comma separated list of all plugins to load 135 135 std::string ogreLogFile_; //!< log filename for Ogre log messages 136 int ogreLogLevelTrivial_; //!< Corresponding Orxonox debug level for LL_TRIVIAL137 int ogreLogLevelNormal_; //!< Corresponding Orxonox debug level for LL_NORMAL138 int ogreLogLevelCritical_; //!< Corresponding Orxonox debug level for LL_CRITICAL139 136 140 137 /// Helper object that executes the surrogate destructor destroy() -
code/trunk/src/libraries/core/Identifier.cc
r8267 r8858 130 130 { 131 131 // If no: We have to store the information and initialize the Identifier 132 COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl;132 orxout(verbose, context::identifier) << "Register Class in ClassIdentifier<" << this->getName() << ">-Singleton -> Initialize Singleton." << endl; 133 133 if (bRootClass) 134 134 this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case. … … 144 144 void Identifier::initialize(std::set<const Identifier*>* parents) 145 145 { 146 COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl;146 orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << this->name_ << ">-Singleton." << endl; 147 147 this->bCreatedOneObject_ = true; 148 148 … … 191 191 void Identifier::createClassHierarchy() 192 192 { 193 COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl;193 orxout(internal_status) << "Create class-hierarchy" << endl; 194 194 Identifier::startCreatingHierarchy(); 195 195 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it) … … 203 203 } 204 204 Identifier::stopCreatingHierarchy(); 205 COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl;205 orxout(internal_status) << "Finished class-hierarchy creation" << endl; 206 206 } 207 207 … … 242 242 else 243 243 { 244 COUT(1) << "An error occurred in Identifier.cc:" << std::endl;245 COUT(1) << "Error: Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << std::endl;246 COUT(1) << "Aborting..." << std::endl;244 orxout(user_error) << "An error occurred in Identifier.cc:" << endl; 245 orxout(user_error) << "Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << endl; 246 orxout(user_error) << "Aborting..." << endl; 247 247 abort(); 248 248 return 0; … … 404 404 if (it != this->configValues_.end()) 405 405 { 406 COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << '.' << std::endl;406 orxout(internal_warning) << "Overwriting config-value with name " << varname << " in class " << this->getName() << '.' << endl; 407 407 delete (it->second); 408 408 } … … 450 450 if (it != this->xmlportParamContainers_.end()) 451 451 { 452 COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << '.' << std::endl;452 orxout(internal_warning) << "Overwriting XMLPortParamContainer in class " << this->getName() << '.' << endl; 453 453 delete (it->second); 454 454 } … … 481 481 if (it != this->xmlportObjectContainers_.end()) 482 482 { 483 COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << '.' << std::endl;483 orxout(internal_warning) << "Overwriting XMLPortObjectContainer in class " << this->getName() << '.' << endl; 484 484 delete (it->second); 485 485 } -
code/trunk/src/libraries/core/Identifier.h
r8706 r8858 64 64 for (Iterator<BaseObject> it = objects.begin(); it != objects.end(); ++it) // iterate through the objects 65 65 ++count; 66 COUT(0) << count << std::endl;// prints "2" because we created 2 instances of MyClass so far66 orxout() << count << endl; // prints "2" because we created 2 instances of MyClass so far 67 67 68 68 … … 89 89 #include <loki/TypeTraits.h> 90 90 91 #include "util/ Debug.h"91 #include "util/Output.h" 92 92 #include "MetaObjectList.h" 93 93 #include "ObjectList.h" … … 405 405 if (ClassIdentifier<T>::classIdentifier_s == proposal) 406 406 { 407 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl;407 orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was not yet existing and got created." << endl; 408 408 } 409 409 else 410 410 { 411 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl;411 orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was already existing and got assigned." << endl; 412 412 } 413 413 } … … 423 423 { 424 424 if (bRootClass) 425 COUT(5) << "*** Register Root-Object: " << className << std::endl;425 orxout(verbose, context::object_list) << "Register Root-Object: " << className << endl; 426 426 else 427 COUT(5) << "*** Register Object: " << className << std::endl;427 orxout(verbose, context::object_list) << "Register Object: " << className << endl; 428 428 429 429 object->identifier_ = this; … … 444 444 else 445 445 { 446 COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;446 orxout(verbose, context::object_list) << "Added object to " << this->getName() << "-list." << endl; 447 447 object->metaList_->add(this->objects_, this->objects_->add(new ObjectListElement<T>(object))); 448 448 -
code/trunk/src/libraries/core/Language.cc
r7401 r8858 35 35 36 36 #include <fstream> 37 #include "util/ Debug.h"37 #include "util/Output.h" 38 38 #include "util/StringUtils.h" 39 39 #include "Core.h" … … 131 131 } 132 132 133 COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << '!' << std::endl;133 orxout(internal_warning, context::language) << "Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << '!' << endl; 134 134 return it->second; 135 135 } … … 142 142 void Language::addEntry(const LanguageEntryLabel& label, const std::string& entry) 143 143 { 144 COUT(5) << "Language: Called addEntry with\n label: " << label << "\n entry: " << entry << std::endl;144 orxout(verbose, context::language) << "Called addEntry with" << '\n' << "label: " << label << '\n' << "entry: " << entry << endl; 145 145 std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label); 146 146 if (it == this->languageEntries_.end()) … … 179 179 { 180 180 // Uh, oh, an undefined entry was requested: return the default string 181 COUT(2) << "Warning: Language entry \"" << label << "\" not found!" << std::endl;181 orxout(internal_warning, context::language) << "Language entry \"" << label << "\" not found!" << endl; 182 182 return this->defaultLocalisation_; 183 183 } … … 201 201 void Language::readDefaultLanguageFile() 202 202 { 203 COUT(4) << "Read default language file." << std::endl;203 orxout(internal_info, context::language) << "Read default language file." << endl; 204 204 205 205 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_); … … 216 216 if (!file.is_open()) 217 217 { 218 COUT(1) << "An error occurred in Language.cc:" << std::endl;219 COUT(1) << "Error: Couldn't open file " << getFilename(this->defaultLanguage_) << " to read the default language entries!" << std::endl;218 orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl; 219 orxout(internal_error, context::language) << "Couldn't open file " << getFilename(this->defaultLanguage_) << " to read the default language entries!" << endl; 220 220 return; 221 221 } … … 237 237 else 238 238 { 239 COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(this->defaultLanguage_) << std::endl;239 orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(this->defaultLanguage_) << endl; 240 240 } 241 241 } … … 250 250 void Language::readTranslatedLanguageFile() 251 251 { 252 COUT(4) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << std::endl;252 orxout(internal_info, context::language) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << endl; 253 253 254 254 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getLanguage()); … … 260 260 if (!file.is_open()) 261 261 { 262 COUT(1) << "An error occurred in Language.cc:" << std::endl;263 COUT(1) << "Error: Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << std::endl;262 orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl; 263 orxout(internal_error, context::language) << "Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << endl; 264 264 Core::getInstance().resetLanguage(); 265 COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << '.' << std::endl;265 orxout(internal_info, context::language) << "Reset language to " << this->defaultLanguage_ << '.' << endl; 266 266 return; 267 267 } … … 291 291 else 292 292 { 293 COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << std::endl;293 orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << endl; 294 294 } 295 295 } … … 304 304 void Language::writeDefaultLanguageFile() const 305 305 { 306 COUT(4) << "Language: Write default language file." << std::endl;306 orxout(verbose, context::language) << "Write default language file." << endl; 307 307 308 308 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_); … … 314 314 if (!file.is_open()) 315 315 { 316 COUT(1) << "An error occurred in Language.cc:" << std::endl;317 COUT(1) << "Error: Couldn't open file " << getFilename(this->defaultLanguage_) << " to write the default language entries!" << std::endl;316 orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl; 317 orxout(internal_error, context::language) << "Couldn't open file " << getFilename(this->defaultLanguage_) << " to write the default language entries!" << endl; 318 318 return; 319 319 } … … 322 322 for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it) 323 323 { 324 file << it->second->getLabel() << '=' << it->second->getDefault() << std::endl;324 file << it->second->getLabel() << '=' << it->second->getDefault() << endl; 325 325 } 326 326 -
code/trunk/src/libraries/core/Language.h
r7401 r8858 51 51 - Get the localisation of the entry in the configured language: 52 52 @code 53 std::cout << Language::getInstance()->getLocalisation("name of the entry") << std::endl;53 orxout() << Language::getInstance()->getLocalisation("name of the entry") << endl; 54 54 @endcode 55 55 … … 58 58 int age = 20; 59 59 AddLanguageEntry("user_age", "Age"); 60 std::cout << GetLocalisation("user_age") << ": " << age << std::endl;60 orxout() << GetLocalisation("user_age") << ": " << age << endl; 61 61 @endcode 62 62 -
code/trunk/src/libraries/core/Loader.cc
r8108 r8858 33 33 #include <boost/scoped_ptr.hpp> 34 34 35 #include "util/ Debug.h"35 #include "util/Output.h" 36 36 #include "util/Exception.h" 37 37 #include "util/StringUtils.h" … … 49 49 ClassTreeMask Loader::currentMask_s; 50 50 51 bool Loader::open(const XMLFile* file, const ClassTreeMask& mask )51 bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose) 52 52 { 53 53 Loader::add(file, mask); 54 return Loader::load(file, mask );54 return Loader::load(file, mask, bVerbose); 55 55 } 56 56 … … 93 93 @param mask 94 94 A ClassTreeMask, which defines which types of classes are loaded and which aren't. 95 @param verbose95 @param bVerbose 96 96 Whether the loader is verbose (prints its progress in a low output level) or not. 97 97 @return 98 98 Returns true if successful. 99 99 */ 100 bool Loader::load(const ClassTreeMask& mask, bool verbose)100 bool Loader::load(const ClassTreeMask& mask, bool bVerbose) 101 101 { 102 102 bool success = true; 103 103 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it) 104 if (!Loader::load(it->first, it->second * mask, verbose))104 if (!Loader::load(it->first, it->second * mask, bVerbose)) 105 105 success = false; 106 106 … … 124 124 @param mask 125 125 A ClassTreeMask, which defines which types of classes are reloaded and which aren't. 126 @param verbose126 @param bVerbose 127 127 Whether the loader is verbose (prints its progress in a low output level) or not. 128 128 @return 129 129 Returns true if successful. 130 130 */ 131 bool Loader::reload(const ClassTreeMask& mask, bool verbose)131 bool Loader::reload(const ClassTreeMask& mask, bool bVerbose) 132 132 { 133 133 Loader::unload(mask); 134 return Loader::load(mask, verbose);134 return Loader::load(mask, bVerbose); 135 135 } 136 136 … … 142 142 @param mask 143 143 A ClassTreeMask, which defines which types of classes are loaded and which aren't. 144 @param verbose144 @param bVerbose 145 145 Whether the loader is verbose (prints its progress in a low output level) or not. 146 146 @param bRemoveLuaTags … … 149 149 Returns true if successful. 150 150 */ 151 bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose, bool bRemoveLuaTags)151 bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose, bool bRemoveLuaTags) 152 152 { 153 153 if (!file) … … 170 170 if (info == NULL) 171 171 { 172 COUT(1) << "Error: Could not find XML file '" << file->getFilename() << "'." << std::endl;172 orxout(user_error, context::loader) << "Could not find XML file '" << file->getFilename() << "'." << endl; 173 173 return false; 174 174 } … … 187 187 try 188 188 { 189 if( verbose)190 { 191 COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl;192 COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;193 } 194 else 195 { 196 COUT(4) << "Start loading " << file->getFilename() << "..." << std::endl;197 COUT(4) << "Mask: " << Loader::currentMask_s << std::endl;189 if(bVerbose) 190 { 191 orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl; 192 orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl; 193 } 194 else 195 { 196 orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl; 197 orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s << endl; 198 198 } 199 199 … … 208 208 rootElement.InsertEndChild(*child); 209 209 210 COUT(4) << " creating root-namespace..." << std::endl;210 orxout(verbose, context::loader) << " creating root-namespace..." << endl; 211 211 Namespace* rootNamespace = new Namespace(0); 212 212 rootNamespace->setLoaderIndentation(" "); … … 216 216 rootNamespace->XMLPort(rootElement, XMLPort::LoadObject); 217 217 218 if( verbose)219 COUT(0) << "Finished loading " << file->getFilename() << '.' << std::endl;220 else 221 COUT(4) << "Finished loading " << file->getFilename() << '.' << std::endl;222 223 COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString(" ") << std::endl;218 if(bVerbose) 219 orxout(user_info) << "Finished loading " << file->getFilename() << '.' << endl; 220 else 221 orxout(verbose, context::loader) << "Finished loading " << file->getFilename() << '.' << endl; 222 223 orxout(verbose, context::loader) << "Namespace-tree:" << '\n' << rootNamespace->toString(" ") << endl; 224 224 225 225 return true; … … 227 227 catch (ticpp::Exception& ex) 228 228 { 229 COUT(1) << std::endl;230 COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;231 COUT(1) << ex.what() << std::endl;232 COUT(1) << "Loading aborted." << std::endl;229 orxout(user_error, context::loader) << endl; 230 orxout(user_error, context::loader) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl; 231 orxout(user_error, context::loader) << ex.what() << endl; 232 orxout(user_error, context::loader) << "Loading aborted." << endl; 233 233 return false; 234 234 } 235 235 catch (Exception& ex) 236 236 { 237 COUT(1) << std::endl;238 COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;239 COUT(1) << ex.what() << std::endl;240 COUT(1) << "Loading aborted." << std::endl;237 orxout(user_error, context::loader) << endl; 238 orxout(user_error, context::loader) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl; 239 orxout(user_error, context::loader) << ex.what() << endl; 240 orxout(user_error, context::loader) << "Loading aborted." << endl; 241 241 return false; 242 242 } 243 243 catch (...) 244 244 { 245 COUT(1) << std::endl;246 COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;247 COUT(1) << Exception::handleMessage() << std::endl;248 COUT(1) << "Loading aborted." << std::endl;245 orxout(user_error, context::loader) << endl; 246 orxout(user_error, context::loader) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl; 247 orxout(user_error, context::loader) << Exception::handleMessage() << endl; 248 orxout(user_error, context::loader) << "Loading aborted." << endl; 249 249 return false; 250 250 } … … 271 271 @param mask 272 272 A ClassTreeMask, which defines which types of classes are reloaded and which aren't. 273 @param verbose273 @param bVerbose 274 274 Whether the loader is verbose (prints its progress in a low output level) or not. 275 275 @return 276 276 Returns true if successful. 277 277 */ 278 bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool verbose)278 bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose) 279 279 { 280 280 Loader::unload(file, mask); 281 return Loader::load(file, mask, verbose);281 return Loader::load(file, mask, bVerbose); 282 282 } 283 283 … … 337 337 if (!expectedValue) 338 338 { 339 COUT(2) << "Warning: Error in level file" << std::endl;339 orxout(internal_error, context::loader) << "Error in level file" << endl; 340 340 // TODO: error handling 341 return false; 341 return false; 342 342 } 343 343 } -
code/trunk/src/libraries/core/Loader.h
r8079 r8858 51 51 { 52 52 public: 53 static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask() );53 static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 54 54 static void close(); 55 55 static void close(const XMLFile* file); … … 58 58 static void remove(const XMLFile* file); 59 59 60 static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);60 static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 61 61 static void unload(const ClassTreeMask& mask = ClassTreeMask()); 62 static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);62 static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 63 63 64 64 static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), 65 bool verbose = true, bool bRemoveLuaTags = false);65 bool bVerbose = true, bool bRemoveLuaTags = false); 66 66 static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 67 static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);67 static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 68 68 69 69 static std::string replaceLuaTags(const std::string& text); -
code/trunk/src/libraries/core/LuaState.cc
r8729 r8858 37 37 #include <loki/ScopeGuard.h> 38 38 39 #include "util/ Debug.h"39 #include "util/Output.h" 40 40 #include "util/Exception.h" 41 41 #include "Resource.h" … … 96 96 else 97 97 { 98 COUT(2) << "LuaState: Cannot include file '" << filename << "' (not found)." << std::endl;98 orxout(internal_warning, context::lua) << "LuaState: Cannot include file '" << filename << "' (not found)." << endl; 99 99 return false; 100 100 } … … 136 136 else 137 137 { 138 COUT(2) << "LuaState: Cannot do file '" << filename << "' (not found)." << std::endl;138 orxout(internal_warning, context::lua) << "LuaState: Cannot do file '" << filename << "' (not found)." << endl; 139 139 return false; 140 140 } … … 176 176 { 177 177 case LUA_ERRSYNTAX: // Syntax error 178 COUT(1) << "Lua syntax error: " << lua_tostring(luaState_, -1) << std::endl;178 orxout(internal_error, context::lua) << "Lua syntax error: " << lua_tostring(luaState_, -1) << endl; 179 179 break; 180 180 case LUA_ERRMEM: // Memory allocation error 181 COUT(1) << "Lua memory allocation error: Consult your dentist immediately!" << std::endl;181 orxout(internal_error, context::lua) << "Lua memory allocation error: Consult your dentist immediately!" << endl; 182 182 break; 183 183 } … … 200 200 std::string errorString = lua_tostring(this->luaState_, -1); 201 201 if (errorString.find("Error propagation") == std::string::npos) 202 COUT(1) << "Lua runtime error: " << errorString << std::endl;202 orxout(internal_error, context::lua) << "Lua runtime error: " << errorString << endl; 203 203 } 204 204 break; 205 205 case LUA_ERRERR: // Error in the error handler 206 COUT(1) << "Lua error in error handler. No message available." << std::endl;206 orxout(internal_error, context::lua) << "Lua error in error handler. No message available." << endl; 207 207 break; 208 208 case LUA_ERRMEM: // Memory allocation error 209 COUT(1) << "Lua memory allocation error: Consult your dentist immediately!" << std::endl;209 orxout(internal_error, context::lua) << "Lua memory allocation error: Consult your dentist immediately!" << endl; 210 210 break; 211 211 } … … 236 236 } 237 237 238 void LuaState::luaLog(unsigned int level, const std::string& message) 239 { 240 OutputHandler::getOutStream(level) << message << std::endl; 238 void LuaState::luaOutput(OutputLevel level, const std::string& context, const std::string& message) 239 { 240 orxout(level, registerContext(context)) << message << endl; 241 } 242 243 void LuaState::luaOutput(OutputLevel level, const std::string& message) 244 { 245 orxout(level, context::lua) << message << endl; 246 } 247 248 void LuaState::luaOutput(const std::string& message) 249 { 250 orxout(debug_output, context::lua) << message << endl; 241 251 } 242 252 … … 288 298 if (it->first == name || it->second == function) 289 299 { 290 COUT(2) << "Warning: Trying to add a Tolua interface with the same name or function." << std::endl;300 orxout(internal_warning, context::lua) << "Trying to add a Tolua interface with the same name or function." << endl; 291 301 return true; 292 302 } … … 307 317 if (it == getToluaInterfaces().end()) 308 318 { 309 COUT(2) << "Warning: Cannot remove Tolua interface '" << name << "': Not found" << std::endl;319 orxout(internal_warning, context::lua) << "Cannot remove Tolua interface '" << name << "': Not found" << endl; 310 320 return true; 311 321 } -
code/trunk/src/libraries/core/LuaState.h
r8729 r8858 49 49 #include <boost/shared_ptr.hpp> 50 50 51 #include "util/Output.h" 52 51 53 namespace orxonox // tolua_export 52 54 { // tolua_export … … 83 85 84 86 void luaPrint(const std::string& str); // tolua_export 85 void luaLog(unsigned int level, const std::string& message); // tolua_export 87 void luaOutput(orxonox::level::OutputLevel level, const std::string& context, const std::string& message); // tolua_export 88 void luaOutput(orxonox::level::OutputLevel level, const std::string& message); // tolua_export 89 void luaOutput(const std::string& message); // tolua_export 86 90 bool fileExists(const std::string& filename); // tolua_export 87 91 std::string getSourceCode(const std::string& filename); // tolua_export -
code/trunk/src/libraries/core/MetaObjectList.cc
r5738 r8858 34 34 #include "MetaObjectList.h" 35 35 36 #include "util/ Debug.h"36 #include "util/Output.h" 37 37 #include "Identifier.h" 38 38 #include "ObjectListBase.h" … … 48 48 MetaObjectListElement::~MetaObjectListElement() 49 49 { 50 COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl;50 orxout(verbose, context::object_list) << "Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << endl; 51 51 this->list_->notifyIterators(this->element_->objectBase_); 52 52 -
code/trunk/src/libraries/core/NamespaceNode.cc
r6417 r8858 28 28 29 29 #include "NamespaceNode.h" 30 #include "util/ Debug.h"30 #include "util/Output.h" 31 31 32 32 namespace orxonox … … 70 70 if (this->bRoot_) 71 71 { 72 COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << std::endl;72 orxout(internal_warning) << "Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << endl; 73 73 nodes = this->getNodeRelative(secondPart); 74 74 } 75 75 else if (!this->parent_) 76 76 { 77 COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << std::endl;77 orxout(internal_warning) << "Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << endl; 78 78 nodes = this->getNodeRelative(secondPart); 79 79 } … … 91 91 if (it->second->isHidden()) 92 92 { 93 COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl;93 orxout(internal_warning) << "Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << endl; 94 94 nodes.insert(this); 95 95 } … … 115 115 if (!bFoundMatchingNamespace) 116 116 { 117 COUT(2) << "Warning: No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << std::endl;117 orxout(internal_warning) << "No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << endl; 118 118 nodes = this->getNodeRelative(secondPart); 119 119 } -
code/trunk/src/libraries/core/OrxonoxClass.cc
r7849 r8858 60 60 { 61 61 // if (!this->requestedDestruction_) 62 // COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << std::endl;62 // orxout(internal_warning) << "Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << endl; 63 63 64 64 assert(this->referenceCount_ <= 0); -
code/trunk/src/libraries/core/OrxonoxClass.h
r8729 r8858 49 49 #include <vector> 50 50 #include "Super.h" 51 52 /**53 @def CCOUT54 Acts almost exactly like COUT(x), but prepends "ClassName: "55 */56 #define CCOUT(level) \57 COUT(level) << this->getIdentifier()->getName() << ": "58 51 59 52 namespace orxonox -
code/trunk/src/libraries/core/PathConfig.cc
r8729 r8858 51 51 52 52 #include "SpecialConfig.h" 53 #include "util/ Debug.h"53 #include "util/Output.h" 54 54 #include "util/Exception.h" 55 55 #include "CommandLineParser.h" … … 137 137 if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me")) 138 138 { 139 COUT(1) << "Running from the build tree." << std::endl;139 orxout(internal_info) << "Running from the build tree." << endl; 140 140 PathConfig::bBuildDirectoryRun_ = true; 141 141 modulePath_ = specialConfig::moduleDevDirectory; … … 247 247 if (bf::create_directories(it->first)) // function may not return true at all (bug?) 248 248 { 249 COUT(4) << "Created " << it->second << " directory" << std::endl;249 orxout(internal_info) << "Created " << it->second << " directory" << endl; 250 250 } 251 251 } -
code/trunk/src/libraries/core/SubclassIdentifier.h
r7401 r8858 69 69 70 70 #include <cstdlib> 71 #include "util/ Debug.h"71 #include "util/Output.h" 72 72 #include "Identifier.h" 73 73 … … 119 119 if (!identifier || !identifier->isA(ClassIdentifier<T>::getIdentifier())) 120 120 { 121 COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;121 orxout(internal_error) << "An error occurred in SubclassIdentifier (Identifier.h):" << endl; 122 122 if (identifier) 123 123 { 124 COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;125 COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;124 orxout(internal_error) << "Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << endl; 125 orxout(internal_error) << "SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << endl; 126 126 } 127 127 else 128 128 { 129 COUT(1) << "Error: Can't assign NULL identifier" << std::endl;129 orxout(internal_error) << "Can't assign NULL identifier" << endl; 130 130 } 131 131 } … … 177 177 if (this->identifier_) 178 178 { 179 COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;180 COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;181 COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;179 orxout(user_error) << "An error occurred in SubclassIdentifier (Identifier.h):" << endl; 180 orxout(user_error) << "Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << endl; 181 orxout(user_error) << "Couldn't fabricate a new Object." << endl; 182 182 } 183 183 else 184 184 { 185 COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;186 COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl;187 } 188 189 COUT(1) << "Aborting..." << std::endl;185 orxout(user_error) << "An error occurred in SubclassIdentifier (Identifier.h):" << endl; 186 orxout(user_error) << "Couldn't fabricate a new Object - Identifier is undefined." << endl; 187 } 188 189 orxout(user_error) << "Aborting..." << endl; 190 190 abort(); 191 191 return 0; -
code/trunk/src/libraries/core/Super.h
r8729 r8858 73 73 74 74 #include "CorePrereqs.h" 75 #include "util/ Debug.h"75 #include "util/Output.h" 76 76 77 77 /////////////////////// … … 114 114 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ 115 115 { \ 116 COUT(5) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; \116 orxout(verbose, context::super) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << endl; \ 117 117 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \ 118 118 } \ … … 184 184 { 185 185 // Add the SuperFunctionCaller 186 COUT(5) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl;186 orxout(verbose, context::super) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << endl; 187 187 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; 188 188 } -
code/trunk/src/libraries/core/Template.cc
r7163 r8858 32 32 #include <tinyxml/ticpp.h> 33 33 34 #include "util/ Debug.h"34 #include "util/Output.h" 35 35 #include "CoreIncludes.h" 36 36 #include "XMLPort.h" … … 88 88 it = Template::getTemplateMap().find(this->getName()); 89 89 if (it != Template::getTemplateMap().end()) 90 COUT(2) << "Warning: Template with name \"" << this->getName() << "\" already exists." << std::endl;90 orxout(internal_warning, context::templates) << "Template with name \"" << this->getName() << "\" already exists." << endl; 91 91 else 92 92 Template::getTemplateMap()[this->getName()] = this; … … 117 117 else 118 118 { 119 COUT(2) << "Warning: Linking from " << this->getName() << " to " << this->link_ << " leads to an infinite loop. Returning own element." << std::endl;119 orxout(internal_warning, context::templates) << "Linking from \"" << this->getName() << "\" to \"" << this->link_ << "\" leads to an infinite loop. Returning own element." << endl; 120 120 } 121 121 } 122 122 else 123 123 { 124 COUT(2) << "Warning: " << this->link_ << " is not an existing Template name. Returning own element." << std::endl;124 orxout(internal_warning, context::templates) << '"' << this->link_ << "\" is not an existing Template name. Returning own element." << endl; 125 125 } 126 126 } … … 142 142 if (!object->isA(this->baseclassIdentifier_)) 143 143 { 144 COUT(1) << "Error: Can't apply template (name: " << this->getName() << "), object (name: " << object->getName() << ", class: " << object->getIdentifier()->getName() << ") is not a " << this->baseclassIdentifier_->getName() << std::endl;144 orxout(internal_error, context::templates) << "Can't apply template (name: " << this->getName() << "), object (name: " << object->getName() << ", class: " << object->getIdentifier()->getName() << ") is not a " << this->baseclassIdentifier_->getName() << endl; 145 145 return; 146 146 } 147 147 } 148 148 149 COUT(4) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << std::endl;149 orxout(verbose, context::templates) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << endl; 150 150 151 151 Element temp = &const_cast<TiXmlElement&>(this->getXMLElement()); … … 170 170 else 171 171 { 172 COUT(2) << "Warning: Template with name " << name << " doesn't exist." << std::endl;172 orxout(internal_warning, context::templates) << "Template with name " << name << " doesn't exist." << endl; 173 173 return 0; 174 174 } -
code/trunk/src/libraries/core/WeakPtr.h
r8079 r8858 65 65 void myCallback() // definition of the callback function 66 66 { 67 COUT(0) << "Object destroyed" << std::endl;67 orxout() << "Object destroyed" << endl; 68 68 } 69 69 -
code/trunk/src/libraries/core/XMLPort.cc
r7163 r8858 64 64 if (!this->sectionname_.empty()) 65 65 { 66 COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;66 orxout(internal_warning, context::xml) << object->getLoaderIndentation() << "'" << child->Value() << "' is not a valid classname." << endl; 67 67 } 68 68 else … … 74 74 if (!identifier->isA(objectIdentifier_)) 75 75 { 76 COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << objectIdentifier_->getName() << "'." << std::endl;76 orxout(internal_warning, context::xml) << object->getLoaderIndentation() << "'" << child->Value() << "' is not a '" << objectIdentifier_->getName() << "'." << endl; 77 77 continue; 78 78 } 79 79 if (!identifier->isLoadable()) 80 80 { 81 COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;81 orxout(internal_warning, context::xml) << object->getLoaderIndentation() << "'" << child->Value() << "' is not loadable." << endl; 82 82 continue; 83 83 } … … 87 87 try 88 88 { 89 COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;89 orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << endl; 90 90 91 91 BaseObject* newObject = identifier->fabricate(object); … … 95 95 { 96 96 newObject->XMLPort(*child, XMLPort::LoadObject); 97 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;97 orxout(verbose, context::xml) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << endl; 98 98 } 99 99 else 100 100 { 101 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;101 orxout(verbose, context::xml) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << endl; 102 102 } 103 104 COUT(5) << object->getLoaderIndentation();105 103 106 104 this->callLoadExecutor(object, newObject); … … 109 107 newObject->XMLPort(*child, XMLPort::LoadObject); 110 108 111 COUT(5) << object->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;109 orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << endl; 112 110 } 113 111 catch (AbortLoadingException& ex) 114 112 { 115 COUT(1) << "An error occurred while loading object, abort loading..." << std::endl;113 orxout(internal_error, context::xml) << "An error occurred while loading object, abort loading..." << endl; 116 114 throw ex; 117 115 } 118 116 catch (...) 119 117 { 120 COUT(1) << "An error occurred while loading object:" << std::endl;121 COUT(1) << Exception::handleMessage() << std::endl;118 orxout(internal_error, context::xml) << "An error occurred while loading object:" << endl; 119 orxout(internal_error, context::xml) << Exception::handleMessage() << endl; 122 120 } 123 121 } … … 125 123 catch (ticpp::Exception& ex) 126 124 { 127 COUT(1) << std::endl;128 COUT(1) << "An error occurred in XMLPort.h while loading a '" << objectIdentifier_->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << std::endl;129 COUT(1) << ex.what() << std::endl;125 orxout(internal_error, context::xml) << endl; 126 orxout(internal_error, context::xml) << "An error occurred in XMLPort.h while loading a '" << objectIdentifier_->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << endl; 127 orxout(internal_error, context::xml) << ex.what() << endl; 130 128 } 131 129 } -
code/trunk/src/libraries/core/XMLPort.h
r7851 r8858 53 53 #include <tinyxml/ticpp.h> 54 54 55 #include "util/ Debug.h"55 #include "util/Output.h" 56 56 #include "util/Exception.h" 57 57 #include "util/MultiType.h" … … 415 415 if ((!attributeValue.empty()) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet())) 416 416 { 417 COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();417 orxout(verbose_more, context::xml) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << endl; 418 418 int error; 419 419 this->loadexecutor_->parse(object, attributeValue, &error, ","); … … 430 430 catch (ticpp::Exception& ex) 431 431 { 432 COUT(1) << std::endl;433 COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ':' << std::endl;434 COUT(1) << ex.what() << std::endl;432 orxout(internal_error, context::xml) << endl; 433 orxout(internal_error, context::xml) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ':' << endl; 434 orxout(internal_error, context::xml) << ex.what() << endl; 435 435 } 436 436 } -
code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
r8351 r8858 90 90 ArgumentCompletionList _groupsandcommands(const std::string& fragment, bool bOnlyShowHidden) 91 91 { 92 // note: this function returns only arguments that begin with "fragment", which would 't be necessary for the92 // note: this function returns only arguments that begin with "fragment", which wouldn't be necessary for the 93 93 // auto-completion, but it's necessary to place the line-break "\n" between groups and commands 94 94 // only if both groups AND commands are in the list. … … 100 100 const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommand::getCommands(); 101 101 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group) 102 if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find _first_of(fragmentLC) == 0))102 if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0)) 103 103 groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first))); 104 104 … … 113 113 // add the shortcuts 114 114 for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command) 115 if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find _first_of(fragmentLC) == 0))115 if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find(fragmentLC) == 0)) 116 116 groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first))); 117 117 } -
code/trunk/src/libraries/core/command/CommandEvaluation.cc
r7401 r8858 131 131 132 132 if (!this->execCommand_) 133 *error = CommandExecutor:: Error;133 *error = CommandExecutor::Inexistent; 134 134 else if (!this->execCommand_->isActive()) 135 135 *error = CommandExecutor::Deactivated; … … 151 151 if (this->bEvaluatedArguments_) 152 152 { 153 COUT(6) << "CE_execute (evaluation): " << this->execCommand_->getName() << " with " << this->numberOfEvaluatedArguments_ << " arguments: " << this->arguments_[0] << ' ' << this->arguments_[1] << ' ' << this->arguments_[2] << ' ' << this->arguments_[3] << ' ' << this->arguments_[4] << std::endl;153 orxout(verbose, context::commands) << "CE_execute (evaluation): " << this->execCommand_->getName() << " with " << this->numberOfEvaluatedArguments_ << " arguments: " << this->arguments_[0] << ' ' << this->arguments_[1] << ' ' << this->arguments_[2] << ' ' << this->arguments_[3] << ' ' << this->arguments_[4] << endl; 154 154 155 155 // pass as many arguments to the executor as were evaluated (thus the executor can still use additional default values) … … 186 186 { 187 187 if (bPrintError) 188 COUT(1) << "Error: Can't evaluate arguments, no console command assigned." << std::endl;189 return CommandExecutor:: Error;188 orxout(internal_error, context::commands) << "Can't evaluate arguments, no console command assigned." << endl; 189 return CommandExecutor::Inexistent; 190 190 } 191 191 … … 200 200 this->bEvaluatedArguments_ = true; 201 201 else if (bPrintError) 202 COUT(1) << "Error: Can't evaluate arguments, not enough arguments given." << std::endl;202 orxout(internal_error, context::commands) << "Can't evaluate arguments, not enough arguments given." << endl; 203 203 204 204 return error; -
code/trunk/src/libraries/core/command/CommandExecutor.cc
r7401 r8858 69 69 @return Returns the error-code (see @ref CommandExecutorErrorCodes "error codes") 70 70 */ 71 /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl )71 /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl, bool printErrors) 72 72 { 73 73 int error; 74 74 CommandExecutor::queryMT(command, &error, useTcl); 75 if (error && printErrors) 76 orxout(user_error) << "Can't execute \"" << command << "\", " << CommandExecutor::getErrorDescription(error) << ". (execute)" << endl; 75 77 return error; 76 78 } … … 85 87 /* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl) 86 88 { 89 MultiType result; 90 int error_internal; 91 87 92 if (useTcl) 88 93 { 89 94 // pass the command to tcl 90 re turn TclBind::eval(command, error);95 result = TclBind::eval(command, &error_internal); 91 96 } 92 97 else … … 108 113 109 114 // query the command and return its return-value 110 return evaluation.query(error); 111 } 115 result = evaluation.query(&error_internal); 116 } 117 118 if (error) 119 *error = error_internal; 120 else if (error_internal) 121 orxout(user_error) << "Can't execute \"" << command << "\", " << CommandExecutor::getErrorDescription(error_internal) << ". (query)" << endl; 122 123 return result; 112 124 } 113 125 … … 172 184 173 185 /** 186 @brief Returns a description of the error code. 187 @param error The error code 188 */ 189 /* static */ std::string CommandExecutor::getErrorDescription(int error) 190 { 191 switch (error) 192 { 193 case CommandExecutor::Inexistent: return "command doesn't exist"; 194 case CommandExecutor::Incomplete: return "not enough arguments given"; 195 case CommandExecutor::Deactivated: return "command is not active"; 196 case CommandExecutor::Denied: return "access denied"; 197 case CommandExecutor::Error: return "an error occurred"; 198 default: return ""; 199 } 200 } 201 202 /** 174 203 @brief Gets an evaluated command from the cache. 175 204 @param command The command that should be looked up in the cache … … 261 290 if ((tokens.size() == 1 && ConsoleCommand::getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommand::getCommand(tokens[0], tokens[1]))) 262 291 { 263 COUT(1) << "Error: A command with name \"" << alias << "\" already exists." << std::endl;292 orxout(user_error) << "A command with name \"" << alias << "\" already exists." << endl; 264 293 return; 265 294 } … … 271 300 createConsoleCommand(tokens[0], tokens[1], executor); 272 301 else 273 COUT(1) << "Error: \"" << alias << "\" is not a valid alias name (must have one or two words)." << std::endl;302 orxout(user_error) << "\"" << alias << "\" is not a valid alias name (must have one or two words)." << endl; 274 303 } 275 304 else 276 COUT(1) << "Error: \"" << command << "\" is not a valid command (did you mean \"" << evaluation.getCommandSuggestion() << "\"?)." << std::endl;305 orxout(user_error) << "\"" << command << "\" is not a valid command (did you mean \"" << evaluation.getCommandSuggestion() << "\"?)." << endl; 277 306 } 278 307 } -
code/trunk/src/libraries/core/command/CommandExecutor.h
r7401 r8858 111 111 // tolua_end 112 112 public: 113 static int execute(const std::string& command, bool useTcl = true ); // tolua_export113 static int execute(const std::string& command, bool useTcl = true, bool printErrors = true); // tolua_export 114 114 115 115 static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true); … … 119 119 120 120 static const int Success = 0; ///< Error code for "success" (or no error) 121 static const int Error = 1;///< Error code if the command doesn't exist121 static const int Inexistent = 1; ///< Error code if the command doesn't exist 122 122 static const int Incomplete = 2; ///< Error code if the command needs more arguments 123 123 static const int Deactivated = 3; ///< Error code if the command is not active 124 124 static const int Denied = 4; ///< Error code if the command needs a different access level 125 static const int Error = 5; ///< Error code if the command returned an error 126 127 static std::string getErrorDescription(int error); 125 128 126 129 static MultiType unhide(const std::string& command); -
code/trunk/src/libraries/core/command/ConsoleCommand.cc
r8316 r8858 172 172 if (!this->executor_->defaultValueSet(i)) 173 173 { 174 COUT(2) << "Default value " << i << " is missing" << std::endl;174 orxout(internal_warning, context::commands) << "Default value " << i << " is missing" << endl; 175 175 return false; 176 176 } … … 202 202 if (!executor->defaultValueSet(i)) 203 203 { 204 COUT(2) << "Default value " << i << " is missing" << std::endl;204 orxout(internal_warning, context::commands) << "Default value " << i << " is missing" << endl; 205 205 return false; 206 206 } … … 229 229 else 230 230 { 231 COUT(1) << "Error: Couldn't assign new executor to console command \"" << this->baseName_ << "\", headers don't match." << std::endl;231 orxout(internal_error, context::commands) << "Couldn't assign new executor to console command \"" << this->baseName_ << "\", headers don't match." << endl; 232 232 return false; 233 233 } … … 256 256 else 257 257 { 258 COUT(1) << "Error: Couldn't assign new functor to console command \"" << this->baseName_ << "\", headers don't match." << std::endl;258 orxout(internal_error, context::commands) << "Couldn't assign new functor to console command \"" << this->baseName_ << "\", headers don't match." << endl; 259 259 return false; 260 260 } … … 307 307 this->pushFunction(new Executor(*this->executor_.get())); 308 308 else 309 COUT(1) << "Error: Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << std::endl;309 orxout(internal_error, context::commands) << "Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << endl; 310 310 } 311 311 … … 367 367 } 368 368 else if (object) 369 COUT(1) << "Error: Can't assign object to console command \"" << this->baseName_ << "\", no functor set." << std::endl;369 orxout(internal_error, context::commands) << "Can't assign object to console command \"" << this->baseName_ << "\", no functor set." << endl; 370 370 } 371 371 else if (object) 372 COUT(1) << "Error: Can't assign object to console command \"" << this->baseName_ << "\", no executor set." << std::endl;372 orxout(internal_error, context::commands) << "Can't assign object to console command \"" << this->baseName_ << "\", no executor set." << endl; 373 373 374 374 return false; … … 418 418 this->executor_->setDefaultValues(arg1); 419 419 else 420 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;420 orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl; 421 421 422 422 return *this; … … 431 431 this->executor_->setDefaultValues(arg1, arg2); 432 432 else 433 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;433 orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl; 434 434 435 435 return *this; … … 444 444 this->executor_->setDefaultValues(arg1, arg2, arg3); 445 445 else 446 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;446 orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl; 447 447 448 448 return *this; … … 457 457 this->executor_->setDefaultValues(arg1, arg2, arg3, arg4); 458 458 else 459 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;459 orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl; 460 460 461 461 return *this; … … 470 470 this->executor_->setDefaultValues(arg1, arg2, arg3, arg4, arg5); 471 471 else 472 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;472 orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl; 473 473 474 474 return *this; … … 485 485 this->executor_->setDefaultValue(index, arg); 486 486 else 487 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;487 orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl; 488 488 489 489 return *this; … … 500 500 this->argumentCompleter_[index] = completer; 501 501 else 502 COUT(2) << "Warning: Couldn't add autocompletion-function for index " << index << " in console command \"" << this->baseName_ << "\": index out of bound." << std::endl;502 orxout(internal_warning, context::commands) << "Couldn't add autocompletion-function for index " << index << " in console command \"" << this->baseName_ << "\": index out of bound." << endl; 503 503 504 504 return *this; … … 611 611 { 612 612 if (group == "") 613 COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;613 orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl; 614 614 else 615 COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;615 orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl; 616 616 } 617 617 return 0; … … 644 644 { 645 645 if (group == "") 646 COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;646 orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl; 647 647 else 648 COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;648 orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl; 649 649 } 650 650 return 0; … … 681 681 { 682 682 if (group == "") 683 COUT(2) << "Warning: A console command with shortcut \"" << name << "\" already exists." << std::endl;683 orxout(internal_warning, context::commands) << "A console command with shortcut \"" << name << "\" already exists." << endl; 684 684 else 685 COUT(2) << "Warning: A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << std::endl;685 orxout(internal_warning, context::commands) << "A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << endl; 686 686 } 687 687 else -
code/trunk/src/libraries/core/command/ConsoleCommand.h
r8418 r8858 53 53 void myCoutFunction(const std::string& text) // Define a static function 54 54 { 55 COUT(0) << "Text: " << text << std::endl;// Print the text to the console55 orxout() << "Text: " << text << endl; // Print the text to the console 56 56 } 57 57 … … 125 125 void myOtherCoutFunction(const std::string& text) // Define a new static function 126 126 { 127 COUT(0) << "Uppercase: " << getUppercase(text) << std::endl;// Print the text in uppercase to the console127 orxout() << "Uppercase: " << getUppercase(text) << endl; // Print the text in uppercase to the console 128 128 } 129 129 -
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
r8079 r8858 38 38 #include <string> 39 39 40 #include "util/ Debug.h"40 #include "util/Output.h" 41 41 #include "util/ExprParser.h" 42 42 #include "util/StringUtils.h" … … 46 46 namespace orxonox 47 47 { 48 SetConsoleCommand("echo", echo); 49 50 SetConsoleCommand("orxout", orxout_level); 51 SetConsoleCommand("orxout_context", orxout_level_context); 52 53 SetConsoleCommand("log" , log ); 54 SetConsoleCommand("error" , error ).hide(); 55 SetConsoleCommand("warning", warning).hide(); 56 SetConsoleCommand("status" , status ).hide(); 57 SetConsoleCommand("info" , info ).hide(); 58 SetConsoleCommand("debug" , debug ).hide(); 59 48 60 // SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 49 SetConsoleCommand("echo", echo);50 // SetConsoleCommand("puts", puts); // disabled because we use the implementation in Tcl51 52 61 // SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 53 62 // SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl … … 57 66 58 67 /** 68 @brief Simply returns the arguments. 69 */ 70 std::string echo(const std::string& text) 71 { 72 return text; 73 } 74 75 /** 76 @brief Builds a map that maps the levels of all output levels to their ID. 77 */ 78 std::map<std::string, OutputLevel> getOutputLevelsMap() 79 { 80 std::map<std::string, OutputLevel> levels; 81 82 levels["message"] = level::message; 83 levels["debug_output"] = level::debug_output; 84 levels["user_error"] = level::user_error; 85 levels["user_warning"] = level::user_warning; 86 levels["user_status"] = level::user_status; 87 levels["user_info"] = level::user_info; 88 levels["internal_error"] = level::internal_error; 89 levels["internal_warning"] = level::internal_warning; 90 levels["internal_status"] = level::internal_status; 91 levels["internal_info"] = level::internal_info; 92 levels["verbose"] = level::verbose; 93 levels["verbose_more"] = level::verbose_more; 94 levels["verbose_ultra"] = level::verbose_ultra; 95 96 return levels; 97 } 98 99 /** 100 @brief Prints text to the console. 101 @param level_name The name of the output level 102 */ 103 void orxout_level(const std::string& level_name, const std::string& text) 104 { 105 static std::map<std::string, OutputLevel> levels = getOutputLevelsMap(); 106 107 OutputLevel level = level::debug_output; 108 std::map<std::string, OutputLevel>::iterator it = levels.find(level_name); 109 if (it != levels.end()) 110 level = it->second; 111 else 112 orxout(internal_warning) << "'" << level_name << "' is not a valid output level" << endl; 113 114 orxout(level) << text << endl; 115 } 116 117 /** 118 @brief Prints text to the console. 119 @param level_name The name of the output level 120 @param context_name The name of the output context 121 */ 122 void orxout_level_context(const std::string& level_name, const std::string& context_name, const std::string& text) 123 { 124 static std::map<std::string, OutputLevel> levels = getOutputLevelsMap(); 125 126 OutputLevel level = level::debug_output; 127 std::map<std::string, OutputLevel>::iterator it = levels.find(level_name); 128 if (it != levels.end()) 129 level = it->second; 130 else 131 orxout(internal_warning) << "'" << level_name << "' is not a valid output level" << endl; 132 133 OutputContextContainer context = registerContext(context_name); 134 135 orxout(level, context) << text << endl; 136 } 137 138 /// @brief Prints text to the console and the logfile. 139 void log(const std::string& text) 140 { orxout() << text << endl; } 141 142 /// @brief Prints output with error level. 143 void error(const std::string& text) 144 { orxout(user_error) << text << endl; } 145 146 /// @brief Prints output with warning level. 147 void warning(const std::string& text) 148 { orxout(user_warning) << text << endl; } 149 150 /// @brief Prints output with status level. 151 void status(const std::string& text) 152 { orxout(user_status) << text << endl; } 153 154 /// @brief Prints output with info level. 155 void info(const std::string& text) 156 { orxout(user_info) << text << endl; } 157 158 /// @brief Prints debug output with verbose level. 159 void debug(const std::string& text) 160 { orxout(verbose, context::tcl) << text << endl; } 161 162 /** 59 163 @brief Reads the content of a file and executes the commands in it line by line. 60 164 */ … … 66 170 if (it != executingFiles.end()) 67 171 { 68 COUT(1) << "Error: Recurring source command in \"" << filename << "\". Stopped execution." << std::endl;172 orxout(user_error) << "Recurring source command in \"" << filename << "\". Stopped execution." << endl; 69 173 return; 70 174 } … … 76 180 if (!file.is_open()) 77 181 { 78 COUT(1) << "Error: Couldn't open file \"" << filename << "\"." << std::endl;182 orxout(user_error) << "Couldn't open file \"" << filename << "\"." << endl; 79 183 return; 80 184 } … … 95 199 96 200 /** 97 @brief Simply returns the arguments.98 */99 std::string echo(const std::string& text)100 {101 return text;102 }103 104 /**105 @brief Writes text to the console, depending on the first argument with or without a line-break after it.106 */107 void puts(bool newline, const std::string& text)108 {109 if (newline)110 {111 COUT(0) << stripEnclosingBraces(text) << std::endl;112 }113 else114 {115 COUT(0) << stripEnclosingBraces(text);116 }117 }118 119 /**120 201 @brief Writes text to a file. 121 202 */ … … 127 208 if (!file.is_open()) 128 209 { 129 COUT(1) << "Error: Couldn't write to file \"" << filename << "\"." << std::endl;130 return; 131 } 132 133 file << text << std::endl;210 orxout(user_error) << "Couldn't write to file \"" << filename << "\"." << endl; 211 return; 212 } 213 214 file << text << endl; 134 215 file.close(); 135 216 } … … 145 226 if (!file.is_open()) 146 227 { 147 COUT(1) << "Error: Couldn't append to file \"" << filename << "\"." << std::endl;148 return; 149 } 150 151 file << text << std::endl;228 orxout(user_error) << "Couldn't append to file \"" << filename << "\"." << endl; 229 return; 230 } 231 232 file << text << endl; 152 233 file.close(); 153 234 } … … 163 244 if (!file.is_open()) 164 245 { 165 COUT(1) << "Error: Couldn't read from file \"" << filename << "\"." << std::endl;246 orxout(user_error) << "Couldn't read from file \"" << filename << "\"." << endl; 166 247 return ""; 167 248 } … … 192 273 if (expr.getResult() == 42.0) 193 274 { 194 COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;275 orxout(user_info) << "Greetings from the restaurant at the end of the universe." << endl; 195 276 } 196 277 if (!expr.getRemains().empty()) 197 278 { 198 COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;279 orxout(user_warning) << "Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << endl; 199 280 } 200 281 return static_cast<float>(expr.getResult()); … … 202 283 else 203 284 { 204 COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;285 orxout(user_error) << "Cannot calculate expression: Parse error." << endl; 205 286 return 0; 206 287 } -
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h
r7401 r8858 42 42 _CoreExport void source(const std::string& filename); 43 43 _CoreExport std::string echo(const std::string& text); 44 _CoreExport void puts(bool newline, const std::string& test); 44 45 _CoreExport void orxout_level(const std::string& level_name, const std::string& text); 46 _CoreExport void orxout_level_context(const std::string& level_name, const std::string& context_name, const std::string& text); 47 48 _CoreExport void log(const std::string& text); 49 _CoreExport void error(const std::string& text); 50 _CoreExport void warning(const std::string& text); 51 _CoreExport void status(const std::string& text); 52 _CoreExport void info(const std::string& text); 53 _CoreExport void debug(const std::string& text); 45 54 46 55 _CoreExport void write(const std::string& filename, const std::string& text); -
code/trunk/src/libraries/core/command/Executor.cc
r7401 r8858 38 38 39 39 #include "util/Convert.h" 40 #include "util/ Debug.h"40 #include "util/Output.h" 41 41 #include "util/StringUtils.h" 42 42 #include "util/SubString.h" … … 104 104 { 105 105 if (bPrintError) 106 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough arguments or default values given (input: " << arguments.join() << ")." << std::endl;106 orxout(internal_warning) << "Can't call executor " << this->name_ << " through parser: Not enough arguments or default values given (input: " << arguments.join() << ")." << endl; 107 107 return MT_Type::Null; 108 108 } 109 109 110 COUT(5) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << argCount << " arguments: " << arg[0] << " / " << arg[1] << " / " << arg[2] << " / " << arg[3] << " / " << arg[4] << std::endl;110 orxout(verbose, context::misc::executor) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << argCount << " arguments: " << arg[0] << " / " << arg[1] << " / " << arg[2] << " / " << arg[3] << " / " << arg[4] << endl; 111 111 112 112 // execute the function with the evaluated arguments (the default values of the executor are also included in these arguments) -
code/trunk/src/libraries/core/command/Executor.h
r7401 r8858 57 57 void myFunction(int a, int b) // declare a static function 58 58 { 59 COUT(0) << "The sum is " << (a + b) << std::endl;// print the sum of a and b to the console59 orxout() << "The sum is " << (a + b) << endl; // print the sum of a and b to the console 60 60 } 61 61 -
code/trunk/src/libraries/core/command/Functor.h
r8729 r8858 118 118 #include <typeinfo> 119 119 120 #include "util/ Debug.h"120 #include "util/Output.h" 121 121 #include "util/MultiType.h" 122 122 #include "core/OrxonoxClass.h" … … 256 256 else 257 257 { 258 COUT(1) << "Error: Can't execute FunctorMember, no object set." << std::endl;258 orxout(internal_error) << "Can't execute FunctorMember, no object set." << endl; 259 259 return MT_Type::Null; 260 260 } … … 339 339 // see Functor::setRawObjectPointer() 340 340 inline void setRawObjectPointer(void*) 341 { COUT(2) << "Warning: Can't assign an object pointer to a static functor" << std::endl; }341 { orxout(internal_warning) << "Can't assign an object pointer to a static functor" << endl; } 342 342 // see Functor::getRawObjectPointer() 343 343 inline void* getRawObjectPointer() const -
code/trunk/src/libraries/core/command/IOConsolePOSIX.cc
r8729 r8858 37 37 #include "util/Clock.h" 38 38 #include "util/Math.h" 39 #include "util/output/ConsoleWriter.h" 39 40 #include "core/Game.h" 40 41 #include "core/input/InputBuffer.h" … … 55 56 56 57 IOConsole::IOConsole() 57 : shell_(new Shell(" IOConsole", false))58 : shell_(new Shell("Console", false)) 58 59 , buffer_(shell_->getInputBuffer()) 59 60 , cout_(std::cout.rdbuf()) … … 74 75 75 76 // Disable standard std::cout logging 76 OutputHandler::getInstance().disableCout();77 ConsoleWriter::getInstance().disable(); 77 78 // Redirect std::cout to an ostringstream 78 79 // (Other part is in the initialiser list) … … 88 89 std::cout.flush(); 89 90 if (!this->origCout_.str().empty()) 90 this->shell_->addOutput(this->origCout_.str(), Shell:: None);91 this->shell_->addOutput(this->origCout_.str(), Shell::Cout); 91 92 // Erase input and status lines 92 93 this->cout_ << "\033[1G\033[J"; … … 102 103 std::cout.rdbuf(this->cout_.rdbuf()); 103 104 // Enable standard std::cout logging again 104 OutputHandler::getInstance().enableCout();105 ConsoleWriter::getInstance().enable(); 105 106 } 106 107 … … 229 230 if (!this->origCout_.str().empty()) 230 231 { 231 this->shell_->addOutput(this->origCout_.str(), Shell:: None);232 this->shell_->addOutput(this->origCout_.str(), Shell::Cout); 232 233 this->origCout_.str(""); 233 234 } … … 239 240 switch (type) 240 241 { 241 case Shell::Error: this->cout_ << "\033[91m"; 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; 250 default: break; 242 case Shell::Message: 243 case Shell::DebugOutput: this->cout_ << "\033[0m"; break; 244 245 case Shell::UserError: this->cout_ << "\033[91m"; break; 246 case Shell::UserWarning: this->cout_ << "\033[93m"; break; 247 case Shell::UserStatus: this->cout_ << "\033[92m"; break; 248 case Shell::UserInfo: this->cout_ << "\033[96m"; break; 249 250 case Shell::InternalError: this->cout_ << "\033[31m"; break; 251 case Shell::InternalWarning: this->cout_ << "\033[33m"; break; 252 case Shell::InternalStatus: this->cout_ << "\033[32m"; break; 253 case Shell::InternalInfo: this->cout_ << "\033[36m"; break; 254 255 case Shell::Verbose: this->cout_ << "\033[94m"; break; 256 case Shell::VerboseMore: this->cout_ << "\033[34m"; break; 257 case Shell::VerboseUltra: this->cout_ << "\033[34m"; break; 258 259 case Shell::Command: this->cout_ << "\033[95m"; break; 260 case Shell::Hint: this->cout_ << "\033[35m"; break; 261 262 default: this->cout_ << "\033[37m"; break; 251 263 } 252 264 … … 371 383 void IOConsole::executed() 372 384 { 373 this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);385 this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::Command); 374 386 } 375 387 … … 378 390 { 379 391 // Exit is not an option, just do nothing (Shell doesn't really exit too) 380 }381 382 //! Called if only the last output-line has changed383 void IOConsole::onlyLastLineChanged()384 {385 // Save cursor position and move it to the beginning of the first output line386 this->cout_ << "\033[s\033[1A\033[1G";387 // Erase the line388 this->cout_ << "\033[K";389 // Reprint the last output line390 this->printOutputLine(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second);391 // Restore cursor392 this->cout_ << "\033[u";393 this->cout_.flush();394 392 } 395 393 -
code/trunk/src/libraries/core/command/IOConsolePOSIX.h
r7401 r8858 66 66 // Methods from ShellListener 67 67 void linesChanged(); 68 void onlyLastLineChanged();69 68 void lineAdded(); 70 69 void inputChanged(); -
code/trunk/src/libraries/core/command/IOConsoleWindows.cc
r8729 r8858 34 34 #include "util/Clock.h" 35 35 #include "util/Math.h" 36 #include "util/output/ConsoleWriter.h" 36 37 #include "core/Game.h" 37 38 #include "core/input/InputBuffer.h" … … 43 44 //! Redirects std::cout, creates the corresponding Shell and changes the terminal mode 44 45 IOConsole::IOConsole() 45 : shell_(new Shell(" IOConsole", false))46 : shell_(new Shell("Console", false)) 46 47 , buffer_(shell_->getInputBuffer()) 47 48 , cout_(std::cout.rdbuf()) … … 52 53 { 53 54 // Disable standard this->cout_ logging 54 OutputHandler::getInstance().disableCout();55 ConsoleWriter::getInstance().disable(); 55 56 // Redirect std::cout to an ostringstream 56 57 // (Other part is in the initialiser list) … … 95 96 std::cout.flush(); 96 97 if (!this->origCout_.str().empty()) 97 this->shell_->addOutput(this->origCout_.str(), Shell:: None);98 this->shell_->addOutput(this->origCout_.str(), Shell::Cout); 98 99 99 100 this->shell_->unregisterListener(this); … … 108 109 std::cout.rdbuf(this->cout_.rdbuf()); 109 110 // Enable standard this->cout_ logging again 110 OutputHandler::getInstance().enableCout();111 ConsoleWriter::getInstance().enable(); 111 112 112 113 resetTerminalMode(); … … 188 189 if (!this->origCout_.str().empty()) 189 190 { 190 this->shell_->addOutput(this->origCout_.str(), Shell:: None);191 this->shell_->addOutput(this->origCout_.str(), Shell::Cout); 191 192 this->origCout_.str(""); 192 193 } … … 200 201 switch (type) 201 202 { 202 case Shell::Error: colour = FOREGROUND_INTENSITY | FOREGROUND_RED; break; 203 case Shell::Warning: colour = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED; break; 204 case Shell::Info: 205 case Shell::Debug: 206 case Shell::Verbose: 207 case Shell::Ultra: colour = FOREGROUND_INTENSITY ; break; 208 case Shell::Command: colour = FOREGROUND_GREEN | FOREGROUND_BLUE; break; 209 case Shell::Hint: colour = FOREGROUND_GREEN | FOREGROUND_RED ; break; 210 case Shell::TDebug: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE; break; 211 default: colour = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break; 203 case Shell::Message: 204 case Shell::DebugOutput: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 205 206 case Shell::UserError: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | 0 ; break; 207 case Shell::UserWarning: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break; 208 case Shell::UserStatus: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | 0 ; break; 209 case Shell::UserInfo: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 210 211 case Shell::InternalError: colour = 0 | FOREGROUND_RED | 0 | 0 ; break; 212 case Shell::InternalWarning: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break; 213 case Shell::InternalStatus: colour = 0 | 0 | FOREGROUND_GREEN | 0 ; break; 214 case Shell::InternalInfo: colour = 0 | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 215 216 case Shell::Verbose: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break; 217 case Shell::VerboseMore: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break; 218 case Shell::VerboseUltra: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break; 219 220 case Shell::Command: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break; 221 case Shell::Hint: colour = 0 | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break; 222 223 default: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 212 224 } 213 225 … … 238 250 || !SetConsoleMode(this->stdInHandle_, 0)) 239 251 { 240 COUT(1) << "Error: Could not set Windows console settings" << std::endl;252 orxout(user_error) << "Could not set Windows console settings" << endl; 241 253 return; 242 254 } … … 318 330 void IOConsole::executed() 319 331 { 320 this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);332 this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::Command); 321 333 } 322 334 … … 377 389 } 378 390 379 //! Called if only the last output-line has changed380 void IOConsole::onlyLastLineChanged()381 {382 int newLineHeight = 1 + this->shell_->getNewestLineIterator()->first.size() / this->terminalWidth_;383 // Compute the number of new lines needed384 int newLines = newLineHeight - this->lastOutputLineHeight_;385 this->lastOutputLineHeight_ = newLineHeight;386 // Scroll console if necessary387 if (newLines > 0) // newLines < 0 is assumed impossible388 this->createNewOutputLines(newLines);389 Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();390 this->printOutputLine(it->first, it->second, makeCOORD(0, this->inputLineRow_ - newLineHeight));391 }392 393 391 //! Called if a new output line was added 394 392 void IOConsole::lineAdded() -
code/trunk/src/libraries/core/command/IOConsoleWindows.h
r8729 r8858 68 68 // Methods from ShellListener 69 69 void linesChanged(); 70 void onlyLastLineChanged();71 70 void lineAdded(); 72 71 void inputChanged(); -
code/trunk/src/libraries/core/command/IRC.cc
r7401 r8858 85 85 } 86 86 catch (Tcl::tcl_error const &e) 87 { COUT(1) << "Tcl (IRC) error: " << e.what(); }87 { orxout(user_error, context::tcl) << "Tcl (IRC) error: " << e.what() << endl; } 88 88 89 89 this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand())); … … 100 100 { 101 101 IRC::getInstance().initialize(); 102 COUT(1) << "Error: IRC client wasn't yet initialized, please try again." << std::endl;102 orxout(user_error) << "IRC client wasn't yet initialized, please try again." << endl; 103 103 return false; 104 104 } … … 110 110 } 111 111 catch (Tcl::tcl_error const &e) 112 { COUT(1) << "Tcl (IRC) error: " << e.what(); }112 { orxout(user_error, context::tcl) << "Tcl (IRC) error: " << e.what() << endl; } 113 113 114 114 return false; … … 139 139 void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args) 140 140 { 141 COUT(0) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;141 orxout(message) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << endl; 142 142 } 143 143 … … 145 145 void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args) 146 146 { 147 COUT(0) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;147 orxout(message) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << endl; 148 148 } 149 149 … … 151 151 void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args) 152 152 { 153 COUT(0) << "IRC> * " << nick.get() << ' ' << stripEnclosingBraces(args.get()) << std::endl;153 orxout(message) << "IRC> * " << nick.get() << ' ' << stripEnclosingBraces(args.get()) << endl; 154 154 } 155 155 … … 157 157 void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args) 158 158 { 159 COUT(0) << "IRC> --> " << stripEnclosingBraces(args.get()) << std::endl;159 orxout(message) << "IRC> --> " << stripEnclosingBraces(args.get()) << endl; 160 160 } 161 161 } -
code/trunk/src/libraries/core/command/Shell.cc
r8729 r8858 35 35 36 36 #include "util/Math.h" 37 #include "util/OutputHandler.h"38 37 #include "util/StringUtils.h" 39 38 #include "util/SubString.h" 39 #include "util/output/OutputManager.h" 40 #include "util/output/MemoryWriter.h" 40 41 #include "core/CoreIncludes.h" 41 42 #include "core/ConfigFileManager.h" … … 44 45 #include "core/input/InputBuffer.h" 45 46 #include "CommandExecutor.h" 46 #include "ConsoleCommand.h"47 47 48 48 namespace orxonox 49 49 { 50 SetConsoleCommand("log", OutputHandler::log );51 SetConsoleCommand("error", OutputHandler::error ).hide();52 SetConsoleCommand("warning", OutputHandler::warning).hide();53 SetConsoleCommand("info", OutputHandler::info ).hide();54 SetConsoleCommand("debug", OutputHandler::debug ).hide();55 56 50 unsigned int Shell::cacheSize_s; 57 51 58 /** 59 @brief Constructor: Initializes the values and registers itself at OutputHandler. 52 namespace DefaultLogLevel 53 { 54 const OutputLevel Dev = level::internal_warning; 55 const OutputLevel User = level::user_info; 56 } 57 58 /** 59 @brief Constructor: Initializes the values. 60 60 @param consoleName The name of the shell - used to define the name of the soft-debug-level config-value 61 61 @param bScrollable If true, the user is allowed to scroll through the output-lines 62 62 */ 63 63 Shell::Shell(const std::string& consoleName, bool bScrollable) 64 : OutputListener(consoleName)64 : BaseWriter(consoleName, false) 65 65 , inputBuffer_(new InputBuffer()) 66 , consoleName_(consoleName)67 66 , bScrollable_(bScrollable) 68 67 { 69 68 RegisterRootObject(Shell); 69 70 OutputManager::getInstance().registerListener(this); 70 71 71 72 this->scrollPosition_ = 0; … … 73 74 this->historyPosition_ = 0; 74 75 this->historyOffset_ = 0; 75 this->bFinishedLastLine_ = true;76 76 77 77 this->clearOutput(); … … 81 81 ConfigFileManager::getInstance().setFilename(ConfigFileType::CommandHistory, "commandHistory.ini"); 82 82 83 // Use a stringstream object to buffer the output 84 this->outputStream_ = &this->outputBuffer_; 83 // Choose the default level according to the path Orxonox was started (build directory or not) 84 OutputLevel defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User); 85 this->setLevelMax(defaultDebugLevel); 85 86 86 87 this->setConfigValues(); 87 88 88 89 // Get the previous output and add it to the Shell 89 OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin(); 90 for (;it != OutputHandler::getInstance().getOutput().end(); ++it) 91 { 92 if (it->first <= debugLevel_) 93 { 94 this->outputBuffer_ << it->second; 95 this->outputChanged(it->first); 96 } 97 } 98 99 // Register the shell as output listener 100 OutputHandler::getInstance().registerOutputListener(this); 101 OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_); 102 } 103 104 /** 105 @brief Destructor: Unregisters the shell from OutputHandler. 90 MemoryWriter::getInstance().resendOutput(this); 91 } 92 93 /** 94 @brief Destructor 106 95 */ 107 96 Shell::~Shell() 108 97 { 109 OutputHandler::getInstance().unregisterOutputListener(this);110 98 this->inputBuffer_->destroy(); 111 } 112 113 namespace DefaultLogLevel 114 { 115 const OutputLevel::Value Dev = OutputLevel::Info; 116 const OutputLevel::Value User = OutputLevel::Error; 99 100 OutputManager::getInstance().unregisterListener(this); 117 101 } 118 102 … … 129 113 SetConfigValue(cacheSize_s, 32); 130 114 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_); 115 SetConfigValueExternal(this->configurableMaxLevel_, 116 this->getConfigurableSectionName(), 117 this->getConfigurableMaxLevelName(), 118 this->configurableMaxLevel_) 119 .description("The maximum level of output shown in the " + this->getName()) 120 .callback(static_cast<BaseWriter*>(this), &BaseWriter::changedConfigurableLevel); 121 SetConfigValueExternal(this->configurableAdditionalContextsMaxLevel_, 122 this->getConfigurableSectionName(), 123 this->getConfigurableAdditionalContextsMaxLevelName(), 124 this->configurableAdditionalContextsMaxLevel_) 125 .description("The maximum level of output shown in the " + this->getName() + " for additional contexts") 126 .callback(static_cast<BaseWriter*>(this), &BaseWriter::changedConfigurableAdditionalContextsLevel); 127 SetConfigValueExternal(this->configurableAdditionalContexts_, 128 this->getConfigurableSectionName(), 129 this->getConfigurableAdditionalContextsName(), 130 this->configurableAdditionalContexts_) 131 .description("Additional output contexts shown in the " + this->getName()) 132 .callback(static_cast<BaseWriter*>(this), &BaseWriter::changedConfigurableAdditionalContexts); 136 133 } 137 134 … … 168 165 if (isNormal) 169 166 { 170 ModifyConfigValueExternal( debugLevel_, "debugLevel" + consoleName_, update);167 ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), update); 171 168 } 172 169 else 173 170 { 174 OutputLevel ::Valuelevel = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);175 ModifyConfigValueExternal( debugLevel_, "debugLevel" + consoleName_, tset, level);171 OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User); 172 ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, level); 176 173 } 177 174 } … … 252 249 253 250 /** 254 @brief Sends outputto the internal output buffer.251 @brief Adds multiple lines to the internal output buffer. 255 252 */ 256 253 void Shell::addOutput(const std::string& text, LineType type) 257 254 { 258 this->outputBuffer_ << text; 259 this->outputChanged(type); 255 std::vector<std::string> lines; 256 vectorize(text, '\n', &lines); 257 258 for (size_t i = 0; i < lines.size(); ++i) 259 this->addLine(lines[i], type); 260 } 261 262 /** 263 @brief Adds a line to the internal output buffer. 264 */ 265 void Shell::addLine(const std::string& line, LineType type) 266 { 267 // yes it was - push the new line to the list 268 this->outputLines_.push_front(std::make_pair(line, static_cast<LineType>(type))); 269 270 // adjust the scroll position if needed 271 if (this->scrollPosition_) 272 this->scrollPosition_++; 273 else 274 this->scrollIterator_ = this->outputLines_.begin(); 275 276 if (!this->scrollPosition_) 277 this->updateListeners<&ShellListener::lineAdded>(); 260 278 } 261 279 … … 269 287 270 288 this->scrollPosition_ = 0; 271 this->bFinishedLastLine_ = true;272 289 273 290 this->updateListeners<&ShellListener::linesChanged>(); 291 } 292 293 /** 294 @brief Inherited from BaseWriter (LogListener), called if a new line of output was sent. 295 */ 296 void Shell::printLine(const std::string& line, OutputLevel level) 297 { 298 this->addLine(line, static_cast<LineType>(level)); 274 299 } 275 300 … … 323 348 324 349 /** 325 @brief Called by OutputHandler or internally whenever output was sent to the output buffer. Reads from the buffer and writes the new output-lines to the list.326 */327 void Shell::outputChanged(int lineType)328 {329 bool newline = false;330 do331 {332 // get the first line from the buffer333 std::string output;334 std::getline(this->outputBuffer_, output);335 336 // check the state of the buffer337 bool eof = this->outputBuffer_.eof();338 bool fail = this->outputBuffer_.fail();339 if (eof)340 this->outputBuffer_.flush(); // check if more output was received in the meantime341 if (eof || fail)342 this->outputBuffer_.clear(); // clear the error flags343 344 // the line is terminated with a line-break if neither an error occurred nor the end of the file was reached345 newline = (!eof && !fail);346 347 // no output retrieved - break the loop348 if (!newline && output.empty())349 break;350 351 // check if the last line was terminated with a line-break352 if (this->bFinishedLastLine_)353 {354 // yes it was - push the new line to the list355 this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));356 357 // adjust the scroll position if needed358 if (this->scrollPosition_)359 this->scrollPosition_++;360 else361 this->scrollIterator_ = this->outputLines_.begin();362 363 if (!this->scrollPosition_)364 this->updateListeners<&ShellListener::lineAdded>();365 }366 else367 {368 // no it wasn't - add the new output to the last line369 this->outputLines_.front().first += output;370 this->updateListeners<&ShellListener::onlyLastLineChanged>();371 }372 373 // remember if the last line was terminated with a line-break374 this->bFinishedLastLine_ = newline;375 376 } while (newline); // loop as long as more lines are in the buffer377 }378 379 /**380 350 @brief Clears the text in the input buffer. 381 351 */ … … 409 379 const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &error); 410 380 if (error) 411 { 412 switch (error) 413 { 414 case CommandExecutor::Error: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command doesn't exist. (S)" << std::endl; break; 415 case CommandExecutor::Incomplete: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", not enough arguments given. (S)" << std::endl; break; 416 case CommandExecutor::Deactivated: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command is not active. (S)" << std::endl; break; 417 case CommandExecutor::Denied: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", access denied. (S)" << std::endl; break; 418 } 419 this->outputChanged(Error); 420 } 381 this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", " + CommandExecutor::getErrorDescription(error) + ". (Shell)", UserError); 421 382 else if (result != "") 422 { 423 this->outputBuffer_ << result << std::endl; 424 this->outputChanged(Command); 425 } 383 this->addOutput(result, Result); 426 384 427 385 this->clearInput(); … … 432 390 { 433 391 this->inputBuffer_->set(CommandExecutor::evaluate(this->inputBuffer_->get()).complete()); 434 this->outputBuffer_ << CommandExecutor::evaluate(this->inputBuffer_->get()).hint() << std::endl; 435 this->outputChanged(Hint); 392 this->addOutput(CommandExecutor::evaluate(this->inputBuffer_->get()).hint(), Hint); 436 393 437 394 this->inputChanged(); -
code/trunk/src/libraries/core/command/Shell.h
r8729 r8858 48 48 #include <vector> 49 49 50 #include "util/ OutputHandler.h"50 #include "util/output/BaseWriter.h" 51 51 #include "core/Core.h" 52 52 #include "core/OrxonoxClass.h" … … 66 66 private: 67 67 virtual void linesChanged() {} ///< Called if all output-lines have changed 68 virtual void onlyLastLineChanged() {} ///< Called if only the last output-line has changed69 68 virtual void lineAdded() {} ///< Called if a new line was added to the output 70 69 virtual void inputChanged() {} ///< Called if the input has changed … … 78 77 @brief The Shell is the logical component of the console that displays output to the user and allows him to enter commands. 79 78 80 The Shell gathers output sent from Output Handler by inheriting from OutputListener.79 The Shell gathers output sent from OutputManager by inheriting from BaseWriter. 81 80 The output-lines are stored in the shell, so they can be displayed in a graphical 82 81 console. Additionally the Shell has an InputBuffer which is needed by the user to … … 85 84 Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole. 86 85 */ 87 class _CoreExport Shell : public OutputListener, public DevModeListener86 class _CoreExport Shell : public BaseWriter, public DevModeListener 88 87 { 89 88 public: … … 91 90 enum LineType 92 91 { 93 TDebug = OutputLevel::TDebug, 94 None = OutputLevel::None, 95 Warning = OutputLevel::Warning, 96 Error = OutputLevel::Error, 97 Info = OutputLevel::Info, 98 Debug = OutputLevel::Debug, 99 Verbose = OutputLevel::Verbose, 100 Ultra = OutputLevel::Ultra, 92 DebugOutput = debug_output, 93 Message = message, 94 UserError = user_error, 95 UserWarning = user_warning, 96 UserStatus = user_status, 97 UserInfo = user_info, 98 InternalError = internal_error, 99 InternalWarning = internal_warning, 100 InternalStatus = internal_status, 101 InternalInfo = internal_info, 102 Verbose = verbose, 103 VerboseMore = verbose_more, 104 VerboseUltra = verbose_ultra, 105 Cout, 101 106 Input, 102 107 Command, 108 Result, 103 109 Hint 104 110 }; … … 127 133 LineList::const_iterator getEndIterator() const; 128 134 129 void addOutput(const std::string& text, LineType type = None); 135 void addOutput(const std::string& text, LineType type = DebugOutput); 136 void addLine(const std::string& line, LineType type = DebugOutput); 130 137 void clearOutput(); 131 138 … … 150 157 const std::string& getFromHistory() const; 151 158 void clearInput(); 152 // OutputListener153 v oid outputChanged(intlevel);159 // BaseWriter 160 virtual void printLine(const std::string& line, OutputLevel level); 154 161 155 162 void configureInputBuffer(); … … 183 190 std::list<ShellListener*> listeners_; ///< The registered shell listeners 184 191 InputBuffer* inputBuffer_; ///< The input buffer that is needed by the user to enter text 185 std::stringstream outputBuffer_; ///< The output buffer that is used to retrieve lines of output from OutputListener186 bool bFinishedLastLine_; ///< Stores if the most recent output-line was terminated with a line-break or if more output is expected for this line187 192 LineList outputLines_; ///< A list of all output-lines that were displayed in the shell so far 188 193 LineList::const_iterator scrollIterator_; ///< An iterator to an entry of the list of output-lines, changes if the user scrolls through the output in the shell 189 194 unsigned int scrollPosition_; ///< The number of the line that is currently being referenced by scrollIterator_ 190 195 unsigned int historyPosition_; ///< If the user scrolls through the history of entered commands (stored in commandHistory_), this contains the currently viewed history entry 191 192 const std::string consoleName_; ///< The name of this shell - used to define the name of the soft-debug-level config-value193 196 const bool bScrollable_; ///< If true, the user can scroll through the output-lines 194 197 … … 197 200 unsigned int historyOffset_; ///< The command history is a circular buffer, this variable defines the current write-offset 198 201 std::vector<std::string> commandHistory_; ///< The history of commands that were entered by the user 199 int debugLevel_; //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)200 202 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 203 }; -
code/trunk/src/libraries/core/command/TclBind.cc
r8366 r8858 34 34 35 35 #include "SpecialConfig.h" 36 #include "util/ Debug.h"36 #include "util/Output.h" 37 37 #include "util/Exception.h" 38 38 #include "util/StringUtils.h" … … 106 106 } 107 107 catch (Tcl::tcl_error const &e) 108 { COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; }108 { orxout(internal_error, context::tcl) << "Tcl error while creating Tcl-interpreter: " << e.what() << endl; } 109 109 } 110 110 } … … 129 129 } 130 130 catch (Tcl::tcl_error const &e) 131 { COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl; } 131 { 132 orxout(internal_error, context::tcl) << "Tcl error while creating Tcl-interpreter: " << e.what() << endl; 133 orxout(user_error, context::tcl) << "Tcl isn't properly initialized. Orxonox might possibly not work like that." << endl; 134 } 132 135 133 136 return interpreter; … … 154 157 std::string TclBind::tcl_query(Tcl::object const &args) 155 158 { 156 COUT(4) << "Tcl_query: " << args.get() << std::endl;159 orxout(verbose, context::commands) << "Tcl_query: " << args.get() << endl; 157 160 return TclBind::tcl_helper(args, true); 158 161 } … … 163 166 void TclBind::tcl_execute(Tcl::object const &args) 164 167 { 165 COUT(4) << "Tcl_execute: " << args.get() << std::endl;168 orxout(verbose, context::commands) << "Tcl_execute: " << args.get() << endl; 166 169 TclBind::tcl_helper(args, false); 167 170 } … … 184 187 error = evaluation.execute(); 185 188 186 switch (error) 187 { 188 case CommandExecutor::Error: COUT(1) << "Error: Can't execute command \"" << command << "\", command doesn't exist. (B)" << std::endl; break; 189 case CommandExecutor::Incomplete: COUT(1) << "Error: Can't execute command \"" << command << "\", not enough arguments given. (B)" << std::endl; break; 190 case CommandExecutor::Deactivated: COUT(1) << "Error: Can't execute command \"" << command << "\", command is not active. (B)" << std::endl; break; 191 case CommandExecutor::Denied: COUT(1) << "Error: Can't execute command \"" << command << "\", access denied. (B)" << std::endl; break; 192 } 193 194 if (error == CommandExecutor::Error) 195 COUT(3) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << std::endl; 189 if (error) 190 { 191 orxout(user_error) << "Can't execute command \"" << command << "\", " + CommandExecutor::getErrorDescription(error) + ". (TclBind)" << endl; 192 if (error == CommandExecutor::Inexistent) 193 orxout(user_info) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << endl; 194 } 196 195 197 196 return result; … … 211 210 } 212 211 catch (Tcl::tcl_error const &e) 213 { COUT(1) << "Tcl error: " << e.what() << std::endl; }212 { orxout(user_error, context::tcl) << "Tcl error: " << e.what() << endl; } 214 213 } 215 214 … … 223 222 void TclBind::bgerror(const std::string& error) 224 223 { 225 COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;224 orxout(user_error, context::tcl) << "Tcl background error: " << stripEnclosingBraces(error) << endl; 226 225 } 227 226 … … 243 242 } 244 243 catch (Tcl::tcl_error const &e) 245 { COUT(1) << "Tcl error: " << e.what() << std::endl; }244 { orxout(user_error, context::tcl) << "Tcl error: " << e.what() << endl; } 246 245 247 246 if (error) -
code/trunk/src/libraries/core/command/TclThreadManager.cc
r8351 r8858 225 225 TclThreadManager::getInstance().numInterpreterBundles_++; 226 226 TclThreadManager::createWithId(TclThreadManager::getInstance().numInterpreterBundles_); 227 COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().numInterpreterBundles_ << std::endl;227 orxout(user_info) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().numInterpreterBundles_ << endl; 228 228 return TclThreadManager::getInstance().numInterpreterBundles_; 229 229 } … … 288 288 } 289 289 catch (const Tcl::tcl_error& e) 290 { bundle->interpreter_ = 0; COUT(1) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl; } 290 { 291 bundle->interpreter_ = 0; 292 orxout(user_error, context::tcl) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << endl; 293 } 291 294 } 292 295 … … 407 410 { 408 411 // This query would lead to a deadlock - return with an error 409 TclThreadManager::error(" Error:Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + multi_cast<std::string>(source_bundle->id_) \412 TclThreadManager::error("Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + multi_cast<std::string>(source_bundle->id_) \ 410 413 + " -> " + multi_cast<std::string>(target_bundle->id_) \ 411 414 + "), couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) \ … … 446 449 int error; 447 450 output = CommandExecutor::query(command, &error, false); 448 switch (error) 449 { 450 case CommandExecutor::Error: TclThreadManager::error("Error: Can't execute command \"" + command + "\", command doesn't exist. (T)"); break; 451 case CommandExecutor::Incomplete: TclThreadManager::error("Error: Can't execute command \"" + command + "\", not enough arguments given. (T)"); break; 452 case CommandExecutor::Deactivated: TclThreadManager::error("Error: Can't execute command \"" + command + "\", command is not active. (T)"); break; 453 case CommandExecutor::Denied: TclThreadManager::error("Error: Can't execute command \"" + command + "\", access denied. (T)"); break; 454 } 451 if (error) 452 TclThreadManager::error("Can't execute command \"" + command + "\", " + CommandExecutor::getErrorDescription(error) + ". (TclThreadManager)"); 455 453 } 456 454 else … … 476 474 // This happens if the main thread tries to query a busy interpreter 477 475 // To avoid a lock of the main thread, we simply don't proceed with the query in this case 478 TclThreadManager::error(" Error:Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) + ", interpreter is busy right now.");476 TclThreadManager::error("Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) + ", interpreter is busy right now."); 479 477 } 480 478 } … … 522 520 else 523 521 { 524 TclThreadManager::error(" Error:No Tcl-interpreter with ID " + multi_cast<std::string>(id) + " existing.");522 TclThreadManager::error("No Tcl-interpreter with ID " + multi_cast<std::string>(id) + " existing."); 525 523 return 0; 526 524 } -
code/trunk/src/libraries/core/input/Button.cc
r7891 r8858 38 38 #include "util/SubString.h" 39 39 #include "util/StringUtils.h" 40 #include "util/ Debug.h"40 #include "util/Output.h" 41 41 #include "core/command/ConsoleCommand.h" 42 42 #include "core/command/CommandEvaluation.h" … … 255 255 if (serious) 256 256 { 257 COUT(2) << "Error while parsing binding for button/axis " << this->name_ << ". "258 << message << std::endl;257 orxout(internal_error, context::input) << "Error while parsing binding for button/axis " << this->name_ << ". " 258 << message << endl; 259 259 } 260 260 else 261 261 { 262 COUT(3) << "Warning while parsing binding for button/axis " << this->name_ << ". "263 << message << std::endl;262 orxout(internal_warning, context::input) << "Warning while parsing binding for button/axis " << this->name_ << ". " 263 << message << endl; 264 264 } 265 265 } -
code/trunk/src/libraries/core/input/InputDevice.h
r8351 r8858 43 43 44 44 #include "util/Clock.h" 45 #include "util/ Debug.h"45 #include "util/Output.h" 46 46 #include "util/Exception.h" 47 47 #include "InputState.h" … … 135 135 // invalid right until the subclass has been constructed! 136 136 oisDevice_->setEventCallback(static_cast<DeviceClass*>(this)); 137 COUT(4) << "Instantiated a " << this->getClassName() << std::endl;137 orxout(verbose, context::input) << "Instantiated a " << this->getClassName() << endl; 138 138 } 139 139 … … 147 147 catch (const OIS::Exception& ex) 148 148 { 149 COUT(1) << this->getClassName() << " destruction failed: " << ex.eText << std::endl150 << " Potential resource leak!" << std::endl;149 orxout(internal_error, context::input) << this->getClassName() << " destruction failed: " << ex.eText << '\n' 150 << "Potential resource leak!" << endl; 151 151 } 152 152 } -
code/trunk/src/libraries/core/input/InputManager.cc
r8729 r8858 100 100 RegisterRootObject(InputManager); 101 101 102 CCOUT(4) << "Constructing..." << std::endl;102 orxout(internal_status, context::input) << "InputManager: Constructing..." << endl; 103 103 104 104 // Allocate space for the function call buffer … … 128 128 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this); 129 129 130 CCOUT(4) << "Construction complete." << std::endl;130 orxout(internal_status, context::input) << "InputManager: Construction complete." << endl; 131 131 internalState_ = Nothing; 132 132 } … … 143 143 void InputManager::loadDevices() 144 144 { 145 CCOUT(4) << "Loading input devices..." << std::endl;145 orxout(verbose, context::input) << "InputManager: Loading input devices..." << endl; 146 146 147 147 // When loading the devices they should not already be loaded … … 196 196 // Exception-safety 197 197 Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, oisInputManager_); 198 CCOUT(4) << "Created OIS input manager." << std::endl;198 orxout(verbose, context::input) << "Created OIS input manager." << endl; 199 199 200 200 if (oisInputManager_->getNumberOfDevices(OIS::OISKeyboard) > 0) … … 219 219 this->updateActiveStates(); 220 220 221 CCOUT(4) << "Input devices loaded." << std::endl;221 orxout(verbose, context::input) << "Input devices loaded." << endl; 222 222 } 223 223 … … 233 233 catch (const std::exception& ex) 234 234 { 235 CCOUT(2) << "Warning: Failed to create Mouse:" << ex.what() << std::endl236 << "Proceeding without mouse support." << std::endl;237 } 238 } 239 else 240 CCOUT(2) << "Warning: No mouse found! Proceeding without mouse support." << std::endl;235 orxout(user_warning, context::input) << "Failed to create Mouse:" << ex.what() << '\n' 236 << "Proceeding without mouse support." << endl; 237 } 238 } 239 else 240 orxout(user_warning, context::input) << "No mouse found! Proceeding without mouse support." << endl; 241 241 } 242 242 … … 252 252 catch (const std::exception& ex) 253 253 { 254 CCOUT(2) << "Warning: Failed to create joy stick: " << ex.what() << std::endl;254 orxout(user_warning, context::input) << "Failed to create joy stick: " << ex.what() << endl; 255 255 } 256 256 } … … 270 270 InputManager::~InputManager() 271 271 { 272 CCOUT(3) << "Destroying..." << std::endl;272 orxout(internal_status, context::input) << "InputManager: Destroying..." << endl; 273 273 274 274 // Leave all active InputStates (except "empty") … … 295 295 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0); 296 296 297 CCOUT(3) << "Destruction complete." << std::endl;297 orxout(internal_status, context::input) << "InputManager: Destruction complete." << endl; 298 298 } 299 299 … … 306 306 void InputManager::destroyDevices() 307 307 { 308 CCOUT(4) << "Destroying devices..." << std::endl;308 orxout(verbose, context::input) << "InputManager: Destroying devices..." << endl; 309 309 310 310 BOOST_FOREACH(InputDevice*& device, devices_) … … 315 315 delete device; 316 316 device = 0; 317 CCOUT(4) << className << " destroyed." << std::endl;317 orxout(verbose, context::input) << className << " destroyed." << endl; 318 318 } 319 319 devices_.resize(InputDeviceEnumerator::FirstJoyStick); … … 326 326 catch (const OIS::Exception& ex) 327 327 { 328 COUT(1) << "OIS::InputManager destruction failed" << ex.eText << std::endl329 << " Potential resource leak!" << std::endl;328 orxout(internal_error, context::input) << "OIS::InputManager destruction failed" << ex.eText << '\n' 329 << "Potential resource leak!" << endl; 330 330 } 331 331 oisInputManager_ = NULL; 332 332 333 333 internalState_ |= Bad; 334 CCOUT(4) << "Destroyed devices." << std::endl;334 orxout(verbose, context::input) << "Destroyed devices." << endl; 335 335 } 336 336 … … 343 343 { 344 344 if (internalState_ & Calibrating) 345 CCOUT(2) << "Warning: Cannot reload input system. Joy sticks are currently being calibrated." << std::endl;345 orxout(internal_warning, context::input) << "Cannot reload input system. Joy sticks are currently being calibrated." << endl; 346 346 else 347 347 reloadInternal(); … … 351 351 void InputManager::reloadInternal() 352 352 { 353 CCOUT(4) << "Reloading ..." << std::endl;353 orxout(verbose, context::input) << "InputManager: Reloading ..." << endl; 354 354 355 355 this->destroyDevices(); … … 357 357 358 358 internalState_ &= ~Bad; 359 CCOUT(4) << "Reloading complete." << std::endl;359 orxout(verbose, context::input) << "InputManager: Reloading complete." << endl; 360 360 } 361 361 … … 471 471 void InputManager::calibrate() 472 472 { 473 COUT(0) << "Move all joy stick axes fully in all directions." << std::endl474 << "When done, put the axex in the middle position and press enter." << std::endl;473 orxout(message) << "Move all joy stick axes fully in all directions." << '\n' 474 << "When done, put the axex in the middle position and press enter." << endl; 475 475 476 476 BOOST_FOREACH(InputDevice* device, devices_) … … 495 495 this->clearBuffers(); 496 496 497 COUT(0) << "Calibration has been stored." << std::endl;497 orxout(message) << "Calibration has been stored." << endl; 498 498 } 499 499 … … 535 535 if (it->second->getPriority() == priority) 536 536 { 537 COUT(2) << "Warning:Could not add an InputState with the same priority '"538 << static_cast<int>(priority) << "' != 0." << std::endl;537 orxout(internal_warning, context::input) << "Could not add an InputState with the same priority '" 538 << static_cast<int>(priority) << "' != 0." << endl; 539 539 return 0; 540 540 } … … 548 548 else 549 549 { 550 COUT(2) << "Warning: Could not add an InputState with the same name '" << name << "'." << std::endl;550 orxout(internal_warning, context::input) << "Could not add an InputState with the same name '" << name << "'." << endl; 551 551 return 0; 552 552 } … … 598 598 if (name == "empty") 599 599 { 600 COUT(2) << "InputManager: Leaving the empty state is not allowed!" << std::endl;600 orxout(internal_warning, context::input) << "InputManager: Leaving the empty state is not allowed!" << endl; 601 601 return false; 602 602 } … … 623 623 if (name == "empty") 624 624 { 625 COUT(2) << "InputManager: Removing the empty state is not allowed!" << std::endl;625 orxout(internal_warning, context::input) << "InputManager: Removing the empty state is not allowed!" << endl; 626 626 return false; 627 627 } … … 649 649 if (name == "empty") 650 650 { 651 COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl;651 orxout(internal_warning, context::input) << "InputManager: Changing the empty state is not allowed!" << endl; 652 652 return false; 653 653 } -
code/trunk/src/libraries/core/input/JoyStick.cc
r6536 r8858 80 80 } 81 81 82 COUT(4) << "Created OIS joy stick with ID " << deviceName_ << std::endl;82 orxout(verbose, context::input) << "Created OIS joy stick with ID " << deviceName_ << endl; 83 83 84 84 // Load calibration -
code/trunk/src/libraries/core/input/KeyBinder.cc
r8366 r8858 32 32 #include <sstream> 33 33 #include "util/Convert.h" 34 #include "util/ Debug.h"34 #include "util/Output.h" 35 35 #include "util/Exception.h" 36 36 #include "core/ConfigValueIncludes.h" … … 251 251 void KeyBinder::loadBindings() 252 252 { 253 COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;253 orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl; 254 254 255 255 this->configFile_ = new ConfigFile(this->filename_, !PathConfig::buildDirectoryRun()); … … 277 277 } 278 278 279 COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;279 orxout(internal_info, context::input) << "KeyBinder: Loading key bindings done." << endl; 280 280 } 281 281 … … 294 294 else 295 295 { 296 COUT(2) << "Could not find key/button/axis with name '" << name << "'." << std::endl;296 orxout(internal_warning, context::input) << "Could not find key/button/axis with name '" << name << "'." << endl; 297 297 return false; 298 298 } -
code/trunk/src/libraries/core/input/KeyBinderManager.cc
r7284 r8858 29 29 #include "KeyBinderManager.h" 30 30 31 #include "util/ Debug.h"31 #include "util/Output.h" 32 32 #include "util/Exception.h" 33 33 #include "util/ScopedSingletonManager.h" … … 168 168 if (!this->bBinding_) 169 169 { 170 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;170 orxout(message) << "Press any button/key or move a mouse/joystick axis" << endl; 171 171 KeyDetector::getInstance().setCallback(createFunctor(&KeyBinderManager::keybindKeyPressed, this)); 172 172 InputManager::getInstance().enterState("detector"); … … 185 185 if (keyName == "Keys.KeyEscape") 186 186 { 187 COUT(0) << "Keybinding aborted." << std::endl;187 orxout(message) << "Keybinding aborted." << endl; 188 188 } 189 189 else 190 190 { 191 COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;191 orxout(message) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << endl; 192 192 this->currentBinder_->setBinding(command_, keyName, bTemporary_); 193 193 } -
code/trunk/src/libraries/network/CMakeLists.txt
r8351 r8858 19 19 20 20 SET_SOURCE_FILES(NETWORK_SRC_FILES 21 ChatListener.cc22 21 Client.cc 23 22 ClientConnection.cc … … 45 44 46 45 SET_SOURCE_FILES(NETWORK_HDR_FILES 47 ChatListener.h48 46 Client.h 49 47 ClientConnection.h … … 61 59 WANDiscovery.h 62 60 MasterServerComm.h 61 NetworkChatListener.h 63 62 NetworkFunction.h 64 63 NetworkPrecompiledHeaders.h -
code/trunk/src/libraries/network/Client.cc
r8327 r8858 44 44 45 45 #include "util/Clock.h" 46 #include "util/ Debug.h"46 #include "util/Output.h" 47 47 #include "util/ScopedSingletonManager.h" 48 48 #include "synchronisable/Synchronisable.h" … … 116 116 } 117 117 118 bool Client::processChat(const std::string& message, unsigned int playerID)119 {120 // COUT(1) << "Player " << playerID << ": " << message << std::endl;121 return true;122 }123 124 118 void Client::printRTT() 125 119 { 126 COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;127 } 128 129 /** 130 * This function implements the method of sending a chat message to the server120 orxout(message) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl; 121 } 122 123 /** 124 * @brief Sends a chat message to the server. 131 125 * @param message message to be sent 132 * @return result(true/false) 126 * @param sourceID the ID of the sender 127 * @param targetID the ID of the receiver 133 128 */ 134 bool Client::chat(const std::string& message) 135 { 136 packet::Chat *m = new packet::Chat(message, Host::getPlayerID()); 137 return m->send(static_cast<Host*>(this)); 138 } 139 129 void Client::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 130 { 131 // send the message to the server 132 packet::Chat* packet = new packet::Chat(message, sourceID, targetID); 133 packet->send(static_cast<Host*>(this)); 134 } 135 136 /** 137 * @brief Gets called if a packet::Chat packet is received. Calls the parent function which passes the message to the listeners. 138 */ 139 void Client::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 140 { 141 // call the parent function which passes the message to the listeners 142 Host::doReceiveChat(message, sourceID, targetID); 143 } 140 144 141 145 /** … … 150 154 { 151 155 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 152 // COUT(3) << '.';153 156 if ( isConnected() && isSynched_ ) 154 157 { 155 COUT(4) << "popping partial gamestate: " << std::endl;158 orxout(verbose, context::network) << "popping partial gamestate: " << endl; 156 159 // packet::Gamestate *gs = GamestateClient::getGamestate(); 157 160 if( GamestateManager::update() ) … … 166 169 //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now 167 170 // if(gs){ 168 // COUT(4) << "client tick: sending gs " << gs << std::endl;171 // orxout(verbose, context::network) << "client tick: sending gs " << gs << endl; 169 172 // if( !gs->send() ) 170 // COUT(2) << "Problem adding partial gamestate to queue" << std::endl;173 // orxout(internal_warning, context::network) << "Problem adding partial gamestate to queue" << endl; 171 174 // // gs gets automatically deleted by enet callback 172 175 // } … … 204 207 Game::getInstance().popState(); 205 208 } 206 209 207 210 void Client::processPacket(packet::Packet* packet) 208 211 { … … 217 220 packet->process(static_cast<Host*>(this)); 218 221 } 219 220 221 222 223 222 } -
code/trunk/src/libraries/network/Client.h
r7801 r8858 73 73 Client(); 74 74 ~Client(); 75 75 76 76 static Client* getInstance(){ return singletonPtr_s; } // tolua_export 77 77 … … 81 81 void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID); 82 82 virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); } 83 bool processChat(const std::string& message, unsigned int playerID); 84 virtual bool chat(const std::string& message); 85 virtual bool broadcast(const std::string& message) { return false; } 83 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 84 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 86 85 virtual void printRTT(); 87 86 -
code/trunk/src/libraries/network/ClientConnection.cc
r8327 r8858 32 32 #define WIN32_LEAN_AND_MEAN 33 33 #include <enet/enet.h> 34 #include "util/ Debug.h"34 #include "util/Output.h" 35 35 36 36 namespace orxonox … … 60 60 void ClientConnection::setServerAddress( const std::string& serverAddress ) { 61 61 if (enet_address_set_host (this->serverAddress_, serverAddress.c_str()) < 0) 62 COUT(1) << "Error: Could not resolve \"" << serverAddress << "\"." << std::endl;62 orxout(internal_error, context::network) << "Could not resolve \"" << serverAddress << "\"." << endl; 63 63 } 64 64 … … 76 76 if ( this->host_ == NULL ) 77 77 { 78 COUT(1) << "ClientConnection: host_ == NULL" << std::endl;78 orxout(internal_error, context::network) << "ClientConnection: host_ == NULL" << endl; 79 79 // error handling 80 80 return false; … … 86 86 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 87 87 if (this->host_->socket4 == ENET_SOCKET_NULL) 88 COUT(2) << "Warning: IPv4 Socket failed." << std::endl;88 orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl; 89 89 else if (this->host_->socket6 == ENET_SOCKET_NULL) 90 COUT(2) << "Warning: IPv6 Socket failed." << std::endl;90 orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl; 91 91 else 92 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;92 orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl; 93 93 94 94 this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CHANNEL_COUNT, 0); 95 95 if ( this->server_==NULL ) 96 96 { 97 COUT(1) << "ClientConnection: server_ == NULL" << std::endl;97 orxout(internal_error, context::network) << "ClientConnection: server_ == NULL" << endl; 98 98 // error handling 99 99 return false; … … 113 113 } 114 114 } 115 COUT(1) << "Could not connect to server" << endl;115 orxout(user_error, context::network) << "Could not connect to server" << endl; 116 116 return false; 117 117 } … … 140 140 break; 141 141 case ENET_EVENT_TYPE_DISCONNECT: 142 COUT(4) << "received disconnect confirmation from server" << endl;142 orxout(verbose, context::network) << "received disconnect confirmation from server" << endl; 143 143 this->connectionClosed(); 144 144 return true; … … 167 167 { 168 168 this->established_=false; 169 COUT(1) << "Received disconnect Packet from Server!" << endl;169 orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl; 170 170 // server closed the connection 171 171 this->stopCommunicationThread(); -
code/trunk/src/libraries/network/Connection.cc
r8327 r8858 144 144 while( outgoingEventsCount > 0 ) 145 145 { 146 // COUT(0) << "outgoing event" << endl;146 // orxout(verbose, context::network) << "outgoing event" << endl; 147 147 this->outgoingEventsMutex_->lock(); 148 148 outgoingEvent outEvent = this->outgoingEvents_.front(); -
code/trunk/src/libraries/network/GamestateManager.cc
r8407 r8858 52 52 #include "core/command/Executor.h" 53 53 #include "core/GameMode.h" 54 #include "util/ Debug.h"54 #include "util/Output.h" 55 55 #include "util/Clock.h" 56 56 #include "util/OrxAssert.h" … … 128 128 if( !this->sendPacket(ack)) 129 129 { 130 COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;130 orxout(internal_warning, context::network) << "could not ack gamestate: " << gamestateID << endl; 131 131 return false; 132 132 } 133 133 else 134 134 { 135 COUT(5) << "acked a gamestate: " << gamestateID << std::endl;135 orxout(verbose_more, context::network) << "acked a gamestate: " << gamestateID << endl; 136 136 return true; 137 137 } … … 182 182 if( !peerIt->second.isSynched ) 183 183 { 184 COUT(5) << "Server: not sending gamestate" << std::endl;184 orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl; 185 185 continue; 186 186 } 187 COUT(5) << "client id: " << peerIt->first << std::endl;188 COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;187 orxout(verbose_more, context::network) << "client id: " << peerIt->first << endl; 188 orxout(verbose_more, context::network) << "Server: doing gamestate gamestate preparation" << endl; 189 189 int peerID = peerIt->first; //get client id 190 190 … … 256 256 // OrxVerify(gs->compressData(), ""); 257 257 clock.capture(); 258 COUT(5) << "diff and compress time: " << clock.getDeltaTime() << endl;259 // COUT(5) << "sending gamestate with id " << gs->getID();258 orxout(verbose_more, context::network) << "diff and compress time: " << clock.getDeltaTime() << endl; 259 // orxout(verbose_more, context::network) << "sending gamestate with id " << gs->getID(); 260 260 // if(gamestate->isDiffed()) 261 // COUT(5) << " and baseid " << gs->getBaseID() << endl;261 // orxout(verbose_more, context::network) << " and baseid " << gs->getBaseID() << endl; 262 262 // else 263 // COUT(5) << endl;263 // orxout(verbose_more, context::network) << endl; 264 264 gs->setPeerID(peerID); 265 265 destgamestate = gs; … … 291 291 if( gamestateID <= curid && curid != GAMESTATEID_INITIAL ) 292 292 return true; 293 COUT(4) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl;293 orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl; 294 294 std::map<uint32_t, packet::Gamestate*>::iterator it2; 295 295 for( it2=it->second.gamestates.begin(); it2!=it->second.gamestates.end(); ) -
code/trunk/src/libraries/network/Host.cc
r8408 r8858 32 32 #include <string> 33 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/ObjectList.h" 35 36 #include "core/command/ConsoleCommand.h" 36 #include " ChatListener.h"37 #include "NetworkChatListener.h" 37 38 38 39 namespace orxonox { … … 41 42 static const std::string __CC_printRTT_name = "printRTT"; 42 43 43 SetConsoleCommand("chat", &Host::Chat);44 44 SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT); 45 45 … … 89 89 } 90 90 91 void Host::Chat(const std::string& message) 91 /** 92 * @brief Sends a chat message through the network. 93 * @param message message to be sent 94 * @param sourceID the ID of the sender 95 * @param targetID the ID of the receiver 96 */ 97 void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 92 98 { 93 if(instances_s.size()==0) 94 { 95 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 96 it->incomingChat(message, 0); 97 // return true; 98 } 99 else 100 { 101 bool result = true; 102 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) 103 { 104 if( (*it)->isActive() ) 105 { 106 if( !(*it)->chat(message) ) 107 result = false; 108 } 109 } 110 // return result; 111 } 99 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) 100 if( (*it)->isActive() ) 101 (*it)->doSendChat(message, sourceID, targetID); 112 102 } 113 103 114 bool Host::Broadcast(const std::string& message) 104 /** 105 * @brief Gets called if a packet::Chat packet is received. Passes the message to the listeners. 106 */ 107 void Host::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 115 108 { 116 if(instances_s.size()==0) 117 { 118 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 119 it->incomingChat(message, NETWORK_PEER_ID_BROADCAST); 120 return true; 121 } 122 else 123 { 124 bool result = true; 125 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) 126 { 127 if( (*it)->isActive() ) 128 { 129 if( !(*it)->broadcast(message) ) 130 result = false; 131 } 132 } 133 return result; 134 } 109 for (ObjectList<NetworkChatListener>::iterator it = ObjectList<NetworkChatListener>::begin(); it != ObjectList<NetworkChatListener>::end(); ++it) 110 it->incomingChat(message, sourceID); 135 111 } 136 112 137 bool Host::incomingChat(const std::string& message, unsigned int playerID)138 {139 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)140 it->incomingChat(message, playerID);141 142 bool result = true;143 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )144 {145 if( (*it)->isActive() )146 {147 if( !(*it)->processChat(message, playerID) )148 result = false;149 }150 }151 return result;152 }153 113 154 114 bool Host::isServer() … … 156 116 for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it ) 157 117 { 158 if( (*it)->isServer_() ) 159 return true; 118 if( (*it)->isActive() ) 119 { 120 if( (*it)->isServer_() ) 121 return true; 122 } 160 123 } 161 124 return false; 162 125 } 163 126 164 127 Host* Host::getActiveInstance() 165 128 { … … 176 139 177 140 141 ////////////////////////////////////////////////////////////////////////// 142 // NetworkChatListener // 143 ////////////////////////////////////////////////////////////////////////// 144 145 NetworkChatListener::NetworkChatListener() 146 { 147 RegisterRootObject(NetworkChatListener); 148 } 149 178 150 }//namespace orxonox -
code/trunk/src/libraries/network/Host.h
r8403 r8858 52 52 class _NetworkExport Host: public GamestateManager 53 53 { 54 friend class packet::Chat; 55 54 56 private: 55 //TODO add these functions or adequate56 //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;57 //virtual bool sendChat(packet::Chat *chat)=0;58 57 virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID)=0; 59 virtual bool chat(const std::string& message)=0;60 virtual bool broadcast(const std::string& message)=0;61 virtual bool processChat(const std::string& message, unsigned int playerID)=0;62 58 virtual bool isServer_()=0; 63 64 65 59 66 60 protected: … … 68 62 virtual ~Host(); 69 63 void setActive( bool bActive ){ bIsActive_ = bActive; } 70 // static Host *instance_; 64 65 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0; 66 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0; 71 67 72 68 public: … … 74 70 static bool running(){ return instances_s.size(); } 75 71 static void addPacket(ENetPacket* packet, int clientID = NETWORK_PEER_ID_SERVER, uint8_t channelID = 0); 76 //static bool chat(std::string& message);77 // static bool receiveChat(packet::Chat *message, unsigned int clientID);78 72 static unsigned int getPlayerID(){ return clientID_s; } 79 73 static void setClientID(unsigned int id){ clientID_s = id; } 80 74 static bool isServer(); 81 static void Chat(const std::string& message); 82 static bool Broadcast(const std::string& message); 83 static bool incomingChat(const std::string& message, unsigned int playerID); 75 static void sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 84 76 virtual void printRTT()=0; 85 77 bool isActive(){ return bIsActive_; } -
code/trunk/src/libraries/network/LANDiscoverable.cc
r8351 r8858 33 33 #include <cstring> 34 34 35 #include "util/ Debug.h"35 #include "util/Output.h" 36 36 #include "packet/ServerInformation.h" 37 37 … … 71 71 this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 ); 72 72 if ( this->host_ == NULL ) 73 COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl;73 orxout(internal_error, context::network) << "LANDiscoverable: host_ == NULL" << endl; 74 74 } 75 75 else … … 94 94 { 95 95 case ENET_EVENT_TYPE_CONNECT: 96 COUT(4) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << std::endl;96 orxout(verbose, context::network) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << endl; 97 97 break; 98 98 case ENET_EVENT_TYPE_DISCONNECT: … … 102 102 if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 ) // check for a suitable orxonox client 103 103 { 104 COUT(3) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << std::endl;104 orxout(internal_info, context::network) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << endl; 105 105 packet::ServerInformation info; 106 106 info.setServerName("Orxonox Server"); -
code/trunk/src/libraries/network/LANDiscovery.cc
r8706 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oliver Scheuss 24 24 * Co-authors: 25 25 * ... … … 44 44 this->host_ = enet_host_create(NULL, 10, 0, 0, 0 ); 45 45 if ( this->host_ == NULL ) 46 COUT(1) << "LANDiscovery: host_ == NULL" << std::endl;46 orxout(internal_error, context::network) << "LANDiscovery: host_ == NULL" << endl; 47 47 } 48 48 … … 66 66 peer = enet_host_connect(this->host_, &address, 0, 0); 67 67 if (peer == NULL) 68 COUT(1) << "Error: Could not send LAN discovery to IPv4 Broadcast." << std::endl;68 orxout(internal_error, context::network) << "Could not send LAN discovery to IPv4 Broadcast." << endl; 69 69 70 70 /* IPv6 */ … … 72 72 peer = enet_host_connect(this->host_, &address, 0, 0); 73 73 if (peer == NULL) 74 COUT(1) << "Error: Could not send LAN discovery to IPv6 Multicast." << std::endl;74 orxout(internal_error, context::network) << "Could not send LAN discovery to IPv6 Multicast." << endl; 75 75 76 76 ENetEvent event; … … 81 81 case ENET_EVENT_TYPE_CONNECT: 82 82 { 83 COUT(4) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << std::endl;83 orxout(verbose, context::network) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << endl; 84 84 ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE); 85 85 enet_peer_send(event.peer, 0, packet); … … 89 89 { 90 90 packet::ServerInformation info(&event); 91 COUT(3) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;91 orxout(internal_info, context::network) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl; 92 92 std::vector<packet::ServerInformation>::iterator it; 93 93 for( it=this->servers_.begin(); it!=this->servers_.end(); ++it ) -
code/trunk/src/libraries/network/LANDiscovery.h
r8351 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oliver Scheuss 24 24 * Co-authors: 25 25 * ... -
code/trunk/src/libraries/network/MasterServer.cc
r8351 r8858 38 38 helper_output_debug( ENetEvent *event, char *addrconv ) 39 39 { 40 COUT(4) << "A packet of length" 40 orxout(verbose, context::master_server) 41 << "A packet of length" 41 42 << event->packet->dataLength 42 43 << " containing " … … 45 46 << addrconv 46 47 << " on channel " 47 << event->channelID << "\n";48 << event->channelID << endl; 48 49 } 49 50 … … 66 67 + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 ); 67 68 if( !tosend ) 68 { COUT(2) << "Masterserver.cc: Memory allocation failed.\n";69 { orxout(internal_warning, context::master_server) << "Masterserver.cc: Memory allocation failed." << endl; 69 70 continue; 70 71 } … … 108 109 { /* check for bad parameters */ 109 110 if( !event ) 110 { COUT(2) << "MasterServer::eventConnect: No event given.\n";111 { orxout(internal_warning, context::master_server) << "MasterServer::eventConnect: No event given." << endl; 111 112 return -1; 112 113 } … … 117 118 118 119 /* output debug info */ 119 COUT(4) << "A new client connected from "120 orxout(verbose, context::master_server) << "A new client connected from " 120 121 << addrconv 121 122 << " on port " 122 << event->peer->address.port << "\n";123 << event->peer->address.port << endl; 123 124 124 125 /* store string form of address here */ … … 134 135 { /* check for bad parameters */ 135 136 if( !event ) 136 { COUT(2) << "No event given.\n";137 { orxout(internal_warning, context::master_server) << "No event given." << endl; 137 138 return -1; 138 139 } 139 140 140 141 /* output that the disconnect happened */ 141 COUT(4) << (char*)event->peer->data << " disconnected.\n";142 orxout(verbose, context::master_server) << (char*)event->peer->data << " disconnected." << endl; 142 143 143 144 /* create string from peer data */ … … 159 160 { /* validate packet */ 160 161 if( !event || !(event->packet) || !(event->peer) ) 161 { COUT(2) << "No complete event given.\n";162 { orxout(internal_warning, context::master_server) << "No complete event given." << endl; 162 163 return -1; 163 164 } … … 182 183 183 184 /* tell people we did so */ 184 COUT(2) << "Added new server to list: " <<185 packet::ServerInformation( event ).getServerIP() << "\n";185 orxout(internal_info, context::master_server) << "Added new server to list: " << 186 packet::ServerInformation( event ).getServerIP() << endl; 186 187 } 187 188 … … 197 198 198 199 /* tell the user */ 199 COUT(2) << "Removed server " << name << " from list.\n";200 orxout(internal_info, context::master_server) << "Removed server " << name << " from list." << endl; 200 201 } 201 202 … … 230 231 if( event == NULL ) 231 232 { 232 COUT(1) << "Could not create ENetEvent structure, exiting.\n";233 orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl; 233 234 exit( EXIT_FAILURE ); 234 235 } … … 263 264 /***** INITIALIZE NETWORKING *****/ 264 265 if( enet_initialize () != 0) 265 { COUT(1) << "An error occurred while initializing ENet.\n";266 { orxout(user_error, context::master_server) << "An error occurred while initializing ENet." << endl; 266 267 exit( EXIT_FAILURE ); 267 268 } … … 285 286 /* see if creation worked */ 286 287 if( !this->server ) 287 { COUT(1) <<288 "An error occurred while trying to create an ENet server host. \n";288 { orxout(user_error, context::master_server) << 289 "An error occurred while trying to create an ENet server host." << endl; 289 290 exit( EXIT_FAILURE ); 290 291 } … … 294 295 295 296 /* tell people we're now initialized */ 296 COUT(0) << "MasterServer initialized, waiting for connections.\n";297 orxout(internal_status, context::master_server) << "MasterServer initialized, waiting for connections." << endl; 297 298 } 298 299 -
code/trunk/src/libraries/network/MasterServerComm.cc
r8351 r8858 28 28 29 29 #include "MasterServerComm.h" 30 #include "util/Debug.h" 30 #include "util/Output.h" 31 #include "WANDiscovery.h" 31 32 32 33 namespace orxonox … … 44 45 /* initialize Enet */ 45 46 if( enet_initialize () != 0 ) 46 { COUT(1) << "An error occurred while initializing ENet.\n";47 { orxout(internal_error, context::master_server) << "An error occurred while initializing ENet." << endl; 47 48 return 1; 48 49 } … … 61 62 /* see if it worked */ 62 63 if (this->client == NULL) 63 { COUT(1) << "An error occurred while trying to create an "64 << "ENet client host. \n";64 { orxout(internal_error, context::master_server) << "An error occurred while trying to create an " 65 << "ENet client host." << endl; 65 66 return 1; 66 67 } … … 85 86 86 87 if( this->peer == NULL ) 87 { COUT(2) << "ERROR:No available peers for initiating an ENet"88 << " connection. \n";88 { orxout(internal_error, context::master_server) << "No available peers for initiating an ENet" 89 << " connection." << endl; 89 90 return -1; 90 91 } … … 93 94 if (enet_host_service (this->client, &this->event, 500) > 0 && 94 95 this->event.type == ENET_EVENT_TYPE_CONNECT ) 95 COUT(3) << "Connection to master server succeeded.\n";96 orxout(internal_info, context::master_server) << "Connection to master server succeeded." << endl; 96 97 else 97 98 { 98 99 enet_peer_reset (this->peer); 99 COUT(2) << "ERROR: connection to " << address << " failed.\n";100 orxout(internal_warning, context::master_server) << "Connection to " << address << " failed." << endl; 100 101 return -1; 101 102 } … … 128 129 129 130 case ENET_EVENT_TYPE_DISCONNECT: 130 COUT(4) << "Disconnect from master server successful.\n";131 orxout(verbose, context::master_server) << "Disconnect from master server successful." << endl; 131 132 return 0; 132 133 default: break; … … 149 150 * so we can also make callbacks from objects 150 151 */ 151 int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ), 152 int delayms ) 152 int MasterServerComm::pollForReply( WANDiscovery* listener, int delayms ) 153 153 { 154 154 /* see whether anything happened */ 155 155 /* WORK MARK REMOVE THIS OUTPUT */ 156 COUT(2) << "polling masterserver...\n";156 orxout(verbose, context::master_server) << "polling masterserver..." << endl; 157 157 158 158 /* address buffer */ … … 176 176 addrconv = (char *) calloc( 50, 1 ); 177 177 if( !addrconv ) 178 { COUT(2) << "MasterServerComm.cc: Could not allocate memory!\n";178 { orxout(internal_warning, context::master_server) << "MasterServerComm.cc: Could not allocate memory!" << endl; 179 179 break; 180 180 } … … 185 185 186 186 /* DEBUG */ 187 COUT(3) << "MasterServer Debug: A packet of length "187 orxout(verbose, context::master_server) << "MasterServer Debug: A packet of length " 188 188 << this->event.packet->dataLength 189 189 << " containing " << this->event.packet->data … … 193 193 194 194 /* call the supplied callback, if any. */ 195 if( (*callback)!= NULL )196 retval = (*callback)( addrconv, &(this->event) );195 if( listener != NULL ) 196 retval = listener->rhandler( addrconv, &(this->event) ); 197 197 198 198 /* clean up */ -
code/trunk/src/libraries/network/MasterServerComm.h
r8351 r8858 93 93 * 94 94 * Poll the master server for new data and act accordingly */ 95 int pollForReply( int (*callback)( char*, ENetEvent* ), int delayms );95 int pollForReply( WANDiscovery* listener, int delayms ); 96 96 97 97 private: -
code/trunk/src/libraries/network/NetworkPrecompiledHeaders.h
r8351 r8858 52 52 #include <set> // 20 53 53 54 #include "util/ Debug.h" // 2054 #include "util/Output.h" // 20 55 55 #include <loki/TypeTraits.h> // 18 56 56 -
code/trunk/src/libraries/network/NetworkPrereqs.h
r8351 r8858 118 118 namespace orxonox 119 119 { 120 class ChatListener;121 120 class Client; 122 121 class ClientConnection; … … 130 129 class GamestateManager; 131 130 class Host; 131 class MasterServer; 132 class MasterServerComm; 133 class NetworkChatListener; 132 134 class NetworkFunctionBase; 133 135 struct NetworkFunctionPointer; … … 136 138 class NetworkMemberFunction; 137 139 class NetworkMemberFunctionBase; 140 class PeerList; 138 141 class Server; 139 142 class ServerConnection; 140 143 class TrafficControl; 144 class WANDiscoverable; 145 class WANDiscovery; 141 146 142 147 // packet -
code/trunk/src/libraries/network/PeerList.cc
r8351 r8858 28 28 29 29 #include "PeerList.h" 30 #include <network/packet/ServerInformation.h> 30 31 31 #include <cstdio> 32 #include "util/Output.h" 33 #include "network/packet/ServerInformation.h" 32 34 33 35 namespace orxonox … … 40 42 { /* error correction */ 41 43 if( toadd == NULL ) 42 { fprintf( stderr, "PeerList::addPeer: empty peer given.\n" );44 { orxout(internal_error, context::master_server) << "PeerList::addPeer: empty peer given." << endl; 43 45 return -1; 44 46 } -
code/trunk/src/libraries/network/Server.cc
r8706 r8858 47 47 48 48 #include "util/Clock.h" 49 #include "util/ Debug.h"49 #include "util/Output.h" 50 50 #include "core/ObjectList.h" 51 51 #include "core/command/Executor.h" … … 56 56 #include "packet/Gamestate.h" 57 57 #include "packet/Welcome.h" 58 #include "ChatListener.h"59 58 // #include "ClientInformation.h" 60 59 #include "FunctionCallManager.h" 61 60 #include "GamestateManager.h" 62 #include "WANDiscovery.h"63 61 64 62 namespace orxonox … … 100 98 } 101 99 102 103 /** helper that connects to the master server */104 void Server::helper_ConnectToMasterserver()105 {106 // WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " "107 // MSPROTO_REGISTER_SERVER );108 }109 110 100 /** 111 101 * This function opens the server by creating the listener thread … … 114 104 { 115 105 Host::setActive(true); 116 COUT(4) << "opening server" << endl;106 orxout(verbose, context::network) << "opening server" << endl; 117 107 this->openListener(); 118 108 119 109 /* make discoverable on LAN */ 120 110 LANDiscoverable::setActivity(true); … … 122 112 /* make discoverable on WAN */ 123 113 WANDiscoverable::setActivity(true); 124 /* TODO this needs to be optional, we need a switch from the UI to125 * enable/disable this126 */127 // helper_ConnectToMasterserver();128 114 129 115 /* done */ … … 137 123 { 138 124 Host::setActive(false); 139 COUT(4) << "closing server" << endl;125 orxout(verbose, context::network) << "closing server" << endl; 140 126 this->disconnectClients(); 141 127 this->closeListener(); 142 128 143 129 /* tell master server we're closing */ 144 COUT(2) << "disconnecting." << endl;145 WANDiscoverable::setActivity(false); 146 COUT(2) << "disconnecting done" << endl;130 orxout(internal_info, context::network) << "disconnecting." << endl; 131 WANDiscoverable::setActivity(false); 132 orxout(internal_info, context::network) << "disconnecting done" << endl; 147 133 148 134 LANDiscoverable::setActivity(false); 149 135 return; 150 }151 152 bool Server::processChat(const std::string& message, unsigned int playerID)153 {154 // ClientInformation *temp = ClientInformation::getBegin();155 packet::Chat *chat;156 // while(temp){157 chat = new packet::Chat(message, playerID);158 chat->setPeerID(NETWORK_PEER_ID_BROADCAST);159 chat->send( static_cast<Host*>(this) );160 // COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;161 // temp = temp->next();162 // }163 // COUT(1) << "Player " << playerID << ": " << message << std::endl;164 return true;165 }166 167 168 /* handle incoming data */169 int rephandler( char *addr, ENetEvent *ev )170 {171 /* reply to pings */172 if( !strncmp( (char *)ev->packet->data, MSPROTO_PING_GAMESERVER,173 MSPROTO_PING_GAMESERVER_LEN ) )174 //this->msc.sendRequest( MSPROTO_ACK );175 /* NOTE implement this after pollForReply176 * reimplementation177 */178 return 0;179 180 /* done handling, return all ok code 0 */181 return 0;182 }183 184 void Server::helper_HandleMasterServerRequests()185 {186 /* poll the master server for replies and see whether something187 * has to be done or changed.188 */189 //WANDiscovery::getInstance().msc.pollForReply( rhandler, 10 );190 136 } 191 137 … … 202 148 // receive and process incoming discovery packets 203 149 LANDiscoverable::update(); 204 205 // receive and process requests from master server206 /* todo */207 //helper_HandleMasterServerRequests();208 150 209 151 if ( GamestateManager::hasPeers() ) … … 246 188 { 247 189 // for( ClientInformation* temp=ClientInformation::getBegin(); temp!=0; temp=temp->next() ) 248 // COUT(0) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;190 // orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl; 249 191 } 250 192 … … 268 210 return; 269 211 GamestateManager::update(); 270 // COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;271 // std::cout << "updated gamestate, sending it" << std::endl;212 // orxout(verbose_more, context::network) << "Server: one gamestate update complete, goig to sendGameState" << endl; 213 //orxout(verbose_more, context::network) << "updated gamestate, sending it" << endl; 272 214 //if(clients->getGamestateID()!=GAMESTATEID_INITIAL) 273 215 sendGameStates(); 274 216 sendObjectDeletes(); 275 // COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;276 // std::cout << "sent gamestate" << std::endl;217 // orxout(verbose_more, context::network) << "Server: one sendGameState turn complete, repeat in next tick" << endl; 218 //orxout(verbose_more, context::network) << "sent gamestate" << endl; 277 219 } 278 220 … … 305 247 return true; //everything ok (no deletes this tick) 306 248 } 307 // COUT(3) << "sending DeleteObjects" << std::endl;249 // orxout(verbose, context::network) << "sending DeleteObjects" << endl; 308 250 // while(temp != NULL){ 309 251 // if( !(temp->getSynched()) ) 310 252 // { 311 // COUT(5) << "Server: not sending gamestate" << std::endl;253 // orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl; 312 254 // temp=temp->next(); 313 255 // continue; … … 318 260 del->setPeerID(NETWORK_PEER_ID_BROADCAST); 319 261 if ( !del->send( static_cast<Host*>(this) ) ) 320 COUT(3) << "Server: could not broadcast deleteObjects packet" << std::endl;262 orxout(internal_warning, context::network) << "Server: could not broadcast deleteObjects packet" << endl; 321 263 // temp=temp->next(); 322 264 // gs gets automatically deleted by enet callback … … 330 272 { 331 273 // static unsigned int newid=1; 332 // 333 // COUT(2) << "Server: adding client" << std::endl;274 // 275 // orxout(internal_info, context::network) << "Server: adding client" << endl; 334 276 // ClientInformation *temp = ClientInformation::insertBack(new ClientInformation); 335 277 // if(!temp) 336 278 // { 337 // COUT(2) << "Server: could not add client" << std::endl;279 // orxout(internal_warning, context::network) << "Server: could not add client" << endl; 338 280 // } 339 281 // temp->setID(newid); … … 347 289 // ++newid; 348 290 349 COUT(3) << "Server: added client id: " << peerID << std::endl;291 orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl; 350 292 createClient(peerID); 351 293 } … … 353 295 void Server::removePeer(uint32_t peerID) 354 296 { 355 COUT(4) << "removing client from list" << std::endl;297 orxout(verbose, context::network) << "removing client from list" << endl; 356 298 // ClientInformation *client = ClientInformation::findClient(&event->peer->address); 357 299 // if(!client) … … 375 317 // } 376 318 } 377 319 378 320 void Server::processPacket(packet::Packet* packet) 379 321 { … … 395 337 // if(!temp) 396 338 // { 397 // COUT(2) << "Server. could not create client with id: " << clientID << std::endl;339 // orxout(internal_error, context::network) << "Server. could not create client with id: " << clientID << endl; 398 340 // return false; 399 341 // } 400 // COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;342 // orxout(verbose, context::network) << "Con.Man: creating client id: " << temp->getID() << endl; 401 343 402 344 // synchronise class ids … … 411 353 // temp->setSynched(true); 412 354 GamestateManager::setSynched(clientID); 413 414 COUT(4) << "sending welcome" << std::endl;355 356 orxout(verbose, context::network) << "sending welcome" << endl; 415 357 packet::Welcome *w = new packet::Welcome(clientID); 416 358 w->setPeerID(clientID); … … 438 380 } 439 381 440 bool Server::chat(const std::string& message) 441 { 442 return this->sendChat(message, Host::getPlayerID()); 443 } 444 445 bool Server::broadcast(const std::string& message) 446 { 447 return this->sendChat(message, NETWORK_PEER_ID_BROADCAST); 448 } 449 450 bool Server::sendChat(const std::string& message, unsigned int clientID) 451 { 452 // ClientInformation *temp = ClientInformation::getBegin(); 453 packet::Chat *chat; 454 // while(temp) 455 { 456 chat = new packet::Chat(message, clientID); 457 chat->setPeerID(NETWORK_PEER_ID_BROADCAST); 458 chat->send( static_cast<Host*>(this) ); 459 // COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl; 460 // temp = temp->next(); 461 } 462 // COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl; 463 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 464 it->incomingChat(message, clientID); 465 466 return true; 382 /** 383 * @brief Sends a chat message to the given target ID. 384 * @param message message to be sent 385 * @param sourceID the ID of the sender 386 * @param targetID the ID of the receiver 387 */ 388 void Server::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 389 { 390 // check if the target exists. just ignore the message otherwise 391 if (!this->isValidTarget(targetID)) // TODO: remove this if an invalid clientIDs don't trigger assertions anymore 392 return; 393 394 // send the message to the target 395 packet::Chat* packet = new packet::Chat(message, sourceID, targetID); 396 packet->setPeerID(targetID); 397 packet->send( static_cast<Host*>(this) ); 398 399 // if the target is (or includes) this host as well, call the parent function which passes the message to the listeners 400 if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == Host::getPlayerID()) 401 Host::doReceiveChat(message, sourceID, targetID); 402 } 403 404 /** 405 * @brief Gets called if a packet::Chat packet is received. Forwards the packet to the target 406 * and calls the parent function if necessary. 407 */ 408 void Server::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 409 { 410 this->doSendChat(message, sourceID, targetID); 411 } 412 413 /** 414 * @brief Returns true if the target ID is in the list of clients (or if it 415 * corresponds to the broadcast or the server ID). 416 */ 417 bool Server::isValidTarget(unsigned int targetID) 418 { 419 if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == NETWORK_PEER_ID_SERVER) 420 return true; 421 422 std::vector<uint32_t>::iterator it; 423 for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it ) 424 if( *it == targetID ) 425 return true; 426 427 return false; 467 428 } 468 429 … … 476 437 } 477 438 assert(failures<10); 478 COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;439 orxout(verbose, context::network) << "syncClassid:\tall synchClassID packets have been sent" << endl; 479 440 } 480 441 -
code/trunk/src/libraries/network/Server.h
r8351 r8858 42 42 #include "LANDiscoverable.h" 43 43 #include "WANDiscoverable.h" 44 // #include "MasterServerComm.h"45 // #include "MasterServerProtocol.h"46 44 47 45 … … 61 59 ~Server(); 62 60 63 /* helpers */64 void helper_ConnectToMasterserver();65 void helper_HandleMasterServerRequests();66 int replyhandler( char *addr, ENetEvent *ev );67 68 61 void open(); 69 62 void close(); 70 bool processChat(const std::string& message, unsigned int playerID);71 63 void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID); 72 64 virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); } … … 89 81 bool sendGameStates(); 90 82 bool sendObjectDeletes(); 91 virtual bool chat(const std::string& message);92 virtual bool broadcast(const std::string& message);93 bool sendChat(const std::string& message, unsigned int clientID);83 bool isValidTarget(unsigned int targetID); 84 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 85 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 94 86 void syncClassid(unsigned int clientID); 95 87 -
code/trunk/src/libraries/network/ServerConnection.cc
r8358 r8858 34 34 #include <enet/enet.h> 35 35 36 #include "util/ Debug.h"36 #include "util/Output.h" 37 37 #include <util/Sleep.h> 38 38 // #include "ClientInformation.h" … … 61 61 { 62 62 if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0) 63 COUT(1) << "Error: Could not resolve \"" << bindAddress << "\"." << std::endl;63 orxout(internal_error, context::network) << "Could not resolve \"" << bindAddress << "\"." << endl; 64 64 } 65 65 … … 75 75 if ( this->host_ == NULL ) 76 76 { 77 COUT(1) << "ServerConnection: host_ == NULL" << std::endl;77 orxout(internal_error, context::network) << "ServerConnection: host_ == NULL" << endl; 78 78 return false; 79 79 } … … 83 83 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 84 84 if (this->host_->socket4 == ENET_SOCKET_NULL) 85 COUT(2) << "Warning: IPv4 Socket failed." << std::endl;85 orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl; 86 86 else if (this->host_->socket6 == ENET_SOCKET_NULL) 87 COUT(2) << "Warning: IPv6 Socket failed." << std::endl;87 orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl; 88 88 else 89 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;89 orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl; 90 90 91 91 // start communication thread … … 114 114 // ClientInformation *temp = ClientInformation::findClient(clientID); 115 115 // if(!temp){ 116 // COUT(3) << "C.Man: addPacket findClient failed" << std::endl;116 // orxout(internal_warning, context::network) << "C.Man: addPacket findClient failed" << endl; 117 117 // } 118 118 Connection::addPacket(packet, clientID, channelID); -
code/trunk/src/libraries/network/TrafficControl.cc
r6417 r8858 287 287 { 288 288 std::list<obj>::iterator it; 289 COUT(0) << "=========== Objectlist ===========" << endl;289 orxout(debug_output, context::network) << "=========== Objectlist ===========" << endl; 290 290 for( it=list.begin(); it!=list.end(); it++) 291 COUT(0) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl;291 orxout(debug_output, context::network) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl; 292 292 } 293 293 -
code/trunk/src/libraries/network/WANDiscoverable.cc
r8351 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau (original)23 * Sandro 'smerkli' Merkli 24 24 * Co-authors: 25 * Sandro 'smerkli' Merkli (adaptions to WAN) 26 * ... 25 * Oliver Scheuss (original) 27 26 * 28 27 */ … … 44 43 { 45 44 /* debugging output */ 46 COUT(4) << "Creating WANDiscoverable.\n";45 orxout(verbose, context::master_server) << "Creating WANDiscoverable." << endl; 47 46 48 47 /* register object in orxonox */ … … 91 90 if( msc.initialize() ) 92 91 { 93 COUT(2) << "Error: could not initialize master server communications!\n";92 orxout(internal_error, context::master_server) << "Could not initialize master server communications!" << endl; 94 93 return false; 95 94 } … … 98 97 if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) ) 99 98 { 100 COUT(2) << "Error: could not connect to master server at "101 << this->msaddress << std::endl;99 orxout(internal_error, context::master_server) << "Could not connect to master server at " 100 << this->msaddress << endl; 102 101 return false; 103 102 } 104 103 105 104 /* debugging output */ 106 COUT(4) << "Initialization of WANDiscoverable complete.\n";105 orxout(verbose, context::master_server) << "Initialization of WANDiscoverable complete." << endl; 107 106 108 107 -
code/trunk/src/libraries/network/WANDiscoverable.h
r8729 r8858 19 19 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 20 * 21 * Author: Fabian 'x3n' Landau (original) Co-authors: Sandro 'smerkli' Merkli 22 * (copied and adapted to WAN) 21 * Author: 22 * Sandro 'smerkli' Merkli 23 * Co-authors: 24 * Oliver Scheuss (original) 23 25 * 24 26 */ -
code/trunk/src/libraries/network/WANDiscovery.cc
r8351 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau (original)23 * Sandro 'smerkli' Merkli 24 24 * Co-authors: 25 * Sandro 'smerkli' Merkli (adaptions to WAN) 26 * ... 25 * Oliver Scheuss (original) 27 26 * 28 27 */ … … 33 32 #include <cstring> 34 33 35 #include "util/ScopedSingletonManager.h"36 34 #include "core/CoreIncludes.h" 37 35 … … 39 37 namespace orxonox 40 38 { 41 ManageScopedSingleton(WANDiscovery, ScopeID::Graphics, true);42 43 44 39 WANDiscovery::WANDiscovery() 45 40 { 46 41 /* debugging output */ 47 COUT(4) << "Creating WANDiscovery.\n";42 orxout(verbose, context::master_server) << "Creating WANDiscovery." << endl; 48 43 49 44 /* register object in orxonox */ … … 55 50 /* initialize it and see if it worked */ 56 51 if( msc.initialize() ) 57 COUT(2) << "Error: could not initialize master server communications!\n";52 orxout(internal_error, context::master_server) << "Could not initialize master server communications!" << endl; 58 53 59 54 /* connect and see if it worked */ 60 55 if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) ) 61 COUT(2) << "Error: could not connect to master server at "62 << this->msaddress << std::endl;56 orxout(internal_error, context::master_server) << "Could not connect to master server at " 57 << this->msaddress << endl; 63 58 64 59 /* debugging output */ 65 COUT(4) << "Initialization of WANDiscovery complete.\n";60 orxout(verbose, context::master_server) << "Initialization of WANDiscovery complete." << endl; 66 61 } 67 62 … … 81 76 82 77 /* callback for the network reply poller */ 83 int rhandler( char *addr, ENetEvent *ev )78 int WANDiscovery::rhandler( char *addr, ENetEvent *ev ) 84 79 { 85 80 /* error recognition */ 86 81 if( !ev || !ev->packet || !ev->packet->data ) 87 { COUT(2) << "Bad arguments received in WANDiscovery's reply handler.\n";82 { orxout(internal_warning, context::master_server) << "Bad arguments received in WANDiscovery's reply handler." << endl; 88 83 return 0; 89 84 } … … 104 99 105 100 /* add to list */ 106 WANDiscovery::getInstance().servers_.push_back( toadd );101 this->servers_.push_back( toadd ); 107 102 } 108 103 else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END, … … 133 128 { 134 129 /* poll for reply and act according to what was received */ 135 switch( this->msc.pollForReply( rhandler, 500 ) )130 switch( this->msc.pollForReply( this, 500 ) ) 136 131 { case 0: /* no event occured, decrease timeout */ 137 132 --i; break; -
code/trunk/src/libraries/network/WANDiscovery.h
r8351 r8858 19 19 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 20 * 21 * Author: Fabian 'x3n' Landau (original) Co-authors: Sandro 'smerkli' Merkli 22 * (copied and adapted to WAN) 21 * Author: 22 * Sandro 'smerkli' Merkli 23 * Co-authors: 24 * Oliver Scheuss (original) 23 25 * 24 26 */ … … 30 32 #include "packet/ServerInformation.h" 31 33 #include "core/ConfigFileManager.h" 32 #include "util/Singleton.h"33 34 #include "core/OrxonoxClass.h" 34 35 #include "core/ConfigValueIncludes.h" … … 47 48 class _NetworkExport WANDiscovery 48 49 // tolua_end 49 : public Singleton<WANDiscovery>, publicOrxonoxClass50 : public OrxonoxClass 50 51 { // tolua_export 51 friend class Singleton<WANDiscovery>;52 52 public: 53 53 /** constructor */ 54 WANDiscovery(); 54 WANDiscovery(); // tolua_export 55 55 56 56 /** destructor */ … … 81 81 std::string getServerListItemIP( unsigned int index ); // tolua_export 82 82 83 /** \return an instance of WANDiscovery84 *85 * Create and return an instance of WANDiscovery.86 */87 static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export88 89 83 /* todo: might make this private and use getter/setter methods 90 84 * at some later time. … … 98 92 /** Master server communications object */ 99 93 MasterServerComm msc; 94 95 int rhandler( char *addr, ENetEvent *ev ); 100 96 101 97 private: 102 /** Singleton pointer */103 static WANDiscovery* singletonPtr_s;104 105 98 /** master server address */ 106 99 std::string msaddress; -
code/trunk/src/libraries/network/packet/Acknowledgement.cc
r7801 r8858 29 29 #include "Acknowledgement.h" 30 30 31 #include "util/ Debug.h"31 #include "util/Output.h" 32 32 #include "network/GamestateHandler.h" 33 33 #include "network/Host.h" … … 64 64 65 65 bool Acknowledgement::process(orxonox::Host* host){ 66 COUT(5) << "processing ACK with ID: " << getAckID() << endl;66 orxout(verbose_more, context::packets) << "processing ACK with ID: " << getAckID() << endl; 67 67 bool b = host->ackGamestate(getAckID(), peerID_); 68 68 delete this; -
code/trunk/src/libraries/network/packet/Chat.cc
r7801 r8858 39 39 40 40 /* Some lengths */ 41 #define _PACKETID 0 42 const int _PLAYERID = _PACKETID + sizeof(Type::Value); 43 #define _MESSAGELENGTH _PLAYERID + sizeof(uint32_t) 44 #define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t) 41 #define _PACKETID 0 42 #define _SOURCEID _PACKETID + sizeof(Type::Value) 43 #define _TARGETID _SOURCEID + sizeof(uint32_t) 44 #define _MESSAGELENGTH _TARGETID + sizeof(uint32_t) 45 #define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t) 45 46 46 Chat::Chat( const std::string& message, unsigned int playerID )47 Chat::Chat( const std::string& message, unsigned int sourceID, unsigned int targetID ) 47 48 : Packet() 48 49 { … … 57 58 58 59 *(Type::Value *)(data_ + _PACKETID ) = Type::Chat; 59 *(unsigned int *)(data_ + _PLAYERID ) = playerID; 60 *(unsigned int *)(data_ + _SOURCEID ) = sourceID; 61 *(unsigned int *)(data_ + _TARGETID ) = targetID; 60 62 *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_; 61 63 … … 81 83 82 84 bool Chat::process(orxonox::Host* host){ 83 bool b = host->incomingChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_PLAYERID));85 host->doReceiveChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_SOURCEID), *(uint32_t *)(data_+_TARGETID)); 84 86 delete this; 85 return b;87 return true; 86 88 } 87 89 -
code/trunk/src/libraries/network/packet/Chat.h
r7801 r8858 42 42 public: 43 43 /* constructors */ 44 Chat( const std::string& message, unsigned int playerID );44 Chat( const std::string& message, unsigned int sourceID, unsigned int targetID ); 45 45 Chat( uint8_t* data, unsigned int clientID ); 46 46 -
code/trunk/src/libraries/network/packet/ClassID.cc
r7801 r8858 92 92 assert(tempsize==packetSize); 93 93 94 COUT(5) << "classid packetSize is " << packetSize << endl;94 orxout(verbose_more, context::packets) << "classid packetSize is " << packetSize << endl; 95 95 96 96 } … … 131 131 Identifier::clearNetworkIDs(); 132 132 133 COUT(4) << "=== processing classids: " << endl;133 orxout(verbose, context::packets) << "=== processing classids: " << endl; 134 134 std::pair<uint32_t, std::string> tempPair; 135 135 Identifier *id; … … 143 143 classname = temp+2*sizeof(uint32_t); 144 144 id=ClassByString( std::string((const char*)classname) ); 145 COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;145 orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl; 146 146 if(id==NULL){ 147 COUT(0) << "Received a bad classname" << endl;147 orxout(user_error, context::packets) << "Received a bad classname" << endl; 148 148 abort(); 149 149 } -
code/trunk/src/libraries/network/packet/DeleteObjects.cc
r7801 r8858 31 31 32 32 #include <cassert> 33 #include "util/ Debug.h"33 #include "util/Output.h" 34 34 #include "network/synchronisable/Synchronisable.h" 35 35 … … 62 62 if(number==0) 63 63 return false; 64 COUT(4) << "sending DeleteObjects: ";64 orxout(verbose, context::packets) << "sending DeleteObjects: "; 65 65 unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1); 66 66 data_ = new uint8_t[size]; … … 73 73 unsigned int temp = Synchronisable::popDeletedObject(); 74 74 *reinterpret_cast<uint32_t*>(tdata) = temp; 75 COUT(4) << temp << ' ';75 orxout(verbose, context::packets) << temp << ' '; 76 76 tdata += sizeof(uint32_t); 77 77 } 78 COUT(4) << std::endl;78 orxout(verbose, context::packets) << endl; 79 79 return true; 80 80 } … … 90 90 for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++) 91 91 { 92 COUT(4) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;92 orxout(verbose, context::packets) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << endl; 93 93 Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) ); 94 94 } -
code/trunk/src/libraries/network/packet/FunctionIDs.cc
r7801 r8858 34 34 #include <string> 35 35 36 #include "util/ Debug.h"36 #include "util/Output.h" 37 37 #include "core/ObjectList.h" 38 38 #include "network/NetworkFunction.h" … … 88 88 } 89 89 90 COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;90 orxout(verbose_more, context::packets) << "FunctionIDs packetSize is " << packetSize << endl; 91 91 92 92 } … … 126 126 unsigned char *functionname; 127 127 128 COUT(4) << "=== processing functionids: " << endl;128 orxout(verbose, context::packets) << "=== processing functionids: " << endl; 129 129 std::pair<uint32_t, std::string> tempPair; 130 130 // read the total number of classes … … 137 137 stringsize = *(uint32_t*)(temp+sizeof(uint32_t)); 138 138 functionname = temp+2*sizeof(uint32_t); 139 COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl;139 orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl; 140 140 NetworkFunctionBase::setNetworkID((const char*)functionname, networkID); 141 141 temp += 2*sizeof(uint32_t) + stringsize; -
code/trunk/src/libraries/network/packet/Gamestate.cc
r8394 r8858 31 31 #include <zlib.h> 32 32 33 #include "util/ Debug.h"33 #include "util/Output.h" 34 34 #include "util/OrxAssert.h" 35 35 #include "core/GameMode.h" … … 108 108 uint32_t size = calcGamestateSize(id, mode); 109 109 110 COUT(5) << "G.ST.Man: producing gamestate with id: " << id << std::endl;110 orxout(verbose_more, context::packets) << "G.ST.Man: producing gamestate with id: " << id << endl; 111 111 if(size==0) 112 112 return false; … … 114 114 if(!data_) 115 115 { 116 COUT(2) << "GameStateManager: could not allocate memory" << std::endl;116 orxout(internal_warning, context::packets) << "GameStateManager: could not allocate memory" << endl; 117 117 return false; 118 118 } … … 139 139 assert(0); // if we don't use multithreading this part shouldn't be neccessary 140 140 // start allocate additional memory 141 COUT(3) << "Gamestate: need additional memory" << std::endl;141 orxout(internal_info, context::packets) << "Gamestate: need additional memory" << endl; 142 142 ObjectList<Synchronisable>::iterator temp = it; 143 143 uint32_t addsize=tempsize; … … 167 167 //stop write gamestate header 168 168 169 COUT(5) << "Gamestate: Gamestate size: " << currentsize << std::endl;170 COUT(5) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << std::endl;169 orxout(verbose_more, context::packets) << "Gamestate: Gamestate size: " << currentsize << endl; 170 orxout(verbose_more, context::packets) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << endl; 171 171 return true; 172 172 } … … 175 175 bool Gamestate::spreadData(uint8_t mode) 176 176 { 177 COUT(5) << "processing gamestate with id " << header_.getID() << endl;177 orxout(verbose_more, context::packets) << "processing gamestate with id " << header_.getID() << endl; 178 178 assert(data_); 179 179 assert(!header_.isCompressed()); … … 195 195 else 196 196 { 197 // COUT(4) << "not creating object of classid " << objectheader.getClassID() << endl;197 // orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl; 198 198 mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() ); 199 199 } … … 201 201 else 202 202 { 203 // COUT(4) << "updating object of classid " << objectheader.getClassID() << endl;203 // orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl; 204 204 OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data"); 205 205 } … … 219 219 if (it->objectMode_ != 0x0) 220 220 { 221 COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;222 COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;223 COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;221 orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl; 222 orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl; 223 orxout(user_error, context::packets) << "Objects class: " << it->getIdentifier()->getName() << endl; 224 224 assert(false); 225 225 } … … 232 232 if (it->getObjectID() == *it2) 233 233 { 234 COUT(0) << "Found duplicate objectIDs on the client!" << std::endl235 << "Are you sure you don't create a Sychnronisable objcect with 'new' \236 that doesn't have objectMode = 0x0?" << std::endl;234 orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl 235 << "Are you sure you don't create a Sychnronisable objcect with 'new' \ 236 that doesn't have objectMode = 0x0?" << endl; 237 237 assert(false); 238 238 } … … 293 293 switch ( retval ) 294 294 { 295 case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;296 case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; return false;297 case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; return false;298 case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false;295 case Z_OK: orxout(verbose_more, context::packets) << "G.St.Man: compress: successfully compressed" << endl; break; 296 case Z_MEM_ERROR: orxout(internal_error, context::packets) << "G.St.Man: compress: not enough memory available in gamestate.compress" << endl; return false; 297 case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << endl; return false; 298 case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: data corrupted in gamestate.compress" << endl; return false; 299 299 } 300 300 … … 310 310 header_.setCompSize( buffer ); 311 311 header_.setCompressed( true ); 312 COUT(4) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << std::endl;312 orxout(verbose, context::packets) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << endl; 313 313 return true; 314 314 } … … 319 319 assert(data_); 320 320 assert(header_.isCompressed()); 321 COUT(4) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << std::endl;321 orxout(verbose, context::packets) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << endl; 322 322 uint32_t datasize = header_.getDataSize(); 323 323 uint32_t compsize = header_.getCompSize(); … … 333 333 switch ( retval ) 334 334 { 335 case Z_OK: COUT(5) << "successfully decompressed" << std::endl; break;336 case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return false;337 case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return false;338 case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;335 case Z_OK: orxout(verbose_more, context::packets) << "successfully decompressed" << endl; break; 336 case Z_MEM_ERROR: orxout(internal_error, context::packets) << "not enough memory available" << endl; return false; 337 case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "not enough memory available in the buffer" << endl; return false; 338 case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "data corrupted (zlib)" << endl; return false; 339 339 } 340 340 … … 375 375 if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 ) 376 376 { 377 // COUT(4) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;377 // orxout(verbose, context::packets) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl; 378 378 origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object 379 379 baseDataPtr += objectOffset + objectHeader.getDataSize(); … … 431 431 inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes ) 432 432 { 433 // COUT(4) << "docopy" << endl;433 // orxout(verbose, context::packets) << "docopy" << endl; 434 434 // Just copy over the whole Object 435 435 memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() ); … … 440 440 // SynchronisableHeader baseHeader( baseData ); 441 441 // baseData += baseHeader.getDataSize()+SynchronisableHeader::getSize(); 442 // COUT(4) << "copy " << h.getObjectID() << endl;443 // COUT(4) << "copy " << h.getObjectID() << ":";442 // orxout(verbose, context::packets) << "copy " << h.getObjectID() << endl; 443 // orxout(verbose, context::packets) << "copy " << h.getObjectID() << ":"; 444 444 sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); 445 445 // for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i ) 446 446 // { 447 // // COUT(4) << " " << *sizes;447 // // orxout(verbose, context::packets) << " " << *sizes; 448 448 // ++sizes; 449 449 // } 450 // COUT(4) << endl;450 // orxout(verbose, context::packets) << endl; 451 451 } 452 452 … … 541 541 if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() ) 542 542 { 543 // COUT(4) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;543 // orxout(verbose, context::packets) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 544 544 diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 545 545 diffedObject = true; … … 547 547 else 548 548 { 549 // COUT(4) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;549 // orxout(verbose, context::packets) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 550 550 copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 551 551 assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd); … … 565 565 if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() ) 566 566 { 567 // COUT(4) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;567 // orxout(verbose, context::packets) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 568 568 diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 569 569 diffedObject = true; … … 571 571 else 572 572 { 573 // COUT(4) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;573 // orxout(verbose, context::packets) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 574 574 copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 575 575 assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd); … … 578 578 else 579 579 { 580 // COUT(4) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;580 // orxout(verbose, context::packets) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 581 581 assert(baseDataPtr == oldBaseDataPtr); 582 582 copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); … … 718 718 //copy in the zeros 719 719 // std::list<obj>::iterator itt; 720 // COUT(0) << "myvector contains:";720 // orxout() << "myvector contains:"; 721 721 // for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ ) 722 // COUT(0) << " " << (*itt).objID;723 // COUT(0) << endl;722 // orxout() << " " << (*itt).objID; 723 // orxout() << endl; 724 724 for(it=dataVector_.begin(); it!=dataVector_.end();){ 725 725 SynchronisableHeader oldobjectheader(origdata); … … 771 771 nrOfVariables += it->getNrOfVariables(); 772 772 } 773 // COUT(0) << "allocating " << nrOfVariables << " ints" << endl;773 // orxout() << "allocating " << nrOfVariables << " ints" << endl; 774 774 this->sizes_.reserve(nrOfVariables); 775 775 return size; -
code/trunk/src/libraries/network/packet/Packet.cc
r8327 r8858 37 37 #include <boost/thread/mutex.hpp> 38 38 39 #include "util/ Debug.h"39 #include "util/Output.h" 40 40 #include "Acknowledgement.h" 41 41 #include "Chat.h" … … 192 192 // peerID = NETWORK_PEER_ID_SERVER; 193 193 Packet *p = 0; 194 // COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;194 // orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl; 195 195 switch( *(Type::Value *)(data + _PACKETID) ) 196 196 { 197 197 case Type::Acknowledgement: 198 // COUT(5) << "ack" << std::endl;198 // orxout(verbose_more, context::packets) << "ack" << endl; 199 199 p = new Acknowledgement( data, peerID ); 200 200 break; 201 201 case Type::Chat: 202 // COUT(5) << "chat" << std::endl;202 // orxout(verbose_more, context::packets) << "chat" << endl; 203 203 p = new Chat( data, peerID ); 204 204 break; 205 205 case Type::ClassID: 206 // COUT(5) << "classid" << std::endl;206 // orxout(verbose_more, context::packets) << "classid" << endl; 207 207 p = new ClassID( data, peerID ); 208 208 break; 209 209 case Type::Gamestate: 210 // COUT(5) << "gamestate" << std::endl;210 // orxout(verbose_more, context::packets) << "gamestate" << endl; 211 211 p = new Gamestate( data, peerID ); 212 212 break; 213 213 case Type::Welcome: 214 // COUT(5) << "welcome" << std::endl;214 // orxout(verbose_more, context::packets) << "welcome" << endl; 215 215 p = new Welcome( data, peerID ); 216 216 break; 217 217 case Type::DeleteObjects: 218 // COUT(5) << "deleteobjects" << std::endl;218 // orxout(verbose_more, context::packets) << "deleteobjects" << endl; 219 219 p = new DeleteObjects( data, peerID ); 220 220 break; 221 221 case Type::FunctionCalls: 222 // COUT(5) << "functionCalls" << std::endl;222 // orxout(verbose_more, context::packets) << "functionCalls" << endl; 223 223 p = new FunctionCalls( data, peerID ); 224 224 break; 225 225 case Type::FunctionIDs: 226 // COUT(5) << "functionIDs" << std::endl;226 // orxout(verbose_more, context::packets) << "functionIDs" << endl; 227 227 p = new FunctionIDs( data, peerID ); 228 228 break; … … 255 255 packetMap_.erase(it); 256 256 Packet::packetMapMutex_.unlock(); 257 // COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;257 // orxout(verbose_ultra, context::packets) << "PacketMap size: " << packetMap_.size() << endl; 258 258 } 259 259 -
code/trunk/src/libraries/network/packet/Welcome.cc
r8706 r8858 32 32 33 33 #include <cassert> 34 #include "util/ Debug.h"34 #include "util/Output.h" 35 35 #include "network/Host.h" 36 36 #include "network/synchronisable/Synchronisable.h" … … 78 78 assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321); 79 79 host->setClientID(clientID); 80 COUT(3) << "Welcome set clientId: " << clientID << endl;80 orxout(internal_info, context::packets) << "Welcome set clientId: " << clientID << endl; 81 81 Synchronisable::setClient(true); 82 82 delete this; -
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
r8706 r8858 130 130 // assert( !header.isDiffed() ); 131 131 132 COUT(4) << "fabricating object with id: " << header.getObjectID() << std::endl;132 orxout(verbose, context::network) << "fabricating object with id: " << header.getObjectID() << endl; 133 133 134 134 Identifier* id = ClassByID(header.getClassID()); … … 136 136 { 137 137 for(int i = 0; i<160; i++) 138 COUT(0) << "classid: " << i << " identifier: " << ClassByID(i) << endl;139 COUT(0) << "Assertion failed: id" << std::endl;140 COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;138 orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl; 139 orxout(user_error, context::network) << "Assertion failed: id" << endl; 140 orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl; 141 141 abort(); 142 142 } … … 168 168 bo->setLevel(creator->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself) 169 169 //assert(no->classID_ == header.getClassID()); 170 COUT(4) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << std::endl;170 orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl; 171 171 // update data and create object/entity... 172 172 bool b = no->updateData(mem, mode, true); … … 242 242 uint8_t* oldmem = mem; 243 243 if (this->classID_==0) 244 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;244 orxout(internal_info, context::network) << "classid 0 " << this->getIdentifier()->getName() << endl; 245 245 #endif 246 246 … … 258 258 // end copy header 259 259 260 CCOUT(5) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << std::endl;261 // COUT(4) << "objectid: " << this->objectID_ << ":";260 orxout(verbose_more, context::network) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << endl; 261 // orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":"; 262 262 // copy to location 263 263 for(i=syncList_.begin(); i!=syncList_.end(); ++i) 264 264 { 265 265 uint32_t varsize = (*i)->getData( mem, mode ); 266 // COUT(4) << " " << varsize;266 // orxout(verbose, context::network) << " " << varsize; 267 267 tempsize += varsize; 268 268 sizes.push_back(varsize); … … 271 271 } 272 272 assert(tempsize!=0); // if this happens an empty object (with no variables) would be transmitted 273 // COUT(4) << endl;273 // orxout(verbose, context::network) << endl; 274 274 275 275 header.setObjectID( this->objectID_ ); … … 305 305 if(syncList_.empty()) 306 306 { 307 orxout(internal_warning, context::network) << "Synchronisable::updateData syncList_ is empty" << endl; 307 308 assert(0); 308 COUT(2) << "Synchronisable::updateData syncList_ is empty" << std::endl;309 309 return false; 310 310 } … … 326 326 } 327 327 328 // COUT(5) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;328 //orxout(verbose_more, context::network) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << endl; 329 329 if( !syncHeaderLight.isDiffed() ) 330 330 { … … 344 344 { 345 345 mem += SynchronisableHeaderLight::getSize(); 346 // COUT(0) << "objectID: " << this->objectID_ << endl;346 // orxout(debug_output, context::network) << "objectID: " << this->objectID_ << endl; 347 347 while( mem < data+syncHeaderLight.getDataSize()+SynchronisableHeaderLight::getSize() ) 348 348 { 349 349 VariableID varID = *(VariableID*)mem; 350 // COUT(0) << "varID: " << varID << endl;350 // orxout(debug_output, context::network) << "varID: " << varID << endl; 351 351 assert( varID < syncList_.size() ); 352 352 mem += sizeof(VariableID); -
code/trunk/src/libraries/network/synchronisable/Synchronisable.h
r8706 r8858 232 232 it++; 233 233 } 234 COUT(1) << "Tried to unregister not registered variable" << endl;234 orxout(internal_error, context::network) << "Tried to unregister not registered variable" << endl; 235 235 assert(false); //if we reach this point something went wrong: 236 236 // the variable has not been registered before -
code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
r7266 r8858 202 202 if ( *static_cast<uint8_t*>(mem) != this->varReference_ ) 203 203 { // wrong reference number, so discard the data 204 // COUT(0) << "discharding data" << endl;204 // orxout(debug_output, context::network) << "discharding data" << endl; 205 205 mem += getSize( mode ); // SynchronisableVariableBidirectional::getSize returns size of variable + reference 206 206 return; -
code/trunk/src/libraries/tools/BillboardSet.cc
r6417 r8858 80 80 catch (...) 81 81 { 82 COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;82 orxout(internal_error) << "Couldn't load billboard \"" << file << '"' << endl; 83 83 this->billboardSet_ = 0; 84 84 } … … 103 103 catch (...) 104 104 { 105 COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;105 orxout(internal_error) << "Couldn't load billboard \"" << file << '"' << endl; 106 106 this->billboardSet_ = 0; 107 107 } -
code/trunk/src/libraries/tools/Mesh.cc
r8351 r8858 72 72 catch (...) 73 73 { 74 COUT(1) << "Error: Couln't load mesh \"" << meshsource << '"' << std::endl;74 orxout(internal_error) << "Couldn't load mesh \"" << meshsource << '"' << endl; 75 75 this->entity_ = 0; 76 76 } -
code/trunk/src/libraries/tools/ParticleInterface.cc
r7166 r8858 78 78 catch (...) 79 79 { 80 COUT(1) << "Error: Couln't load particle system \"" << templateName << '"' << std::endl;80 orxout(internal_error) << "Couldn't load particle system \"" << templateName << '"' << endl; 81 81 this->particleSystem_ = 0; 82 82 } -
code/trunk/src/libraries/tools/ResourceCollection.cc
r8351 r8858 62 62 if (resourceGroup.empty()) 63 63 { 64 COUT(2) << "Warning: \"\" is not a valid resource group." << std::endl;64 orxout(internal_warning) << "\"\" is not a valid resource group." << endl; 65 65 return; 66 66 } -
code/trunk/src/libraries/tools/ResourceLocation.cc
r8366 r8858 80 80 else 81 81 { 82 COUT(2) << "Warning: ResourceLocation '" << this->getPath() << "' does not seem to exist" << std::endl;82 orxout(internal_warning) << "ResourceLocation '" << this->getPath() << "' does not seem to exist" << endl; 83 83 return; 84 84 } … … 101 101 catch (const Ogre::Exception& ex) 102 102 { 103 COUT(1) << "Removing of a ResourceLocation failed: " << ex.what() << std::endl;103 orxout(internal_error) << "Removing of a ResourceLocation failed: " << ex.what() << endl; 104 104 } 105 105 } -
code/trunk/src/libraries/tools/Shader.cc
r8079 r8858 141 141 } 142 142 else 143 COUT(2) << "Warning: Couldn't load compositor with name \"" << this->compositorName_ << "\"." << std::endl;143 orxout(internal_warning) << "Couldn't load compositor with name \"" << this->compositorName_ << "\"." << endl; 144 144 } 145 145 this->oldcompositorName_ = this->compositorName_; … … 217 217 } 218 218 else 219 COUT(2) << "Warning: No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << std::endl;219 orxout(internal_warning) << "No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << endl; 220 220 } 221 221 else 222 COUT(2) << "Warning: No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << std::endl;222 orxout(internal_warning) << "No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << endl; 223 223 } 224 224 this->parameters_.clear(); -
code/trunk/src/libraries/tools/Timer.h
r8729 r8858 66 66 void MyClass::myFunction() 67 67 { 68 COUT(0) << "Hello World" << std::endl;68 orxout() << "Hello World" << endl; 69 69 } 70 70 @endcode -
code/trunk/src/libraries/util/CMakeLists.txt
r8729 r8858 26 26 CRC32.cc 27 27 ExprParser.cc 28 OutputHandler.cc29 28 Scope.cc 30 29 ScopedSingletonManager.cc … … 42 41 ) 43 42 43 ADD_SUBDIRECTORY(output) 44 44 45 ORXONOX_ADD_LIBRARY(util 45 46 FIND_HEADER_FILES -
code/trunk/src/libraries/util/Clipboard.cc
r7401 r8858 48 48 #undef min 49 49 #undef max 50 #include " Debug.h"50 #include "Output.h" 51 51 52 52 namespace orxonox … … 76 76 catch (...) 77 77 { 78 COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;79 COUT(1) << " \"" << text << '"' << std::endl;78 orxout(user_error) << "Unable to copy the following text to the clipboard:" << endl; 79 orxout(user_error) << '"' << text << '"' << endl; 80 80 } 81 81 return false; … … 104 104 catch (...) 105 105 { 106 COUT(1) << "Error: Unable to retrieve text from the clipboard." << std::endl;106 orxout(user_error) << "Unable to retrieve text from the clipboard." << endl; 107 107 } 108 108 return ""; -
code/trunk/src/libraries/util/Convert.h
r8729 r8858 130 130 #include <loki/TypeManip.h> 131 131 132 #include " Debug.h"132 #include "Output.h" 133 133 #include "ImplicitConversion.h" 134 134 … … 151 151 ORX_FORCEINLINE static bool convert(ToType* /*output*/, const FromType& /*input*/) 152 152 { 153 COUT(2) << "Could not convert value of type " << typeid(FromType).name()154 << " to type " << typeid(ToType).name() << std::endl;153 orxout(internal_warning) << "Could not convert value of type " << typeid(FromType).name() 154 << " to type " << typeid(ToType).name() << endl; 155 155 return false; 156 156 } -
code/trunk/src/libraries/util/Exception.cc
r8410 r8858 37 37 #include <cstddef> 38 38 #include <CEGUIExceptions.h> 39 #include " Debug.h"39 #include "Output.h" 40 40 41 41 namespace orxonox … … 111 111 catch (...) 112 112 { 113 COUT(0) << "BIG WARNING: Unknown exception type encountered."114 << "Rethrowing" << endl;113 orxout(user_error) << "BIG WARNING: Unknown exception type encountered." 114 << " Rethrowing" << endl; 115 115 throw; 116 116 } -
code/trunk/src/libraries/util/Exception.h
r8706 r8858 63 63 #include <sstream> 64 64 #include <string> 65 #include " Debug.h"65 #include "Output.h" 66 66 67 67 namespace orxonox … … 176 176 inline const T& exceptionThrowerHelper(const T& exception) 177 177 { 178 // let the catcher decide whether to display the message below level 4179 COUT(4) << exception.getFullDescription() << std::endl;178 // let the catcher decide whether to display the message also to the user 179 orxout(internal_error) << exception.getFullDescription() << endl; 180 180 return exception; 181 181 } -
code/trunk/src/libraries/util/ExprParser.h
r8351 r8858 55 55 if (!expr.getRemains().empty()) 56 56 { 57 COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;57 orxout(user_warning) << "Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << endl; 58 58 } 59 59 float result = expr.getResult(); 60 60 } 61 61 else 62 COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;62 orxout(user_error) << "Cannot calculate expression: Parse error." << endl; 63 63 @endcode 64 64 getRemains() returns the expression after what could be parsed. For instance -
code/trunk/src/libraries/util/MultiType.h
r7401 r8858 78 78 void myfunction(int value) 79 79 { 80 COUT(0) << "doubled value is " << (2 * value) << std::endl;80 orxout() << "doubled value is " << (2 * value) << endl; 81 81 } 82 82 -
code/trunk/src/libraries/util/OrxAssert.h
r8372 r8858 40 40 41 41 #include <cassert> 42 #include " Debug.h"42 #include "Output.h" 43 43 44 44 #ifndef NDEBUG … … 46 46 /** Run time assertion like assert(), but with an embedded message. 47 47 @details 48 The message will be printed as error with COUT(1). <br>48 The message will be printed as error with orxout(user_error). <br> 49 49 You can use the same magic here as you can with \ref ThrowException 50 50 @code … … 57 57 if (!(condition)) \ 58 58 { \ 59 COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \60 COUT(1) << "Assertion failed in " << __FUNCTIONNAME__ << std::endl; \61 COUT(1) << "Expression: " << #condition << std::endl; \62 COUT(1) << "Message : " << errorMessage << std::endl; \59 orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \ 60 orxout(user_error) << "Assertion failed in " << __FUNCTIONNAME__ << endl; \ 61 orxout(user_error) << "Expression: " << #condition << endl; \ 62 orxout(user_error) << "Message : " << errorMessage << endl; \ 63 63 /* Don't use the condition again to avoid double evaluation */ \ 64 64 /* Instead, stringify the expression and negate it */ \ … … 70 70 mode (no abort() triggered then). 71 71 @details 72 The message will be printed as error with COUT(1). <br>72 The message will be printed as error with orxout(user_error). <br> 73 73 You can use the same magic here as you can with \ref ThrowException 74 74 @code … … 81 81 if (!(condition)) \ 82 82 { \ 83 COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \84 COUT(1) << "Verification failed in " << __FUNCTIONNAME__ << std::endl; \85 COUT(1) << "Expression: " << #condition << std::endl; \86 COUT(1) << "Message : " << errorMessage << std::endl; \83 orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \ 84 orxout(user_error) << "Verification failed in " << __FUNCTIONNAME__ << endl; \ 85 orxout(user_error) << "Expression: " << #condition << endl; \ 86 orxout(user_error) << "Message : " << errorMessage << endl; \ 87 87 /* Don't use the condition again to avoid double evaluation */ \ 88 88 /* Instead, stringify the expression and negate it */ \ … … 100 100 if (!(condition)) \ 101 101 { \ 102 COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \103 COUT(1) << "Verification failed in " << __FUNCTIONNAME__ << std::endl; \104 COUT(1) << "Expression: " << #condition << std::endl; \105 COUT(1) << "Message : " << errorMessage << std::endl; \102 orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \ 103 orxout(user_error) << "Verification failed in " << __FUNCTIONNAME__ << endl; \ 104 orxout(user_error) << "Expression: " << #condition << endl; \ 105 orxout(user_error) << "Message : " << errorMessage << endl; \ 106 106 /* No assert() in release configuration */ \ 107 107 } \ -
code/trunk/src/libraries/util/Scope.h
r7401 r8858 60 60 #include <loki/ScopeGuard.h> 61 61 62 #include " Debug.h"62 #include "Output.h" 63 63 64 64 namespace orxonox … … 128 128 Scope() 129 129 { 130 orxout(internal_status) << "creating scope... (" << scope << ")" << endl; 131 130 132 try 131 133 { … … 148 150 throw; 149 151 } 152 153 orxout(internal_status) << "created scope (" << scope << ")" << endl; 150 154 } 151 155 … … 153 157 ~Scope() 154 158 { 159 orxout(internal_status) << "destroying scope... (" << scope << ")" << endl; 160 155 161 ScopeManager::instanceCounts_s[scope]--; 156 162 … … 162 168 if (ScopeManager::instanceCounts_s[scope] == 0) 163 169 this->deactivateListeners(); 170 171 orxout(internal_status) << "destroyed scope (" << scope << ")" << endl; 164 172 } 165 173 … … 174 182 { (*it)->deactivated(); } 175 183 catch (...) 176 { COUT(0) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << std::endl; }184 { orxout(internal_warning) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << endl; } 177 185 (*(it++))->bActivated_ = false; 178 186 } -
code/trunk/src/libraries/util/ScopedSingletonManager.h
r8706 r8858 231 231 { singletonPtr_ = new T(); } 232 232 catch (const InitialisationAbortedException& ex) 233 { COUT(3) << ex.getDescription() << std::endl; }233 { orxout(internal_error) << ex.getDescription() << endl; } 234 234 catch (...) 235 { COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }235 { orxout(internal_error) << "Singleton creation failed: " << Exception::handleMessage() << endl; } 236 236 } 237 237 -
code/trunk/src/libraries/util/SignalHandler.cc
r8351 r8858 39 39 #include <cstdio> 40 40 41 #include " Debug.h"41 #include "Output.h" 42 42 43 43 namespace orxonox … … 127 127 if( SignalHandler::singletonPtr_s == 0 ) 128 128 { 129 COUT(0) << "Received signal " << sigName.c_str() << std::endl << "Can't write backtrace because SignalHandler is already destroyed" << std::endl;129 orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl; 130 130 exit(EXIT_FAILURE); 131 131 } … … 137 137 138 138 139 COUT(0) << "Received signal " << sigName.c_str() << std::endl << "Try to write backtrace to file orxonox_crash.log" << std::endl;139 orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Try to write backtrace to file orxonox_crash.log" << endl; 140 140 141 141 … … 206 206 #ifdef PR_SET_PTRACER 207 207 if( prctl(PR_SET_PTRACER, gdbPid, 0, 0, 0) == -1 ) 208 COUT(0) << "could not set proper permissions for GDB to attach to process..." << endl;208 orxout(user_error) << "could not set proper permissions for GDB to attach to process..." << endl; 209 209 #endif 210 210 … … 213 213 214 214 if( read( sigPipe[0], &someData, sizeof(someData) ) != sizeof(someData) ) 215 COUT(0) << "something went wrong :(" << std::endl;215 orxout(user_error) << "something went wrong :(" << endl; 216 216 217 217 if ( someData != 0x12345678 ) 218 218 { 219 COUT(0) << "something went wrong :(" << std::endl;219 orxout(user_error) << "something went wrong :(" << endl; 220 220 } 221 221 … … 328 328 if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() ) 329 329 { 330 COUT(0) << "could not write " << bt.length() << " byte to " << getInstance().filename << std::endl;330 orxout(user_error) << "could not write " << bt.length() << " byte to " << getInstance().filename << endl; 331 331 exit(EXIT_FAILURE); 332 332 } … … 364 364 _UtilExport void __cdecl abort() 365 365 { 366 COUT(1) << "This application has requested the Runtime to terminate it in an unusual way." << std::endl; 367 COUT(1) << "Please contact the application's support team for more information." << std::endl; 366 using namespace orxonox; 367 orxout(user_error) << "This application has requested the Runtime to terminate it in an unusual way." << endl; 368 orxout(user_error) << "Please contact the application's support team for more information." << endl; 368 369 DebugBreak(); 369 370 exit(0x3); … … 373 374 _UtilExport void __cdecl _assert(const char* expression, const char* file, int line) 374 375 { 375 COUT(1) << "Assertion failed: " << expression << ", file " << file << ", line " << line << std::endl; 376 COUT(1) << std::endl; 376 using namespace orxonox; 377 orxout(user_error) << "Assertion failed: " << expression << ", file " << file << ", line " << line << endl; 378 orxout(user_error) << endl; 377 379 abort(); 378 380 } … … 423 425 bExecuting = true; 424 426 425 COUT(1) << std::endl;427 orxout(user_error) << endl; 426 428 427 429 // if the signalhandler has already been destroyed then don't do anything 428 430 if (SignalHandler::singletonPtr_s == 0) 429 431 { 430 COUT(1) << "Caught an unhandled exception" << std::endl << "Can't write backtrace because SignalHandler is already destroyed" << std::endl;432 orxout(user_error) << "Caught an unhandled exception" << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl; 431 433 exit(EXIT_FAILURE); 432 434 } 433 435 434 COUT(1) << "Caught an unhandled exception" << std::endl << "Try to write backtrace to orxonox_crash.log..." << std::endl;436 orxout(user_error) << "Caught an unhandled exception" << endl << "Try to write backtrace to orxonox_crash.log..." << endl; 435 437 436 438 // write the crash log … … 439 441 time_t now = time(NULL); 440 442 441 crashlog << "=======================================================" << std::endl;443 crashlog << "=======================================================" << endl; 442 444 crashlog << "= Time: " << std::string(ctime(&now)); 443 crashlog << "=======================================================" << std::endl;444 crashlog << std::endl;445 crashlog << "=======================================================" << endl; 446 crashlog << endl; 445 447 446 448 const std::string& error = SignalHandler::getExceptionType(pExceptionInfo); 447 449 448 crashlog << error << std::endl;449 crashlog << std::endl;450 crashlog << error << endl; 451 crashlog << endl; 450 452 451 453 const std::string& callstack = SignalHandler::getStackTrace(pExceptionInfo); 452 454 453 crashlog << "Call stack:" << std::endl;454 crashlog << callstack << std::endl;455 crashlog << "Call stack:" << endl; 456 crashlog << callstack << endl; 455 457 456 458 crashlog.close(); 457 459 458 460 // print the same information also to the console 459 COUT(1) << std::endl;460 COUT(1) << error << std::endl;461 COUT(1) << std::endl;462 COUT(1) << "Call stack:" << std::endl;463 COUT(1) << callstack << std::endl;461 orxout(user_error) << endl; 462 orxout(user_error) << error << endl; 463 orxout(user_error) << endl; 464 orxout(user_error) << "Call stack:" << endl; 465 orxout(user_error) << callstack << endl; 464 466 465 467 bExecuting = false; … … 467 469 else 468 470 { 469 COUT(1) << "An error occurred while writing the backtrace" << std::endl;471 orxout(user_error) << "An error occurred while writing the backtrace" << endl; 470 472 } 471 473 -
code/trunk/src/libraries/util/Singleton.h
r7904 r8858 100 100 void TestSingleton::testFunction() // implement testFunction 101 101 { 102 COUT(0) << "My value is " << this->testValue_ << std::endl;102 orxout() << "My value is " << this->testValue_ << endl; 103 103 } 104 104 -
code/trunk/src/libraries/util/Sleep.cc
r5738 r8858 34 34 35 35 #include "Sleep.h" 36 #include " Debug.h"36 #include "Output.h" 37 37 38 38 #ifdef ORXONOX_PLATFORM_WINDOWS … … 49 49 { 50 50 //if (microseconds < 1000) 51 // COUT(2) << "Warning: Windows cannot sleep less than 1ms, ignoring" << std::endl;51 // orxout(internal_warning) << "Windows cannot sleep less than 1ms, ignoring" << endl; 52 52 Sleep(microseconds / 1000); 53 53 } -
code/trunk/src/libraries/util/StringUtils.cc
r8232 r8858 79 79 for (; pos2 > 0 && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--); 80 80 return str.substr(pos1, pos2 - pos1 + 1); 81 } 82 83 /// Splits a given string by a delimiter and stores it in an output vector 84 void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output) 85 { 86 for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1) 87 { 88 end = str.find_first_of(delimiter, start); 89 output->push_back(str.substr(start, end - start)); 90 } 81 91 } 82 92 … … 517 527 return matrix[(rows-1)*cols + cols-1]; 518 528 } 519 529 520 530 /** 521 531 @brief -
code/trunk/src/libraries/util/StringUtils.h
r8232 r8858 43 43 #include "UtilPrereqs.h" 44 44 #include <string> 45 #include <vector> 45 46 46 47 namespace orxonox … … 54 55 55 56 _UtilExport std::string removeTrailingWhitespaces(const std::string& str); 57 58 _UtilExport void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output); 56 59 57 60 _UtilExport size_t getNextQuote(const std::string& str, size_t start); … … 88 91 89 92 _UtilExport unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2); 90 93 91 94 _UtilExport std::string getTimestamp(void); 92 95 } -
code/trunk/src/libraries/util/SubString.cc
r7401 r8858 45 45 #include "SubString.h" 46 46 #include <cstdio> 47 #include " Debug.h"47 #include "Output.h" 48 48 49 49 namespace orxonox … … 513 513 void SubString::debug() const 514 514 { 515 COUT(0) << "Substring-information::count=" << this->tokens_.size() << " ::";515 orxout(debug_output) << "Substring-information::count=" << this->tokens_.size() << " ::"; 516 516 for (unsigned int i = 0; i < this->tokens_.size(); ++i) 517 COUT(0) << "s" << i << "='" << this->tokens_[i].c_str() << "'::";518 COUT(0) << std::endl;517 orxout(debug_output) << "s" << i << "='" << this->tokens_[i].c_str() << "'::"; 518 orxout(debug_output) << endl; 519 519 } 520 520 } -
code/trunk/src/libraries/util/SubString.h
r8706 r8858 59 59 60 60 for (unsigned int i = 0; i < tokens.size(); ++i) 61 COUT(0) << i << ": " << tokens[i] << std::endl;61 orxout() << i << ": " << tokens[i] << endl; 62 62 @endcode 63 63 -
code/trunk/src/libraries/util/UtilPrereqs.h
r8729 r8858 88 88 class ExprParser; 89 89 class MultiType; 90 class OutputHandler;91 90 class OutputListener; 91 class OutputManager; 92 class OutputStream; 92 93 template <ScopeID::Value> 93 94 class Scope;
Note: See TracChangeset
for help on using the changeset viewer.