Changeset 11054 for code/branches/cpp11_v3/src/libraries
- Timestamp:
- Jan 10, 2016, 1:54:11 PM (9 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 deleted
- 260 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/src/libraries/core/ApplicationPaths.cc
r10624 r11054 68 68 69 69 //! Static pointer to the singleton 70 ApplicationPaths* ApplicationPaths::singletonPtr_s = 0;70 ApplicationPaths* ApplicationPaths::singletonPtr_s = nullptr; 71 71 72 72 ApplicationPaths::ApplicationPaths() … … 84 84 // get executable module 85 85 TCHAR buffer[1024]; 86 if (GetModuleFileName( NULL, buffer, 1024) == 0)86 if (GetModuleFileName(nullptr, buffer, 1024) == 0) 87 87 ThrowException(General, "Could not retrieve executable path."); 88 88 -
code/branches/cpp11_v3/src/libraries/core/ApplicationPaths.h
r10624 r11054 104 104 105 105 private: 106 ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol) 106 // non-copyable: 107 ApplicationPaths(const ApplicationPaths&) = delete; 108 ApplicationPaths& operator=(const ApplicationPaths&) = delete; 107 109 108 110 std::vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension); -
code/branches/cpp11_v3/src/libraries/core/BaseObject.cc
r10624 r11054 65 65 this->bRegisteredEventStates_ = false; 66 66 67 this->lastLoadedXMLElement_ = 0;68 69 this->mainStateFunctor_ = 0;67 this->lastLoadedXMLElement_ = nullptr; 68 69 this->mainStateFunctor_ = nullptr; 70 70 71 71 if (context) … … 86 86 else 87 87 { 88 this->file_ = 0;88 this->file_ = nullptr; 89 89 this->sceneID_ = OBJECTID_UNKNOWN; 90 90 } … … 132 132 XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode); 133 133 134 Element* events = 0;134 Element* events = nullptr; 135 135 if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject) 136 136 events = xmlelement.FirstChildElement("events", false); … … 163 163 this->setName(name); 164 164 165 for ( ObjectList<XMLNameListener>::iterator it = ObjectList<XMLNameListener>::begin(); it != ObjectList<XMLNameListener>::end(); ++it)166 it->loadedNewXMLName(this);165 for (XMLNameListener* listener : ObjectList<XMLNameListener>()) 166 listener->loadedNewXMLName(this); 167 167 } 168 168 … … 205 205 Template* link; 206 206 assert(!(link = Template::getTemplate(temp->getLink())) || !link->isLink()); 207 link = NULL;207 link = nullptr; 208 208 } 209 209 else … … 234 234 { 235 235 unsigned int i = 0; 236 for ( std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)236 for (Template* temp : this->templates_) 237 237 { 238 238 if (i == index) 239 return (*it);239 return temp; 240 240 i++; 241 241 } 242 return 0;242 return nullptr; 243 243 } 244 244 … … 269 269 { 270 270 unsigned int i = 0; 271 for ( std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); ++it)272 { 273 if ( it->second != state)271 for (const auto& mapEntry : this->eventSources_) 272 { 273 if (mapEntry.second != state) 274 274 continue; 275 275 276 276 if (i == index) 277 return it->first;277 return mapEntry.first; 278 278 ++i; 279 279 } 280 return 0;280 return nullptr; 281 281 } 282 282 … … 296 296 { 297 297 unsigned int i = 0; 298 for ( std::set<BaseObject*>::const_iterator it = this->eventListenersXML_.begin(); it != this->eventListenersXML_.end(); ++it)298 for (BaseObject* listener : this->eventListenersXML_) 299 299 { 300 300 if (i == index) 301 return *it;301 return listener; 302 302 ++i; 303 303 } 304 return 0;304 return nullptr; 305 305 } 306 306 … … 331 331 return (it->second); 332 332 else 333 return 0;333 return nullptr; 334 334 } 335 335 … … 358 358 Event event(activate, originator, name); 359 359 360 for ( std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)361 { 362 event.statename_ = (*it)->eventSources_[this];363 (*it)->processEvent(event);360 for (BaseObject* listener : this->eventListeners_) 361 { 362 event.statename_ = listener->eventSources_[this]; 363 listener->processEvent(event); 364 364 } 365 365 } … … 370 370 void BaseObject::fireEvent(Event& event) 371 371 { 372 for ( std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)373 (*it)->processEvent(event);372 for (BaseObject* listener : this->eventListeners_) 373 listener->processEvent(event); 374 374 } 375 375 … … 423 423 void BaseObject::changedMainStateName() 424 424 { 425 this->mainStateFunctor_ = 0;425 this->mainStateFunctor_ = nullptr; 426 426 427 427 if (!this->mainStateName_.empty()) … … 474 474 475 475 // iterate through all states and get the event sources 476 for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it) 477 { 478 const std::string& statename = (*it); 479 476 for (const std::string& statename : eventnames) 477 { 480 478 // if the event state is already known, continue with the next state 481 479 orxonox::EventState* eventstate = object->getEventState(statename); -
code/branches/cpp11_v3/src/libraries/core/BaseObject.h
r10624 r11054 163 163 inline void setScene(const StrongOrWeakPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; } 164 164 inline Scene* getScene() const { return this->scene_.get(); } 165 inline virtualuint32_t getSceneID() const { return this->sceneID_; }165 virtual inline uint32_t getSceneID() const { return this->sceneID_; } 166 166 167 167 inline void setGametype(const StrongOrWeakPtr<Gametype>& gametype) { this->gametype_ = gametype; } … … 218 218 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 219 219 const XMLFile* file_; //!< The XMLFile that loaded this object 220 Element* lastLoadedXMLElement_; //!< Non 0if the TinyXML attributes have already been copied to our own lowercase map220 Element* lastLoadedXMLElement_; //!< Non nullptr if the TinyXML attributes have already been copied to our own lowercase map 221 221 std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes 222 222 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader … … 265 265 return this->weakPtr_; 266 266 else 267 return NULL;267 return nullptr; 268 268 } 269 269 -
code/branches/cpp11_v3/src/libraries/core/ClassTreeMask.cc
r10624 r11054 207 207 return ((*this->nodes_.top().first) == compare); 208 208 else 209 return (compare == 0);209 return (compare == nullptr); 210 210 } 211 211 … … 218 218 return ((*this->nodes_.top().first) != compare); 219 219 else 220 return (compare != 0);220 return (compare != nullptr); 221 221 } 222 222 … … 293 293 { 294 294 // No it's not: Search for classes inheriting from the given class and add the rules for them 295 for ( std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)296 if ( (*it)->isA(this->root_->getClass()))297 if (overwrite || (!this->nodeExists( *it))) // If we don't want to overwrite, only add nodes that don't already exist298 this->add(this->root_, *it, bInclude, overwrite);295 for (const Identifier* directChild : subclass->getDirectChildren()) 296 if (directChild->isA(this->root_->getClass())) 297 if (overwrite || (!this->nodeExists(directChild))) // If we don't want to overwrite, only add nodes that don't already exist 298 this->add(this->root_, directChild, bInclude, overwrite); 299 299 } 300 300 … … 325 325 { 326 326 // Search for an already existing node, containing the subclass we want to add 327 for ( std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)327 for (ClassTreeMaskNode* subnode : node->subnodes_) 328 328 { 329 if (subclass->isA( (*it)->getClass()))329 if (subclass->isA(subnode->getClass())) 330 330 { 331 331 // We've found an existing node -> delegate the work with a recursive function-call and return 332 this->add( *it, subclass, bInclude, overwrite);332 this->add(subnode, subclass, bInclude, overwrite); 333 333 return; 334 334 } … … 392 392 if (!subclass) 393 393 return; 394 for ( std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)395 this->add( *it, this->isIncluded(*it), false, false);394 for (const Identifier* directChild : subclass->getDirectChildren()) 395 this->add(directChild, this->isIncluded(directChild), false, false); 396 396 397 397 this->add(subclass, bInclude, false, clean); … … 435 435 436 436 // Go through the list of subnodes and look for a node containing the searched subclass and delegate the request by a recursive function-call. 437 for ( std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)438 if (subclass->isA( (*it)->getClass()))439 return isIncluded( *it, subclass);437 for (ClassTreeMaskNode* subnode : node->subnodes_) 438 if (subclass->isA(subnode->getClass())) 439 return isIncluded(subnode, subclass); 440 440 441 441 // There is no subnode containing our class -> the rule of the current node takes in effect … … 851 851 this->objectIterator_ = Context::getRootContext()->getObjectList(this->subclassIterator_->first)->begin(); 852 852 else 853 this->objectIterator_ = ObjectList<BaseObject> ::end();853 this->objectIterator_ = ObjectList<BaseObject>().end(); 854 854 855 855 // Check if the iterator points on a valid object. If not, go to the next object by calling ++ … … 915 915 916 916 // Iterate through all subnodes 917 for ( std::list<ClassTreeMaskNode*>::iterator it1 = node->subnodes_.begin(); it1 != node->subnodes_.end(); ++it1)917 for (ClassTreeMaskNode* subnode : node->subnodes_) 918 918 { 919 919 // Recursive call to this function with the subnode 920 this->create( *it1);920 this->create(subnode); 921 921 922 922 // Only execute the following code if the current node is included, meaning some of the subnodes might be included too … … 926 926 927 927 // Iterate through all direct children 928 for (std::set<const Identifier*>::iterator it 2 = directChildren.begin(); it2 != directChildren.end(); ++it2)928 for (std::set<const Identifier*>::iterator it = directChildren.begin(); it != directChildren.end(); ++it) 929 929 { 930 930 // Check if the subnode (it1) is a child of the directChild (it2) 931 if ( (*it1)->getClass()->isA(*it2))931 if (subnode->getClass()->isA(*it)) 932 932 { 933 933 // Yes it is - remove the directChild (it2) from the list, because it will already be handled by a recursive call to the create() function 934 directChildren.erase(it 2);934 directChildren.erase(it); 935 935 936 936 // Check if the removed directChild was exactly the subnode 937 if (! (*it1)->getClass()->isExactlyA(*it2))937 if (!subnode->getClass()->isExactlyA(*it)) 938 938 { 939 939 // No, it wasn't exactly the subnode - therefore there are some classes between 940 940 941 941 // Add the previously removed directChild (it2) to the subclass-list 942 this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it 2, true));942 this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it, true)); 943 943 944 944 // Insert all directChildren of the directChild 945 directChildren.insert((*it 2)->getDirectChildren().begin(), (*it2)->getDirectChildren().end());945 directChildren.insert((*it)->getDirectChildren().begin(), (*it)->getDirectChildren().end()); 946 946 947 947 // Restart the scan with the expanded set of directChildren … … 957 957 // The bool is "false", meaning they have no subnodes and therefore need no further checks 958 958 if (node->isIncluded()) 959 for ( std::set<const Identifier*>::iterator it = directChildren.begin(); it != directChildren.end(); ++it)960 this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>( *it, false));959 for (const Identifier* directChild : directChildren) 960 this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(directChild, false)); 961 961 } 962 962 } -
code/branches/cpp11_v3/src/libraries/core/ClassTreeMask.h
r10693 r11054 152 152 ClassTreeMaskNode* operator*() const; 153 153 ClassTreeMaskNode* operator->() const; 154 operator bool() const;154 explicit operator bool() const; 155 155 bool operator==(ClassTreeMaskNode* compare) const; 156 156 bool operator!=(ClassTreeMaskNode* compare) const; 157 157 158 158 private: 159 std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> 159 std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator>> nodes_; ///< A stack to store list-iterators 160 160 std::list<ClassTreeMaskNode*> rootlist_; ///< A list for internal use (it only stores the root-node) 161 161 }; … … 211 211 inline const ClassTreeMask& begin() const { return (*this); } 212 212 /// End of the ClassTreeMaskObjectIterator. 213 inline BaseObject* end() const { return 0; }213 inline BaseObject* end() const { return nullptr; } 214 214 215 215 ClassTreeMask& operator=(const ClassTreeMask& other); … … 276 276 public: 277 277 /// Default-constructor: Does nothing. 278 inline ClassTreeMaskObjectIterator() {}278 inline ClassTreeMaskObjectIterator() = default; 279 279 /// Copy-Constructor: Initializes the iterator from another ClassTreeMask. 280 280 inline ClassTreeMaskObjectIterator(const ClassTreeMask& mask) { (*this) = mask; } … … 285 285 286 286 /// Returns true if the ClassTreeMaskObjectIterator points at the given object. 287 inline bool operator==(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) == pointer) || (!this->objectIterator_ && pointer == 0); }287 inline bool operator==(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) == pointer) || (!this->objectIterator_ && pointer == nullptr); } 288 288 /// Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. 289 inline bool operator!=(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) != pointer) || (!this->objectIterator_ && pointer != 0); }289 inline bool operator!=(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) != pointer) || (!this->objectIterator_ && pointer != nullptr); } 290 290 /// Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. 291 inline operator bool() const { return (this->objectIterator_); }291 inline explicit operator bool() const { return this->objectIterator_.operator bool(); } 292 292 /// Returns the object the ClassTreeMaskObjectIterator currently points at. 293 293 inline BaseObject* operator*() const { return (*this->objectIterator_); } … … 298 298 void create(ClassTreeMaskNode* node); 299 299 300 std::list<std::pair<const Identifier*, bool> 301 std::list<std::pair<const Identifier*, bool> 302 Iterator<BaseObject> 300 std::list<std::pair<const Identifier*, bool>> subclasses_; ///< A list of all Identifiers through which objects the iterator should iterate 301 std::list<std::pair<const Identifier*, bool>>::iterator subclassIterator_; ///< The current class of the iterator 302 Iterator<BaseObject> objectIterator_; ///< The current object of the iterator 303 303 }; 304 304 } -
code/branches/cpp11_v3/src/libraries/core/ConfigurablePaths.cc
r10624 r11054 54 54 #include "util/Exception.h" 55 55 #include "commandline/CommandLineIncludes.h" 56 #include "core/ApplicationPaths.h" 56 57 57 58 // Differentiate Boost Filesystem v2 and v3 … … 67 68 68 69 //! Static pointer to the singleton 69 ConfigurablePaths* ConfigurablePaths::singletonPtr_s = 0;70 ConfigurablePaths* ConfigurablePaths::singletonPtr_s = nullptr; 70 71 71 72 SetCommandLineArgument(externalDataPath, "").information("Path to the external data files"); … … 122 123 char* userDataPathPtr(getenv("APPDATA")); 123 124 #endif 124 if (userDataPathPtr == NULL)125 if (userDataPathPtr == nullptr) 125 126 ThrowException(General, "Could not retrieve user data path."); 126 127 bf::path userDataPath(userDataPathPtr); … … 143 144 144 145 // Create directories to avoid problems when opening files in non existent folders. 145 std::vector<std::pair<bf::path, std::string> 146 directories. push_back(std::make_pair(bf::path(configPath_), std::string("config")));147 directories. push_back(std::make_pair(bf::path(logPath_), std::string("log")));146 std::vector<std::pair<bf::path, std::string>> directories; 147 directories.emplace_back(bf::path(configPath_), std::string("config")); 148 directories.emplace_back(bf::path(logPath_), std::string("log")); 148 149 149 for (std::vector<std::pair<bf::path, std::string> 150 for (std::vector<std::pair<bf::path, std::string>>::iterator it = directories.begin(); 150 151 it != directories.end(); ++it) 151 152 { -
code/branches/cpp11_v3/src/libraries/core/ConfigurablePaths.h
r10624 r11054 93 93 94 94 private: 95 ConfigurablePaths(const ConfigurablePaths&); //!< Don't use (undefined symbol) 95 // non-copyable: 96 ConfigurablePaths(const ConfigurablePaths&) = delete; 97 ConfigurablePaths& operator=(const ConfigurablePaths&) = delete; 96 98 97 99 boost::filesystem::path& dataPath_; //!< Path to the data files folder -
code/branches/cpp11_v3/src/libraries/core/Core.cc
r11011 r11054 83 83 { 84 84 //! Static pointer to the singleton 85 Core* Core::singletonPtr_s = 0;85 Core* Core::singletonPtr_s = nullptr; 86 86 87 87 SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file"); … … 98 98 99 99 Core::Core(const std::string& cmdLine) 100 : applicationPaths_( NULL)101 , configurablePaths_( NULL)102 , dynLibManager_( NULL)103 , signalHandler_( NULL)104 , configFileManager_( NULL)105 , languageInstance_( NULL)106 , loaderInstance_( NULL)107 , ioConsole_( NULL)108 , tclBind_( NULL)109 , tclThreadManager_( NULL)110 , rootScope_( NULL)111 , graphicsManager_( NULL)112 , inputManager_( NULL)113 , guiManager_( NULL)114 , graphicsScope_( NULL)100 : applicationPaths_(nullptr) 101 , configurablePaths_(nullptr) 102 , dynLibManager_(nullptr) 103 , signalHandler_(nullptr) 104 , configFileManager_(nullptr) 105 , languageInstance_(nullptr) 106 , loaderInstance_(nullptr) 107 , ioConsole_(nullptr) 108 , tclBind_(nullptr) 109 , tclThreadManager_(nullptr) 110 , rootScope_(nullptr) 111 , graphicsManager_(nullptr) 112 , inputManager_(nullptr) 113 , guiManager_(nullptr) 114 , graphicsScope_(nullptr) 115 115 , bGraphicsLoaded_(false) 116 , staticInitHandler_( NULL)117 , pluginManager_( NULL)118 , rootModule_( NULL)119 , config_( NULL)116 , staticInitHandler_(nullptr) 117 , pluginManager_(nullptr) 118 , rootModule_(nullptr) 119 , config_(nullptr) 120 120 , destructionHelper_(this) 121 121 { … … 179 179 180 180 // initialize root context 181 Context::setRootContext(new Context( NULL));181 Context::setRootContext(new Context(nullptr)); 182 182 183 183 // Do this soon after the ConfigFileManager has been created to open up the … … 282 282 283 283 const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths(); 284 for ( std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)285 { 286 ModuleInstance* module = new ModuleInstance( *it);284 for (const std::string& modulePath : modulePaths) 285 { 286 ModuleInstance* module = new ModuleInstance(modulePath); 287 287 this->loadModule(module); 288 288 this->modules_.push_back(module); … … 312 312 void Core::unloadModules() 313 313 { 314 for (std::list<ModuleInstance*>::iterator it = this->modules_.begin(); it != this->modules_.end(); ++it) 315 { 316 ModuleInstance* module = (*it); 314 for (ModuleInstance* module : this->modules_) 315 { 317 316 this->unloadModule(module); 318 317 delete module; … … 329 328 module->deleteAllStaticallyInitializedInstances(); 330 329 this->dynLibManager_->unload(module->getDynLib()); 331 module->setDynLib( NULL);330 module->setDynLib(nullptr); 332 331 } 333 332 … … 464 463 { 465 464 // Update UpdateListeners before general ticking 466 for ( ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it)467 it->preUpdate(time);465 for (UpdateListener* listener : ObjectList<UpdateListener>()) 466 listener->preUpdate(time); 468 467 if (this->bGraphicsLoaded_) 469 468 { … … 474 473 } 475 474 // Process console events and status line 476 if (this->ioConsole_ != NULL)475 if (this->ioConsole_ != nullptr) 477 476 this->ioConsole_->preUpdate(time); 478 477 // Process thread commands … … 483 482 { 484 483 // Update UpdateListeners just before rendering 485 for ( ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it)486 it->postUpdate(time);484 for (UpdateListener* listener : ObjectList<UpdateListener>()) 485 listener->postUpdate(time); 487 486 if (this->bGraphicsLoaded_) 488 487 { -
code/branches/cpp11_v3/src/libraries/core/Core.h
r11012 r11054 73 73 74 74 /// Leave empty and use destroy() instead 75 ~Core() {}75 ~Core() = default; 76 76 /// Destructor that also executes when the object fails to construct 77 77 void destroy(); … … 92 92 93 93 private: 94 Core(const Core&); //!< Don't use (undefined symbol) 94 // non-copyable: 95 Core(const Core&) = delete; 96 Core& operator=(const Core&) = delete; 95 97 96 98 void setThreadAffinity(int limitToCPU); -
code/branches/cpp11_v3/src/libraries/core/CoreConfig.cc
r11052 r11054 35 35 #include "core/Language.h" 36 36 #include "core/ApplicationPaths.h" 37 38 #include <random> 37 39 38 40 namespace orxonox … … 106 108 { 107 109 // Inform listeners 108 ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin(); 109 for (; it != ObjectList<DevModeListener>::end(); ++it) 110 it->devModeChanged(bDevMode_); 110 for (DevModeListener* listener : ObjectList<DevModeListener>()) 111 listener->devModeChanged(bDevMode_); 111 112 } 112 113 … … 129 130 if (!bInitialized && this->bInitRandomNumberGenerator_) 130 131 { 131 srand(static_cast<unsigned int>(time(0))); 132 std::random_device rnddev; 133 rndseed(rnddev()); 134 //Keep the old seeding around because people will probably still use the old functions 135 srand(rnddev()); 132 136 rand(); 133 137 bInitialized = true; … … 137 141 void CoreConfig::updateLastLevelTimestamp() 138 142 { 139 ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time( NULL)));143 ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(nullptr))); 140 144 } 141 145 142 146 void CoreConfig::updateOgreConfigTimestamp() 143 147 { 144 ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time( NULL)));148 ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(nullptr))); 145 149 } 146 150 -
code/branches/cpp11_v3/src/libraries/core/CoreConfig.h
r11052 r11054 76 76 public: 77 77 DevModeListener(); 78 virtual ~DevModeListener() {}78 virtual ~DevModeListener() = default; 79 79 virtual void devModeChanged(bool value) = 0; 80 80 }; -
code/branches/cpp11_v3/src/libraries/core/CoreIncludes.h
r11020 r11054 120 120 */ 121 121 #define RegisterAbstractClass(ClassName) \ 122 RegisterClassWithFactory(ClassName, static_cast<ClassFactory<ClassName>*>( NULL), false)122 RegisterClassWithFactory(ClassName, static_cast<ClassFactory<ClassName>*>(nullptr), false) 123 123 124 124 /** … … 221 221 struct InheritsFromClass : public Identifier::InheritsFrom 222 222 { 223 virtual Identifier* getParent() const { return Class(T); }223 virtual Identifier* getParent() const override { return Class(T); } 224 224 }; 225 225 … … 231 231 ~StaticallyInitializedIdentifier() { identifier_->destroy(); } 232 232 233 virtual void load() 233 virtual void load() override 234 234 { 235 235 IdentifierManager::getInstance().addIdentifier(this->identifier_); 236 236 } 237 237 238 virtual void unload() 238 virtual void unload() override 239 239 { 240 240 IdentifierManager::getInstance().removeIdentifier(this->identifier_); -
code/branches/cpp11_v3/src/libraries/core/CorePrecompiledHeaders.h
r8858 r11054 50 50 #include <sstream> // 53 51 51 #include <set> // 50 52 #include <memory> 52 53 53 54 #include "util/Output.h" // 48 … … 66 67 #include <OgreColourValue.h> // 36 67 68 #include <boost/preprocessor/cat.hpp> // 27 68 #include <boost/shared_ptr.hpp> // 2169 69 70 70 #ifdef ORXONOX_COMPILER_MSVC … … 76 76 #include "util/SubString.h" // 14 77 77 78 #include <boost/scoped_ptr.hpp> // 1379 78 #include <stack> // 12 80 79 -
code/branches/cpp11_v3/src/libraries/core/CorePrereqs.h
r10624 r11054 68 68 namespace orxonox 69 69 { 70 static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);70 static constexpr uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1); 71 71 } 72 72 … … 82 82 83 83 //!A list of available scopes for the Scope template. 84 static const Value ROOT = 1;85 static const Value GRAPHICS = 2;84 static constexpr Value ROOT = 1; 85 static constexpr Value GRAPHICS = 2; 86 86 } 87 87 … … 90 90 typedef int Type; 91 91 92 static const Type STATIC_INITIALIZATION_HANDLER = 1;93 static const Type IDENTIFIER = 2;94 static const Type SCOPED_SINGLETON_WRAPPER = 3;95 static const Type COMMAND_LINE_ARGUMENT = 4;96 static const Type CONSOLE_COMMAND = 5;92 static constexpr Type STATIC_INITIALIZATION_HANDLER = 1; 93 static constexpr Type IDENTIFIER = 2; 94 static constexpr Type SCOPED_SINGLETON_WRAPPER = 3; 95 static constexpr Type COMMAND_LINE_ARGUMENT = 4; 96 static constexpr Type CONSOLE_COMMAND = 5; 97 97 } 98 98 -
code/branches/cpp11_v3/src/libraries/core/CoreStaticInitializationHandler.cc
r10624 r11054 99 99 std::set<Identifier*> identifiers; 100 100 const std::set<StaticallyInitializedInstance*>& instances = module->getInstances(StaticInitialization::IDENTIFIER); 101 for ( std::set<StaticallyInitializedInstance*>::const_iterator it = instances.begin(); it != instances.end(); ++it)102 identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>( *it)->getIdentifier());101 for (StaticallyInitializedInstance* instance : instances) 102 identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(instance)->getIdentifier()); 103 103 104 104 // destroy objects. some objects may survive this at first because they still have strong pointers pointing at them. this is … … 106 106 // that objects within one module may reference each other by strong pointers. but it is not allowed that objects from another 107 107 // module (which is not unloaded) uses strong pointers to point at objects inside the unloaded module. this will lead to a crash. 108 for ( std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)109 (*it)->destroyObjects();108 for (Identifier* identifier : identifiers) 109 identifier->destroyObjects(); 110 110 111 111 // check if all objects were really destroyed. this is not the case if an object is referenced by a strong pointer from another 112 112 // module (or if two objects inside this module reference each other). this will lead to a crash and must be fixed (e.g. by 113 113 // changing object dependencies; or by changing the logic that allows modules to be unloaded). 114 for ( std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)114 for (Identifier* identifier : identifiers) 115 115 { 116 ObjectListBase* objectList = Context::getRootContext()->getObjectList( *it);116 ObjectListBase* objectList = Context::getRootContext()->getObjectList(identifier); 117 117 if (objectList->size() > 0) 118 118 { 119 orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (*it)->getName()119 orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << identifier->getName() 120 120 << " after unloading the Identifier. This may lead to a crash" << endl; 121 121 } … … 123 123 124 124 // destroy object-lists in all contexts 125 for ( std::set<Identifier*>::iterator it_identifier = identifiers.begin(); it_identifier != identifiers.end(); ++it_identifier)125 for (Identifier* identifier : identifiers) 126 126 { 127 127 // only do this if the Identifier is not a Context itself; otherwise we delete the list we're iterating over 128 if (! (*it_identifier)->isExactlyA(Class(Context)))128 if (!identifier->isExactlyA(Class(Context))) 129 129 { 130 130 // iterate over all contexts 131 for ( ObjectList<Context>::iterator it_context = ObjectList<Context>::begin(); it_context != ObjectList<Context>::end(); ++it_context)132 it_context->destroyObjectList((*it_identifier));131 for (Context* context : ObjectList<Context>()) 132 context->destroyObjectList(identifier); 133 133 } 134 134 } -
code/branches/cpp11_v3/src/libraries/core/CoreStaticInitializationHandler.h
r10624 r11054 43 43 CoreStaticInitializationHandler() : bInitInstances_(false) {} 44 44 45 virtual void setupHandler() ;46 virtual void shutdownHandler() ;45 virtual void setupHandler() override; 46 virtual void shutdownHandler() override; 47 47 48 virtual void loadModule(ModuleInstance* module) ;49 virtual void unloadModule(ModuleInstance* module) ;48 virtual void loadModule(ModuleInstance* module) override; 49 virtual void unloadModule(ModuleInstance* module) override; 50 50 51 51 inline void setInitInstances(bool bInitInstances) -
code/branches/cpp11_v3/src/libraries/core/EventIncludes.h
r8729 r11054 86 86 87 87 #define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \ 88 static orxonox::ExecutorMemberPtr<classname> xmlsetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \ 89 static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \ 88 static orxonox::ExecutorPtr xmlsetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')'); \ 89 static orxonox::ExecutorPtr xmlgetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')'); \ 90 static orxonox::ExecutorMemberPtr<classname> xmlsetfunctor##name = std::static_pointer_cast<orxonox::ExecutorMember<classname>>(xmlsetfunctorbase##name); \ 91 static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = std::static_pointer_cast<orxonox::ExecutorMember<classname>>(xmlgetfunctorbase##name); \ 90 92 xmlsetfunctor##name->setDefaultValue(1, statename); \ 91 93 xmlgetfunctor##name->setDefaultValue(1, statename); \ -
code/branches/cpp11_v3/src/libraries/core/GUIManager.cc
r11052 r11054 32 32 #include <fstream> 33 33 #include <memory> 34 #include < boost/bind.hpp>34 #include <functional> 35 35 #include <OgreRenderQueue.h> 36 36 #include <OgreRenderWindow.h> … … 119 119 namespace orxonox 120 120 { 121 namespace arg = std::placeholders; 122 121 123 static void key_esc() 122 124 { GUIManager::getInstance().keyESC(); } … … 126 128 { 127 129 public: 128 v oid logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)130 virtual void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard) override 129 131 { 130 132 OutputLevel orxonoxLevel = level::debug_output; … … 145 147 146 148 /// Carbon copy from CEGUIDefaultLogger.cpp with a bugfix for Windows 147 v oid setLogFilename(const CEGUI::String& filename, bool append = false)149 virtual void setLogFilename(const CEGUI::String& filename, bool append = false) override 148 150 { 149 151 // Close current log file (if any) … … 169 171 d_caching = false; 170 172 171 std::vector<std::pair<CEGUI::String, CEGUI::LoggingLevel> 173 std::vector<std::pair<CEGUI::String, CEGUI::LoggingLevel>>::iterator it = d_cache.begin(); 172 174 173 175 while (it != d_cache.end()) … … 230 232 public: 231 233 /// Callback from Ogre invoked before other stuff in our target queue is rendered 232 v oid renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue)234 virtual void renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue) override 233 235 { 234 236 if (id == Ogre::RENDER_QUEUE_OVERLAY && invocation.empty()) … … 252 254 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); 253 255 254 GUIManager* GUIManager::singletonPtr_s = 0;256 GUIManager* GUIManager::singletonPtr_s = nullptr; 255 257 /*static*/ const std::string GUIManager::defaultScheme_ = "TaharezGreen"; //Alternative: Orxonox (not fully complete yet, see the graphics menu) 256 258 … … 291 293 */ 292 294 GUIManager::GUIManager(const std::pair<int, int>& mousePosition) 293 : guiRenderer_( NULL)294 , resourceProvider_( NULL)295 : guiRenderer_(nullptr) 296 , resourceProvider_(nullptr) 295 297 #ifndef ORXONOX_OLD_CEGUI 296 , rqListener_( NULL)297 , imageCodec_( NULL)298 #endif 299 , luaState_( NULL)300 , scriptModule_( NULL)301 , guiSystem_( NULL)302 , ceguiLogger_( NULL)303 , rootWindow_( NULL)304 , hudRootWindow_( NULL)305 , menuRootWindow_( NULL)306 , camera_( NULL)298 , rqListener_(nullptr) 299 , imageCodec_(nullptr) 300 #endif 301 , luaState_(nullptr) 302 , scriptModule_(nullptr) 303 , guiSystem_(nullptr) 304 , ceguiLogger_(nullptr) 305 , rootWindow_(nullptr) 306 , hudRootWindow_(nullptr) 307 , menuRootWindow_(nullptr) 308 , camera_(nullptr) 307 309 , destructionHelper_(this) 308 310 { … … 353 355 354 356 // Create our own logger to specify the filepath 355 std:: auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());357 std::unique_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); 356 358 ceguiLogger->setLogFilename(ConfigurablePaths::getLogPathString() + "cegui.log"); 357 359 ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_)); … … 360 362 // Create the CEGUI system singleton 361 363 #ifdef ORXONOX_OLD_CEGUI 362 guiSystem_ = new System(guiRenderer_, resourceProvider_, 0, scriptModule_);364 guiSystem_ = new System(guiRenderer_, resourceProvider_, nullptr, scriptModule_); 363 365 // Add functions that have been renamed in newer versions 364 366 luaState_->doString("CEGUI.SchemeManager.create = CEGUI.SchemeManager.loadScheme"); … … 366 368 luaState_->doString("CEGUI.ImagesetManager.createFromImageFile= CEGUI.ImagesetManager.createImagesetFromImageFile"); 367 369 #else 368 guiSystem_ = &System::create(*guiRenderer_, resourceProvider_, 0, imageCodec_, scriptModule_);370 guiSystem_ = &System::create(*guiRenderer_, resourceProvider_, nullptr, imageCodec_, scriptModule_); 369 371 #endif 370 372 … … 474 476 { 475 477 assert(guiSystem_); 476 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectTimePulse,_1, time.getDeltaTime()));478 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectTimePulse, arg::_1, time.getDeltaTime())); 477 479 } 478 480 … … 490 492 { 491 493 #ifdef ORXONOX_OLD_CEGUI 492 if (camera == NULL)493 this->guiRenderer_->setTargetSceneManager( 0);494 if (camera == nullptr) 495 this->guiRenderer_->setTargetSceneManager(nullptr); 494 496 else 495 497 this->guiRenderer_->setTargetSceneManager(camera->getSceneManager()); 496 498 #else 497 if (camera_ != NULL && camera_->getSceneManager() != NULL)499 if (camera_ != nullptr && camera_->getSceneManager() != nullptr) 498 500 camera_->getSceneManager()->removeRenderQueueListener(rqListener_); 499 if (camera != NULL && camera->getSceneManager() != NULL)501 if (camera != nullptr && camera->getSceneManager() != nullptr) 500 502 camera->getSceneManager()->addRenderQueueListener(rqListener_); 501 503 #endif … … 672 674 { 673 675 #if CEGUI_VERSION >= 0x000800 674 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectKeyDown,_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?675 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectChar,_1, evt.getText()));676 #else 677 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectKeyDown,_1, evt.getKeyCode()));678 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectChar,_1, evt.getText()));676 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectKeyDown, arg::_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work? 677 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectChar, arg::_1, evt.getText())); 678 #else 679 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectKeyDown, arg::_1, evt.getKeyCode())); 680 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectChar, arg::_1, evt.getText())); 679 681 #endif 680 682 } … … 683 685 { 684 686 #if CEGUI_VERSION >= 0x000800 685 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectKeyUp,_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?686 #else 687 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectKeyUp,_1, evt.getKeyCode()));687 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectKeyUp, arg::_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work? 688 #else 689 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectKeyUp, arg::_1, evt.getKeyCode())); 688 690 #endif 689 691 } … … 701 703 { 702 704 #if CEGUI_VERSION >= 0x000800 703 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectMouseButtonDown,_1, convertButton(id)));704 #else 705 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectMouseButtonDown,_1, convertButton(id)));705 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseButtonDown, arg::_1, convertButton(id))); 706 #else 707 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseButtonDown, arg::_1, convertButton(id))); 706 708 #endif 707 709 } … … 719 721 { 720 722 #if CEGUI_VERSION >= 0x000800 721 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectMouseButtonUp,_1, convertButton(id)));722 #else 723 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectMouseButtonUp,_1, convertButton(id)));723 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseButtonUp, arg::_1, convertButton(id))); 724 #else 725 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseButtonUp, arg::_1, convertButton(id))); 724 726 #endif 725 727 } … … 728 730 { 729 731 #if CEGUI_VERSION >= 0x000800 730 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectMousePosition,_1, (float)abs.x, (float)abs.y));731 #else 732 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectMousePosition,_1, (float)abs.x, (float)abs.y));732 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMousePosition, arg::_1, (float)abs.x, (float)abs.y)); 733 #else 734 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMousePosition, arg::_1, (float)abs.x, (float)abs.y)); 733 735 #endif 734 736 } … … 737 739 { 738 740 #if CEGUI_VERSION >= 0x000800 739 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectMouseWheelChange,_1, (float)sgn(rel) * this->numScrollLines_));740 #else 741 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectMouseWheelChange,_1, (float)sgn(rel) * this->numScrollLines_));741 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseWheelChange, arg::_1, (float)sgn(rel) * this->numScrollLines_)); 742 #else 743 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseWheelChange, arg::_1, (float)sgn(rel) * this->numScrollLines_)); 742 744 #endif 743 745 } … … 749 751 { 750 752 #if CEGUI_VERSION >= 0x000800 751 this->protectedCeguiContextCall( boost::bind(&CEGUI::GUIContext::injectMouseLeaves,_1));752 #else 753 this->protectedCeguiSystemCall( boost::bind(&CEGUI::System::injectMouseLeaves,_1));753 this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseLeaves, arg::_1)); 754 #else 755 this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseLeaves, arg::_1)); 754 756 #endif 755 757 } … … 798 800 terminate the whole program... 799 801 @note 800 Your life gets easier if you use boost::bind to create the object/function.802 Your life gets easier if you use std::bind to create the object/function. 801 803 @param function 802 804 Any callable object/function that takes this->guiSystem_ as its only parameter. … … 921 923 return; 922 924 923 CEGUI::Font* font = NULL;925 CEGUI::Font* font = nullptr; 924 926 CEGUI::XMLAttributes xmlAttributes; 925 927 … … 937 939 938 940 font = CEGUI::FontManager::getSingleton().createFont("FreeType", xmlAttributes); 939 if(font != NULL)941 if(font != nullptr) 940 942 font->load(); 941 943 #else -
code/branches/cpp11_v3/src/libraries/core/GUIManager.h
r11052 r11054 40 40 #include <map> 41 41 #include <string> 42 #include <memory> 42 43 43 44 #if CEGUI_VERSION >= 0x000800 … … 48 49 # include <CEGUIVersion.h> 49 50 #endif 50 51 #include <boost/shared_ptr.hpp>52 51 53 52 #include "util/DestructionHelper.h" … … 98 97 99 98 //! Leave empty and use cleanup() instead 100 ~GUIManager() {}99 ~GUIManager() = default; 101 100 /// Destructor that also executes when object fails to construct 102 101 void destroy(); … … 137 136 inline void setPlayer(const std::string& guiname, PlayerInfo* player) 138 137 { this->players_[guiname] = player; } 139 inline orxonox::PlayerInfo* getPlayer(const std::string& guiname) const { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; } // tolua_export138 inline orxonox::PlayerInfo* getPlayer(const std::string& guiname) const { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : nullptr; } // tolua_export 140 139 141 140 // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work … … 154 153 155 154 private: 156 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 155 // non-copyable: 156 GUIManager(const GUIManager&) = delete; 157 GUIManager& operator=(const GUIManager&) = delete; 157 158 158 159 void executeCode(const std::string& str); … … 172 173 173 174 // keyHandler functions 174 v oid buttonPressed (const KeyEvent& evt);175 v oid buttonReleased(const KeyEvent& evt);175 virtual void buttonPressed (const KeyEvent& evt) override; 176 virtual void buttonReleased(const KeyEvent& evt) override; 176 177 177 178 // mouseHandler functions 178 v oid buttonPressed (MouseButtonCode::ByEnum id);179 v oid buttonReleased(MouseButtonCode::ByEnum id);180 v oid mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);181 v oid mouseScrolled (int abs, int rel);179 virtual void buttonPressed (MouseButtonCode::ByEnum id) override; 180 virtual void buttonReleased(MouseButtonCode::ByEnum id) override; 181 virtual void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) override; 182 virtual void mouseScrolled (int abs, int rel) override; 182 183 void mouseLeft (); 183 184 184 185 // window event handler 185 virtual void windowResized(unsigned int newWidth, unsigned int newHeight) ;186 virtual void windowFocusChanged(bool bFocus) ;186 virtual void windowResized(unsigned int newWidth, unsigned int newHeight) override; 187 virtual void windowFocusChanged(bool bFocus) override; 187 188 188 189 #ifdef ORXONOX_OLD_CEGUI … … 198 199 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 199 200 CEGUI::System* guiSystem_; //!< CEGUI's main system 200 s hared_ptr<ResourceInfo>rootFileInfo_; //!< Resource information about the root script201 std::shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 201 202 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 202 203 int outputLevelCeguiLog_; //!< CEGUI's log level -
code/branches/cpp11_v3/src/libraries/core/Game.cc
r10624 r11054 36 36 37 37 #include <exception> 38 #include <boost/weak_ptr.hpp>39 38 #include <loki/ScopeGuard.h> 40 39 … … 66 65 67 66 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; 68 Game* Game::singletonPtr_s = 0;67 Game* Game::singletonPtr_s = nullptr; 69 68 70 69 //! Represents one node of the game state tree. … … 72 71 { 73 72 std::string name_; 74 weak_ptr<GameStateTreeNode> parent_;75 std::vector<s hared_ptr<GameStateTreeNode>> children_;73 std::weak_ptr<GameStateTreeNode> parent_; 74 std::vector<std::shared_ptr<GameStateTreeNode>> children_; 76 75 }; 77 76 78 77 Game::Game(const std::string& cmdLine) 79 : gameClock_( NULL)80 , core_( NULL)78 : gameClock_(nullptr) 79 , core_(nullptr) 81 80 , bChangingState_(false) 82 81 , bAbort_(false) 83 , config_( NULL)82 , config_(nullptr) 84 83 , destructionHelper_(this) 85 84 { … … 116 115 117 116 // After the core has been created, we can safely instantiate the GameStates that don't require graphics 118 for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin(); 119 it != gameStateDeclarations_s.end(); ++it) 120 { 121 if (!it->second.bGraphicsMode) 122 constructedStates_[it->second.stateName] = GameStateFactory::fabricate(it->second); 117 for (const auto& mapEntry : gameStateDeclarations_s) 118 { 119 if (!mapEntry.second.bGraphicsMode) 120 constructedStates_[mapEntry.second.stateName] = GameStateFactory::fabricate(mapEntry.second); 123 121 } 124 122 125 123 // The empty root state is ALWAYS loaded! 126 this->rootStateNode_ = s hared_ptr<GameStateTreeNode>(new GameStateTreeNode());124 this->rootStateNode_ = std::shared_ptr<GameStateTreeNode>(std::make_shared<GameStateTreeNode>()); 127 125 this->rootStateNode_->name_ = "emptyRootGameState"; 128 126 this->loadedTopStateNode_ = this->rootStateNode_; … … 137 135 138 136 assert(loadedStates_.size() <= 1); // Just empty root GameState 139 // Destroy all GameStates (s hared_ptrs take care of actual destruction)137 // Destroy all GameStates (std::shared_ptrs take care of actual destruction) 140 138 constructedStates_.clear(); 141 139 … … 235 233 while (this->requestedStateNodes_.size() > 0) 236 234 { 237 s hared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();235 std::shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front(); 238 236 assert(this->loadedTopStateNode_); 239 237 if (!this->loadedTopStateNode_->parent_.expired() && requestedStateNode == this->loadedTopStateNode_->parent_.lock()) … … 263 261 { 264 262 // Note: The first element is the empty root state, which doesn't need ticking 265 for (GameStateVector::const_iterator it = this->loadedStates_.begin() + 1; 266 it != this->loadedStates_.end(); ++it) 263 for (const std::shared_ptr<GameState>& state : this->loadedStates_) 267 264 { 268 265 try … … 270 267 // Add tick time for most of the states 271 268 uint64_t timeBeforeTick = 0; 272 if ( (*it)->getInfo().bIgnoreTickTime)269 if (state->getInfo().bIgnoreTickTime) 273 270 timeBeforeTick = this->gameClock_->getRealMicroseconds(); 274 (*it)->update(*this->gameClock_);275 if ( (*it)->getInfo().bIgnoreTickTime)271 state->update(*this->gameClock_); 272 if (state->getInfo().bIgnoreTickTime) 276 273 this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick)); 277 274 } 278 275 catch (...) 279 276 { 280 orxout(user_error) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << endl;277 orxout(user_error) << "An exception occurred while updating '" << state->getName() << "': " << Exception::handleMessage() << endl; 281 278 orxout(user_error) << "This should really never happen!" << endl; 282 279 orxout(user_error) << "Unloading all GameStates depending on the one that crashed." << endl; 283 s hared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_;284 while (current->name_ != (*it)->getName() && current)280 std::shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_; 281 while (current->name_ != state->getName() && current) 285 282 current = current->parent_.lock(); 286 283 if (current && current->parent_.lock()) … … 372 369 } 373 370 374 s hared_ptr<GameStateTreeNode> lastRequestedNode;371 std::shared_ptr<GameStateTreeNode> lastRequestedNode; 375 372 if (this->requestedStateNodes_.empty()) 376 373 lastRequestedNode = this->loadedTopStateNode_; … … 384 381 385 382 // Check children first 386 std::vector<s hared_ptr<GameStateTreeNode>> requestedNodes;383 std::vector<std::shared_ptr<GameStateTreeNode>> requestedNodes; 387 384 for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i) 388 385 { … … 397 394 { 398 395 // Check parent and all its grand parents 399 s hared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;400 while (currentNode != NULL)396 std::shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode; 397 while (currentNode != nullptr) 401 398 { 402 399 if (currentNode->name_ == name) … … 405 402 requestedNodes.push_back(currentNode); 406 403 } 407 if (currentNode == NULL)404 if (currentNode == nullptr) 408 405 requestedNodes.clear(); 409 406 } … … 424 421 void Game::popState() 425 422 { 426 s hared_ptr<GameStateTreeNode> lastRequestedNode;423 std::shared_ptr<GameStateTreeNode> lastRequestedNode; 427 424 if (this->requestedStateNodes_.empty()) 428 425 lastRequestedNode = this->loadedTopStateNode_; … … 435 432 } 436 433 437 s hared_ptr<GameState> Game::getState(const std::string& name)434 std::shared_ptr<GameState> Game::getState(const std::string& name) 438 435 { 439 436 GameStateMap::const_iterator it = constructedStates_.find(name); … … 447 444 else 448 445 orxout(internal_error) << "Could not find GameState '" << name << "'." << endl; 449 return s hared_ptr<GameState>();446 return std::shared_ptr<GameState>(); 450 447 } 451 448 } … … 454 451 { 455 452 // Split string into pieces of the form whitespacesText 456 std::vector<std::pair<std::string, int> 453 std::vector<std::pair<std::string, int>> stateStrings; 457 454 size_t pos = 0; 458 455 size_t startPos = 0; … … 465 462 while (pos < str.size() && str[pos] != ' ') 466 463 ++pos; 467 stateStrings. push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation));464 stateStrings.emplace_back(str.substr(startPos, pos - startPos), indentation); 468 465 } 469 466 if (stateStrings.empty()) 470 467 ThrowException(GameState, "Emtpy GameState hierarchy provided, terminating."); 471 468 // Add element with large identation to detect the last with just an iterator 472 stateStrings. push_back(std::make_pair(std::string(), -1));469 stateStrings.emplace_back(std::string(), -1); 473 470 474 471 // Parse elements recursively 475 std::vector<std::pair<std::string, int> 472 std::vector<std::pair<std::string, int>>::const_iterator begin = stateStrings.begin(); 476 473 parseStates(begin, this->rootStateNode_); 477 474 } … … 479 476 /*** Internal ***/ 480 477 481 void Game::parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it,shared_ptr<GameStateTreeNode> currentNode)478 void Game::parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, std::shared_ptr<GameStateTreeNode> currentNode) 482 479 { 483 480 SubString tokens(it->first, ","); 484 std::vector<std::pair<std::string, int> 481 std::vector<std::pair<std::string, int>>::const_iterator startIt = it; 485 482 486 483 for (unsigned int i = 0; i < tokens.size(); ++i) … … 491 488 if (tokens[i] == this->rootStateNode_->name_) 492 489 ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy..."); 493 s hared_ptr<GameStateTreeNode> node(new GameStateTreeNode());490 std::shared_ptr<GameStateTreeNode> node(std::make_shared<GameStateTreeNode>()); 494 491 node->name_ = tokens[i]; 495 492 node->parent_ = currentNode; … … 521 518 522 519 // Construct all the GameStates that require graphics 523 for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin(); 524 it != gameStateDeclarations_s.end(); ++it) 525 { 526 if (it->second.bGraphicsMode) 520 for (const auto& mapEntry : gameStateDeclarations_s) 521 { 522 if (mapEntry.second.bGraphicsMode) 527 523 { 528 524 // Game state loading failure is serious --> don't catch 529 s hared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);525 std::shared_ptr<GameState> gameState = GameStateFactory::fabricate(mapEntry.second); 530 526 if (!constructedStates_.insert(std::make_pair( 531 it->second.stateName, gameState)).second)527 mapEntry.second.stateName, gameState)).second) 532 528 assert(false); // GameState was already created! 533 529 } … … 582 578 graphicsUnloader.Dismiss(); 583 579 584 s hared_ptr<GameState> state = this->getState(name);580 std::shared_ptr<GameState> state = this->getState(name); 585 581 state->activateInternal(); 586 582 if (!this->loadedStates_.empty()) … … 599 595 try 600 596 { 601 s hared_ptr<GameState> state = this->getState(name);597 std::shared_ptr<GameState> state = this->getState(name); 602 598 state->activity_.topState = false; 603 599 this->loadedStates_.pop_back(); … … 613 609 // Check if graphics is still required 614 610 bool graphicsRequired = false; 615 for ( unsigned i = 0; i < loadedStates_.size(); ++i)616 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;611 for (const std::shared_ptr<GameState>& state : loadedStates_) 612 graphicsRequired |= state->getInfo().bGraphicsMode; 617 613 if (!graphicsRequired) 618 614 this->unloadGraphics(!this->bAbort_); // if abort is false, that means the game is still running while unloading graphics. in this case we load a graphics manager without renderer (to keep all necessary ogre instances alive) … … 620 616 } 621 617 622 /*static*/ std::map<std::string, s hared_ptr<Game::GameStateFactory>>& Game::GameStateFactory::getFactories()623 { 624 static std::map<std::string, s hared_ptr<GameStateFactory>> factories;618 /*static*/ std::map<std::string, std::shared_ptr<Game::GameStateFactory>>& Game::GameStateFactory::getFactories() 619 { 620 static std::map<std::string, std::shared_ptr<GameStateFactory>> factories; 625 621 return factories; 626 622 } 627 623 628 /*static*/ s hared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info)629 { 630 std::map<std::string, s hared_ptr<Game::GameStateFactory>>::const_iterator it = getFactories().find(info.className);624 /*static*/ std::shared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info) 625 { 626 std::map<std::string, std::shared_ptr<Game::GameStateFactory>>::const_iterator it = getFactories().find(info.className); 631 627 assert(it != getFactories().end()); 632 628 return it->second->fabricateInternal(info); -
code/branches/cpp11_v3/src/libraries/core/Game.h
r10624 r11054 44 44 #include <string> 45 45 #include <vector> 46 #include < boost/shared_ptr.hpp>46 #include <memory> 47 47 #include <boost/preprocessor/cat.hpp> 48 48 … … 84 84 { // tolua_export 85 85 friend class Singleton<Game>; 86 typedef std::vector<s hared_ptr<GameState>> GameStateVector;87 typedef std::map<std::string, s hared_ptr<GameState>> GameStateMap;88 typedef s hared_ptr<GameStateTreeNode> GameStateTreeNodePtr;86 typedef std::vector<std::shared_ptr<GameState>> GameStateVector; 87 typedef std::map<std::string, std::shared_ptr<GameState>> GameStateMap; 88 typedef std::shared_ptr<GameStateTreeNode> GameStateTreeNodePtr; 89 89 90 90 public: … … 92 92 93 93 //! Leave empty and use cleanup() instead 94 ~Game() {}94 ~Game() = default; 95 95 /// Destructor that also executes when object fails to construct 96 96 void destroy(); 97 97 98 98 void setStateHierarchy(const std::string& str); 99 s hared_ptr<GameState> getState(const std::string& name);99 std::shared_ptr<GameState> getState(const std::string& name); 100 100 101 101 void run(); … … 122 122 { 123 123 public: 124 virtual ~GameStateFactory() { }125 static s hared_ptr<GameState> fabricate(const GameStateInfo& info);124 virtual ~GameStateFactory() = default; 125 static std::shared_ptr<GameState> fabricate(const GameStateInfo& info); 126 126 template <class T> 127 127 static void createFactory(const std::string& className) 128 128 { getFactories()[className].reset(new TemplateGameStateFactory<T>()); } 129 129 130 virtual s hared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0;131 static std::map<std::string, s hared_ptr<GameStateFactory>>& getFactories();130 virtual std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0; 131 static std::map<std::string, std::shared_ptr<GameStateFactory>>& getFactories(); 132 132 }; 133 133 template <class T> … … 135 135 { 136 136 public: 137 shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)138 { return s hared_ptr<GameState>(new T(info)); }137 virtual std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) override 138 { return std::shared_ptr<GameState>(std::make_shared<T>(info)); } 139 139 }; 140 140 … … 145 145 }; 146 146 147 Game(Game&); // don't mess with singletons 147 // non-copyable: 148 Game(const Game&) = delete; 149 Game& operator=(const Game&) = delete; 148 150 149 151 void loadGraphics(); 150 152 void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); 151 153 152 void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it,shared_ptr<GameStateTreeNode> currentNode);154 void parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, std::shared_ptr<GameStateTreeNode> currentNode); 153 155 bool checkState(const std::string& name) const; 154 156 void loadState(const std::string& name); -
code/branches/cpp11_v3/src/libraries/core/GameMode.h
r7401 r11054 63 63 64 64 private: 65 GameMode(); 66 GameMode(const GameMode& inst); 67 ~GameMode(); 65 // static class, no instances allowed: 66 GameMode() = delete; 67 GameMode(const GameMode&) = delete; 68 GameMode& operator=(const GameMode&) = delete; 69 ~GameMode() = delete; 68 70 69 71 /// Checks if we're in control of the game (either standalone or server). -
code/branches/cpp11_v3/src/libraries/core/GraphicsManager.cc
r10624 r11054 34 34 #include <sstream> 35 35 #include <boost/filesystem.hpp> 36 #include <boost/shared_array.hpp>37 36 38 37 #include <OgreFrameListener.h> … … 83 82 { 84 83 public: 85 v oid windowResized (Ogre::RenderWindow* rw)84 virtual void windowResized (Ogre::RenderWindow* rw) override 86 85 { orxonox::WindowEventListener::resizeWindow(rw->getWidth(), rw->getHeight()); } 87 v oid windowFocusChange (Ogre::RenderWindow* rw)86 virtual void windowFocusChange (Ogre::RenderWindow* rw) override 88 87 { orxonox::WindowEventListener::changeWindowFocus(rw->isActive()); } 89 v oid windowClosed (Ogre::RenderWindow* rw)88 virtual void windowClosed (Ogre::RenderWindow* rw) override 90 89 { orxonox::Game::getInstance().stop(); } 91 v oid windowMoved (Ogre::RenderWindow* rw)90 virtual void windowMoved (Ogre::RenderWindow* rw) override 92 91 { orxonox::WindowEventListener::moveWindow(); } 93 92 }; 94 93 95 GraphicsManager* GraphicsManager::singletonPtr_s = 0;94 GraphicsManager* GraphicsManager::singletonPtr_s = nullptr; 96 95 97 96 RegisterAbstractClass(GraphicsManager).inheritsFrom<Configurable>(); … … 99 98 GraphicsManager::GraphicsManager(bool bLoadRenderer) 100 99 : ogreWindowEventListener_(new OgreWindowEventListener()) 101 , renderWindow_( 0)102 , viewport_( 0)100 , renderWindow_(nullptr) 101 , viewport_(nullptr) 103 102 , lastFrameStartTime_(0.0f) 104 103 , lastFrameEndTime_(0.0f) … … 178 177 void GraphicsManager::upgradeToGraphics() 179 178 { 180 if (renderWindow_ != NULL)179 if (renderWindow_ != nullptr) 181 180 return; 182 181 … … 304 303 // But in our case we only have one viewport for now anyway, therefore 305 304 // no ScopeGuards or anything to handle exceptions. 306 this->viewport_ = this->renderWindow_->addViewport( 0, 0);305 this->viewport_ = this->renderWindow_->addViewport(nullptr, 0); 307 306 308 307 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(Ogre::MIP_UNLIMITED); … … 312 311 HWND hwnd; 313 312 this->renderWindow_->getCustomAttribute("WINDOW", (void*)&hwnd); 314 LONG iconID = (LONG)LoadIcon(GetModuleHandle( 0), MAKEINTRESOURCE(101));313 LONG iconID = (LONG)LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(101)); 315 314 SetClassLong(hwnd, GCL_HICON, iconID); 316 315 #endif … … 390 389 GUIManager::getInstance().setCamera(camera); 391 390 392 for ( ObjectList<ViewportEventListener>::iterator it = ObjectList<ViewportEventListener>::begin(); it != ObjectList<ViewportEventListener>::end(); ++it)393 it->cameraChanged(this->viewport_, oldCamera);391 for (ViewportEventListener* listener : ObjectList<ViewportEventListener>()) 392 listener->cameraChanged(this->viewport_, oldCamera); 394 393 } 395 394 -
code/branches/cpp11_v3/src/libraries/core/GraphicsManager.h
r10624 r11054 47 47 #include <cassert> 48 48 #include <string> 49 #include <memory> 50 49 51 #include <OgreLog.h> 50 #include <boost/shared_ptr.hpp>51 52 52 53 #include "util/DestructionHelper.h" … … 70 71 71 72 //! Leave empty and use cleanup() instead 72 ~GraphicsManager() {}73 ~GraphicsManager() = default; 73 74 /// Destructor that also executes when object fails to construct 74 75 void destroy(); … … 96 97 void loadDebugOverlay(); 97 98 void unloadDebugOverlay(); 98 bool rendererLoaded() const { return renderWindow_ != NULL; }99 bool rendererLoaded() const { return renderWindow_ != nullptr; } 99 100 100 101 void setCamera(Ogre::Camera* camera); 101 102 102 103 private: 103 GraphicsManager(GraphicsManager&); // don't mess with singletons 104 // non-copyable: 105 GraphicsManager(const GraphicsManager&) = delete; 106 GraphicsManager& operator=(const GraphicsManager&) = delete; 104 107 105 108 // OGRE initialisation … … 110 113 // event from Ogre::LogListener 111 114 #if OGRE_VERSION >= 0x010800 112 v oid messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName, bool& skipThisMessage);115 virtual void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName, bool& skipThisMessage) override; 113 116 #else 114 v oid messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName);117 virtual void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName) override; 115 118 #endif 116 119 … … 130 133 131 134 // XML files for the resources and the debug overlay 132 s hared_ptr<XMLFile> resources_;//!< XML with resource locations133 s hared_ptr<XMLFile> extResources_;//!< XML with resource locations in the external path (only for dev runs)134 s hared_ptr<XMLFile> debugOverlay_;//!< XML with various debug overlays135 std::shared_ptr<XMLFile> resources_; //!< XML with resource locations 136 std::shared_ptr<XMLFile> extResources_; //!< XML with resource locations in the external path (only for dev runs) 137 std::shared_ptr<XMLFile> debugOverlay_; //!< XML with various debug overlays 135 138 136 139 // config values -
code/branches/cpp11_v3/src/libraries/core/Language.cc
r10624 r11054 88 88 // ############################### 89 89 90 Language* Language::singletonPtr_s = 0;90 Language* Language::singletonPtr_s = nullptr; 91 91 92 92 /** … … 107 107 Language::~Language() 108 108 { 109 for ( std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)110 delete ( it->second);109 for (const auto& mapEntry : this->languageEntries_) 110 delete (mapEntry.second); 111 111 } 112 112 … … 319 319 320 320 // Iterate through the list an write the lines into the file 321 for ( std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)322 { 323 file << it->second->getLabel() << '=' << it->second->getDefault() << endl;321 for (const auto& mapEntry : this->languageEntries_) 322 { 323 file << mapEntry.second->getLabel() << '=' << mapEntry.second->getDefault() << endl; 324 324 } 325 325 -
code/branches/cpp11_v3/src/libraries/core/Language.h
r10624 r11054 171 171 172 172 private: 173 Language(const Language&); 173 // non-copyable: 174 Language(const Language&) = delete; 175 Language& operator=(const Language&) = delete; 174 176 175 177 void readDefaultLanguageFile(); -
code/branches/cpp11_v3/src/libraries/core/Loader.cc
r10624 r11054 31 31 #include <sstream> 32 32 #include <tinyxml/ticpp.h> 33 #include <boost/scoped_ptr.hpp>34 33 #include <boost/filesystem.hpp> 35 34 #include <boost/filesystem/fstream.hpp> … … 48 47 namespace orxonox 49 48 { 50 Loader* Loader::singletonPtr_s = 0;49 Loader* Loader::singletonPtr_s = nullptr; 51 50 52 51 /** … … 73 72 std::string xmlInput; 74 73 75 s hared_ptr<std::vector<std::vector<std::pair<std::string, size_t> > > > lineTrace(new std::vector<std::vector<std::pair<std::string, size_t> >>());74 std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> lineTrace(std::make_shared<std::vector<std::vector<std::pair<std::string, size_t>>>>()); 76 75 lineTrace->reserve(1000); //arbitrary number 77 76 … … 80 79 { 81 80 // Use the LuaState to replace the XML tags (calls our function) 82 scoped_ptr<LuaState> luaState(new LuaState());81 const std::unique_ptr<LuaState> luaState(new LuaState()); 83 82 luaState->setTraceMap(lineTrace); 84 83 luaState->setIncludeParser(&Loader::replaceLuaTags); … … 88 87 else 89 88 { 90 s hared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename());91 if (info == NULL)89 std::shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename()); 90 if (info == nullptr) 92 91 { 93 92 orxout(user_error, context::loader) << "Could not find XML file '" << file->getFilename() << "'." << endl; … … 163 162 if (line <= lineTrace->size()) 164 163 { 165 std::vector<std::pair<std::string, size_t> 164 std::vector<std::pair<std::string, size_t>> linesources = lineTrace->at(line - 1); 166 165 std::ostringstream message; 167 166 message << "Possible sources of error:" << endl; 168 for ( std::vector<std::pair<std::string, size_t> >::iterator it = linesources.begin(); it != linesources.end(); ++it)167 for (const std::pair<std::string, size_t>& pair : linesources) 169 168 { 170 message << it->first << ", Line " << it->second << endl;169 message << pair.first << ", Line " << pair.second << endl; 171 170 } 172 171 orxout(user_error, context::loader) << message.str() << endl; … … 208 207 if (!file) 209 208 return; 210 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject> ::begin(); it; )209 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>().begin(); it; ) 211 210 { 212 211 if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier())) … … 262 261 { 263 262 bool expectedValue = true; 264 for ( std::map<size_t, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)265 { 266 if ( it->second == expectedValue)263 for (const auto& mapEntry : luaTags) 264 { 265 if (mapEntry.second == expectedValue) 267 266 expectedValue = !expectedValue; 268 267 else -
code/branches/cpp11_v3/src/libraries/core/Loader.h
r10624 r11054 67 67 static bool getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags); 68 68 69 std::vector<std::pair<const XMLFile*, ClassTreeMask> 69 std::vector<std::pair<const XMLFile*, ClassTreeMask>> files_; 70 70 71 71 static Loader* singletonPtr_s; -
code/branches/cpp11_v3/src/libraries/core/LuaState.cc
r10265 r11054 48 48 LuaState::LuaState() 49 49 : bIsRunning_(false) 50 , includeParseFunction_( NULL)50 , includeParseFunction_(nullptr) 51 51 { 52 52 // Create new lua state and configure it … … 79 79 } 80 80 81 s hared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename)81 std::shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename) 82 82 { 83 83 // Look in the current directory first 84 s hared_ptr<ResourceInfo> sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename);84 std::shared_ptr<ResourceInfo> sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename); 85 85 // Continue search in root directories 86 if (sourceInfo == NULL&& !sourceFileInfo_->path.empty())86 if (sourceInfo == nullptr && !sourceFileInfo_->path.empty()) 87 87 sourceInfo = Resource::getInfo(filename); 88 88 return sourceInfo; … … 91 91 bool LuaState::includeFile(const std::string& filename) 92 92 { 93 s hared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);94 if (sourceInfo != NULL)93 std::shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename); 94 if (sourceInfo != nullptr) 95 95 return this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo); 96 96 else … … 101 101 } 102 102 103 bool LuaState::includeString(const std::string& code, const s hared_ptr<ResourceInfo>& sourceFileInfo)103 bool LuaState::includeString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo) 104 104 { 105 105 // Parse string with provided include parser (otherwise don't preparse at all) 106 106 std::string luaInput; 107 if (includeParseFunction_ != NULL)107 if (includeParseFunction_ != nullptr) 108 108 luaInput = (*includeParseFunction_)(code); 109 109 else 110 110 luaInput = code; 111 111 112 if (sourceFileInfo != NULL)112 if (sourceFileInfo != nullptr) 113 113 { 114 114 // Also fill a map with the actual source code. This is just for the include* commands … … 119 119 bool returnValue = this->doString(luaInput, sourceFileInfo); 120 120 121 if (sourceFileInfo != NULL)121 if (sourceFileInfo != nullptr) 122 122 { 123 123 // Delete source code entry 124 if (sourceFileInfo != NULL)124 if (sourceFileInfo != nullptr) 125 125 this->sourceCodeMap_.erase(sourceFileInfo->filename); 126 126 } … … 131 131 bool LuaState::doFile(const std::string& filename) 132 132 { 133 s hared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);134 if (sourceInfo != NULL)133 std::shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename); 134 if (sourceInfo != nullptr) 135 135 return this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo); 136 136 else … … 141 141 } 142 142 143 bool LuaState::doString(const std::string& code, const s hared_ptr<ResourceInfo>& sourceFileInfo)143 bool LuaState::doString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo) 144 144 { 145 145 // Save the old source file info 146 s hared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_;146 std::shared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_; 147 147 // Only override if sourceFileInfo provides useful information 148 if (sourceFileInfo != NULL)148 if (sourceFileInfo != nullptr) 149 149 sourceFileInfo_ = sourceFileInfo; 150 150 151 151 std::string chunkname; 152 if (sourceFileInfo != NULL)152 if (sourceFileInfo != nullptr) 153 153 { 154 154 // Provide lua_load with the filename for debug purposes … … 245 245 //Note: due to newlines etc., it's possible that one line consists of parts of 246 246 // multiple, different files 247 std::vector<std::vector<std::pair<std::string, size_t> >>::reverse_iterator it = lineTrace_->rbegin();247 std::vector<std::vector<std::pair<std::string, size_t>>>::reverse_iterator it = lineTrace_->rbegin(); 248 248 std::pair<std::string, size_t> temppair = std::make_pair(filename, line); 249 249 //Avoid duplicate entries. This could happen if there were lua blocks on the same line … … 259 259 { 260 260 //Add the new line to the trace map 261 lineTrace_-> push_back(std::vector<std::pair<std::string, size_t> >());261 lineTrace_->emplace_back(); 262 262 //Add the source of the line at the end 263 lineTrace_->rbegin()-> push_back(std::make_pair(filename, line + i));263 lineTrace_->rbegin()->emplace_back(filename, line + i); 264 264 } 265 265 } … … 285 285 bool LuaState::fileExists(const std::string& filename) 286 286 { 287 s hared_ptr<ResourceInfo> info = this->getFileInfo(filename);288 if (info == NULL)287 std::shared_ptr<ResourceInfo> info = this->getFileInfo(filename); 288 if (info == nullptr) 289 289 return false; 290 290 else … … 300 300 if (it != this->sourceCodeMap_.end()) 301 301 return it->second; 302 s hared_ptr<ResourceInfo> info = Resource::getInfo(filename);303 if (info == NULL)302 std::shared_ptr<ResourceInfo> info = Resource::getInfo(filename); 303 if (info == nullptr) 304 304 return ""; 305 305 else … … 326 326 /*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name) 327 327 { 328 for ( ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)329 { 330 if ( it->first == name || it->second == function)328 for (const auto& mapEntry : getToluaInterfaces()) 329 { 330 if (mapEntry.first == name || mapEntry.second == function) 331 331 { 332 332 orxout(internal_warning, context::lua) << "Trying to add a Tolua interface with the same name or function." << endl; … … 337 337 338 338 // Open interface in all LuaStates 339 for ( std::vector<LuaState*>::const_iterator it = getInstances().begin(); it != getInstances().end(); ++it)340 (*function)( (*it)->luaState_);339 for (LuaState* state : getInstances()) 340 (*function)(state->luaState_); 341 341 342 342 // Return dummy bool … … 354 354 355 355 // Close interface in all LuaStates 356 for ( std::vector<LuaState*>::const_iterator itState = getInstances().begin(); itState != getInstances().end(); ++itState)357 { 358 lua_pushnil( (*itState)->luaState_);359 lua_setglobal( (*itState)->luaState_, it->first.c_str());356 for (LuaState* state : getInstances()) 357 { 358 lua_pushnil(state->luaState_); 359 lua_setglobal(state->luaState_, it->first.c_str()); 360 360 } 361 361 … … 369 369 /*static*/ void LuaState::openToluaInterfaces(lua_State* state) 370 370 { 371 for ( ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)372 ( *it->second)(state);371 for (const auto& mapEntry : getToluaInterfaces()) 372 (mapEntry.second)(state); 373 373 } 374 374 375 375 /*static*/ void LuaState::closeToluaInterfaces(lua_State* state) 376 376 { 377 for ( ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)377 for (const auto& mapEntry : getToluaInterfaces()) 378 378 { 379 379 lua_pushnil(state); 380 lua_setglobal(state, it->first.c_str());380 lua_setglobal(state, mapEntry.first.c_str()); 381 381 } 382 382 } -
code/branches/cpp11_v3/src/libraries/core/LuaState.h
r10265 r11054 47 47 #include <string> 48 48 #include <vector> 49 #include < boost/shared_ptr.hpp>49 #include <memory> 50 50 51 51 #include "util/Output.h" … … 79 79 80 80 bool doFile(const std::string& filename); // tolua_export 81 bool doString(const std::string& code, const s hared_ptr<ResourceInfo>& sourceFileInfo =shared_ptr<ResourceInfo>());81 bool doString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo = std::shared_ptr<ResourceInfo>()); 82 82 83 83 bool includeFile(const std::string& filename); // tolua_export 84 bool includeString(const std::string& code, const s hared_ptr<ResourceInfo>& sourceFileInfo =shared_ptr<ResourceInfo>());84 bool includeString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo = std::shared_ptr<ResourceInfo>()); 85 85 86 86 void luaPrint(const std::string& str); // tolua_export … … 94 94 void clearOutput() { output_.clear(); } // tolua_export 95 95 96 void setTraceMap(s hared_ptr<std::vector<std::vector<std::pair<std::string, size_t> > >> map)97 { map-> push_back(std::vector<std::pair<std::string, size_t> >()); lineTrace_ = map; }96 void setTraceMap(std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> map) 97 { map->emplace_back(); lineTrace_ = map; } 98 98 99 99 void setIncludeParser(std::string (*function)(const std::string&)) { includeParseFunction_ = function; } 100 100 lua_State* getInternalLuaState() { return luaState_; } 101 101 102 void setDefaultResourceInfo(const s hared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }103 const s hared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }102 void setDefaultResourceInfo(const std::shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; } 103 const std::shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; } 104 104 105 105 LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export … … 115 115 116 116 private: 117 s hared_ptr<ResourceInfo> getFileInfo(const std::string& filename);118 s hared_ptr<std::vector<std::vector<std::pair<std::string, size_t> > >> lineTrace_;117 std::shared_ptr<ResourceInfo> getFileInfo(const std::string& filename); 118 std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> lineTrace_; 119 119 120 120 std::stringstream output_; 121 121 lua_State* luaState_; 122 122 bool bIsRunning_; 123 s hared_ptr<ResourceInfo> sourceFileInfo_;123 std::shared_ptr<ResourceInfo> sourceFileInfo_; 124 124 std::map<std::string, std::string> sourceCodeMap_; 125 125 std::string (*includeParseFunction_)(const std::string&); -
code/branches/cpp11_v3/src/libraries/core/Namespace.cc
r10624 r11054 53 53 { 54 54 if (this->bRoot_) 55 for ( std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)56 delete (*it);55 for (NamespaceNode* node : this->representingNamespaces_) 56 delete node; 57 57 } 58 58 … … 80 80 for (unsigned int i = 0; i < tokens.size(); i++) 81 81 { 82 for ( std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)82 for (NamespaceNode* node : this->getNamespace()->representingNamespaces_) 83 83 { 84 std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);84 std::set<NamespaceNode*> temp = node->getNodeRelative(tokens[i]); 85 85 this->representingNamespaces_.insert(temp.begin(), temp.end()); 86 86 } … … 93 93 if (this->bAutogeneratedFileRootNamespace_) 94 94 { 95 for ( std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)95 for (NamespaceNode* node : this->representingNamespaces_) 96 96 { 97 (*it)->setRoot(true);98 (*it)->setHidden(true);97 node->setRoot(true); 98 node->setHidden(true); 99 99 } 100 100 } … … 109 109 const BaseObject* Namespace::saveObjects(unsigned int index) const 110 110 { 111 return 0; // todo111 return nullptr; // todo 112 112 } 113 113 114 114 bool Namespace::includes(const Namespace* ns) const 115 115 { 116 for ( std::set<NamespaceNode*>::const_iterator it1 = this->representingNamespaces_.begin(); it1 != this->representingNamespaces_.end(); ++it1)116 for (NamespaceNode* node1 : this->representingNamespaces_) 117 117 { 118 for ( std::set<NamespaceNode*>::const_iterator it2 = ns->representingNamespaces_.begin(); it2 != ns->representingNamespaces_.end(); ++it2)118 for (NamespaceNode* node2 : ns->representingNamespaces_) 119 119 { 120 if ( (*it1)->includes(*it2))120 if (node1->includes(node2)) 121 121 { 122 122 if (this->operator_ == "or") … … 149 149 150 150 int i = 0; 151 for ( std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)151 for (NamespaceNode* node : this->representingNamespaces_) 152 152 { 153 153 if (i > 0) 154 154 output += " / "; 155 155 156 output += (*it)->toString(); 156 output += node->toString(); 157 i++; 157 158 } 158 159 … … 165 166 166 167 int i = 0; 167 for ( std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)168 for (NamespaceNode* node : this->representingNamespaces_) 168 169 { 169 170 if (i > 0) 170 171 output += '\n'; 171 172 172 output += (*it)->toString(indentation); 173 output += node->toString(indentation); 174 i++; 173 175 } 174 176 -
code/branches/cpp11_v3/src/libraries/core/Namespace.h
r9667 r11054 50 50 virtual ~Namespace(); 51 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 53 53 54 54 void loadObjects(BaseObject* object); -
code/branches/cpp11_v3/src/libraries/core/NamespaceNode.cc
r8858 r11054 103 103 bool bFoundMatchingNamespace = false; 104 104 105 for ( std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)105 for (const auto& mapEntry : this->subnodes_) 106 106 { 107 if ( it->first.find(firstPart) == (it->first.size() - firstPart.size()))107 if (mapEntry.first.find(firstPart) == (mapEntry.first.size() - firstPart.size())) 108 108 { 109 std::set<NamespaceNode*> temp2 = it->second->getNodeRelative(secondPart);109 std::set<NamespaceNode*> temp2 = mapEntry.second->getNodeRelative(secondPart); 110 110 nodes.insert(temp2.begin(), temp2.end()); 111 111 bFoundMatchingNamespace = true; … … 132 132 else 133 133 { 134 for ( std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)135 if ( it->second->includes(ns))134 for (const auto& mapEntry : this->subnodes_) 135 if (mapEntry.second->includes(ns)) 136 136 return true; 137 137 } … … 149 149 150 150 int i = 0; 151 for ( std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); i++, ++it)151 for (const auto& mapEntry : this->subnodes_) 152 152 { 153 153 if (i > 0) 154 154 output += ", "; 155 155 156 output += it->second->toString(); 156 output += mapEntry.second->toString(); 157 i++; 157 158 } 158 159 … … 167 168 std::string output = (indentation + this->name_ + '\n'); 168 169 169 for ( std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)170 output += it->second->toString(indentation + " ");170 for (const auto& mapEntry : this->subnodes_) 171 output += mapEntry.second->toString(indentation + " "); 171 172 172 173 return output; -
code/branches/cpp11_v3/src/libraries/core/NamespaceNode.h
r7401 r11054 46 46 { 47 47 public: 48 NamespaceNode(const std::string& name, NamespaceNode* parent = 0);48 NamespaceNode(const std::string& name, NamespaceNode* parent = nullptr); 49 49 ~NamespaceNode(); 50 50 -
code/branches/cpp11_v3/src/libraries/core/Resource.cc
r9675 r11054 58 58 DataStreamListPtr resources(new Ogre::DataStreamList()); 59 59 const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); 60 for ( Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)60 for (const std::string& group : groups) 61 61 { 62 DataStreamListPtr temp = Ogre::ResourceGroupManager::getSingleton().openResources(pattern, *it);62 DataStreamListPtr temp = Ogre::ResourceGroupManager::getSingleton().openResources(pattern, group); 63 63 resources->insert(resources->end(), temp->begin(), temp->end()); 64 64 } … … 79 79 } 80 80 81 s hared_ptr<ResourceInfo> Resource::getInfo(const std::string& name)81 std::shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name) 82 82 { 83 83 std::string group; … … 88 88 catch (const Ogre::Exception&) 89 89 { 90 return s hared_ptr<ResourceInfo>();90 return std::shared_ptr<ResourceInfo>(); 91 91 } 92 92 Ogre::FileInfoListPtr infos = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(group, name); … … 95 95 if (it->filename == name) 96 96 { 97 s hared_ptr<ResourceInfo> ptr(new ResourceInfo());97 std::shared_ptr<ResourceInfo> ptr(std::make_shared<ResourceInfo>()); 98 98 ptr->filename = name; 99 99 ptr->path = it->path; … … 102 102 ptr->size = it->uncompressedSize; 103 103 #if OGRE_VERSION >= 0x010800 104 if (dynamic_cast<const Ogre::FileSystemArchive*>(it->archive) != NULL)104 if (dynamic_cast<const Ogre::FileSystemArchive*>(it->archive) != nullptr) 105 105 #else 106 if (dynamic_cast<Ogre::FileSystemArchive*>(it->archive) != NULL)106 if (dynamic_cast<Ogre::FileSystemArchive*>(it->archive) != nullptr) 107 107 #endif 108 108 { … … 114 114 } 115 115 } 116 return s hared_ptr<ResourceInfo>();116 return std::shared_ptr<ResourceInfo>(); 117 117 } 118 118 … … 121 121 StringVectorPtr resourceNames(new Ogre::StringVector()); 122 122 const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); 123 for ( Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)123 for (const std::string& group : groups) 124 124 { 125 StringVectorPtr temp = Ogre::ResourceGroupManager::getSingleton().findResourceNames( *it, pattern);125 StringVectorPtr temp = Ogre::ResourceGroupManager::getSingleton().findResourceNames(group, pattern); 126 126 resourceNames->insert(resourceNames->end(), temp->begin(), temp->end()); 127 127 } -
code/branches/cpp11_v3/src/libraries/core/Resource.h
r8351 r11054 42 42 #include "CorePrereqs.h" 43 43 44 #include <boost/shared_ptr.hpp> 44 #include <memory> 45 45 46 #include <OgreDataStream.h> 46 47 #include <OgreStringVector.h> … … 93 94 94 95 //! Similar to open(string, string, bool), but with a fileInfo struct 95 static DataStreamPtr open(s hared_ptr<ResourceInfo> fileInfo)96 static DataStreamPtr open(std::shared_ptr<ResourceInfo> fileInfo) 96 97 { 97 98 return open(fileInfo->filename); … … 125 126 Fully qualified name of the file to test for 126 127 */ 127 static s hared_ptr<ResourceInfo> getInfo(const std::string& name);128 static std::shared_ptr<ResourceInfo> getInfo(const std::string& name); 128 129 129 130 /** … … 140 141 141 142 private: 142 Resource(); 143 ~Resource(); 144 Resource(const Resource& instance); 143 // static class, no instances allowed: 144 Resource() = delete; 145 Resource(const Resource&) = delete; 146 Resource& operator=(const Resource&) = delete; 147 ~Resource() = delete; 145 148 }; 146 149 } -
code/branches/cpp11_v3/src/libraries/core/Template.cc
r9667 r11054 49 49 this->bLoadDefaults_ = true; 50 50 this->bIsReturningXMLElement_ = false; 51 this->baseclassIdentifier_ = 0;51 this->baseclassIdentifier_ = nullptr; 52 52 } 53 53 … … 176 176 { 177 177 orxout(internal_warning, context::templates) << "Template with name " << name << " doesn't exist." << endl; 178 return 0;178 return nullptr; 179 179 } 180 180 } -
code/branches/cpp11_v3/src/libraries/core/Template.h
r9667 r11054 54 54 virtual ~Template(); 55 55 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;57 virtual void changedName() ;56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 57 virtual void changedName() override; 58 58 59 59 inline void setLink(const std::string& link) -
code/branches/cpp11_v3/src/libraries/core/Thread.cc
r8399 r11054 34 34 35 35 #include <cassert> 36 #include <functional> 36 37 #include <boost/thread/thread.hpp> 37 #include <boost/bind.hpp>38 38 #include <boost/thread/mutex.hpp> 39 39 #include <boost/thread/thread_time.hpp> … … 48 48 49 49 Thread::Thread(): 50 executor_( 0),50 executor_(nullptr), 51 51 isWorking_(false), 52 52 stopThread_(false) … … 55 55 this->isWorkingMutex_ = new boost::mutex; 56 56 this->stopThreadMutex_ = new boost::mutex; 57 this->workerThread_ = new boost::thread( boost::bind(&Thread::threadLoop, this) );57 this->workerThread_ = new boost::thread( std::bind(&Thread::threadLoop, this) ); 58 58 } 59 59 … … 102 102 (*executor)(); 103 103 this->executorMutex_->lock(); 104 this->executor_ = 0;104 this->executor_ = nullptr; 105 105 this->executorMutex_->unlock(); 106 106 this->isWorkingMutex_->lock(); -
code/branches/cpp11_v3/src/libraries/core/ThreadPool.cc
r8394 r11054 83 83 bool ThreadPool::passFunction( const ExecutorPtr& executor, bool addThread ) 84 84 { 85 std::vector<Thread*>::iterator it; 86 for ( it=this->threadPool_.begin(); it!=this->threadPool_.end(); ++it ) 85 for ( Thread* thread : threadPool_ ) 87 86 { 88 if ( ! (*it)->isWorking() )87 if ( ! thread->isWorking() ) 89 88 { 90 89 // If that fails, then there is some code error 91 OrxVerify( (*it)->evaluateExecutor( executor ), "ERROR: could not evaluate Executor" );90 OrxVerify( thread->evaluateExecutor( executor ), "ERROR: could not evaluate Executor" ); 92 91 return true; 93 92 } … … 105 104 void ThreadPool::synchronise() 106 105 { 107 std::vector<Thread*>::iterator it; 108 for ( it=this->threadPool_.begin(); it!=this->threadPool_.end(); ++it ) 106 for ( Thread* thread : this->threadPool_ ) 109 107 { 110 (*it)->waitUntilFinished();108 thread->waitUntilFinished(); 111 109 } 112 110 } -
code/branches/cpp11_v3/src/libraries/core/ThreadWin.cc
r8706 r11054 31 31 32 32 #include <cassert> 33 // #include <functional> 33 34 // #include <boost/thread/thread.hpp> 34 // #include <boost/bind.hpp>35 35 // #include <boost/thread/mutex.hpp> 36 36 // #include <boost/thread/thread_time.hpp> … … 45 45 46 46 Thread::Thread(): 47 executor_( 0),47 executor_(nullptr), 48 48 isWorking_(false), 49 49 stopThread_(false) … … 52 52 // this->isWorkingMutex_ = new boost::mutex; 53 53 // this->stopThreadMutex_ = new boost::mutex; 54 // this->workerThread_ = new boost::thread( boost::bind(&Thread::threadLoop, this) );54 // this->workerThread_ = new boost::thread( std::bind(&Thread::threadLoop, this) ); 55 55 } 56 56 … … 101 101 // (*executor)(); 102 102 // this->executorMutex_->lock(); 103 // this->executor_ = 0;103 // this->executor_ = nullptr; 104 104 // this->executorMutex_->unlock(); 105 105 // this->isWorkingMutex_->lock(); -
code/branches/cpp11_v3/src/libraries/core/ViewportEventListener.h
r9667 r11054 44 44 protected: 45 45 ViewportEventListener(); 46 virtual ~ViewportEventListener() {}46 virtual ~ViewportEventListener() = default; 47 47 }; 48 48 } -
code/branches/cpp11_v3/src/libraries/core/WindowEventListener.cc
r10624 r11054 45 45 /*static*/ void WindowEventListener::moveWindow() 46 46 { 47 for ( ObjectList<WindowEventListener>::iterator it = ObjectList<WindowEventListener>::begin(); it; ++it)48 it->windowMoved();47 for (WindowEventListener* listener : ObjectList<WindowEventListener>()) 48 listener->windowMoved(); 49 49 } 50 50 … … 54 54 windowWidth_s = newWidth; 55 55 windowHeight_s = newHeight; 56 for ( ObjectList<WindowEventListener>::iterator it = ObjectList<WindowEventListener>::begin(); it; ++it)57 it->windowResized(newWidth, newHeight);56 for (WindowEventListener* listener : ObjectList<WindowEventListener>()) 57 listener->windowResized(newWidth, newHeight); 58 58 } 59 59 … … 61 61 /*static*/ void WindowEventListener::changeWindowFocus(bool bFocus) 62 62 { 63 for ( ObjectList<WindowEventListener>::iterator it = ObjectList<WindowEventListener>::begin(); it; ++it)64 it->windowFocusChanged(bFocus);63 for (WindowEventListener* listener : ObjectList<WindowEventListener>()) 64 listener->windowFocusChanged(bFocus); 65 65 } 66 66 } -
code/branches/cpp11_v3/src/libraries/core/WindowEventListener.h
r9667 r11054 47 47 protected: 48 48 WindowEventListener(); 49 virtual ~WindowEventListener() { }49 virtual ~WindowEventListener() = default; 50 50 51 51 //! Returns the current render window width -
code/branches/cpp11_v3/src/libraries/core/XMLNameListener.h
r9667 r11054 44 44 public: 45 45 XMLNameListener(); 46 virtual ~XMLNameListener() {}46 virtual ~XMLNameListener() = default; 47 47 48 48 virtual void loadedNewXMLName(BaseObject* object) = 0; -
code/branches/cpp11_v3/src/libraries/core/XMLPort.h
r9667 r11054 245 245 return my_added_objects[index]; 246 246 else 247 return 0;247 return nullptr; 248 248 } 249 249 @endcode … … 334 334 XMLPortParamContainer() 335 335 { this->parseResult_ = PR_not_started; } 336 virtual ~XMLPortParamContainer() {}336 virtual ~XMLPortParamContainer() = default; 337 337 338 338 inline const std::string& getName() const … … 378 378 } 379 379 380 ~XMLPortClassParamContainer()381 {382 }383 384 380 XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode) 385 381 { … … 399 395 // Iterate through the attributes manually in order to make them case insensitive 400 396 ticpp::Attribute* attribute = xmlelement.FirstAttribute(false); 401 while (attribute != 0)397 while (attribute != nullptr) 402 398 { 403 399 this->owner_->xmlAttributes_[getLowercase(attribute->Name())] = attribute->Value(); … … 459 455 } 460 456 461 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) 457 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) override 462 458 { 463 459 if (!this->loadexecutor_->defaultValueSet(index)) … … 465 461 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 466 462 } 467 virtual XMLPortParamContainer& defaultValues(const MultiType& param1) 463 virtual XMLPortParamContainer& defaultValues(const MultiType& param1) override 468 464 { 469 465 if (!this->loadexecutor_->defaultValueSet(0)) … … 471 467 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 472 468 } 473 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) 469 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) override 474 470 { 475 471 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1))) … … 477 473 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 478 474 } 479 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 475 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) override 480 476 { 481 477 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2))) … … 483 479 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 484 480 } 485 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 481 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) override 486 482 { 487 483 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3))) … … 489 485 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 490 486 } 491 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 487 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) override 492 488 { 493 489 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4))) … … 511 507 XMLPortObjectContainer() 512 508 { this->bApplyLoaderMask_ = false; } 513 virtual ~XMLPortObjectContainer() {}509 virtual ~XMLPortObjectContainer() = default; 514 510 515 511 XMLPortObjectContainer& port(BaseObject* object, Element& xmlelement, XMLPort::Mode mode); … … 552 548 } 553 549 554 ~XMLPortClassObjectContainer() 555 { 556 } 557 558 void callLoadExecutor(BaseObject* object, BaseObject* newObject) 550 virtual void callLoadExecutor(BaseObject* object, BaseObject* newObject) override 559 551 { 560 552 T* castObject = orxonox_cast<T*>(object); -
code/branches/cpp11_v3/src/libraries/core/class/Identifiable.cc
r10624 r11054 48 48 Identifiable::Identifiable() 49 49 { 50 this->identifier_ = 0;50 this->identifier_ = nullptr; 51 51 this->objectPointers_.reserve(6); // Optimisation 52 52 -
code/branches/cpp11_v3/src/libraries/core/class/Identifiable.h
r9667 r11054 98 98 registered in the class hierarchy. 99 99 @return 100 Returns NULLif the no pointer was found.100 Returns nullptr if the no pointer was found. 101 101 */ 102 102 ORX_FORCEINLINE void* getDerivedPointer(unsigned int classID) … … 107 107 return this->objectPointers_[i].second; 108 108 } 109 return NULL;109 return nullptr; 110 110 } 111 111 … … 121 121 122 122 /// 'Fast map' that holds this-pointers of all derived types 123 std::vector<std::pair<unsigned int, void*> 123 std::vector<std::pair<unsigned int, void*>> objectPointers_; 124 124 }; 125 125 } -
code/branches/cpp11_v3/src/libraries/core/class/Identifier.cc
r10624 r11054 79 79 delete this->factory_; 80 80 81 for ( std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)82 delete (*it);81 for (const InheritsFrom* manualDirectParent : this->manualDirectParents_) 82 delete manualDirectParent; 83 83 84 84 // erase this Identifier from all related identifiers 85 for ( std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)86 const_cast<Identifier*>( *it)->children_.erase(this);87 for ( std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)88 const_cast<Identifier*>( *it)->directChildren_.erase(this);89 for ( std::set<const Identifier*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)90 const_cast<Identifier*>( *it)->parents_.remove(this);91 for ( std::set<const Identifier*>::const_iterator it = this->directChildren_.begin(); it != this->directChildren_.end(); ++it)92 const_cast<Identifier*>( *it)->directParents_.remove(this);93 94 for ( std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)95 delete ( it->second);96 for ( std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)97 delete ( it->second);98 for ( std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)99 delete ( it->second);85 for (const Identifier* parent : this->parents_) 86 const_cast<Identifier*>(parent)->children_.erase(this); 87 for (const Identifier* directParent : this->directParents_) 88 const_cast<Identifier*>(directParent)->directChildren_.erase(this); 89 for (const Identifier* child : this->children_) 90 const_cast<Identifier*>(child)->parents_.remove(this); 91 for (const Identifier* directChild : this->directChildren_) 92 const_cast<Identifier*>(directChild)->directParents_.remove(this); 93 94 for (const auto& mapEntry : this->configValues_) 95 delete (mapEntry.second); 96 for (const auto& mapEntry : this->xmlportParamContainers_) 97 delete (mapEntry.second); 98 for (const auto& mapEntry : this->xmlportObjectContainers_) 99 delete (mapEntry.second); 100 100 } 101 101 … … 117 117 orxout(user_error) << "Aborting..." << endl; 118 118 abort(); 119 return 0;119 return nullptr; 120 120 } 121 121 } … … 157 157 if (this->directParents_.empty()) 158 158 { 159 for ( std::list<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it)160 if ( *it!= this)161 this->parents_.push_back( *it);159 for (const Identifier* identifier : initializationTrace) 160 if (identifier != this) 161 this->parents_.push_back(identifier); 162 162 } 163 163 else … … 184 184 185 185 // initialize all parents 186 for ( std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)187 const_cast<Identifier*>( *it)->finishInitialization(); // initialize parent186 for (const Identifier* parent : this->parents_) 187 const_cast<Identifier*>(parent)->finishInitialization(); // initialize parent 188 188 189 189 // parents of parents are no direct parents of this identifier 190 190 this->directParents_ = this->parents_; 191 for ( std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)192 for ( std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)193 this->directParents_.remove( *it_parent_parent);191 for (const Identifier* parent : this->parents_) 192 for (const Identifier* parent_parent : const_cast<Identifier*>(parent)->parents_) 193 this->directParents_.remove(parent_parent); 194 194 195 195 this->verifyIdentifierTrace(); … … 200 200 201 201 // initialize all direct parents 202 for ( std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)202 for (const InheritsFrom* manualDirectParent : this->manualDirectParents_) 203 203 { 204 Identifier* directParent = (*it)->getParent();204 Identifier* directParent = manualDirectParent->getParent(); 205 205 this->directParents_.push_back(directParent); 206 206 directParent->finishInitialization(); // initialize parent … … 208 208 209 209 // direct parents and their parents are also parents of this identifier (but only add them once) 210 for ( std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)210 for (const Identifier* parent : this->directParents_) 211 211 { 212 for ( std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)213 this->addIfNotExists(this->parents_, *it_parent_parent);214 this->addIfNotExists(this->parents_, *it_parent);212 for (const Identifier* parent_parent : const_cast<Identifier*>(parent)->parents_) 213 this->addIfNotExists(this->parents_, parent_parent); 214 this->addIfNotExists(this->parents_, parent); 215 215 } 216 216 } … … 224 224 225 225 // tell all parents that this identifier is a child 226 for ( std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)227 const_cast<Identifier*>( *it)->children_.insert(this);226 for (const Identifier* parent : this->parents_) 227 const_cast<Identifier*>(parent)->children_.insert(this); 228 228 229 229 // tell all direct parents that this identifier is a direct child 230 for ( std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)231 { 232 const_cast<Identifier*>( *it)->directChildren_.insert(this);230 for (const Identifier* directChild : this->directParents_) 231 { 232 const_cast<Identifier*>(directChild)->directChildren_.insert(this); 233 233 234 234 // Create the super-function dependencies 235 (*it)->createSuperFunctionCaller();235 directChild->createSuperFunctionCaller(); 236 236 } 237 237 … … 261 261 262 262 // if any parent class is virtual, it will be instantiated first, so we need to add them first. 263 for ( std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)264 { 265 if ( (*it_parent)->isVirtualBase())263 for (const Identifier* parent : this->parents_) 264 { 265 if (parent->isVirtualBase()) 266 266 { 267 for ( std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)268 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);269 this->addIfNotExists(expectedIdentifierTrace, *it_parent);267 for (const Identifier* parent_parent : const_cast<Identifier*>(parent)->parents_) 268 this->addIfNotExists(expectedIdentifierTrace, parent_parent); 269 this->addIfNotExists(expectedIdentifierTrace, parent); 270 270 } 271 271 } 272 272 273 273 // now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again. 274 for ( std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)275 { 276 for ( std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)277 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);278 this->addIfNotExists(expectedIdentifierTrace, *it_parent);274 for (const Identifier* directParent : this->directParents_) 275 { 276 for (const Identifier* parent_parent : const_cast<Identifier*>(directParent)->parents_) 277 this->addIfNotExists(expectedIdentifierTrace, parent_parent); 278 this->addIfNotExists(expectedIdentifierTrace, directParent); 279 279 } 280 280 … … 285 285 286 286 orxout(internal_warning) << " Actual trace (after creating a sample instance):" << endl << " "; 287 for ( std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)288 orxout(internal_warning) << " " << (*it_parent)->getName();287 for (const Identifier* parent : this->parents_) 288 orxout(internal_warning) << " " << parent->getName(); 289 289 orxout(internal_warning) << endl; 290 290 291 291 orxout(internal_warning) << " Expected trace (according to class hierarchy definitions):" << endl << " "; 292 for ( std::list<const Identifier*>::const_iterator it_parent = expectedIdentifierTrace.begin(); it_parent != expectedIdentifierTrace.end(); ++it_parent)293 orxout(internal_warning) << " " << (*it_parent)->getName();292 for (const Identifier* parent : expectedIdentifierTrace) 293 orxout(internal_warning) << " " << parent->getName(); 294 294 orxout(internal_warning) << endl; 295 295 296 296 orxout(internal_warning) << " Direct parents (according to class hierarchy definitions):" << endl << " "; 297 for ( std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)298 orxout(internal_warning) << " " << (*it_parent)->getName();297 for (const Identifier* directParent : this->directParents_) 298 orxout(internal_warning) << " " << directParent->getName(); 299 299 orxout(internal_warning) << endl; 300 300 } … … 393 393 return it->second; 394 394 else 395 return 0;395 return nullptr; 396 396 } 397 397 … … 407 407 return it->second; 408 408 else 409 return 0;409 return nullptr; 410 410 } 411 411 … … 438 438 return it->second; 439 439 else 440 return 0;440 return nullptr; 441 441 } 442 442 -
code/branches/cpp11_v3/src/libraries/core/class/Identifier.h
r10624 r11054 56 56 object->getIdentifier()->getName(); // returns "MyClass" 57 57 58 Identifiable* other = object->getIdentifier()->fabricate( 0); // fabricates a new instance of MyClass58 Identifiable* other = object->getIdentifier()->fabricate(nullptr); // fabricates a new instance of MyClass 59 59 60 60 … … 80 80 #include <typeinfo> 81 81 #include <loki/TypeTraits.h> 82 #include <boost/static_assert.hpp>83 #include <boost/type_traits/is_base_of.hpp>84 82 85 83 #include "util/Output.h" … … 120 118 public: 121 119 Identifier(const std::string& name, Factory* factory, bool bLoadable); 122 Identifier(const Identifier& identifier); // don't copy123 120 virtual ~Identifier(); 121 122 // non-copyable: 123 Identifier(const Identifier&) = delete; 124 Identifier& operator=(const Identifier&) = delete; 124 125 125 126 /// Returns the name of the class the Identifier belongs to. … … 137 138 138 139 /// Returns true if the Identifier has a Factory. 139 inline bool hasFactory() const { return (this->factory_ != 0); }140 inline bool hasFactory() const { return (this->factory_ != nullptr); } 140 141 141 142 Identifiable* fabricate(Context* context); … … 269 270 class ClassIdentifier : public Identifier 270 271 { 271 BOOST_STATIC_ASSERT((boost::is_base_of<Identifiable, T>::value));272 static_assert(std::is_base_of<Identifiable, T>::value, "ClassIdentifier can only be used with Identifiables"); 272 273 273 274 #ifndef DOXYGEN_SHOULD_SKIP_THIS … … 279 280 ClassIdentifier(const std::string& name, Factory* factory, bool bLoadable) : Identifier(name, factory, bLoadable) 280 281 { 281 OrxVerify(ClassIdentifier<T>::classIdentifier_s == NULL, "Assertion failed in ClassIdentifier of type " << typeid(T).name());282 OrxVerify(ClassIdentifier<T>::classIdentifier_s == nullptr, "Assertion failed in ClassIdentifier of type " << typeid(T).name()); 282 283 ClassIdentifier<T>::classIdentifier_s = this; 283 284 … … 291 292 bool initializeObject(T* object); 292 293 293 virtual void updateConfigValues(bool updateChildren = true) const ;294 295 virtual const std::type_info& getTypeInfo() 294 virtual void updateConfigValues(bool updateChildren = true) const override; 295 296 virtual const std::type_info& getTypeInfo() override 296 297 { return typeid(T); } 297 298 298 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const 299 { return dynamic_cast<T*>(object) != 0; }300 301 virtual void destroyObjects() ;299 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const override 300 { return dynamic_cast<T*>(object) != nullptr; } 301 302 virtual void destroyObjects() override; 302 303 303 304 static ClassIdentifier<T>* getIdentifier(); 304 305 305 306 private: 306 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 307 // non-copyable: 308 ClassIdentifier(const ClassIdentifier<T>&) = delete; 309 ClassIdentifier& operator=(const ClassIdentifier<T>&) = delete; 307 310 308 311 void setConfigValues(T* object, Configurable*) const; … … 321 324 void updateConfigValues(bool updateChildren, Identifiable*) const; 322 325 323 static WeakPtr<ClassIdentifier<T> 326 static WeakPtr<ClassIdentifier<T>> classIdentifier_s; 324 327 }; 325 328 326 329 template <class T> 327 WeakPtr<ClassIdentifier<T> 330 WeakPtr<ClassIdentifier<T>> ClassIdentifier<T>::classIdentifier_s; 328 331 329 332 /** … … 334 337 /*static*/ inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 335 338 { 336 if (ClassIdentifier<T>::classIdentifier_s == NULL)339 if (ClassIdentifier<T>::classIdentifier_s == nullptr) 337 340 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*) IdentifierManager::getInstance().getIdentifierByTypeInfo(typeid(T)); 338 341 339 OrxVerify(ClassIdentifier<T>::classIdentifier_s != NULL, "Did you forget to register the class of type " << typeid(T).name() << "?");342 OrxVerify(ClassIdentifier<T>::classIdentifier_s != nullptr, "Did you forget to register the class of type " << typeid(T).name() << "?"); 340 343 return ClassIdentifier<T>::classIdentifier_s; 341 344 } … … 365 368 366 369 // Add pointer of type T to the map in the Identifiable instance that enables "dynamic_casts" 367 object->objectPointers_. push_back(std::make_pair(this->getClassID(), static_cast<void*>(object)));370 object->objectPointers_.emplace_back(this->getClassID(), static_cast<void*>(object)); 368 371 return false; 369 372 } … … 408 411 void ClassIdentifier<T>::destroyObjects() 409 412 { 410 this->destroyObjects((T*) 0);413 this->destroyObjects((T*)nullptr); 411 414 } 412 415 … … 417 420 void ClassIdentifier<T>::destroyObjects(Listable*) 418 421 { 419 ObjectListBase* objectList = Context::getRootContext()->getObjectList(this); 420 ObjectListElement<T>* begin = static_cast<ObjectListElement<T>*>(objectList->begin()); 421 ObjectListElement<T>* end = static_cast<ObjectListElement<T>*>(objectList->end()); 422 for (typename ObjectList<T>::iterator it = begin; it != end; ) 422 ObjectList<T> list(Context::getRootContext()->getObjectList(this)); 423 for (typename ObjectList<T>::iterator it = list.begin(); it != list.end(); ) 423 424 this->destroyObject(*(it++)); 424 425 } … … 451 452 void ClassIdentifier<T>::updateConfigValues(bool updateChildren) const 452 453 { 453 this->updateConfigValues(updateChildren, static_cast<T*>( NULL));454 this->updateConfigValues(updateChildren, static_cast<T*>(nullptr)); 454 455 } 455 456 … … 460 461 return; 461 462 462 for ( ObjectListIterator<T> it = ObjectList<T>::begin(); it; ++it)463 this->setConfigValues( *it, *it);463 for (T* object : ObjectList<T>()) 464 this->setConfigValues(object, object); 464 465 465 466 if (updateChildren) 466 for ( std::set<const Identifier*>::const_iterator it = this->getChildren().begin(); it != this->getChildren().end(); ++it)467 (*it)->updateConfigValues(false);467 for (const Identifier* child : this->getChildren()) 468 child->updateConfigValues(false); 468 469 } 469 470 … … 483 484 registered in the class hierarchy. 484 485 @return 485 Returns NULLif the cast is not possible486 Returns nullptr if the cast is not possible 486 487 @note 487 In case of NULLreturn (and using MSVC), a dynamic_cast might still be possible if488 In case of nullptr return (and using MSVC), a dynamic_cast might still be possible if 488 489 a class forgot to register its objects. 489 490 Also note that the function is implemented differently for GCC/MSVC. … … 494 495 #ifdef ORXONOX_COMPILER_MSVC 495 496 typedef Loki::TypeTraits<typename Loki::TypeTraits<T>::PointeeType>::NonConstType ClassType; 496 if (source != NULL)497 if (source != nullptr) 497 498 return source->template getDerivedPointer<ClassType>(ClassIdentifier<ClassType>::getIdentifier()->getClassID()); 498 499 else 499 return NULL;500 return nullptr; 500 501 #else 501 502 return dynamic_cast<T>(source); -
code/branches/cpp11_v3/src/libraries/core/class/IdentifierManager.cc
r10624 r11054 44 44 namespace orxonox 45 45 { 46 IdentifierManager* IdentifierManager::singletonPtr_s = 0;46 IdentifierManager* IdentifierManager::singletonPtr_s = nullptr; 47 47 48 48 IdentifierManager::IdentifierManager() 49 49 { 50 50 this->hierarchyCreatingCounter_s = 0; 51 this->recordTraceForIdentifier_ = NULL;51 this->recordTraceForIdentifier_ = nullptr; 52 52 } 53 53 … … 60 60 61 61 this->identifiers_.insert(identifier); 62 this->identifierByTypeIndex_[identifier->getTypeInfo()] = identifier; 62 63 this->identifierByString_[identifier->getName()] = identifier; 63 64 this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier; … … 71 72 { 72 73 this->identifiers_.erase(identifier); 74 this->identifierByTypeIndex_.erase(identifier->getTypeInfo()); 73 75 this->identifierByString_.erase(identifier->getName()); 74 76 this->identifierByLowercaseString_.erase(getLowercase(identifier->getName())); … … 92 94 // iterate over all identifiers, create one instance of each class and initialize the identifiers 93 95 { 94 Context temporaryContext( NULL);95 for ( std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)96 Context temporaryContext(nullptr); 97 for (Identifier* identifier : this->identifiers_) 96 98 { 97 Identifier* identifier = (*it);98 99 if (identifier->isInitialized()) 99 100 continue; … … 108 109 Identifiable* temp = identifier->fabricate(&temporaryContext); 109 110 110 this->recordTraceForIdentifier_ = NULL;111 this->recordTraceForIdentifier_ = nullptr; 111 112 112 113 if (temp->getIdentifier() != identifier) … … 127 128 128 129 // finish the initialization of all identifiers 129 for ( std::set<Identifier*>::const_iterator it = initializedIdentifiers.begin(); it != initializedIdentifiers.end(); ++it)130 (*it)->finishInitialization();130 for (Identifier* initializedIdentifier : initializedIdentifiers) 131 initializedIdentifier->finishInitialization(); 131 132 132 133 // only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway. … … 144 145 { 145 146 // check if there are any uninitialized identifiers remaining 146 for ( std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)147 if (! (*it)->isInitialized())148 orxout(internal_error) << "Identifier was registered late and is not initialized: " << (*it)->getName() << " / " << (*it)->getTypeInfo().name() << endl;147 for (Identifier* identifier : this->identifiers_) 148 if (!identifier->isInitialized()) 149 orxout(internal_error) << "Identifier was registered late and is not initialized: " << identifier->getName() << " / " << identifier->getTypeInfo().name() << endl; 149 150 150 151 // for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy 151 Context temporaryContext( NULL);152 for ( std::set<Identifier*>::const_iterator it1 = initializedIdentifiers.begin(); it1 != initializedIdentifiers.end(); ++it1)152 Context temporaryContext(nullptr); 153 for (Identifier* initializedIdentifier : initializedIdentifiers) 153 154 { 154 if (! (*it1)->hasFactory())155 if (!initializedIdentifier->hasFactory()) 155 156 continue; 156 157 157 Identifiable* temp = (*it1)->fabricate(&temporaryContext);158 159 for ( std::set<Identifier*>::const_iterator it2 = this->identifiers_.begin(); it2 != this->identifiers_.end(); ++it2)158 Identifiable* temp = initializedIdentifier->fabricate(&temporaryContext); 159 160 for (Identifier* identifier : this->identifiers_) 160 161 { 161 bool isA_AccordingToRtti = (*it2)->canDynamicCastObjectToIdentifierClass(temp);162 bool isA_AccordingToClassHierarchy = temp->isA( (*it2));162 bool isA_AccordingToRtti = identifier->canDynamicCastObjectToIdentifierClass(temp); 163 bool isA_AccordingToClassHierarchy = temp->isA(identifier); 163 164 164 165 if (isA_AccordingToRtti != isA_AccordingToClassHierarchy) 165 166 { 166 orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (*it1)->getName() <<167 (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (*it2)->getName() << " but RTTI says the opposite." << endl;167 orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << initializedIdentifier->getName() << 168 (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << identifier->getName() << " but RTTI says the opposite." << endl; 168 169 } 169 170 } … … 184 185 { 185 186 orxout(internal_status) << "Destroy class-hierarchy" << endl; 186 for ( std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)187 (*it)->reset();187 for (Identifier* identifier : this->identifiers_) 188 identifier->reset(); 188 189 } 189 190 … … 221 222 return it->second; 222 223 else 223 return 0;224 return nullptr; 224 225 } 225 226 … … 235 236 return it->second; 236 237 else 237 return 0;238 return nullptr; 238 239 } 239 240 … … 249 250 return it->second; 250 251 else 251 return 0;252 return nullptr; 252 253 } 253 254 … … 259 260 Identifier* IdentifierManager::getIdentifierByTypeInfo(const std::type_info& typeInfo) 260 261 { 261 // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11)262 for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)263 if ((*it)->getTypeInfo() == typeInfo)264 return (*it);265 return 0;262 auto it = this->identifierByTypeIndex_.find(typeInfo); 263 if (it != this->identifierByTypeIndex_.end()) 264 return it->second; 265 else 266 return nullptr; 266 267 } 267 268 -
code/branches/cpp11_v3/src/libraries/core/class/IdentifierManager.h
r10624 r11054 37 37 #include "core/CorePrereqs.h" 38 38 39 #include <typeindex> 39 40 #include <map> 41 #include <unordered_map> 40 42 #include <set> 41 43 #include <list> … … 52 54 public: 53 55 IdentifierManager(); 54 ~IdentifierManager() {}56 ~IdentifierManager() = default; 55 57 56 58 void addIdentifier(Identifier* identifier); … … 93 95 94 96 private: 95 IdentifierManager(const IdentifierManager&); // not implemented 97 // non-copyable: 98 IdentifierManager(const IdentifierManager&) = delete; 99 IdentifierManager& operator=(const IdentifierManager&) = delete; 96 100 97 101 /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. … … 102 106 { hierarchyCreatingCounter_s--; } 103 107 104 std::set<Identifier*> identifiers_; //!< All identifiers. This is only used internally. 105 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names. 106 std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase. 107 std::map<uint32_t, Identifier*> identifierByNetworkId_; //!< Returns the map that stores all Identifiers with their network IDs. 108 std::set<Identifier*> identifiers_; //!< All identifiers. This is only used internally. 109 std::unordered_map<std::type_index, Identifier*> identifierByTypeIndex_; //!< Map that stores all Identifiers with their type_index. 110 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names. 111 std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase. 112 std::map<uint32_t, Identifier*> identifierByNetworkId_; //!< Returns the map that stores all Identifiers with their network IDs. 108 113 109 114 int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) … … 111 116 /// Used while creating the object hierarchy to keep track of the identifiers of a newly created object (and all other objects that get created as 112 117 /// a consequence of this, e.g. nested member objects). 113 std::map<Identifiable*, std::list<const Identifier*> 118 std::map<Identifiable*, std::list<const Identifier*>> identifierTraceOfNewObject_; 114 119 Identifier* recordTraceForIdentifier_; //!< The identifier for which we want to record the trace of identifiers during object creation. If null, no trace is recorded. 115 120 -
code/branches/cpp11_v3/src/libraries/core/class/SubclassIdentifier.h
r9667 r11054 127 127 else 128 128 { 129 orxout(internal_error) << "Can't assign NULLidentifier" << endl;129 orxout(internal_error) << "Can't assign nullptr identifier" << endl; 130 130 } 131 131 } … … 189 189 orxout(user_error) << "Aborting..." << endl; 190 190 abort(); 191 return 0;191 return nullptr; 192 192 } 193 193 } -
code/branches/cpp11_v3/src/libraries/core/class/Super.h
r10624 r11054 94 94 static void superCheck() \ 95 95 { \ 96 SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>( 0)); \96 SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>(nullptr)); \ 97 97 SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::superCheck(); \ 98 98 } \ … … 103 103 { \ 104 104 ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \ 105 for ( std::set<const Identifier*>::iterator it = identifier->getDirectChildren().begin(); it != identifier->getDirectChildren().end(); ++it) \105 for (const Identifier* child : identifier->getDirectChildren()) \ 106 106 { \ 107 if (((ClassIdentifier<T>*) (*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \107 if (((ClassIdentifier<T>*)child)->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_) \ 108 108 { \ 109 delete ((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_; \110 ((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_ = 0; \111 ((ClassIdentifier<T>*) (*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; \109 delete ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_; \ 110 ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_ = nullptr; \ 111 ((ClassIdentifier<T>*)child)->bSuperFunctionCaller_##functionname##_isFallback_ = false; \ 112 112 } \ 113 113 \ 114 if (!((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_) \114 if (!((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_) \ 115 115 { \ 116 orxout(verbose, context::super) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*) (*it))->getName() << endl; \117 ((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \116 orxout(verbose, context::super) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)child)->getName() << endl; \ 117 ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \ 118 118 } \ 119 else if (((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_->getParentIdentifier() != ClassIdentifier<T>::getIdentifier()) \120 orxout(internal_warning, context::super) << "SuperFunctionCaller for " << #functionname << " in " << ((ClassIdentifier<T>*) (*it))->getName() << " calls function of " << ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_->getParentIdentifier()->getName() << " but " << ClassIdentifier<T>::getIdentifier()->getName() << " is also possible (do you use multiple inheritance?)" << endl; \119 else if (((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_->getParentIdentifier() != ClassIdentifier<T>::getIdentifier()) \ 120 orxout(internal_warning, context::super) << "SuperFunctionCaller for " << #functionname << " in " << ((ClassIdentifier<T>*)child)->getName() << " calls function of " << ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_->getParentIdentifier()->getName() << " but " << ClassIdentifier<T>::getIdentifier()->getName() << " is also possible (do you use multiple inheritance?)" << endl; \ 121 121 } \ 122 122 } \ … … 154 154 // This call to the apply-function is the whole check. By calling the function with 155 155 // a T* pointer, the right function get's called. 156 SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>( 0));156 SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>(nullptr)); 157 157 158 158 // Go go the superCheck for of next super-function (functionnumber + 1) … … 171 171 172 172 // Iterate through all children 173 for ( std::set<const Identifier*>::iterator it = identifier->getDirectChildren().begin(); it != identifier->getDirectChildren().end(); ++it)173 for (const Identifier* child : identifier->getDirectChildren()) 174 174 { 175 175 // Check if the caller is a fallback-caller 176 if (((ClassIdentifier<T>*) (*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)176 if (((ClassIdentifier<T>*)child)->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_) 177 177 { 178 178 // Delete the fallback caller an prepare to get a real caller 179 delete ((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_;180 ((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_ = 0;181 ((ClassIdentifier<T>*) (*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false;179 delete ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_; 180 ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_ = nullptr; 181 ((ClassIdentifier<T>*)child)->bSuperFunctionCaller_##functionname##_isFallback_ = false; 182 182 } 183 183 184 184 // Check if there's not already a caller 185 if (!((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_)185 if (!((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_) 186 186 { 187 187 // Add the SuperFunctionCaller 188 orxout(verbose, context::super) << "adding functionpointer to " << ((ClassIdentifier<T>*) (*it))->getName() << endl;189 ((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;188 orxout(verbose, context::super) << "adding functionpointer to " << ((ClassIdentifier<T>*)child)->getName() << endl; 189 ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; 190 190 } 191 191 192 192 // If there is already a caller, but for another parent, print a warning 193 else if (((ClassIdentifier<T>*) (*it))->superFunctionCaller_##functionname##_->getParentIdentifier() != ClassIdentifier<T>::getIdentifier())194 orxout(internal_warning, context::super) << "SuperFunctionCaller for " << #functionname << " in " << ((ClassIdentifier<T>*) (*it))->getName() << " calls function of " << ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_->getParentIdentifier()->getName() << " but " << ClassIdentifier<T>::getIdentifier()->getName() << " is also possible (do you use multiple inheritance?)" << endl;193 else if (((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_->getParentIdentifier() != ClassIdentifier<T>::getIdentifier()) 194 orxout(internal_warning, context::super) << "SuperFunctionCaller for " << #functionname << " in " << ((ClassIdentifier<T>*)child)->getName() << " calls function of " << ((ClassIdentifier<T>*)child)->superFunctionCaller_##functionname##_->getParentIdentifier()->getName() << " but " << ClassIdentifier<T>::getIdentifier()->getName() << " is also possible (do you use multiple inheritance?)" << endl; 195 195 } 196 196 } … … 584 584 // Creates the super-function-callers by calling the first SuperFunctionCondition check 585 585 // This get's called within the initialization of an Identifier 586 virtual void createSuperFunctionCaller() const 586 virtual void createSuperFunctionCaller() const override 587 587 { 588 588 SuperFunctionCondition<0, T, 0, 0>::superCheck(); -
code/branches/cpp11_v3/src/libraries/core/command/ArgumentCompletionFunctions.cc
r10624 r11054 77 77 bool groupIsVisible(const std::map<std::string, ConsoleCommand*>& group, bool bOnlyShowHidden) 78 78 { 79 for ( std::map<std::string, ConsoleCommand*>::const_iterator it_command = group.begin(); it_command != group.end(); ++it_command)80 if ( it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)79 for (const auto& mapEntry : group) 80 if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden) 81 81 return true; 82 82 … … 99 99 100 100 // get all the groups that are visible (except the shortcut group "") 101 const std::map<std::string, std::map<std::string, ConsoleCommand*> 102 for ( std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)103 if (groupIsVisible( it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0))104 groupList. push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));101 const std::map<std::string, std::map<std::string, ConsoleCommand*>>& commands = ConsoleCommandManager::getInstance().getCommands(); 102 for (const auto& mapEntry : commands) 103 if (groupIsVisible(mapEntry.second, bOnlyShowHidden) && mapEntry.first != "" && (fragmentLC == "" || getLowercase(mapEntry.first).find(fragmentLC) == 0)) 104 groupList.emplace_back(mapEntry.first, getLowercase(mapEntry.first)); 105 105 106 106 // now add all shortcuts (in group "") 107 std::map<std::string, std::map<std::string, ConsoleCommand*> 107 std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = commands.find(""); 108 108 if (it_group != commands.end()) 109 109 { 110 110 // add a line-break if the list isn't empty 111 111 if (!groupList.empty()) 112 groupList. push_back(ArgumentCompletionListElement("", "", "\n"));112 groupList.emplace_back("", "", "\n"); 113 113 114 114 // add the shortcuts 115 for ( std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)116 if ( it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find(fragmentLC) == 0))117 groupList. push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));115 for (const auto& mapEntry : it_group->second) 116 if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(mapEntry.first).find(fragmentLC) == 0)) 117 groupList.emplace_back(mapEntry.first, getLowercase(mapEntry.first)); 118 118 } 119 119 … … 138 138 139 139 // find the iterator of the given group 140 std::map<std::string, std::map<std::string, ConsoleCommand*> 140 std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().begin(); 141 141 for ( ; it_group != ConsoleCommandManager::getInstance().getCommands().end(); ++it_group) 142 142 if (getLowercase(it_group->first) == groupLC) … … 146 146 if (it_group != ConsoleCommandManager::getInstance().getCommands().end()) 147 147 { 148 for ( std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)149 if ( it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)150 commandList. push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));148 for (const auto& mapEntry : it_group->second) 149 if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden) 150 commandList.emplace_back(mapEntry.first, getLowercase(mapEntry.first)); 151 151 } 152 152 … … 188 188 { 189 189 ArgumentCompletionList list; 190 list. push_back(ArgumentCompletionListElement("", "", hint));190 list.emplace_back("", "", hint); 191 191 return list; 192 192 } … … 212 212 if (tokens.size() == 1) 213 213 { 214 std::map<std::string, std::map<std::string, ConsoleCommand*> 214 std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().find(tokens[0]); 215 215 if (it_group != ConsoleCommandManager::getInstance().getCommands().end()) 216 216 return detail::_subcommands(fragment, tokens[0], true); … … 261 261 { 262 262 if (boost::filesystem::is_directory(*file)) 263 dirlist. push_back(ArgumentCompletionListElement(file->BF_DICTIONARY_ENTRY_NAME() + '/', getLowercase(file->BF_DICTIONARY_ENTRY_NAME()) + '/', file->BF_LEAF() + '/'));263 dirlist.emplace_back(file->BF_DICTIONARY_ENTRY_NAME() + '/', getLowercase(file->BF_DICTIONARY_ENTRY_NAME()) + '/', file->BF_LEAF() + '/'); 264 264 else 265 filelist. push_back(ArgumentCompletionListElement(file->BF_DICTIONARY_ENTRY_NAME(), getLowercase(file->BF_DICTIONARY_ENTRY_NAME()), file->BF_LEAF()));265 filelist.emplace_back(file->BF_DICTIONARY_ENTRY_NAME(), getLowercase(file->BF_DICTIONARY_ENTRY_NAME()), file->BF_LEAF()); 266 266 ++file; 267 267 } … … 281 281 282 282 const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames(); 283 for ( std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)284 sectionList. push_back(ArgumentCompletionListElement(*it, getLowercase(*it)));283 for (const std::string& name : names) 284 sectionList.emplace_back(name, getLowercase(name)); 285 285 286 286 return sectionList; … … 298 298 SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC); 299 299 for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it) 300 entryList. push_back(ArgumentCompletionListElement(it->second.second->getName(), it->second.first));300 entryList.emplace_back(it->second.second->getName(), it->second.first); 301 301 302 302 return entryList; … … 319 319 { 320 320 const std::string& valuestring = it->second.second->toString(); 321 oldValue. push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));321 oldValue.emplace_back(valuestring, getLowercase(valuestring), "Old value: " + valuestring); 322 322 } 323 323 } … … 334 334 ArgumentCompletionList threads; 335 335 336 for ( std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)337 threads. push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));336 for (unsigned int threadnumber : threadnumbers) 337 threads.emplace_back(multi_cast<std::string>(threadnumber)); 338 338 339 339 return threads; -
code/branches/cpp11_v3/src/libraries/core/command/ArgumentCompletionFunctions.h
r11052 r11054 86 86 { 87 87 for (int month = 1; month <= 12; ++month) 88 list. push_back(ArgumentCompletionListElement(multi_cast<std::string>(month)));88 list.emplace_back(multi_cast<std::string>(month)); 89 89 } 90 90 else 91 91 { 92 list. push_back(ArgumentCompletionListElement("January", "january"));93 list. push_back(ArgumentCompletionListElement("February", "february"));94 list. push_back(ArgumentCompletionListElement("March", "march"));95 list. push_back(ArgumentCompletionListElement("April", "april"));96 list. push_back(ArgumentCompletionListElement("May", "may"));97 list. push_back(ArgumentCompletionListElement("June", "june"));98 list. push_back(ArgumentCompletionListElement("July", "july"));99 list. push_back(ArgumentCompletionListElement("August", "august"));100 list. push_back(ArgumentCompletionListElement("September", "september"));101 list. push_back(ArgumentCompletionListElement("October", "october"));102 list. push_back(ArgumentCompletionListElement("November", "november"));103 list. push_back(ArgumentCompletionListElement("December", "december"));92 list.emplace_back("January", "january"); 93 list.emplace_back("February", "february"); 94 list.emplace_back("March", "march"); 95 list.emplace_back("April", "april"); 96 list.emplace_back("May", "may"); 97 list.emplace_back("June", "june"); 98 list.emplace_back("July", "july"); 99 list.emplace_back("August", "august"); 100 list.emplace_back("September", "september"); 101 list.emplace_back("October", "october"); 102 list.emplace_back("November", "november"); 103 list.emplace_back("December", "december"); 104 104 } 105 105 -
code/branches/cpp11_v3/src/libraries/core/command/CommandEvaluation.cc
r10624 r11054 54 54 void CommandEvaluation::initialize(const std::string& command) 55 55 { 56 this->execCommand_ = 0;57 this->hintCommand_ = 0;56 this->execCommand_ = nullptr; 57 this->hintCommand_ = nullptr; 58 58 this->string_ = command; 59 59 this->execArgumentsOffset_ = 0; … … 119 119 /** 120 120 @brief Executes the command which was evaluated by this object and returns its return-value. 121 @param error A pointer to an integer (or NULL) which will be used to write error codes to (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")121 @param error A pointer to an integer (or nullptr) which will be used to write error codes to (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 122 122 @return Returns the result of the command (or MultiType::Null if there is no return value) 123 123 */ … … 306 306 // the user typed 1-2 arguments, check what he tried to type and print a suitable error 307 307 std::string groupLC = getLowercase(this->getToken(0)); 308 for ( std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)309 if ( it_group->first == groupLC)308 for (const auto& mapEntry : ConsoleCommandManager::getInstance().getCommandsLC()) 309 if (mapEntry.first == groupLC) 310 310 return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\"."; 311 311 … … 328 328 329 329 // iterate through all groups and their commands and calculate the distance to the current command. keep the best. 330 for ( std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)331 { 332 if ( it_group->first != "")333 { 334 for ( std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)335 { 336 std::string command = it_group->first + " " + it_name->first;330 for (const auto& mapEntryGroup : ConsoleCommandManager::getInstance().getCommandsLC()) 331 { 332 if (mapEntryGroup.first != "") 333 { 334 for (const auto& mapEntryName : mapEntryGroup.second) 335 { 336 std::string command = mapEntryGroup.first + " " + mapEntryName.first; 337 337 unsigned int distance = getLevenshteinDistance(command, token0_LC + " " + token1_LC); 338 338 if (distance < nearestDistance) … … 346 346 347 347 // now also iterate through all shortcuts and keep the best if it's better than the one found above. 348 std::map<std::string, std::map<std::string, ConsoleCommand*> 348 std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().find(""); 349 349 if (it_group != ConsoleCommandManager::getInstance().getCommandsLC().end()) 350 350 { 351 for ( std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)352 { 353 std::string command = it_name->first;351 for (const auto& mapEntry : it_group->second) 352 { 353 std::string command = mapEntry.first; 354 354 unsigned int distance = getLevenshteinDistance(command, token0_LC); 355 355 if (distance < nearestDistance) … … 429 429 { 430 430 size_t count = 0; 431 for ( ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)432 if ( it->getComparable() != "")431 for (const ArgumentCompletionListElement& element : list) 432 if (element.getComparable() != "") 433 433 ++count; 434 434 return count; … … 495 495 { 496 496 // only one (non-empty) value in the list - search it and return it 497 for ( ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)498 { 499 if ( it->getComparable() != "")497 for (const ArgumentCompletionListElement& element : list) 498 { 499 if (element.getComparable() != "") 500 500 { 501 501 // arguments that have a separate string to be displayed need a little more care - just return them without modification. add a space character to the others. 502 if ( it->hasDisplay())503 return ( it->getString());502 if (element.hasDisplay()) 503 return (element.getString()); 504 504 else 505 return ( it->getString() + ' ');505 return (element.getString() + ' '); 506 506 } 507 507 } … … 517 517 char tempComparable = '\0'; 518 518 char temp = '\0'; 519 for ( ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)520 { 521 const std::string& argumentComparable = it->getComparable();522 const std::string& argument = it->getString();519 for (const ArgumentCompletionListElement& element : list) 520 { 521 const std::string& argumentComparable = element.getComparable(); 522 const std::string& argument = element.getString(); 523 523 524 524 // ignore empty arguments … … 560 560 { 561 561 std::string output; 562 for ( ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)563 { 564 output += it->getDisplay();562 for (const ArgumentCompletionListElement& element : list) 563 { 564 output += element.getDisplay(); 565 565 566 566 // add a space character between two elements for all non-empty arguments 567 if ( it->getComparable() != "")567 if (element.getComparable() != "") 568 568 output += ' '; 569 569 } -
code/branches/cpp11_v3/src/libraries/core/command/CommandEvaluation.h
r8079 r11054 86 86 87 87 int execute(); 88 MultiType query(int* error = 0);88 MultiType query(int* error = nullptr); 89 89 90 90 std::string complete(); … … 97 97 /// Returns true if the command evaluation contains a valid command that can be executed. 98 98 inline bool isValid() const 99 { return (this->execCommand_ != 0); }99 { return (this->execCommand_ != nullptr); } 100 100 101 101 /// Returns the console command that was evaluated by this object. … … 137 137 static std::string getCommonBegin(const ArgumentCompletionList& list); 138 138 139 const ConsoleCommand* execCommand_; ///< The command that will be executed (can be NULLif the command is not valid)139 const ConsoleCommand* execCommand_; ///< The command that will be executed (can be nullptr if the command is not valid) 140 140 const ConsoleCommand* hintCommand_; ///< The command that is used to display hints and argument lists (can be different to execCommand_ in some cases) 141 141 SubString tokens_; ///< The single words of the command string, split into tokens -
code/branches/cpp11_v3/src/libraries/core/command/CommandExecutor.cc
r10624 r11054 81 81 @brief Executes a command and returns its return-value. 82 82 @param command A string containing the command 83 @param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes")83 @param error A pointer to a value (or nullptr) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes") 84 84 @param useTcl If true, the command is passed to tcl (see TclBind) 85 85 @return Returns the return-value of the command (if any - MultiType::Null otherwise) … … 127 127 @brief Executes a command and returns its return-value as string. 128 128 @param command A string containing the command 129 @param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes")129 @param error A pointer to a value (or nullptr) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes") 130 130 @param useTcl If true, the command is passed to tcl (see TclBind) 131 131 @return Returns the return-value of the command converted to a string (or "" if there's no return value) … … 275 275 { 276 276 // it is valid - copy the executor of this command 277 ExecutorPtr executor = new Executor(*evaluation.getConsoleCommand()->getExecutor().get());277 ExecutorPtr executor = std::make_shared<Executor>(*evaluation.getConsoleCommand()->getExecutor().get()); 278 278 279 279 // evaluate the arguments and if this returns no error, store them as default values -
code/branches/cpp11_v3/src/libraries/core/command/CommandExecutor.h
r8858 r11054 113 113 static int execute(const std::string& command, bool useTcl = true, bool printErrors = true); // tolua_export 114 114 115 static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true);116 static std::string query(const std::string& command, int* error = 0, bool useTcl = true); // tolua_export115 static MultiType queryMT(const std::string& command, int* error = nullptr, bool useTcl = true); 116 static std::string query(const std::string& command, int* error = NULL, bool useTcl = true); // tolua_export 117 117 118 118 static CommandEvaluation evaluate(const std::string& command); 119 119 120 static const int Success = 0; ///< Error code for "success" (or no error)121 static const int Inexistent = 1; ///< Error code if the command doesn't exist122 static const int Incomplete = 2; ///< Error code if the command needs more arguments123 static const int Deactivated = 3; ///< Error code if the command is not active124 static const int Denied = 4; ///< Error code if the command needs a different access level125 static const int Error = 5; ///< Error code if the command returned an error120 static constexpr int Success = 0; ///< Error code for "success" (or no error) 121 static constexpr int Inexistent = 1; ///< Error code if the command doesn't exist 122 static constexpr int Incomplete = 2; ///< Error code if the command needs more arguments 123 static constexpr int Deactivated = 3; ///< Error code if the command is not active 124 static constexpr int Denied = 4; ///< Error code if the command needs a different access level 125 static constexpr int Error = 5; ///< Error code if the command returned an error 126 126 127 127 static std::string getErrorDescription(int error); … … 132 132 133 133 private: 134 CommandExecutor() {} ///< Empty constructor 135 CommandExecutor(const CommandExecutor& other); ///< Not implemented copy-constructor 136 ~CommandExecutor() {} ///< Empty destructor 134 CommandExecutor() = default; ///< Empty constructor 135 ~CommandExecutor() = default; ///< Empty destructor 136 137 // non-copyable: 138 CommandExecutor(const CommandExecutor&) = delete; 139 CommandExecutor& operator=(const CommandExecutor&) = delete; 137 140 138 141 static CommandExecutor& getInstance(); -
code/branches/cpp11_v3/src/libraries/core/command/ConsoleCommand.cc
r10624 r11054 50 50 */ 51 51 ConsoleCommand::ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized) 52 {53 this->init("", name, executor, bInitialized);52 : ConsoleCommand("", name, executor, bInitialized) 53 { 54 54 } 55 55 … … 75 75 this->baseFunctor_ = executor->getFunctor(); 76 76 77 for ( size_t i = 0; i < MAX_FUNCTOR_ARGUMENTS; ++i)78 this->argumentCompleter_[i] = 0;77 for (ArgumentCompleter*& completer : this->argumentCompleter_) 78 completer = nullptr; 79 79 80 80 this->keybindMode_ = KeybindMode::OnPress; … … 84 84 this->executor_ = executor; 85 85 86 this->names_. push_back(CommandName(group, name));86 this->names_.emplace_back(group, name); 87 87 } 88 88 … … 99 99 ConsoleCommand& ConsoleCommand::addShortcut() 100 100 { 101 this->names_. push_back(CommandName("", this->baseName_));101 this->names_.emplace_back("", this->baseName_); 102 102 return *this; 103 103 } … … 108 108 ConsoleCommand& ConsoleCommand::addShortcut(const std::string& name) 109 109 { 110 this->names_. push_back(CommandName("", name));110 this->names_.emplace_back("", name); 111 111 return *this; 112 112 } … … 117 117 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group) 118 118 { 119 this->names_. push_back(CommandName(group, this->baseName_));119 this->names_.emplace_back(group, this->baseName_); 120 120 return *this; 121 121 } … … 126 126 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string& name) 127 127 { 128 this->names_. push_back(CommandName(group, name));128 this->names_.emplace_back(group, name); 129 129 return *this; 130 130 } … … 320 320 { 321 321 if (this->executor_) 322 this->pushFunction( new Executor(*this->executor_.get()));322 this->pushFunction(std::make_shared<Executor>(*this->executor_.get())); 323 323 else 324 324 orxout(internal_error, context::commands) << "Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << endl; … … 348 348 349 349 /** 350 @brief Sets the functor to NULL(which also deactivates the command).350 @brief Sets the functor to nullptr (which also deactivates the command). 351 351 */ 352 352 void ConsoleCommand::resetFunction() 353 353 { 354 354 if (this->executor_) 355 this->executor_->setFunctor( 0);355 this->executor_->setFunctor(nullptr); 356 356 this->objectStack_.clear(); 357 357 } … … 405 405 void ConsoleCommand::popObject() 406 406 { 407 void* newobject = 0;407 void* newobject = nullptr; 408 408 if (!this->objectStack_.empty()) 409 409 { … … 422 422 return this->executor_->getFunctor()->getRawObjectPointer(); 423 423 else 424 return 0;424 return nullptr; 425 425 } 426 426 … … 528 528 return this->argumentCompleter_[index]; 529 529 else 530 return 0;530 return nullptr; 531 531 } 532 532 -
code/branches/cpp11_v3/src/libraries/core/command/ConsoleCommand.h
r10624 r11054 195 195 { if (this->command_) { this->command_->popFunction(); } return *this; } 196 196 197 /// Sets the current function-pointer to NULL, which also deactivates the command.197 /// Sets the current function-pointer to nullptr, which also deactivates the command. 198 198 inline ConsoleCommandManipulator& resetFunction() 199 199 { if (this->command_) { this->command_->resetFunction(); } return *this; } … … 205 205 inline ConsoleCommandManipulator& pushObject(void* object) 206 206 { if (this->command_) { this->command_->pushObject(object); } return *this; } 207 /// Removes the current object from the object-stack and restores the old object (or NULLif there's no object left on the stack).207 /// Removes the current object from the object-stack and restores the old object (or nullptr if there's no object left on the stack). 208 208 inline ConsoleCommandManipulator& popObject() 209 209 { if (this->command_) { this->command_->popObject(); } return *this; } -
code/branches/cpp11_v3/src/libraries/core/command/ConsoleCommandIncludes.h
r10624 r11054 316 316 ~StaticallyInitializedConsoleCommand() { delete command_; } 317 317 318 virtual void load() ;319 virtual void unload() ;318 virtual void load() override; 319 virtual void unload() override; 320 320 321 321 inline ConsoleCommand& getCommand() … … 331 331 @brief Returns a manipulator for a command with the given name. 332 332 333 @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,333 @note If the command doesn't exist, the manipulator contains a nullptr to the command, 334 334 but it can still be used without checks, because all functions of ConsoleCommandManipulator 335 335 check internally if the command exists. … … 340 340 @brief Returns a manipulator for a command with the given group and name. 341 341 342 @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,342 @note If the command doesn't exist, the manipulator contains a nullptr to the command, 343 343 but it can still be used without checks, because all functions of ConsoleCommandManipulator 344 344 check internally if the command exists. -
code/branches/cpp11_v3/src/libraries/core/command/ConsoleCommandManager.cc
r11052 r11054 39 39 namespace orxonox 40 40 { 41 ConsoleCommandManager* ConsoleCommandManager::singletonPtr_s = 0;41 ConsoleCommandManager* ConsoleCommandManager::singletonPtr_s = nullptr; 42 42 43 43 /** … … 50 50 { 51 51 // find the group 52 std::map<std::string, std::map<std::string, ConsoleCommand*> 52 std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = this->commandMap_.find(group); 53 53 if (it_group != this->commandMap_.end()) 54 54 { … … 68 68 orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl; 69 69 } 70 return 0;70 return nullptr; 71 71 } 72 72 … … 83 83 84 84 // find the group 85 std::map<std::string, std::map<std::string, ConsoleCommand*> 85 std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = this->commandMapLC_.find(groupLC); 86 86 if (it_group != this->commandMapLC_.end()) 87 87 { … … 101 101 orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl; 102 102 } 103 return 0;103 return nullptr; 104 104 } 105 105 … … 125 125 126 126 // check if a command with this name already exists 127 if (this->getCommand(group, name) != 0)127 if (this->getCommand(group, name) != nullptr) 128 128 { 129 129 if (group == "") … … 146 146 { 147 147 // iterate through all groups 148 for (std::map<std::string, std::map<std::string, ConsoleCommand*> 148 for (std::map<std::string, std::map<std::string, ConsoleCommand*>>::iterator it_group = this->commandMap_.begin(); it_group != this->commandMap_.end(); ) 149 149 { 150 150 // iterate through all commands of each group … … 168 168 169 169 // iterate through all groups 170 for (std::map<std::string, std::map<std::string, ConsoleCommand*> 170 for (std::map<std::string, std::map<std::string, ConsoleCommand*>>::iterator it_group = this->commandMapLC_.begin(); it_group != this->commandMapLC_.end(); ) 171 171 { 172 172 // iterate through all commands of each group -
code/branches/cpp11_v3/src/libraries/core/command/ConsoleCommandManager.h
r10624 r11054 39 39 #include "util/Singleton.h" 40 40 41 #include <map> 42 41 43 namespace orxonox 42 44 { … … 54 56 55 57 /// Returns the map with all groups and commands. 56 inline const std::map<std::string, std::map<std::string, ConsoleCommand*> 58 inline const std::map<std::string, std::map<std::string, ConsoleCommand*>>& getCommands() 57 59 { return this->commandMap_; } 58 60 /// Returns the map with all groups and commands in lowercase. 59 inline const std::map<std::string, std::map<std::string, ConsoleCommand*> 61 inline const std::map<std::string, std::map<std::string, ConsoleCommand*>>& getCommandsLC() 60 62 { return this->commandMapLC_; } 61 63 … … 71 73 72 74 private: 73 std::map<std::string, std::map<std::string, ConsoleCommand*> 74 std::map<std::string, std::map<std::string, ConsoleCommand*> 75 std::map<std::string, std::map<std::string, ConsoleCommand*>> commandMap_; 76 std::map<std::string, std::map<std::string, ConsoleCommand*>> commandMapLC_; 75 77 76 78 static ConsoleCommandManager* singletonPtr_s; -
code/branches/cpp11_v3/src/libraries/core/command/Executor.cc
r9550 r11054 67 67 68 68 /** 69 @brief Destructor70 */71 Executor::~Executor()72 {73 }74 75 /**76 69 @brief Calls the wrapped function with arguments that are passed in a string. 77 70 @param arguments The arguments that should be passed to the function, separated by @a delimiter 78 @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")71 @param error A pointer to a variable (or nullptr) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 79 72 @param delimiter The delimiter that is used to separate the arguments in the string @a arguments 80 73 @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments … … 89 82 @brief Calls the wrapped function with arguments that are passed as tokens in a SubString 90 83 @param arguments The arguments that should be passed to the function 91 @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")84 @param error A pointer to a variable (or nullptr) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 92 85 @param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments) 93 86 @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments … … 127 120 @param arguments The arguments that should be converted 128 121 @param arg An array of MultiType where the converted arguments will be stored 129 @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")122 @param error A pointer to a variable (or nullptr) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 130 123 @param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments) 131 124 @return Returns the number of evaluated arguments -
code/branches/cpp11_v3/src/libraries/core/command/Executor.h
r9550 r11054 42 42 orxonox::Executor is used to wrap an orxonox::Functor and to store default values for 43 43 its parameters. Usually one uses the function createExecutor() to create a new executor. 44 This function returns an orxonox::ExecutorPtr which is a typedef of @ref orxonox::SharedPtr45 "SharedPtr<Executor>",used to manage the pointer to the executor.44 This function returns an orxonox::ExecutorPtr which is a typedef of "std::shared_ptr<Executor>", 45 used to manage the pointer to the executor. 46 46 47 47 Executors are mostly used to execute callbacks. Because some callback functions need arguments, … … 74 74 @endcode 75 75 76 Because executors that were created with createExecutor() are managed by an orxonox::SharedPtr,77 they don't need to be deleted after usage.76 Executors don't need to be deleted after usage normally because they are managed by an 77 std::shared_ptr when they were created with createExecutor(). 78 78 */ 79 79 … … 100 100 Executor(const FunctorPtr& functor, const std::string& name = ""); 101 101 Executor(const Executor& other); 102 virtual ~Executor() ;102 virtual ~Executor() = default; 103 103 104 104 /// Calls the wrapped function with 0 arguments. If the function needs more arguments, the executor's default values are used. … … 121 121 { return (*this->functor_)(arg1, arg2, arg3, arg4, arg5); } 122 122 123 MultiType parse(const std::string& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const;124 MultiType parse(const SubString& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const;125 126 int evaluateArguments(const SubString& arguments, MultiType arg[MAX_FUNCTOR_ARGUMENTS], int* error = 0, const std::string& delimiter = " ") const;123 MultiType parse(const std::string& arguments, int* error = nullptr, const std::string& delimiter = " ", bool bPrintError = false) const; 124 MultiType parse(const SubString& arguments, int* error = nullptr, const std::string& delimiter = " ", bool bPrintError = false) const; 125 126 int evaluateArguments(const SubString& arguments, MultiType arg[MAX_FUNCTOR_ARGUMENTS], int* error = nullptr, const std::string& delimiter = " ") const; 127 127 128 128 /// Changes the functor. … … 249 249 250 250 /// Overloads Executor::parse() with an additional object-pointer. 251 MultiType parse(T* object, const std::string& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const251 MultiType parse(T* object, const std::string& arguments, int* error = nullptr, const std::string& delimiter = " ", bool bPrintError = false) const 252 252 { 253 253 T* oldobject = this->functorMember_->getObject(); … … 267 267 inline ExecutorPtr createExecutor(const FunctorPtr& functor, const std::string& name = "") 268 268 { 269 return new Executor(functor, name);269 return std::make_shared<Executor>(functor, name); 270 270 } 271 271 … … 274 274 inline ExecutorMemberPtr<T> createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "") 275 275 { 276 return new ExecutorMember<T>(functor, name);276 return std::make_shared<ExecutorMember<T>>(functor, name); 277 277 } 278 278 … … 280 280 inline ExecutorStaticPtr createExecutor(const FunctorStaticPtr& functor, const std::string& name = "") 281 281 { 282 return new ExecutorStatic(functor, name);282 return std::make_shared<ExecutorStatic>(functor, name); 283 283 } 284 284 } -
code/branches/cpp11_v3/src/libraries/core/command/ExecutorPtr.h
r7401 r11054 32 32 @brief Typedefs and definitions of ExecutorPtr, ExecutorStaticPtr, and ExecutorMemberPtr 33 33 34 Instances of orxonox::Executor are usually managed by an orxonox::SharedPtr. This ensures34 Instances of orxonox::Executor are usually managed by an std::shared_ptr. This ensures 35 35 that Executors will be destroyed after usage. To make things easier, there's a typedef 36 that defines ExecutorPtr as SharedPtr<Executor>.36 that defines ExecutorPtr as std::shared_ptr<Executor>. 37 37 38 38 Because there's not only orxonox::Executor, but also orxonox::ExecutorStatic, and … … 49 49 50 50 #include "core/CorePrereqs.h" 51 #include "util/SharedPtr.h"51 #include <memory> 52 52 53 53 namespace orxonox 54 54 { 55 /// ExecutorPtr is just a typedef of SharedPtr 56 typedef SharedPtr<Executor> ExecutorPtr; 57 58 /// ExecutorStaticPtr is just a typedef of SharedChildPtr 59 typedef SharedChildPtr<ExecutorStatic, ExecutorPtr> ExecutorStaticPtr; 60 61 /// It's not possible to use a typedef for ExecutorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 55 using ExecutorPtr = std::shared_ptr<Executor>; 56 using ExecutorStaticPtr = std::shared_ptr<ExecutorStatic>; 62 57 template <class T> 63 class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, ExecutorPtr> 64 { 65 public: 66 inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>() {} 67 inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(pointer) {} 68 inline ExecutorMemberPtr(const SharedPtr<ExecutorMember<T> >& other) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(other) {} 69 }; 58 using ExecutorMemberPtr = std::shared_ptr<ExecutorMember<T>>; 70 59 } 71 60 -
code/branches/cpp11_v3/src/libraries/core/command/Functor.h
r9667 r11054 40 40 41 41 To create a Functor, the helper function createFunctor() is used. It returns an instance 42 of orxonox::FunctorPtr which is simply a typedef of @ref orxonox::SharedPtr "SharedPtr<Functor>".43 Thismeans you don't have to delete the Functor after using it, because it is managed44 by the SharedPtr.42 of orxonox::FunctorPtr which is simply a typedef of "std::shared_ptr<Functor>". This 43 means you don't have to delete the Functor after using it, because it is managed 44 by the std::shared_ptr. 45 45 46 46 Example: … … 187 187 188 188 public: 189 virtual ~Functor() {}189 virtual ~Functor() = default; 190 190 191 191 /// Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function. @return Returns the return-value of the function (if any; MultiType::Null otherwise) … … 215 215 virtual void* getRawObjectPointer() const = 0; 216 216 217 /// Enables or disables the safe mode which causes the functor to change the object pointer to NULLif the object is deleted (only member functors).217 /// Enables or disables the safe mode which causes the functor to change the object pointer to nullptr if the object is deleted (only member functors). 218 218 virtual void setSafeMode(bool bSafeMode) = 0; 219 219 … … 242 242 public: 243 243 /// Constructor: Stores the object-pointer. 244 FunctorMember(O* object = 0) : object_(object), bSafeMode_(false) {}244 FunctorMember(O* object = nullptr) : object_(object), bSafeMode_(false) {} 245 245 virtual ~FunctorMember() { if (this->bSafeMode_) { this->unregisterObject(this->object_); } } 246 246 247 /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MultiType::Null otherwise)247 /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be nullptr. @return Returns the return-value of the function (if any; MultiType::Null otherwise) 248 248 virtual MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0; 249 249 250 250 // see Functor::operator()() 251 MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)251 virtual MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) override 252 252 { 253 253 // call the function if an object was assigned … … 262 262 263 263 // see Functor::getType() 264 inline Functor::Type::Enum getType() const264 virtual inline Functor::Type::Enum getType() const override 265 265 { return Functor::Type::Member; } 266 266 … … 280 280 281 281 // see Functor::setRawObjectPointer() 282 inline void setRawObjectPointer(void* object)282 virtual inline void setRawObjectPointer(void* object) override 283 283 { this->setObject((O*)object); } 284 284 // see Functor::getRawObjectPointer() 285 inline void* getRawObjectPointer() const285 virtual inline void* getRawObjectPointer() const override 286 286 { return this->object_; } 287 287 288 288 // see Functor::setSafeMode() 289 inline void setSafeMode(bool bSafeMode)289 virtual inline void setSafeMode(bool bSafeMode) override 290 290 { 291 291 if (bSafeMode == this->bSafeMode_) … … 301 301 302 302 protected: 303 /// Casts the object and registers as destruction listener. 304 inline void registerObject(O* object) 305 { Destroyable* base = dynamic_cast<Destroyable*>(object); if (base) { this->registerAsDestructionListener(base); } } 306 /// Casts the object and unregisters as destruction listener. 307 inline void unregisterObject(O* object) 308 { Destroyable* base = dynamic_cast<Destroyable*>(object); if (base) { this->unregisterAsDestructionListener(base); } } 309 310 /// Will be called by Destroyable::~Destroyable() if the stored object is deleted and the Functor is in safe mode. 311 inline void objectDeleted() 312 { this->object_ = 0; } 313 314 O* object_; ///< The stored object-pointer, used to execute a member-function (or NULL for static functions) 315 bool bSafeMode_; ///< If true, the functor is in safe mode and registers itself as listener at the object and changes the pointer to NULL if the object is deleted 303 /// Casts the object and registers as destruction listener if the object is a Destroyable. 304 inline void registerObject(Destroyable* object) 305 { this->registerAsDestructionListener(object); } 306 307 inline void registerObject(void* object) {} 308 309 /// Casts the object and unregisters as destruction listener if the object is a Destroyable. 310 inline void unregisterObject(Destroyable* object) 311 { this->unregisterAsDestructionListener(object); } 312 313 inline void unregisterObject(void* object) {} 314 315 /// Will be called by Destroyable::~Destroyable() if the stored object is a Destroyable and deleted and the Functor is in safe mode. 316 virtual inline void objectDeleted() override 317 { this->object_ = nullptr; } 318 319 O* object_; ///< The stored object-pointer, used to execute a member-function (or nullptr for static functions) 320 bool bSafeMode_; ///< If true, the functor is in safe mode and registers itself as listener at the object and changes the pointer to nullptr if the object is deleted 316 321 }; 317 322 … … 322 327 public: 323 328 /// Constructor: Stores the object-pointer. 324 FunctorMember(void* object = 0) {}325 326 /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MultiType::Null otherwise)329 FunctorMember(void* object = nullptr) {} 330 331 /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be nullptr. @return Returns the return-value of the function (if any; MultiType::Null otherwise) 327 332 virtual MultiType operator()(void* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0; 328 333 329 334 // see Functor::operator()() 330 MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)331 { 332 return (*this)((void*) 0, param1, param2, param3, param4, param5);335 virtual MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) override 336 { 337 return (*this)((void*)nullptr, param1, param2, param3, param4, param5); 333 338 } 334 339 335 340 // see Functor::getType() 336 inline Functor::Type::Enum getType() const341 virtual inline Functor::Type::Enum getType() const override 337 342 { return Functor::Type::Static; } 338 343 339 344 // see Functor::setRawObjectPointer() 340 inline void setRawObjectPointer(void*)345 virtual inline void setRawObjectPointer(void*) override 341 346 { orxout(internal_warning) << "Can't assign an object pointer to a static functor" << endl; } 342 347 // see Functor::getRawObjectPointer() 343 inline void* getRawObjectPointer() const344 { return 0; }348 virtual inline void* getRawObjectPointer() const override 349 { return nullptr; } 345 350 346 351 // see Functor::setSafeMode() 347 inline void setSafeMode(bool){}352 virtual inline void setSafeMode(bool) override {} 348 353 }; 349 354 … … 352 357 353 358 /** 354 @brief FunctorPointer is a child class of FunctorMember and ex pands it with a function-pointer.355 @param F The type of the function-pointer 356 @param O The type of the function's class (or void if it's a static function )359 @brief FunctorPointer is a child class of FunctorMember and extends it with a function-pointer (or a function-object). 360 @param F The type of the function-pointer (or the function-object) 361 @param O The type of the function's class (or void if it's a static function or a function-object) 357 362 358 363 The template FunctorPointer has an additional template parameter that defines the type 359 of the function-pointer . This can be handy if you want to get or set the function-pointer.360 You can then use a static_cast to cast a Functor to FunctorPointer if you know the type361 of the function-pointer.364 of the function-pointer (or the function-object). This can be handy if you want to get 365 or set the function-pointer (or the function-object). You can then use a static_cast 366 to cast a Functor to FunctorPointer if you know the type of the function. 362 367 363 368 However FunctorPointer is not aware of the types of the different parameters or the … … 369 374 public: 370 375 /// Constructor: Initializes the base class and stores the function-pointer. 371 FunctorPointer(F functionPointer, O* object = 0) : FunctorMember<O>(object), functionPointer_(functionPointer) {}376 FunctorPointer(F functionPointer, O* object = nullptr) : FunctorMember<O>(object), functionPointer_(functionPointer) {} 372 377 373 378 /// Changes the function-pointer. … … 378 383 { return this->functionPointer_; } 379 384 380 // see Functor::getFullIdentifier()381 const std::type_info& getFullIdentifier() const382 { return typeid(F); }383 384 385 protected: 385 386 F functionPointer_; ///< The stored function-pointer … … 388 389 namespace detail 389 390 { 390 // Helper class to get the type of the function pointer with the given class, parameters, return-value, and constness 391 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer { typedef R (O::*Type)(P1, P2, P3, P4, P5); }; 392 template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, false, P1, P2, P3, P4, P5> { typedef R (O::*Type)(P1, P2, P3, P4, P5); }; 393 template <class R, class O, class P1, class P2, class P3, class P4> struct FunctionPointer<R, O, false, P1, P2, P3, P4, void> { typedef R (O::*Type)(P1, P2, P3, P4); }; 394 template <class R, class O, class P1, class P2, class P3> struct FunctionPointer<R, O, false, P1, P2, P3, void, void> { typedef R (O::*Type)(P1, P2, P3); }; 395 template <class R, class O, class P1, class P2> struct FunctionPointer<R, O, false, P1, P2, void, void, void> { typedef R (O::*Type)(P1, P2); }; 396 template <class R, class O, class P1> struct FunctionPointer<R, O, false, P1, void, void, void, void> { typedef R (O::*Type)(P1); }; 397 template <class R, class O> struct FunctionPointer<R, O, false, void, void, void, void, void> { typedef R (O::*Type)(); }; 398 template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, true, P1, P2, P3, P4, P5> { typedef R (O::*Type)(P1, P2, P3, P4, P5) const; }; 399 template <class R, class O, class P1, class P2, class P3, class P4> struct FunctionPointer<R, O, true, P1, P2, P3, P4, void> { typedef R (O::*Type)(P1, P2, P3, P4) const; }; 400 template <class R, class O, class P1, class P2, class P3> struct FunctionPointer<R, O, true, P1, P2, P3, void, void> { typedef R (O::*Type)(P1, P2, P3) const; }; 401 template <class R, class O, class P1, class P2> struct FunctionPointer<R, O, true, P1, P2, void, void, void> { typedef R (O::*Type)(P1, P2) const; }; 402 template <class R, class O, class P1> struct FunctionPointer<R, O, true, P1, void, void, void, void> { typedef R (O::*Type)(P1) const; }; 403 template <class R, class O> struct FunctionPointer<R, O, true, void, void, void, void, void> { typedef R (O::*Type)() const; }; 404 template <class R, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, void, false, P1, P2, P3, P4, P5> { typedef R (*Type)(P1, P2, P3, P4, P5); }; 405 template <class R, class P1, class P2, class P3, class P4> struct FunctionPointer<R, void, false, P1, P2, P3, P4, void> { typedef R (*Type)(P1, P2, P3, P4); }; 406 template <class R, class P1, class P2, class P3> struct FunctionPointer<R, void, false, P1, P2, P3, void, void> { typedef R (*Type)(P1, P2, P3); }; 407 template <class R, class P1, class P2> struct FunctionPointer<R, void, false, P1, P2, void, void, void> { typedef R (*Type)(P1, P2); }; 408 template <class R, class P1> struct FunctionPointer<R, void, false, P1, void, void, void, void> { typedef R (*Type)(P1); }; 409 template <class R> struct FunctionPointer<R, void, false, void, void, void, void, void> { typedef R (*Type)(); }; 410 411 // Helper class, used to call a function-pointer with a given object and parameters and to return its return-value (if available) 412 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4, param5); } }; 413 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (object->*functionPointer)(param1, param2, param3, param4); } }; 414 template <class R, class O, bool isconst, class P1, class P2, class P3> struct FunctorCaller<R, O, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2, param3); } }; 415 template <class R, class O, bool isconst, class P1, class P2> struct FunctorCaller<R, O, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2); } }; 416 template <class R, class O, bool isconst, class P1> struct FunctorCaller<R, O, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1); } }; 417 template <class R, class O, bool isconst> struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(); } }; 418 template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } }; 419 template <class O, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (object->*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } }; 420 template <class O, bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2, param3); return MultiType::Null; } }; 421 template <class O, bool isconst, class P1, class P2> struct FunctorCaller<void, O, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2); return MultiType::Null; } }; 422 template <class O, bool isconst, class P1> struct FunctorCaller<void, O, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1); return MultiType::Null; } }; 423 template <class O, bool isconst> struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(); return MultiType::Null; } }; 424 template <class R, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4, param5); } }; 425 template <class R, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (*functionPointer)(param1, param2, param3, param4); } }; 426 template <class R, bool isconst, class P1, class P2, class P3> struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2, param3); } }; 427 template <class R, bool isconst, class P1, class P2> struct FunctorCaller<R, void, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2); } }; 428 template <class R, bool isconst, class P1> struct FunctorCaller<R, void, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1); } }; 429 template <class R, bool isconst> struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(); } }; 430 template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } }; 431 template <bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } }; 432 template <bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2, param3); return MultiType::Null; } }; 433 template <bool isconst, class P1, class P2> struct FunctorCaller<void, void, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2); return MultiType::Null; } }; 434 template <bool isconst, class P1> struct FunctorCaller<void, void, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1); return MultiType::Null; } }; 435 template <bool isconst> struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(); return MultiType::Null; } }; 436 437 // Helper class, used to identify the header of a function-pointer (independent of its class) 438 template <class R, class P1, class P2, class P3, class P4, class P5> 439 struct FunctorHeaderIdentifier 440 {}; 391 // Helper class to get the type of the function-pointer (or the function-object) with the given class, parameters, return-value, and constness 392 template <class F, class R, class O, bool isconst, class... Params> struct FunctionType /* generic type is undefined */; 393 template < class R, class O, class... Params> struct FunctionType<void, R, O, false, Params...> { typedef R (O::*Type)(Params...); }; // spezialization: non-const member function 394 template < class R, class O, class... Params> struct FunctionType<void, R, O, true, Params...> { typedef R (O::*Type)(Params...) const; }; // spezialization: const member function 395 template < class R, class... Params> struct FunctionType<void, R, void, false, Params...> { typedef R (*Type)(Params...); }; // spezialization: static function 396 template <class F, class R, class... Params> struct FunctionType<F, R, void, false, Params...> { typedef F Type; }; // spezialization: function object 397 398 // Helper class, used to call a function with a given object and parameters and to return its return-value (if available) 399 template <class F, class R, class O, bool isconst, class... Params> struct FunctorCaller /* generic type is undefined */; 400 template < class R, class O, bool isconst, class... Params> struct FunctorCaller<void, R, O, isconst, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, R, O, isconst, Params...>::Type functionPointer, O* object, const Params&... parameters, const UnusedParams&...) { return (object->*functionPointer)(parameters...); } }; // spezialization: member function with return value 401 template < class O, bool isconst, class... Params> struct FunctorCaller<void, void, O, isconst, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, void, O, isconst, Params...>::Type functionPointer, O* object, const Params&... parameters, const UnusedParams&...) { (object->*functionPointer)(parameters...); return MultiType::Null; } }; // spezialization: member function without return value 402 template < class R, class... Params> struct FunctorCaller<void, R, void, false, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, R, void, false, Params...>::Type functionPointer, void*, const Params&... parameters, const UnusedParams&...) { return (*functionPointer)(parameters...); } }; // spezialization: static function with return value 403 template < class... Params> struct FunctorCaller<void, void, void, false, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, void, void, false, Params...>::Type functionPointer, void*, const Params&... parameters, const UnusedParams&...) { (*functionPointer)(parameters...); return MultiType::Null; } }; // spezialization: static function without return value 404 template <class F, class R, class... Params> struct FunctorCaller<F, R, void, false, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<F, R, void, false, Params...>::Type functor, void*, const Params&... parameters, const UnusedParams&...) { return functor(parameters...); } }; // spezialization: function object with return value 405 template <class F, class... Params> struct FunctorCaller<F, void, void, false, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<F, void, void, false, Params...>::Type functor, void*, const Params&... parameters, const UnusedParams&...) { functor(parameters...); return MultiType::Null; } }; // spezialization: function object without return value 441 406 442 407 // Helper class to determine if a function has a returnvalue … … 448 413 { enum { result = false }; }; 449 414 450 // Helper class to count the number of parameters 451 template <class P1, class P2, class P3, class P4, class P5> 452 struct FunctorParamCount 453 { enum { result = 5 }; }; 454 template <class P1, class P2, class P3, class P4> 455 struct FunctorParamCount<P1, P2, P3, P4, void> 456 { enum { result = 4 }; }; 457 template <class P1, class P2, class P3> 458 struct FunctorParamCount<P1, P2, P3, void, void> 459 { enum { result = 3 }; }; 460 template <class P1, class P2> 461 struct FunctorParamCount<P1, P2, void, void, void> 462 { enum { result = 2 }; }; 463 template <class P1> 464 struct FunctorParamCount<P1, void, void, void, void> 465 { enum { result = 1 }; }; 415 // Helper class to determine the N-th parameter of a variadic template (with 0 being the index of the first parameter) 416 template <int n, typename T = void, typename... Other> 417 struct GetNthParamType 418 { typedef typename GetNthParamType<n - 1, Other...>::Type Type; }; 419 template <typename T, typename... Other> 420 struct GetNthParamType<0, T, Other...> 421 { typedef T Type; }; 422 423 // Helper structs to deduce the first N types of a parameter pack 424 template<class... Types> struct type_list {}; 425 426 template <class T1, class... AllTypes> 427 struct make_type_list_helper 428 { 429 template <std::size_t N, class... Types> 430 struct make_type_list_impl : make_type_list_helper<AllTypes...>::template make_type_list_impl<N - 1, Types..., T1> {}; 431 432 template <class... Types> 433 struct make_type_list_impl<1u, Types...> : type_list<Types..., T1> {}; 434 }; 435 436 template <class T1> 437 struct make_type_list_helper<T1> 438 { 439 template <std::size_t N, class... Types> 440 struct make_type_list_impl : type_list<Types..., T1> {}; 441 }; 442 443 template <std::size_t N, class... Types> 444 struct make_type_list : make_type_list_helper<Types...>::template make_type_list_impl<N> {}; 445 446 template <class... Types> 447 struct make_type_list<0u, Types...> : type_list<> {}; 448 449 template <std::size_t N> 450 struct make_type_list<N> : type_list<> {}; 451 466 452 template <> 467 struct FunctorParamCount<void, void, void, void, void> 468 { enum { result = 0 }; }; 453 struct make_type_list<0u> : type_list<> {}; 469 454 } 470 455 … … 473 458 that need to know the exact types of the parameters, return-value, and class. 474 459 460 @param F the type of the function-object (or void if a function-pointer is used). 475 461 @param R The type of the return-value of the function 476 462 @param O The class of the function 477 463 @param isconst True if the function is a const member-function 478 @param P1 The type of the first parameter 479 @param P2 The type of the second parameter 480 @param P3 The type of the third parameter 481 @param P4 The type of the fourth parameter 482 @param P5 The type of the fifth parameter 464 @param Params The types of the parameters 483 465 484 466 This template has many parameters and is usually not used directly. It is created by … … 489 471 All template arguments can be void. 490 472 */ 491 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> 492 class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O> 493 { 473 template <class F, class R, class O, bool isconst, class... Params> 474 class FunctorTemplate : public FunctorPointer<typename detail::FunctionType<F, R, O, isconst, Params...>::Type, O> 475 { 476 static_assert(sizeof...(Params) <= 5, "Only up to 5 parameters are supported"); 477 494 478 public: 495 479 /// Constructor: Initializes the base class. 496 FunctorTemplate(typename detail::Function Pointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object = 0) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>(functionPointer, object) {}480 FunctorTemplate(typename detail::FunctionType<F, R, O, isconst, Params...>::Type functionPointer, O* object = nullptr) : FunctorPointer<typename detail::FunctionType<F, R, O, isconst, Params...>::Type, O>(functionPointer, object) {} 497 481 498 482 // see FunctorMember::operator()() 499 MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)500 { 501 return detail::FunctorCaller< R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);483 virtual MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) override 484 { 485 return detail::FunctorCaller<F, R, O, isconst, Params...>::call(this->functionPointer_, object, param1, param2, param3, param4, param5); 502 486 } 503 487 504 488 // see Functor::clone() 505 FunctorPtr clone()506 { 507 return new FunctorTemplate(*this);489 virtual FunctorPtr clone() override 490 { 491 return std::make_shared<FunctorTemplate>(*this); 508 492 } 509 493 510 494 // see Functor::evaluateArgument() 511 v oid evaluateArgument(unsigned int index, MultiType& argument) const495 virtual void evaluateArgument(unsigned int index, MultiType& argument) const override 512 496 { 513 497 switch (index) 514 498 { 515 case 0: argument.convert< P1>(); break;516 case 1: argument.convert< P2>(); break;517 case 2: argument.convert< P3>(); break;518 case 3: argument.convert< P4>(); break;519 case 4: argument.convert< P5>(); break;499 case 0: argument.convert<typename detail::GetNthParamType<0, Params...>::Type>(); break; 500 case 1: argument.convert<typename detail::GetNthParamType<1, Params...>::Type>(); break; 501 case 2: argument.convert<typename detail::GetNthParamType<2, Params...>::Type>(); break; 502 case 3: argument.convert<typename detail::GetNthParamType<3, Params...>::Type>(); break; 503 case 4: argument.convert<typename detail::GetNthParamType<4, Params...>::Type>(); break; 520 504 } 521 505 } 522 506 523 507 // see Functor::getParamCount() 524 unsigned int getParamCount() const525 { 526 return detail::FunctorParamCount<P1, P2, P3, P4, P5>::result;508 virtual unsigned int getParamCount() const override 509 { 510 return sizeof...(Params); 527 511 } 528 512 529 513 // see Functor::hasReturnvalue() 530 bool hasReturnvalue() const514 virtual bool hasReturnvalue() const override 531 515 { 532 516 return detail::FunctorHasReturnvalue<R>::result; … … 534 518 535 519 // see Functor::getTypenameParam() 536 std::string getTypenameParam(unsigned int index) const520 virtual std::string getTypenameParam(unsigned int index) const override 537 521 { 538 522 switch (index) 539 523 { 540 case 0: return typeToString< P1>();541 case 1: return typeToString< P2>();542 case 2: return typeToString< P3>();543 case 3: return typeToString< P4>();544 case 4: return typeToString< P5>();524 case 0: return typeToString<typename detail::GetNthParamType<0, Params...>::Type>(); 525 case 1: return typeToString<typename detail::GetNthParamType<1, Params...>::Type>(); 526 case 2: return typeToString<typename detail::GetNthParamType<2, Params...>::Type>(); 527 case 3: return typeToString<typename detail::GetNthParamType<3, Params...>::Type>(); 528 case 4: return typeToString<typename detail::GetNthParamType<4, Params...>::Type>(); 545 529 default: return ""; 546 530 } … … 548 532 549 533 // see Functor::getTypenameReturnvalue() 550 std::string getTypenameReturnvalue() const534 virtual std::string getTypenameReturnvalue() const override 551 535 { 552 536 return typeToString<R>(); 553 537 } 554 538 539 // see Functor::getFullIdentifier() 540 virtual const std::type_info& getFullIdentifier() const override 541 { 542 return typeid(typename detail::FunctionType<void, R, O, isconst, Params...>::Type); 543 } 544 555 545 // see Functor::getHeaderIdentifier() 556 const std::type_info& getHeaderIdentifier() const557 { 558 return typeid( detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);546 virtual const std::type_info& getHeaderIdentifier() const override 547 { 548 return typeid(typename detail::FunctionType<void, R, void, false, Params...>::Type); 559 549 } 560 550 561 551 // see Functor::getHeaderIdentifier(unsigned int) 562 const std::type_info& getHeaderIdentifier(unsigned int params) const552 virtual const std::type_info& getHeaderIdentifier(unsigned int params) const override 563 553 { 564 554 switch (params) 565 555 { 566 case 0: return t ypeid(detail::FunctorHeaderIdentifier<R, void, void, void, void, void>);567 case 1: return t ypeid(detail::FunctorHeaderIdentifier<R, P1, void, void, void, void>);568 case 2: return t ypeid(detail::FunctorHeaderIdentifier<R, P1, P2, void, void, void>);569 case 3: return t ypeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, void, void>);570 case 4: return t ypeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, void>);571 default: return t ypeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);556 case 0: return this->getTypelistIdentifier(detail::make_type_list<0, Params...>{}); 557 case 1: return this->getTypelistIdentifier(detail::make_type_list<1, Params...>{}); 558 case 2: return this->getTypelistIdentifier(detail::make_type_list<2, Params...>{}); 559 case 3: return this->getTypelistIdentifier(detail::make_type_list<3, Params...>{}); 560 case 4: return this->getTypelistIdentifier(detail::make_type_list<4, Params...>{}); 561 default: return this->getTypelistIdentifier(detail::make_type_list<5, Params...>{}); 572 562 } 573 563 } 564 565 private: 566 /// Helper function that deduces a parameter pack of types and returns the corresponding identifier 567 template<class... Types> 568 const std::type_info& getTypelistIdentifier(detail::type_list<Types...>) const 569 { 570 return typeid(typename detail::FunctionType<void, R, void, false, Types...>::Type); 571 } 574 572 }; 575 573 576 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 577 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 578 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 579 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 580 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 581 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 582 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 583 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 584 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 585 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 586 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 587 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 588 589 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 590 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 591 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 592 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2)) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 593 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1)) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 594 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)()) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 595 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 596 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 597 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 598 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 599 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 600 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 601 602 template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new Functor with the given function-pointer 603 template <class R, class P1, class P2, class P3, class P4> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 604 template <class R, class P1, class P2, class P3> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, void, false, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 605 template <class R, class P1, class P2> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2)) { return new FunctorTemplate<R, void, false, P1, P2, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 606 template <class R, class P1> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1)) { return new FunctorTemplate<R, void, false, P1, void, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 607 template <class R> inline FunctorStaticPtr createFunctor(R (*functionPointer)()) { return new FunctorTemplate<R, void, false, void, void, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 574 575 namespace detail 576 { 577 // Helper functions to deduce types and constness of operator() and return the correct FunctorTemplate 578 template <class F> 579 struct CallableHelper 580 { 581 template <class R, class... Params> static inline FunctorStaticPtr create(const F& functionObject, R(F::*)(Params...)) { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); } 582 template <class R, class... Params> static inline FunctorStaticPtr create(const F& functionObject, R(F::*)(Params...) const) { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); } // note: both const and non-const function-objects are treated as static functors with isconst=false. 583 }; 584 } 585 586 template <class R, class O, class OO, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...), OO* object) { return std::make_shared<FunctorTemplate<void, R, O, false, Params...>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 587 template <class R, class O, class OO, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...) const, OO* object) { return std::make_shared<FunctorTemplate<void, R, O, true, Params...>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 588 589 template <class R, class O, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...)) { return std::make_shared<FunctorTemplate<void, R, O, false, Params...>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 590 template <class R, class O, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...) const) { return std::make_shared<FunctorTemplate<void, R, O, true, Params...>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 591 592 template <class R, class... Params> inline FunctorStaticPtr createFunctor(R (*functionPointer)(Params...)) { return std::make_shared<FunctorTemplate<void, R, void, false, Params...>>(functionPointer); } ///< Creates a new FunctorStatic with the given function-pointer 593 594 /** Take care that this functor does not outlive objects that have been captured by reference in a lambda. */ 595 template <class F> inline FunctorStaticPtr createFunctor(const F& functionObject) { return detail::CallableHelper<F>::create(functionObject, &F::operator()); } ///< Creates a new Functor with a callable object 608 596 } 609 597 -
code/branches/cpp11_v3/src/libraries/core/command/FunctorPtr.h
r7401 r11054 32 32 @brief Typedefs and definitions of FunctorPtr, FunctorMemberPtr, FunctorStaticPtr, and FunctorPointerPtr 33 33 34 Instances of orxonox::Functor are usually managed by an orxonox::SharedPtr. This ensures34 Instances of orxonox::Functor are usually managed by an std::shared_ptr. This ensures 35 35 that Functors will be destroyed after usage. To make things easier, there's a typedef 36 that defines FunctorPtr as SharedPtr<Functor>.36 that defines FunctorPtr as std::shared_ptr<Functor>. 37 37 38 38 Because there's not only orxonox::Functor, but also orxonox::FunctorStatic, and … … 51 51 52 52 #include "core/CorePrereqs.h" 53 #include "util/SharedPtr.h"53 #include <memory> 54 54 55 55 namespace orxonox 56 56 { 57 /// FunctorPtr is just a typedef of SharedPtr 58 typedef SharedPtr<Functor> FunctorPtr; 59 60 /// It's not possible to use a typedef for FunctorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 57 using FunctorPtr = std::shared_ptr<Functor>; 61 58 template <class T> 62 class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr> 63 { 64 public: 65 inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, FunctorPtr>() {} 66 inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {} 67 inline FunctorMemberPtr(const SharedPtr<FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {} 68 }; 69 70 /// FunctorStaticPtr is just FunctorMemberPtr with @a T = void 71 typedef FunctorMemberPtr<void> FunctorStaticPtr; 72 73 /// It's not possible to use a typedef for FunctorPointerPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 59 using FunctorMemberPtr = std::shared_ptr<FunctorMember<T>>; 60 using FunctorStaticPtr = std::shared_ptr<FunctorMember<void>>; 74 61 template <class F, class T> 75 class FunctorPointerPtr : public SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> > 76 { 77 public: 78 inline FunctorPointerPtr() : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >() {} 79 inline FunctorPointerPtr(FunctorPointer<F, T>* pointer) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(pointer) {} 80 inline FunctorPointerPtr(const SharedPtr<FunctorPointer<F, T> >& other) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(other) {} 81 }; 62 using FunctorPointerPtr = std::shared_ptr<FunctorPointer<F, T>>; 82 63 } 83 64 -
code/branches/cpp11_v3/src/libraries/core/command/IOConsolePOSIX.cc
r9667 r11054 44 44 namespace orxonox 45 45 { 46 IOConsole* IOConsole::singletonPtr_s = NULL;46 IOConsole* IOConsole::singletonPtr_s = nullptr; 47 47 48 48 namespace EscapeMode … … 62 62 , promptString_("orxonox # ") 63 63 , bStatusPrinted_(false) 64 , originalTerminalSettings_( 0)64 , originalTerminalSettings_(nullptr) 65 65 { 66 66 this->setTerminalMode(); … … 326 326 tcsetattr(0, TCSANOW, IOConsole::singletonPtr_s->originalTerminalSettings_); 327 327 delete IOConsole::singletonPtr_s->originalTerminalSettings_; 328 IOConsole::singletonPtr_s->originalTerminalSettings_ = 0;328 IOConsole::singletonPtr_s->originalTerminalSettings_ = nullptr; 329 329 } 330 330 } … … 353 353 const char* s; 354 354 if (!this->terminalWidth_ && (s = getenv("COLUMNS"))) 355 this->terminalWidth_ = strtol(s, NULL, 10);355 this->terminalWidth_ = strtol(s, nullptr, 10); 356 356 if (!this->terminalWidth_) 357 357 this->terminalWidth_ = 80; 358 358 if (!this->terminalHeight_ && (s = getenv("LINES"))) 359 this->terminalHeight_ = strtol(s, NULL, 10);359 this->terminalHeight_ = strtol(s, nullptr, 10); 360 360 if (!this->terminalHeight_) 361 361 this->terminalHeight_ = 24; -
code/branches/cpp11_v3/src/libraries/core/command/IOConsolePOSIX.h
r8858 r11054 65 65 66 66 // Methods from ShellListener 67 v oid linesChanged();68 v oid lineAdded();69 v oid inputChanged();70 v oid cursorChanged();71 v oid executed();72 v oid exit();67 virtual void linesChanged() override; 68 virtual void lineAdded() override; 69 virtual void inputChanged() override; 70 virtual void cursorChanged() override; 71 virtual void executed() override; 72 virtual void exit() override; 73 73 74 74 bool willPrintStatusLines(); -
code/branches/cpp11_v3/src/libraries/core/command/IOConsoleWindows.cc
r9676 r11054 41 41 namespace orxonox 42 42 { 43 IOConsole* IOConsole::singletonPtr_s = NULL;43 IOConsole* IOConsole::singletonPtr_s = nullptr; 44 44 45 45 //! Redirects std::cout, creates the corresponding Shell and changes the terminal mode … … 300 300 this->terminalWidth_ - 1, this->inputLineRow_ + this->inputLineHeight_ + this->statusLines_ - 1); 301 301 this->inputLineRow_ += linesDown; 302 ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, this->inputLineRow_), &fillChar);302 ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, nullptr, makeCOORD(0, this->inputLineRow_), &fillChar); 303 303 // Move cursor down to the new bottom so the user can see the status lines 304 304 COORD pos = makeCOORD(0, this->inputLineRow_ + this->inputLineHeight_ - 1 + this->statusLines_); … … 312 312 // Scroll output up 313 313 SMALL_RECT oldRect = makeSMALL_RECT(0, lines - linesDown, this->terminalWidth_ - 1, this->inputLineRow_ - 1); 314 ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, 0), &fillChar);314 ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, nullptr, makeCOORD(0, 0), &fillChar); 315 315 } 316 316 } … … 360 360 SMALL_RECT oldRect = makeSMALL_RECT(0, statusLineRow, this->terminalWidth_ - 1, statusLineRow + this->statusLines_); 361 361 CHAR_INFO fillChar = {{' '}, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED}; 362 ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, statusLineRow + newLines), &fillChar);362 ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, nullptr, makeCOORD(0, statusLineRow + newLines), &fillChar); 363 363 // Clear potential leftovers 364 364 if (-newLines - this->statusLines_ > 0) -
code/branches/cpp11_v3/src/libraries/core/command/IOConsoleWindows.h
r9676 r11054 67 67 68 68 // Methods from ShellListener 69 v oid linesChanged();70 v oid lineAdded();71 v oid inputChanged();72 v oid cursorChanged();73 v oid executed();74 v oid exit();69 virtual void linesChanged() override; 70 virtual void lineAdded() override; 71 virtual void inputChanged() override; 72 virtual void cursorChanged() override; 73 virtual void executed() override; 74 virtual void exit() override; 75 75 76 76 void resetTerminalMode(); -
code/branches/cpp11_v3/src/libraries/core/command/IRC.cc
r10624 r11054 44 44 namespace orxonox 45 45 { 46 static const unsigned int IRC_TCL_THREADID = 1421421421; ///< The ID of the thread in TclThreadManager that is used for the IRC connection46 static constexpr unsigned int IRC_TCL_THREADID = 1421421421; ///< The ID of the thread in TclThreadManager that is used for the IRC connection 47 47 48 48 SetConsoleCommand("IRC", "say", &IRC::say); … … 66 66 IRC::IRC() 67 67 { 68 this->interpreter_ = 0;68 this->interpreter_ = nullptr; 69 69 } 70 70 -
code/branches/cpp11_v3/src/libraries/core/command/IRC.h
r7401 r11054 65 65 66 66 IRC(); 67 IRC(const IRC& other); ///< Copy-constructor: Not implemented 68 ~IRC() {} ///< Destructor 67 ~IRC() = default; 68 69 // non-copyable: 70 IRC(const IRC&) = delete; 71 IRC& operator=(const IRC&) = delete; 69 72 70 73 Tcl::interpreter* interpreter_; ///< The Tcl interpreter that is used for the IRC connection -
code/branches/cpp11_v3/src/libraries/core/command/Shell.cc
r10624 r11054 258 258 vectorize(text, '\n', &lines); 259 259 260 for ( size_t i = 0; i < lines.size(); ++i)261 this->addLine(line s[i], type);260 for (const std::string& line : lines) 261 this->addLine(line, type); 262 262 } 263 263 -
code/branches/cpp11_v3/src/libraries/core/command/Shell.h
r10624 r11054 61 61 62 62 public: 63 virtual ~ShellListener() {} 63 ShellListener() = default; 64 virtual ~ShellListener() = default; 64 65 65 66 private: … … 128 129 const std::string& getInput() const; 129 130 130 typedef std::list<std::pair<std::string, LineType> 131 typedef std::list<std::pair<std::string, LineType>> LineList; 131 132 LineList::const_iterator getNewestLineIterator() const; 132 133 LineList::const_iterator getEndIterator() const; … … 148 149 149 150 private: 150 Shell(const Shell& other); 151 // non-copyable: 152 Shell(const Shell&) = delete; 153 Shell& operator=(const Shell&) = delete; 151 154 152 155 // DevModeListener 153 v oid devModeChanged(bool value);156 virtual void devModeChanged(bool value) override; 154 157 155 158 void addToHistory(const std::string& command); … … 157 160 void clearInput(); 158 161 // BaseWriter 159 virtual void printLine(const std::string& line, OutputLevel level) ;162 virtual void printLine(const std::string& line, OutputLevel level) override; 160 163 161 164 void configureInputBuffer(); -
code/branches/cpp11_v3/src/libraries/core/command/TclBind.cc
r10624 r11054 47 47 SetConsoleCommand("bgerror", &TclBind::bgerror).hide(); 48 48 49 TclBind* TclBind::singletonPtr_s = 0;49 TclBind* TclBind::singletonPtr_s = nullptr; 50 50 51 51 /** … … 55 55 TclBind::TclBind(const std::string& datapath) 56 56 { 57 this->interpreter_ = 0;57 this->interpreter_ = nullptr; 58 58 this->bSetTclDataPath_ = false; 59 59 this->setDataPath(datapath); … … 228 228 @brief Executes Tcl-code and returns the return-value. 229 229 @param tclcode A string that contains Tcl-code 230 @param error A pointer to an integer (or NULL) that is used to write an error-code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")230 @param error A pointer to an integer (or nullptr) that is used to write an error-code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 231 231 @return Returns the return-value of the executed code (or an empty string if there's no return-value) 232 232 */ -
code/branches/cpp11_v3/src/libraries/core/command/TclBind.h
r8079 r11054 121 121 static void tcl_execute(Tcl::object const &args); 122 122 123 static std::string eval(const std::string& tclcode, int* error = 0);123 static std::string eval(const std::string& tclcode, int* error = nullptr); 124 124 125 125 private: 126 TclBind(const TclBind& other); ///< Copy-constructor, not implemented 126 // non-copyable: 127 TclBind(const TclBind&) = delete; 128 TclBind& operator=(const TclBind&) = delete; 127 129 128 130 static std::string tcl_helper(Tcl::object const &args, bool bQuery); -
code/branches/cpp11_v3/src/libraries/core/command/TclThreadList.h
r7401 r11054 262 262 boost::shared_lock<boost::shared_mutex> lock(this->mutex_); 263 263 264 for ( typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)265 if ( *it == value)264 for (const T& element : this->list_) 265 if (element == value) 266 266 return true; 267 267 -
code/branches/cpp11_v3/src/libraries/core/command/TclThreadManager.cc
r10624 r11054 34 34 #include "TclThreadManager.h" 35 35 36 #include < boost/bind.hpp>36 #include <functional> 37 37 #include <boost/thread/thread.hpp> 38 38 #include <boost/thread/locks.hpp> … … 86 86 }; 87 87 88 TclThreadManager* TclThreadManager::singletonPtr_s = 0;88 TclThreadManager* TclThreadManager::singletonPtr_s = nullptr; 89 89 90 90 /** … … 145 145 { 146 146 boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_); 147 for ( std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)147 for (const auto& mapEntry : this->interpreterBundles_) 148 148 { 149 if ( it->first == 0)149 if (mapEntry.first == 0) 150 150 continue; // We'll handle the default interpreter later (and without threads of course) 151 151 152 TclInterpreterBundle* bundle = it->second;152 TclInterpreterBundle* bundle = mapEntry.second; 153 153 if (!bundle->queue_.empty()) 154 154 { … … 163 163 { 164 164 // Start a thread to execute the command 165 boost::thread( boost::bind(&tclThread, bundle, command));165 boost::thread(std::bind(&tclThread, bundle, command)); 166 166 } 167 167 else … … 289 289 catch (const Tcl::tcl_error& e) 290 290 { 291 bundle->interpreter_ = 0;291 bundle->interpreter_ = nullptr; 292 292 orxout(user_error, context::tcl) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << endl; 293 293 } … … 488 488 void TclThreadManager::source(const std::string& file) 489 489 { 490 boost::thread( boost::bind(&sourceThread, file));490 boost::thread(std::bind(&sourceThread, file)); 491 491 } 492 492 … … 521 521 { 522 522 TclThreadManager::error("No Tcl-interpreter with ID " + multi_cast<std::string>(id) + " existing."); 523 return 0;523 return nullptr; 524 524 } 525 525 } … … 551 551 552 552 std::list<unsigned int> threads; 553 for ( std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)554 if ( it->first > 0 && it->first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters)555 threads.push_back( it->first);553 for (const auto& mapEntry : this->interpreterBundles_) 554 if (mapEntry.first > 0 && mapEntry.first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters) 555 threads.push_back(mapEntry.first); 556 556 return threads; 557 557 } -
code/branches/cpp11_v3/src/libraries/core/commandline/CommandLineIncludes.h
r10535 r11054 64 64 ~StaticallyInitializedCommandLineArgument() { delete argument_; } 65 65 66 virtual void load() 66 virtual void load() override 67 67 { CommandLineParser::addArgument(this->argument_); } 68 68 69 virtual void unload() 69 virtual void unload() override 70 70 { CommandLineParser::removeArgument(this->argument_); } 71 71 -
code/branches/cpp11_v3/src/libraries/core/commandline/CommandLineParser.cc
r10542 r11054 40 40 namespace orxonox 41 41 { 42 CommandLineParser* CommandLineParser::singletonPtr_s = 0;42 CommandLineParser* CommandLineParser::singletonPtr_s = nullptr; 43 43 44 44 /** … … 110 110 { 111 111 // first shove all the shortcuts in a map 112 for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin(); 113 it != cmdLineArgs_.end(); ++it) 112 for (const auto& mapEntry : cmdLineArgs_) 114 113 { 115 OrxAssert(cmdLineArgsShortcut_.find( it->second->getShortcut()) == cmdLineArgsShortcut_.end(),114 OrxAssert(cmdLineArgsShortcut_.find(mapEntry.second->getShortcut()) == cmdLineArgsShortcut_.end(), 116 115 "Cannot have two command line shortcut with the same name."); 117 if (! it->second->getShortcut().empty())118 cmdLineArgsShortcut_[ it->second->getShortcut()] = it->second;116 if (!mapEntry.second->getShortcut().empty()) 117 cmdLineArgsShortcut_[mapEntry.second->getShortcut()] = mapEntry.second; 119 118 } 120 119 bFirstTimeParse_ = false; … … 124 123 std::string shortcut; 125 124 std::string value; 126 for ( unsigned int i = 0; i < arguments.size(); ++i)127 { 128 if (argument s[i].size() != 0)125 for (const std::string& argument : arguments) 126 { 127 if (argument.size() != 0) 129 128 { 130 129 // sure not "" 131 if (argument s[i][0] == '-')130 if (argument[0] == '-') 132 131 { 133 132 // start with "-" 134 if (argument s[i].size() == 1)133 if (argument.size() == 1) 135 134 { 136 135 // argument[i] is "-", probably a minus sign 137 136 value += "- "; 138 137 } 139 else if (argument s[i][1] <= 57 && arguments[i][1] >= 48)138 else if (argument[1] <= 57 && argument[1] >= 48) 140 139 { 141 140 // negative number as a value 142 value += argument s[i]+ ' ';141 value += argument + ' '; 143 142 } 144 143 else … … 161 160 } 162 161 163 if (argument s[i][1] == '-')162 if (argument[1] == '-') 164 163 { 165 164 // full name argument with "--name" 166 name = argument s[i].substr(2);165 name = argument.substr(2); 167 166 } 168 167 else 169 168 { 170 169 // shortcut with "-s" 171 shortcut = argument s[i].substr(1);170 shortcut = argument.substr(1); 172 171 } 173 172 … … 186 185 187 186 // Concatenate strings as long as there's no new argument by "-" or "--" 188 value += argument s[i]+ ' ';187 value += argument + ' '; 189 188 } 190 189 } … … 257 256 // determine maximum name size 258 257 size_t maxNameSize = 0; 259 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin(); 260 it != inst.cmdLineArgs_.end(); ++it) 261 { 262 maxNameSize = std::max(it->second->getName().size(), maxNameSize); 258 for (const auto& mapEntry : inst.cmdLineArgs_) 259 { 260 maxNameSize = std::max(mapEntry.second->getName().size(), maxNameSize); 263 261 } 264 262 … … 267 265 infoStr << "Available options:" << endl; 268 266 269 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin(); 270 it != inst.cmdLineArgs_.end(); ++it) 271 { 272 if (!it->second->getShortcut().empty()) 273 infoStr << " [-" << it->second->getShortcut() << "] "; 267 for (const auto& mapEntry : inst.cmdLineArgs_) 268 { 269 if (!mapEntry.second->getShortcut().empty()) 270 infoStr << " [-" << mapEntry.second->getShortcut() << "] "; 274 271 else 275 272 infoStr << " "; 276 infoStr << "--" << it->second->getName() << ' ';277 if ( it->second->getValue().isType<bool>())273 infoStr << "--" << mapEntry.second->getName() << ' '; 274 if (mapEntry.second->getValue().isType<bool>()) 278 275 infoStr << " "; 279 276 else 280 277 infoStr << "ARG "; 281 278 // fill with the necessary amount of blanks 282 infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');283 infoStr << ": " << it->second->getInformation();279 infoStr << std::string(maxNameSize - mapEntry.second->getName().size(), ' '); 280 infoStr << ": " << mapEntry.second->getInformation(); 284 281 infoStr << endl; 285 282 } -
code/branches/cpp11_v3/src/libraries/core/commandline/CommandLineParser.h
r10542 r11054 107 107 108 108 private: 109 //! Undefined copy constructor 110 CommandLineArgument(const CommandLineArgument& instance); 109 // non-copyable: 110 CommandLineArgument(const CommandLineArgument&) = delete; 111 CommandLineArgument& operator=(const CommandLineArgument&) = delete; 111 112 112 113 //! Parses the value string of a command line argument. -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFile.cc
r10624 r11054 35 35 36 36 #include <boost/filesystem.hpp> 37 38 #include <iterator> 39 #include <algorithm> 40 #include <fstream> 37 41 38 42 #include "util/Convert.h" … … 93 97 try 94 98 { 95 boost::filesystem::copy_file(defaultFilepath, filepath); 99 std::ifstream input(defaultFilepath.string().c_str(), std::ifstream::in | std::ifstream::binary); 100 std::ofstream output(filepath.string().c_str(), std::ofstream::out | std::ofstream::binary); 101 copy(std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>(), std::ostream_iterator<char>(output)); 96 102 orxout(internal_info, context::config) << "Copied " << this->filename_ << " from the default config folder." << endl; 97 103 } … … 108 114 if (file.is_open()) 109 115 { 110 ConfigFileSection* newsection = 0;116 ConfigFileSection* newsection = nullptr; 111 117 112 118 while (file.good() && !file.eof()) … … 135 141 } 136 142 137 if (newsection != 0)143 if (newsection != nullptr) 138 144 { 139 145 if (isComment(line)) … … 228 234 } 229 235 230 for ( std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)231 { 232 file << (*it)->getFileEntry() << endl;233 234 for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)236 for (ConfigFileSection* section : this->sections_) 237 { 238 file << section->getFileEntry() << endl; 239 240 for (std::list<ConfigFileEntry*>::const_iterator it_entries = section->getEntriesBegin(); it_entries != section->getEntriesEnd(); ++it_entries) 235 241 file << (*it_entries)->getFileEntry() << endl; 236 242 … … 270 276 271 277 /** 272 @brief Returns a pointer to the section with given name (or NULLif the section doesn't exist).273 */ 274 ConfigFileSection* ConfigFile::getSection(const std::string& section ) const275 { 276 for ( std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)277 if ( (*it)->getName() == section)278 return (*it);279 return NULL;278 @brief Returns a pointer to the section with given name (or nullptr if the section doesn't exist). 279 */ 280 ConfigFileSection* ConfigFile::getSection(const std::string& sectionName) const 281 { 282 for (ConfigFileSection* section : this->sections_) 283 if (section->getName() == sectionName) 284 return section; 285 return nullptr; 280 286 } 281 287 … … 283 289 @brief Returns a pointer to the section with given name. If it doesn't exist, the section is created. 284 290 */ 285 ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& section )286 { 287 for ( std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)288 if ( (*it)->getName() == section)289 return (*it);291 ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& sectionName) 292 { 293 for (ConfigFileSection* section : this->sections_) 294 if (section->getName() == sectionName) 295 return section; 290 296 291 297 this->bUpdated_ = true; 292 298 293 return (*this->sections_.insert(this->sections_.end(), new ConfigFileSection(section )));299 return (*this->sections_.insert(this->sections_.end(), new ConfigFileSection(sectionName))); 294 300 } 295 301 … … 301 307 bool sectionsUpdated = false; 302 308 303 for ( std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)304 { 305 if ( (*it)->bUpdated_)309 for (ConfigFileSection* section : this->sections_) 310 { 311 if (section->bUpdated_) 306 312 { 307 313 sectionsUpdated = true; 308 (*it)->bUpdated_ = false;314 section->bUpdated_ = false; 309 315 } 310 316 } -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFileEntry.h
r9559 r11054 51 51 public: 52 52 /// Destructor 53 virtual ~ConfigFileEntry() {};53 virtual ~ConfigFileEntry() = default; 54 54 55 55 /// Changes the value of the entry. -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFileEntryComment.h
r9559 r11054 54 54 55 55 /// Destructor 56 inline virtual ~ConfigFileEntryComment() {}56 virtual inline ~ConfigFileEntryComment() = default; 57 57 58 inline virtual const std::string& getName() const58 virtual inline const std::string& getName() const override 59 59 { return this->comment_; } 60 60 61 inline virtual void setComment(const std::string& comment)61 virtual inline void setComment(const std::string& comment) override 62 62 { this->comment_ = comment; } 63 63 64 inline virtual void setValue(const std::string& value)64 virtual inline void setValue(const std::string& value) override 65 65 {} 66 inline virtual const std::string& getValue() const66 virtual inline const std::string& getValue() const override 67 67 { return BLANKSTRING; } 68 68 69 inline void setString(bool bString)69 virtual inline void setString(bool bString) override 70 70 {} 71 71 72 inline virtual const std::string& getFileEntry() const72 virtual inline const std::string& getFileEntry() const override 73 73 { return this->comment_; } 74 74 -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFileEntryValue.h
r9684 r11054 67 67 68 68 /// Destructor 69 inline virtual ~ConfigFileEntryValue() {}69 virtual inline ~ConfigFileEntryValue() = default; 70 70 71 inline virtual const std::string& getName() const71 virtual inline const std::string& getName() const override 72 72 { return this->name_; } 73 73 74 inline virtual void setComment(const std::string& comment)74 virtual inline void setComment(const std::string& comment) override 75 75 { this->additionalComment_ = comment; this->update(); } 76 76 77 inline virtual void setValue(const std::string& value)77 virtual inline void setValue(const std::string& value) override 78 78 { this->value_ = value; this->update(); } 79 inline virtual const std::string& getValue() const79 virtual inline const std::string& getValue() const override 80 80 { return this->value_; } 81 81 82 inline void virtual setString(bool bString)82 virtual inline void setString(bool bString) override 83 83 { this->bString_ = bString; this->update(); } 84 84 85 inline virtual const std::string& getFileEntry() const85 virtual inline const std::string& getFileEntry() const override 86 86 { return this->fileEntry_; } 87 87 88 88 /// Returns the "key" of the value (in this case it's just the name of the entry, but for vectors it's different) 89 inline virtualconst std::string& getKeyString() const89 virtual inline const std::string& getKeyString() const 90 90 { return this->name_; } 91 91 -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFileEntryVectorValue.h
r9559 r11054 65 65 66 66 /// Destructor 67 inline ~ConfigFileEntryVectorValue() {}67 inline ~ConfigFileEntryVectorValue() = default; 68 68 69 inline unsigned int getIndex() const69 virtual inline unsigned int getIndex() const override 70 70 { return this->index_; } 71 71 72 72 /// Returns the "key" of the value (the name of the vector plus the index of the element) 73 inline const std::string& getKeyString() const73 virtual inline const std::string& getKeyString() const override 74 74 { return this->keyString_; } 75 75 76 76 private: 77 v oid update();77 virtual void update() override; 78 78 79 79 unsigned int index_; ///< The index of the element in the vector -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFileManager.cc
r9559 r11054 42 42 /////////////////////// 43 43 44 ConfigFileManager* ConfigFileManager::singletonPtr_s = 0;44 ConfigFileManager* ConfigFileManager::singletonPtr_s = nullptr; 45 45 46 /// Constructor: Initializes the array of config files with NULL.46 /// Constructor: Initializes the array of config files with nullptr. 47 47 ConfigFileManager::ConfigFileManager() 48 48 { 49 this->configFiles_. assign(NULL);49 this->configFiles_.fill(nullptr); 50 50 } 51 51 … … 53 53 ConfigFileManager::~ConfigFileManager() 54 54 { 55 for ( boost::array<ConfigFile*, 3>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)56 if ( *it)57 delete (*it);55 for (ConfigFile* configFile : this->configFiles_) 56 if (configFile) 57 delete configFile; 58 58 } 59 59 -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFileManager.h
r9559 r11054 38 38 #include "core/CorePrereqs.h" 39 39 40 #include < boost/array.hpp>40 #include <array> 41 41 42 42 #include "util/Singleton.h" … … 67 67 68 68 private: 69 ConfigFileManager(const ConfigFileManager&); ///< Copy-constructor: not implemented 69 // non-copyable: 70 ConfigFileManager(const ConfigFileManager&) = delete; 71 ConfigFileManager& operator=(const ConfigFileManager&) = delete; 70 72 71 boost::array<ConfigFile*, 3> configFiles_;///< Stores the config files for each type in an array (must have the same size like ConfigFileType::Value)73 std::array<ConfigFile*, 3> configFiles_; ///< Stores the config files for each type in an array (must have the same size like ConfigFileType::Value) 72 74 static ConfigFileManager* singletonPtr_s; ///< Stores the singleton-pointer 73 75 }; -
code/branches/cpp11_v3/src/libraries/core/config/ConfigFileSection.cc
r9559 r11054 80 80 { 81 81 unsigned int size = 0; 82 for ( std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)83 if ( (*it)->getName() == name)84 if ( (*it)->getIndex() >= size)85 size = (*it)->getIndex() + 1;82 for (ConfigFileEntry* entry : this->entries_) 83 if (entry->getName() == name) 84 if (entry->getIndex() >= size) 85 size = entry->getIndex() + 1; 86 86 return size; 87 87 } … … 99 99 100 100 /** 101 @brief Returns the entry with given name (or NULLif it doesn't exist).101 @brief Returns the entry with given name (or nullptr if it doesn't exist). 102 102 103 103 @param name The name of the entry … … 105 105 ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name) const 106 106 { 107 for ( std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)107 for (ConfigFileEntry* entry : this->entries_) 108 108 { 109 if ( (*it)->getName() == name)110 return *it;109 if (entry->getName() == name) 110 return entry; 111 111 } 112 return NULL;112 return nullptr; 113 113 } 114 114 115 115 /** 116 @brief Returns the entry of a vector element with given name and index (or NULLif it doesn't exist).116 @brief Returns the entry of a vector element with given name and index (or nullptr if it doesn't exist). 117 117 118 118 @param name The name of the vector … … 121 121 ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name, unsigned int index) const 122 122 { 123 for ( std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)123 for (ConfigFileEntry* entry : this->entries_) 124 124 { 125 if (( (*it)->getName() == name) && ((*it)->getIndex() == index))126 return *it;125 if ((entry->getName() == name) && (entry->getIndex() == index)) 126 return entry; 127 127 } 128 return NULL;128 return nullptr; 129 129 } 130 130 -
code/branches/cpp11_v3/src/libraries/core/config/ConfigValueContainer.cc
r9559 r11054 53 53 this->sectionname_ = sectionname; 54 54 this->varname_ = varname; 55 this->callback_ = 0;55 this->callback_ = nullptr; 56 56 this->bContainerIsNew_ = true; 57 57 this->bDoInitialCallback_ = false; … … 191 191 for (unsigned int i = this->valueVector_.size(); i <= index; i++) 192 192 { 193 this->valueVector_. push_back(MultiType());193 this->valueVector_.emplace_back(); 194 194 } 195 195 } -
code/branches/cpp11_v3/src/libraries/core/config/ConfigValueContainer.h
r9667 r11054 59 59 public: 60 60 virtual void call(void* object) = 0; 61 inline virtual~ConfigValueCallbackBase() {}61 virtual inline ~ConfigValueCallbackBase() {} 62 62 }; 63 63 … … 67 67 public: 68 68 inline ConfigValueCallback(void (T::*function) (void)) : function_(function) {} 69 inline virtual ~ConfigValueCallback() {}70 inline virtual void call(void* object)69 virtual inline ~ConfigValueCallback() = default; 70 virtual inline void call(void* object) override 71 71 { 72 72 if (!IdentifierManager::getInstance().isCreatingHierarchy()) … … 130 130 131 131 this->value_ = V(); 132 for ( unsigned int i = 0; i < defvalue.size(); i++)133 this->valueVector_. push_back(MultiType(defvalue[i]));132 for (const D& defvalueElement : defvalue) 133 this->valueVector_.emplace_back(defvalueElement); 134 134 135 135 this->initVector(); … … 183 183 std::vector<T> temp = *value; 184 184 value->clear(); 185 for ( unsigned int i = 0; i < this->valueVector_.size(); ++i)186 value->push_back( this->valueVector_[i]);185 for (const MultiType& vectorEntry : this->valueVector_) 186 value->push_back(vectorEntry); 187 187 188 188 if (value->size() != temp.size()) … … 211 211 { 212 212 value->clear(); 213 for ( unsigned int i = 0; i < this->valueVector_.size(); ++i)214 value->push_back( this->valueVector_[i]);213 for (const MultiType& vectorEntry : this->valueVector_) 214 value->push_back(vectorEntry); 215 215 } 216 216 return *this; … … 223 223 inline const std::string& getSectionName() const 224 224 { return this->sectionname_; } 225 /// Returns the associated identifier (can be NULL).225 /// Returns the associated identifier (can be nullptr). 226 226 inline Identifier* getIdentifier() const 227 227 { return this->identifier_; } -
code/branches/cpp11_v3/src/libraries/core/config/SettingsConfigFile.cc
r10624 r11054 57 57 SetConsoleCommand(__CC_getConfig_name, &SettingsConfigFile::getConfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()); 58 58 59 SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0;59 SettingsConfigFile* SettingsConfigFile::singletonPtr_s = nullptr; 60 60 61 61 /** … … 77 77 SettingsConfigFile::~SettingsConfigFile() 78 78 { 79 ModifyConsoleCommand(__CC_load_name).setObject( 0);80 ModifyConsoleCommand(__CC_setFilename_name).setObject( 0);81 ModifyConsoleCommand(__CC_config_name).setObject( 0);82 ModifyConsoleCommand(__CC_tconfig_name).setObject( 0);83 ModifyConsoleCommand(__CC_getConfig_name).setObject( 0);79 ModifyConsoleCommand(__CC_load_name).setObject(nullptr); 80 ModifyConsoleCommand(__CC_setFilename_name).setObject(nullptr); 81 ModifyConsoleCommand(__CC_config_name).setObject(nullptr); 82 ModifyConsoleCommand(__CC_tconfig_name).setObject(nullptr); 83 ModifyConsoleCommand(__CC_getConfig_name).setObject(nullptr); 84 84 } 85 85 … … 106 106 void SettingsConfigFile::addConfigValueContainer(ConfigValueContainer* container) 107 107 { 108 if (container == NULL)108 if (container == nullptr) 109 109 return; 110 110 std::pair<std::string, ConfigValueContainer*> second(getLowercase(container->getName()), container); … … 118 118 void SettingsConfigFile::removeConfigValueContainer(ConfigValueContainer* container) 119 119 { 120 if (container == NULL)120 if (container == nullptr) 121 121 return; 122 122 const std::string& sectionLC = getLowercase(container->getSectionName()); … … 142 142 // todo: can this be done more efficiently? looks like some identifiers will be updated multiple times. 143 143 144 for ( ContainerMap::const_iterator it = this->containers_.begin(); it != this->containers_.end(); ++it)145 { 146 it->second.second->update();147 it->second.second->getIdentifier()->updateConfigValues();144 for (const auto& mapEntry : this->containers_) 145 { 146 mapEntry.second.second->update(); 147 mapEntry.second.second->getIdentifier()->updateConfigValues(); 148 148 } 149 149 } … … 269 269 { 270 270 std::string value; 271 it->second.second->getValue<std::string, void>(&value, NULL);271 it->second.second->getValue<std::string, void>(&value, nullptr); 272 272 return value; 273 273 } -
code/branches/cpp11_v3/src/libraries/core/config/SettingsConfigFile.h
r9684 r11054 63 63 64 64 public: 65 typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*> 65 typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*>> ContainerMap; 66 66 67 67 SettingsConfigFile(const std::string& filename); 68 68 ~SettingsConfigFile(); 69 69 70 v oid load(); // tolua_export70 virtual void load() override; // tolua_export 71 71 void setFilename(const std::string& filename); // tolua_export 72 72 void clean(bool bCleanComments = false); // tolua_export -
code/branches/cpp11_v3/src/libraries/core/input/Button.cc
r9983 r11054 53 53 Button::Button() 54 54 : bButtonThresholdUser_(false) 55 , paramCommandBuffer_( 0)55 , paramCommandBuffer_(nullptr) 56 56 { 57 57 nCommands_[0]=0; … … 75 75 delete commands_[j][i]; 76 76 delete[] commands_[j]; 77 commands_[j] = 0;77 commands_[j] = nullptr; 78 78 nCommands_[j] = 0; 79 79 } … … 196 196 197 197 // add command to the buffer if not yet existing 198 for ( unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer_->size(); iParamCmd++)199 { 200 if ( (*paramCommandBuffer_)[iParamCmd]->evaluation_.getConsoleCommand()198 for (BufferedParamCommand* command : *paramCommandBuffer_) 199 { 200 if (command->evaluation_.getConsoleCommand() 201 201 == eval.getConsoleCommand()) 202 202 { 203 203 // already in list 204 cmd->paramCommand_ = (*paramCommandBuffer_)[iParamCmd];204 cmd->paramCommand_ = command; 205 205 break; 206 206 } 207 207 } 208 if (cmd->paramCommand_ == 0)208 if (cmd->paramCommand_ == nullptr) 209 209 { 210 210 cmd->paramCommand_ = new BufferedParamCommand(); … … 239 239 } 240 240 else 241 commands_[j] = 0;241 commands_[j] = nullptr; 242 242 } 243 243 } -
code/branches/cpp11_v3/src/libraries/core/input/HalfAxis.h
r7859 r11054 49 49 : relVal_(0.0f) 50 50 , absVal_(0.0f) 51 , paramCommands_( 0)51 , paramCommands_(nullptr) 52 52 , nParamCommands_(0) 53 53 , pressed_(false) … … 56 56 using Button::execute; 57 57 bool execute(); 58 bool addParamCommand(ParamCommand* command);59 v oid clear();58 virtual bool addParamCommand(ParamCommand* command) override; 59 virtual void clear() override; 60 60 void reset(); 61 61 -
code/branches/cpp11_v3/src/libraries/core/input/InputBuffer.cc
r9667 r11054 75 75 InputBuffer::~InputBuffer() 76 76 { 77 for (std::list<BaseInputBufferListenerTuple*>::const_iterator it = this->listeners_.begin(); 78 it != this->listeners_.end(); ++it) 79 delete *it; 77 for (BaseInputBufferListenerTuple* listener : this->listeners_) 78 delete listener; 80 79 } 81 80 … … 110 109 void InputBuffer::insert(const std::string& input, bool update) 111 110 { 112 for ( unsigned int i = 0; i < input.size(); ++i)113 { 114 this->insert(input [i], false);111 for (const char& inputChar : input) 112 { 113 this->insert(inputChar, false); 115 114 116 115 if (update) 117 this->updated(input [i], false);116 this->updated(inputChar, false); 118 117 } 119 118 … … 170 169 void InputBuffer::updated() 171 170 { 172 for ( std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)173 { 174 if ( (*it)->bListenToAllChanges_)175 (*it)->callFunction();171 for (BaseInputBufferListenerTuple* listener : this->listeners_) 172 { 173 if (listener->bListenToAllChanges_) 174 listener->callFunction(); 176 175 } 177 176 } … … 179 178 void InputBuffer::updated(const char& update, bool bSingleInput) 180 179 { 181 for ( std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)182 { 183 if ((! (*it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput))184 (*it)->callFunction();180 for (BaseInputBufferListenerTuple* listener : this->listeners_) 181 { 182 if ((!listener->trueKeyFalseChar_) && (listener->bListenToAllChanges_ || (listener->char_ == update)) && (!listener->bOnlySingleInput_ || bSingleInput)) 183 listener->callFunction(); 185 184 } 186 185 } … … 201 200 return; 202 201 203 for ( std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)204 { 205 if ( (*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.getKeyCode()))206 (*it)->callFunction();202 for (BaseInputBufferListenerTuple* listener : this->listeners_) 203 { 204 if (listener->trueKeyFalseChar_ && (listener->key_ == evt.getKeyCode())) 205 listener->callFunction(); 207 206 } 208 207 -
code/branches/cpp11_v3/src/libraries/core/input/InputBuffer.h
r9667 r11054 47 47 trueKeyFalseChar_(trueKeyFalseChar), char_(_char), key_(key) 48 48 { } 49 virtual ~BaseInputBufferListenerTuple() { }49 virtual ~BaseInputBufferListenerTuple() = default; 50 50 virtual void callFunction() = 0; 51 51 bool bListenToAllChanges_; … … 65 65 listener_(listener), function_(function) 66 66 { } 67 virtual ~InputBufferListenerTuple() { }68 v oid callFunction()67 virtual ~InputBufferListenerTuple() = default; 68 virtual void callFunction() override 69 69 { 70 70 (listener_->*function_)(); … … 165 165 { if (this->cursor_ > 0) { --this->cursor_; } } 166 166 167 v oid buttonPressed(const KeyEvent& evt);167 virtual void buttonPressed(const KeyEvent& evt) override; 168 168 169 169 private: 170 170 bool charIsAllowed(const char& input); 171 171 172 v oid buttonHeld (const KeyEvent& evt);173 void processKey 172 virtual void buttonHeld (const KeyEvent& evt) override; 173 void processKey (const KeyEvent& evt); 174 174 175 v oid keyboardUpdated(float dt);175 virtual void keyboardUpdated(float dt) override; 176 176 177 177 std::string buffer_; -
code/branches/cpp11_v3/src/libraries/core/input/InputCommands.h
r9978 r11054 57 57 public: 58 58 BaseCommand() : bFixedKeybindMode_(false) {} 59 virtual ~BaseCommand() { }59 virtual ~BaseCommand() = default; 60 60 61 61 virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0; … … 76 76 { 77 77 public: 78 bool execute(float abs = 1.0f, float rel = 1.0f);79 CommandEvaluation* getEvaluation();80 virtual SimpleCommand* clone() { return new SimpleCommand(*this); }78 virtual bool execute(float abs = 1.0f, float rel = 1.0f) override; 79 virtual CommandEvaluation* getEvaluation() override; 80 virtual SimpleCommand* clone() override { return new SimpleCommand(*this); } 81 81 82 82 CommandEvaluation evaluation_; … … 103 103 { 104 104 public: 105 ParamCommand() : scale_(1.0f), paramCommand_( 0) { }106 bool execute(float abs = 1.0f, float rel = 1.0f);107 CommandEvaluation* getEvaluation();108 virtual ParamCommand* clone() { return new ParamCommand(*this); }105 ParamCommand() : scale_(1.0f), paramCommand_(nullptr) { } 106 virtual bool execute(float abs = 1.0f, float rel = 1.0f) override; 107 virtual CommandEvaluation* getEvaluation() override; 108 virtual ParamCommand* clone() override { return new ParamCommand(*this); } 109 109 110 110 float scale_; … … 118 118 return &this->paramCommand_->evaluation_; 119 119 else 120 return 0;120 return nullptr; 121 121 } 122 122 } -
code/branches/cpp11_v3/src/libraries/core/input/InputDevice.h
r8858 r11054 60 60 //! Only resets the members 61 61 InputDevice(unsigned int id) : bCalibrating_(false), deviceID_(id) { } 62 virtual ~InputDevice() { }62 virtual ~InputDevice() = default; 63 63 //! Returns the device class (derived) name as string 64 64 virtual std::string getClassName() const = 0; … … 99 99 100 100 private: 101 InputDevice(const InputDevice& rhs); //!< Don't use! 101 // non-copyable: 102 InputDevice(const InputDevice&) = delete; 103 InputDevice& operator=(const InputDevice&) = delete; 102 104 103 105 bool bCalibrating_; //!< Whether the device is in calibration mode … … 153 155 154 156 //! Captures OIS events (which then get distributed to the derived class) and creates the button held events 155 v oid update(const Clock& time)157 virtual void update(const Clock& time) override 156 158 { 157 159 oisDevice_->capture(); 158 160 159 161 // Call all the states with the held button event 160 for ( unsigned int iB = 0; iB < pressedButtons_.size(); ++iB)161 for ( unsigned int iS = 0; iS < inputStates_.size(); ++iS)162 inputStates_[iS]->buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(163 this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg( pressedButtons_[iB]));162 for (ButtonType& button : pressedButtons_) 163 for (InputState* state : inputStates_) 164 state->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>( 165 this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button)); 164 166 165 167 // Call states with device update events 166 for ( unsigned int i = 0; i < inputStates_.size(); ++i)167 inputStates_[i]->update(time.getDeltaTime(), this->getDeviceID());168 for (InputState* state : inputStates_) 169 state->update(time.getDeltaTime(), this->getDeviceID()); 168 170 169 171 static_cast<DeviceClass*>(this)->updateImpl(time); … … 171 173 172 174 //! Clears the list of pressed buttons and calls the derived class's method 173 v oid clearBuffers()175 virtual void clearBuffers() override 174 176 { 175 177 pressedButtons_.clear(); … … 180 182 OISDeviceClass* getOISDevice() { return this->oisDevice_; } 181 183 // Returns the name of the derived class as string 182 std::string getClassName() const{ return DeviceClass::getClassNameImpl(); }184 virtual std::string getClassName() const override { return DeviceClass::getClassNameImpl(); } 183 185 184 186 protected: … … 196 198 197 199 // Call states 198 for ( unsigned int i = 0; i < inputStates_.size(); ++i)199 inputStates_[i]->buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));200 for (InputState* state : inputStates_) 201 state->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button)); 200 202 } 201 203 … … 218 220 219 221 // Call states 220 for ( unsigned int i = 0; i < inputStates_.size(); ++i)221 inputStates_[i]->buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));222 for (InputState* state : inputStates_) 223 state->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button)); 222 224 } 223 225 -
code/branches/cpp11_v3/src/libraries/core/input/InputHandler.h
r8729 r11054 119 119 { 120 120 public: 121 virtual ~InputHandler() { }121 virtual ~InputHandler() = default; 122 122 123 123 template<class T> void buttonEvent(unsigned int device, T button, ButtonEvent::TPress) -
code/branches/cpp11_v3/src/libraries/core/input/InputManager.cc
r10624 r11054 39 39 #include <ois/OISException.h> 40 40 #include <ois/OISInputManager.h> 41 #include <boost/foreach.hpp>42 41 #include <loki/ScopeGuard.h> 43 42 … … 72 71 InputHandler InputHandler::EMPTY; 73 72 74 InputManager* InputManager::singletonPtr_s = 0;73 InputManager* InputManager::singletonPtr_s = nullptr; 75 74 76 75 //! Defines the |= operator for easier use. … … 94 93 InputManager::InputManager() 95 94 : internalState_(Bad) 96 , oisInputManager_( 0)95 , oisInputManager_(nullptr) 97 96 , devices_(2) 98 97 , exclusiveMouse_(false) 99 , emptyState_( 0)100 , calibratorCallbackHandler_( 0)98 , emptyState_(nullptr) 99 , calibratorCallbackHandler_(nullptr) 101 100 { 102 101 RegisterObject(InputManager); … … 149 148 // When loading the devices they should not already be loaded 150 149 assert(internalState_ & Bad); 151 assert(devices_[InputDeviceEnumerator::Mouse] == 0);152 assert(devices_[InputDeviceEnumerator::Keyboard] == 0);150 assert(devices_[InputDeviceEnumerator::Mouse] == nullptr); 151 assert(devices_[InputDeviceEnumerator::Keyboard] == nullptr); 153 152 assert(devices_.size() == InputDeviceEnumerator::FirstJoyStick); 154 153 … … 210 209 catch (const std::exception& ex) 211 210 { 212 oisInputManager_ = NULL;211 oisInputManager_ = nullptr; 213 212 internalState_ |= Bad; 214 213 ThrowException(InitialisationFailed, "Could not initialise the input system: " << ex.what()); … … 294 293 295 294 // Reset console commands 296 ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject( 0);297 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject( 0);295 ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(nullptr); 296 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(nullptr); 298 297 299 298 orxout(internal_status, context::input) << "InputManager: Destruction complete." << endl; … … 310 309 orxout(verbose, context::input) << "InputManager: Destroying devices..." << endl; 311 310 312 BOOST_FOREACH(InputDevice*& device,devices_)313 { 314 if (device == NULL)311 for (InputDevice*& device : devices_) 312 { 313 if (device == nullptr) 315 314 continue; 316 315 const std::string& className = device->getClassName(); 317 316 delete device; 318 device = 0;317 device = nullptr; 319 318 orxout(verbose, context::input) << className << " destroyed." << endl; 320 319 } 321 320 devices_.resize(InputDeviceEnumerator::FirstJoyStick); 322 321 323 assert(oisInputManager_ != NULL);322 assert(oisInputManager_ != nullptr); 324 323 try 325 324 { … … 331 330 << "Potential resource leak!" << endl; 332 331 } 333 oisInputManager_ = NULL;332 oisInputManager_ = nullptr; 334 333 335 334 internalState_ |= Bad; … … 374 373 // check whether a state has changed its EMPTY situation 375 374 bool bUpdateRequired = false; 376 for ( std::map<int, InputState*>::iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)377 { 378 if ( it->second->hasExpired())379 { 380 it->second->resetExpiration();375 for (const auto& mapEntry : activeStates_) 376 { 377 if (mapEntry.second->hasExpired()) 378 { 379 mapEntry.second->resetExpiration(); 381 380 bUpdateRequired = true; 382 381 } … … 387 386 // Capture all the input and collect the function calls 388 387 // No event gets triggered here yet! 389 BOOST_FOREACH(InputDevice* device,devices_)390 if (device != NULL)388 for (InputDevice* device : devices_) 389 if (device != nullptr) 391 390 device->update(time); 392 391 393 392 // Collect function calls for the update 394 for ( unsigned int i = 0; i < activeStatesTicked_.size(); ++i)395 activeStatesTicked_[i]->update(time.getDeltaTime());393 for (InputState* state : activeStatesTicked_) 394 state->update(time.getDeltaTime()); 396 395 397 396 // Execute all cached function calls in order … … 402 401 // If we delay the calls, then OIS and and the InputStates are not anymore 403 402 // in the call stack and can therefore be edited. 404 for ( size_t i = 0; i < this->callBuffer_.size(); ++i)405 this->callBuffer_[i]();403 for (auto& function : this->callBuffer_) 404 function(); 406 405 407 406 this->callBuffer_.clear(); … … 419 418 for (unsigned int i = 0; i < devices_.size(); ++i) 420 419 { 421 if (devices_[i] == NULL)420 if (devices_[i] == nullptr) 422 421 continue; 423 422 std::vector<InputState*>& states = devices_[i]->getStateListRef(); … … 438 437 // Using an std::set to avoid duplicates 439 438 std::set<InputState*> tempSet; 440 for ( unsigned int i = 0; i < devices_.size(); ++i)441 if (device s_[i] != NULL)442 for (unsigned int iState = 0; iState < device s_[i]->getStateListRef().size(); ++iState)443 tempSet.insert(device s_[i]->getStateListRef()[iState]);439 for (InputDevice* device : devices_) 440 if (device != nullptr) 441 for (unsigned int iState = 0; iState < device->getStateListRef().size(); ++iState) 442 tempSet.insert(device->getStateListRef()[iState]); 444 443 445 444 // Copy the content of the std::set back to the actual vector 446 445 activeStatesTicked_.clear(); 447 for ( std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)448 activeStatesTicked_.push_back( *it);446 for (InputState* state : tempSet) 447 activeStatesTicked_.push_back(state); 449 448 450 449 // Check whether we have to change the mouse mode … … 466 465 void InputManager::clearBuffers() 467 466 { 468 BOOST_FOREACH(InputDevice* device,devices_)469 if (device != NULL)467 for (InputDevice* device : devices_) 468 if (device != nullptr) 470 469 device->clearBuffers(); 471 470 } … … 476 475 << "When done, put the axex in the middle position and press enter." << endl; 477 476 478 BOOST_FOREACH(InputDevice* device,devices_)479 if (device != NULL)477 for (InputDevice* device : devices_) 478 if (device != nullptr) 480 479 device->startCalibration(); 481 480 … … 487 486 void InputManager::stopCalibration() 488 487 { 489 BOOST_FOREACH(InputDevice* device,devices_)490 if (device != NULL)488 for (InputDevice* device : devices_) 489 if (device != nullptr) 491 490 device->stopCalibration(); 492 491 … … 509 508 { 510 509 Mouse* mouse = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse]); 511 if (mouse != NULL)510 if (mouse != nullptr) 512 511 { 513 512 const OIS::MouseState state = mouse->getOISDevice()->getMouseState(); … … 526 525 { 527 526 if (name.empty()) 528 return 0;527 return nullptr; 529 528 if (statesByName_.find(name) == statesByName_.end()) 530 529 { … … 532 531 { 533 532 // Make sure we don't add two high priority states with the same priority 534 for (std::map<std::string, InputState*>::const_iterator it = this->statesByName_.begin(); 535 it != this->statesByName_.end(); ++it) 533 for (const auto& mapEntry : this->statesByName_) 536 534 { 537 if ( it->second->getPriority() == priority)535 if (mapEntry.second->getPriority() == priority) 538 536 { 539 537 orxout(internal_warning, context::input) << "Could not add an InputState with the same priority '" 540 538 << static_cast<int>(priority) << "' != 0." << endl; 541 return 0;539 return nullptr; 542 540 } 543 541 } … … 551 549 { 552 550 orxout(internal_warning, context::input) << "Could not add an InputState with the same name '" << name << "'." << endl; 553 return 0;551 return nullptr; 554 552 } 555 553 } … … 561 559 return it->second; 562 560 else 563 return 0;561 return nullptr; 564 562 } 565 563 -
code/branches/cpp11_v3/src/libraries/core/input/InputManager.h
r8729 r11054 35 35 #include <string> 36 36 #include <vector> 37 #include < boost/function.hpp>37 #include <functional> 38 38 39 39 #include "util/Singleton.h" … … 134 134 Returns a pointer to a InputState referenced by name. 135 135 @return 136 Returns NULLif state was not found.136 Returns nullptr if state was not found. 137 137 */ 138 138 InputState* getState(const std::string& name); … … 186 186 // Function call caching 187 187 //------------------------------- 188 void pushCall(const boost::function<void ()>& function)188 void pushCall(const std::function<void ()>& function) 189 189 { this->callBuffer_.push_back(function); } 190 190 … … 192 192 193 193 private: // functions 194 // don't mess with a Singleton 195 InputManager(const InputManager&); 194 // non-copyable: 195 InputManager(const InputManager&) = delete; 196 InputManager& operator=(const InputManager&) = delete; 196 197 197 198 // Internal methods … … 208 209 209 210 // From WindowEventListener 210 v oid windowFocusChanged(bool bFocus);211 virtual void windowFocusChanged(bool bFocus) override; 211 212 212 213 private: // variables … … 225 226 std::vector<InputState*> activeStatesTicked_; //!< Like activeStates_, but only contains the ones that currently receive events 226 227 227 std::vector< boost::function<void ()>> callBuffer_; //!< Caches all calls from InputStates to be executed afterwards (see preUpdate)228 std::vector<std::function<void ()>> callBuffer_; //!< Caches all calls from InputStates to be executed afterwards (see preUpdate) 228 229 229 230 static InputManager* singletonPtr_s; //!< Pointer reference to the singleton -
code/branches/cpp11_v3/src/libraries/core/input/InputPrereqs.h
r8729 r11054 454 454 OrxEnumConstructors(InputStatePriority); 455 455 456 static const int Empty = -1;457 static const int Dynamic = 0;458 459 static const int HighPriority = 1000;460 static const int Console = HighPriority + 0;461 static const int Calibrator = HighPriority + 1;462 static const int Detector = HighPriority + 2;456 static constexpr int Empty = -1; 457 static constexpr int Dynamic = 0; 458 459 static constexpr int HighPriority = 1000; 460 static constexpr int Console = HighPriority + 0; 461 static constexpr int Calibrator = HighPriority + 1; 462 static constexpr int Detector = HighPriority + 2; 463 463 }; 464 464 } -
code/branches/cpp11_v3/src/libraries/core/input/InputState.cc
r8729 r11054 40 40 , bExpired_(true) 41 41 , handlers_(2) 42 , joyStickHandlerAll_( 0)43 , enterFunctor_( 0)44 , leaveFunctor_( 0)42 , joyStickHandlerAll_(nullptr) 43 , enterFunctor_(nullptr) 44 , leaveFunctor_(nullptr) 45 45 { 46 46 if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty) … … 49 49 priority_ = 0; 50 50 51 handlers_.resize(InputDeviceEnumerator::FirstJoyStick + this->getJoyStickList().size(), NULL);51 handlers_.resize(InputDeviceEnumerator::FirstJoyStick + this->getJoyStickList().size(), nullptr); 52 52 } 53 53 … … 55 55 { 56 56 if (device < handlers_.size()) 57 return handlers_[device] != NULL;57 return handlers_[device] != nullptr; 58 58 else 59 59 return false; … … 64 64 { 65 65 unsigned int oldSize = handlers_.size(); 66 handlers_.resize(InputDeviceEnumerator::FirstJoyStick + joyStickList.size(), NULL);66 handlers_.resize(InputDeviceEnumerator::FirstJoyStick + joyStickList.size(), nullptr); 67 67 68 68 for (unsigned int i = oldSize; i < handlers_.size(); ++i) -
code/branches/cpp11_v3/src/libraries/core/input/InputState.h
r8729 r11054 35 35 #include <string> 36 36 #include <vector> 37 #include <boost/function.hpp> 38 #include <boost/bind.hpp> 37 #include <functional> 39 38 40 39 #include "util/tribool.h" … … 44 43 45 44 #define INPUT_STATE_PUSH_CALL(deviceIndex, functionName, ...) \ 46 InputManager::getInstance().pushCall( boost::function<void ()>(boost::bind(&InputHandler::functionName, handlers_[deviceIndex], __VA_ARGS__)))45 InputManager::getInstance().pushCall(std::function<void ()>(std::bind(&InputHandler::functionName, handlers_[deviceIndex], __VA_ARGS__))) 47 46 48 47 namespace orxonox … … 156 155 private: 157 156 InputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority); 158 ~InputState() { }159 160 v oid JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);157 ~InputState() = default; 158 159 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) override; 161 160 162 161 //! Sets the priority (only to be used by the InputManager!) … … 179 178 { 180 179 for (unsigned int i = 0; i < handlers_.size(); ++i) 181 if (handlers_[i] != NULL)180 if (handlers_[i] != nullptr) 182 181 INPUT_STATE_PUSH_CALL(i, allDevicesUpdated, dt); 183 182 } … … 188 187 { 189 188 case InputDeviceEnumerator::Keyboard: 190 if (handlers_[keyboardIndex_s] != NULL)189 if (handlers_[keyboardIndex_s] != nullptr) 191 190 INPUT_STATE_PUSH_CALL(keyboardIndex_s, keyboardUpdated, dt); 192 191 break; 193 192 194 193 case InputDeviceEnumerator::Mouse: 195 if (handlers_[mouseIndex_s] != NULL)194 if (handlers_[mouseIndex_s] != nullptr) 196 195 INPUT_STATE_PUSH_CALL(mouseIndex_s, mouseUpdated, dt); 197 196 break; 198 197 199 198 default: // joy sticks 200 if (handlers_[device] != NULL)199 if (handlers_[device] != nullptr) 201 200 INPUT_STATE_PUSH_CALL(device, joyStickUpdated, device - firstJoyStickIndex_s, dt); 202 201 break; … … 208 207 { 209 208 assert(device < handlers_.size()); 210 if (handlers_[device] != NULL)209 if (handlers_[device] != nullptr) 211 210 { 212 211 // We have to store the function pointer to tell the compiler about its actual type because of overloading 213 212 void (InputHandler::*function)(unsigned int, ButtonTypeParam, EventType) = &InputHandler::buttonEvent<ButtonTypeParam>; 214 InputManager::getInstance().pushCall( boost::function<void ()>(boost::bind(function, handlers_[device], device, button, EventType())));213 InputManager::getInstance().pushCall(std::function<void ()>(std::bind(function, handlers_[device], device, button, EventType()))); 215 214 } 216 215 } … … 218 217 ORX_FORCEINLINE void InputState::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 219 218 { 220 if (handlers_[mouseIndex_s] != NULL)219 if (handlers_[mouseIndex_s] != nullptr) 221 220 INPUT_STATE_PUSH_CALL(mouseIndex_s, mouseMoved, abs, rel, clippingSize); 222 221 } … … 224 223 ORX_FORCEINLINE void InputState::mouseScrolled(int abs, int rel) 225 224 { 226 if (handlers_[mouseIndex_s] != NULL)225 if (handlers_[mouseIndex_s] != nullptr) 227 226 INPUT_STATE_PUSH_CALL(mouseIndex_s, mouseScrolled, abs, rel); 228 227 } … … 231 230 { 232 231 assert(device < handlers_.size()); 233 if (handlers_[device] != NULL)232 if (handlers_[device] != nullptr) 234 233 INPUT_STATE_PUSH_CALL(device, axisMoved, device - firstJoyStickIndex_s, axis, value); 235 234 } -
code/branches/cpp11_v3/src/libraries/core/input/JoyStick.cc
r10624 r11054 31 31 #include <climits> 32 32 #include <ois/OISJoyStick.h> 33 #include <boost/foreach.hpp>34 33 35 34 #include "util/StringUtils.h" … … 73 72 //deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Vector3)); 74 73 75 BOOST_FOREACH(std::string& idString,deviceNames_s)74 for (const std::string& idString : deviceNames_s) 76 75 { 77 76 if (deviceName_ == idString) … … 128 127 { 129 128 // Set initial values 130 BOOST_FOREACH(int& minVal,configMinValues_)129 for (int& minVal : configMinValues_) 131 130 minVal = INT_MAX; 132 BOOST_FOREACH(int& minVal,configMaxValues_)131 for (int& minVal : configMaxValues_) 133 132 minVal = INT_MIN; 134 BOOST_FOREACH(int& zeroVal,configZeroValues_)133 for (int& zeroVal : configZeroValues_) 135 134 zeroVal = 0; 136 135 } … … 187 186 void JoyStick::clearBuffersImpl() 188 187 { 189 for (int j = 0; j < 4; ++j)190 povStates_[j]= 0;188 for (int& state : povStates_) 189 state = 0; 191 190 } 192 191 … … 209 208 fValue *= negativeCoeffs_[axis]; 210 209 211 BOOST_FOREACH(InputState* state,inputStates_)210 for (InputState* state : inputStates_) 212 211 state->joyStickAxisMoved(this->getDeviceID(), axis, fValue); 213 212 } -
code/branches/cpp11_v3/src/libraries/core/input/JoyStick.h
r9667 r11054 70 70 //! Assigns a generated ID string and loads the calibration (if present) 71 71 JoyStick(unsigned int id, OIS::InputManager* oisInputManager); 72 ~JoyStick() { }72 ~JoyStick() = default; 73 73 void setConfigValues(); 74 74 … … 77 77 78 78 private: 79 v oid calibrationStarted();80 v oid calibrationStopped();79 virtual void calibrationStarted() override; 80 virtual void calibrationStopped() override; 81 81 void evaluateCalibration(); 82 82 … … 86 86 87 87 //! OIS event handler 88 bool buttonPressed (const OIS::JoyStickEvent &arg, int button)88 virtual bool buttonPressed (const OIS::JoyStickEvent &arg, int button) override 89 89 { 90 90 super::buttonPressed(static_cast<JoyStickButtonCode::ByEnum>(button)); … … 93 93 94 94 //! OIS event handler 95 bool buttonReleased(const OIS::JoyStickEvent &arg, int button)95 virtual bool buttonReleased(const OIS::JoyStickEvent &arg, int button) override 96 96 { 97 97 super::buttonReleased(static_cast<JoyStickButtonCode::ByEnum>(button)); … … 99 99 } 100 100 101 bool axisMoved (const OIS::JoyStickEvent &arg, int axis);102 bool sliderMoved (const OIS::JoyStickEvent &arg, int id);103 bool povMoved (const OIS::JoyStickEvent &arg, int id);101 virtual bool axisMoved (const OIS::JoyStickEvent &arg, int axis) override; 102 virtual bool sliderMoved (const OIS::JoyStickEvent &arg, int id) override; 103 virtual bool povMoved (const OIS::JoyStickEvent &arg, int id) override; 104 104 //! OIS event handler (don't remove that because of OIS version issues!) 105 bool vector3Moved (const OIS::JoyStickEvent &arg, int id){ return true; }105 virtual bool vector3Moved (const OIS::JoyStickEvent &arg, int id) override { return true; } 106 106 107 107 //! Returns the class name as string -
code/branches/cpp11_v3/src/libraries/core/input/JoyStickQuantityListener.cc
r10624 r11054 47 47 { 48 48 joyStickList_s = joyStickList; 49 for ( ObjectList<JoyStickQuantityListener>::iterator it = ObjectList<JoyStickQuantityListener>::begin(); it; ++it)50 it->JoyStickQuantityChanged(joyStickList);49 for (JoyStickQuantityListener* listener : ObjectList<JoyStickQuantityListener>()) 50 listener->JoyStickQuantityChanged(joyStickList); 51 51 } 52 52 } -
code/branches/cpp11_v3/src/libraries/core/input/JoyStickQuantityListener.h
r9667 r11054 48 48 protected: 49 49 JoyStickQuantityListener(); 50 virtual ~JoyStickQuantityListener() { }50 virtual ~JoyStickQuantityListener() = default; 51 51 52 52 //! Returns a list with all JoySticks currently loaded -
code/branches/cpp11_v3/src/libraries/core/input/KeyBinder.cc
r11052 r11054 53 53 : deriveTime_(0.0f) 54 54 , filename_(filename) 55 , configFile_( NULL)56 , fallbackConfigFile_( NULL)55 , configFile_(nullptr) 56 , fallbackConfigFile_(nullptr) 57 57 { 58 58 mouseRelative_[0] = 0; … … 153 153 void KeyBinder::buttonThresholdChanged() 154 154 { 155 for ( unsigned int i = 0; i < allHalfAxes_.size(); i++)156 if (! allHalfAxes_[i]->bButtonThresholdUser_)157 allHalfAxes_[i]->buttonThreshold_ = this->buttonThreshold_;155 for (HalfAxis* halfAxis : allHalfAxes_) 156 if (!halfAxis->bButtonThresholdUser_) 157 halfAxis->buttonThreshold_ = this->buttonThreshold_; 158 158 } 159 159 … … 170 170 171 171 // load the bindings if required 172 if (configFile_ != NULL)172 if (configFile_ != nullptr) 173 173 { 174 174 for (unsigned int iDev = oldValue; iDev < joySticks_.size(); ++iDev) … … 188 188 { 189 189 while (joyStickAxes_.size() < joySticks_.size()) 190 joyStickAxes_.push_back(s hared_ptr<JoyStickAxisVector>(new JoyStickAxisVector()));190 joyStickAxes_.push_back(std::make_shared<JoyStickAxisVector>()); 191 191 while (joyStickButtons_.size() < joySticks_.size()) 192 joyStickButtons_.push_back(s hared_ptr<JoyStickButtonVector>(new JoyStickButtonVector()));192 joyStickButtons_.push_back(std::make_shared<JoyStickButtonVector>()); 193 193 // For the case the new size is smaller 194 194 this->joyStickAxes_.resize(joySticks_.size()); … … 274 274 275 275 // Parse bindings and create the ConfigValueContainers if necessary 276 for ( std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)277 { 278 it->second->readBinding(this->configFile_, this->fallbackConfigFile_);279 addButtonToCommand( it->second->bindingString_, it->second);276 for (const auto& mapEntry : allButtons_) 277 { 278 mapEntry.second->readBinding(this->configFile_, this->fallbackConfigFile_); 279 addButtonToCommand(mapEntry.second->bindingString_, mapEntry.second); 280 280 } 281 281 … … 420 420 void KeyBinder::clearBindings() 421 421 { 422 for ( std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)423 it->second->clear();424 425 for ( unsigned int i = 0; i < paramCommandBuffer_.size(); i++)426 delete paramCommandBuffer_[i];422 for (const auto& mapEntry : allButtons_) 423 mapEntry.second->clear(); 424 425 for (BufferedParamCommand* command : paramCommandBuffer_) 426 delete command; 427 427 paramCommandBuffer_.clear(); 428 428 } … … 434 434 { 435 435 // iterate over all buttons 436 for ( std::map<std::string, Button*>::iterator it = this->allButtons_.begin(); it != this->allButtons_.end(); ++it)437 { 438 Button* button = it->second;436 for (const auto& mapEntry : this->allButtons_) 437 { 438 Button* button = mapEntry.second; 439 439 440 440 // iterate over all modes … … 479 479 { 480 480 delete[] button->commands_[mode_index]; 481 button->commands_[mode_index] = 0;481 button->commands_[mode_index] = nullptr; 482 482 } 483 483 … … 505 505 this->mousePosition_[1] = 0.0f; 506 506 507 for ( unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)508 mouseAxes_[i].reset();507 for (HalfAxis& axis : mouseAxes_) 508 axis.reset(); 509 509 } 510 510 … … 545 545 } 546 546 547 for ( unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)547 for (HalfAxis& axis : mouseAxes_) 548 548 { 549 549 // Why dividing relative value by dt? The reason lies in the simple fact, that when you … … 555 555 { 556 556 // just ignore if dt == 0.0 because we have multiplied by 0.0 anyway.. 557 mouseAxes_[i].relVal_ /= dt;558 } 559 560 tickHalfAxis( mouseAxes_[i]);557 axis.relVal_ /= dt; 558 } 559 560 tickHalfAxis(axis); 561 561 } 562 562 } -
code/branches/cpp11_v3/src/libraries/core/input/KeyBinder.h
r11052 r11054 36 36 #include <vector> 37 37 #include <map> 38 #include < boost/shared_ptr.hpp>38 #include <memory> 39 39 40 40 #include "InputHandler.h" … … 85 85 void compilePointerLists(); 86 86 // from JoyStickQuantityListener interface 87 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) ;88 89 v oid allDevicesUpdated(float dt);90 v oid mouseUpdated(float dt);91 v oid joyStickUpdated(unsigned int joyStick, float dt);87 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) override; 88 89 virtual void allDevicesUpdated(float dt) override; 90 virtual void mouseUpdated(float dt) override; 91 virtual void joyStickUpdated(unsigned int joyStick, float dt) override; 92 92 // internal 93 93 void tickHalfAxis(HalfAxis& halfAxis); 94 94 95 v oid buttonPressed (const KeyEvent& evt);96 v oid buttonReleased(const KeyEvent& evt);97 v oid buttonHeld (const KeyEvent& evt);98 99 v oid buttonPressed (MouseButtonCode::ByEnum button);100 v oid buttonReleased(MouseButtonCode::ByEnum button);101 v oid buttonHeld (MouseButtonCode::ByEnum button);102 v oid mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);103 v oid mouseScrolled (int abs, int rel);104 105 v oid buttonPressed (unsigned int device, JoyStickButtonCode::ByEnum button);106 v oid buttonReleased(unsigned int device, JoyStickButtonCode::ByEnum button);107 v oid buttonHeld (unsigned int device, JoyStickButtonCode::ByEnum button);108 v oid axisMoved (unsigned int device, unsigned int axis, float value);95 virtual void buttonPressed (const KeyEvent& evt) override; 96 virtual void buttonReleased(const KeyEvent& evt) override; 97 virtual void buttonHeld (const KeyEvent& evt) override; 98 99 virtual void buttonPressed (MouseButtonCode::ByEnum button) override; 100 virtual void buttonReleased(MouseButtonCode::ByEnum button) override; 101 virtual void buttonHeld (MouseButtonCode::ByEnum button) override; 102 virtual void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) override; 103 virtual void mouseScrolled (int abs, int rel) override; 104 105 virtual void buttonPressed (unsigned int device, JoyStickButtonCode::ByEnum button) override; 106 virtual void buttonReleased(unsigned int device, JoyStickButtonCode::ByEnum button) override; 107 virtual void buttonHeld (unsigned int device, JoyStickButtonCode::ByEnum button) override; 108 virtual void axisMoved (unsigned int device, unsigned int axis, float value) override; 109 109 110 110 protected: // variables … … 128 128 }; 129 129 //! Actual key bindings for joy stick buttons 130 std::vector<s hared_ptr<JoyStickButtonVector>> joyStickButtons_;130 std::vector<std::shared_ptr<JoyStickButtonVector>> joyStickButtons_; 131 131 //! Helper class to use something like std:vector<HalfAxis[48]> 132 132 struct JoyStickAxisVector … … 136 136 }; 137 137 //! Actual key bindings for joy stick axes (and sliders) 138 std::vector<s hared_ptr<JoyStickAxisVector>> joyStickAxes_;138 std::vector<std::shared_ptr<JoyStickAxisVector>> joyStickAxes_; 139 139 140 140 //! Pointer map with all Buttons, including half axes … … 143 143 std::vector<HalfAxis*> allHalfAxes_; 144 144 //! Maps input commands to all Button names, including half axes 145 std::map< std::string, std::vector<std::string> 145 std::map< std::string, std::vector<std::string>> allCommands_; 146 146 147 147 /** … … 160 160 //! Name of the file used in this KeyBinder (constant!) 161 161 const std::string filename_; 162 //! Config file used. NULLin case of KeyDetector. Also indicates whether we've already loaded.162 //! Config file used. nullptr in case of KeyDetector. Also indicates whether we've already loaded. 163 163 ConfigFile* configFile_; 164 164 //! Config file from the data directory that only serves as fallback … … 227 227 { 228 228 // execute all buffered bindings (additional parameter) 229 for ( unsigned int i = 0; i < paramCommandBuffer_.size(); i++)229 for (BufferedParamCommand* command : paramCommandBuffer_) 230 230 { 231 paramCommandBuffer_[i]->rel_ *= dt;232 paramCommandBuffer_[i]->execute();231 command->rel_ *= dt; 232 command->execute(); 233 233 } 234 234 235 235 // always reset the relative movement of the mouse 236 for ( unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)237 mouseAxes_[i].relVal_ = 0.0f;236 for (HalfAxis& axis : mouseAxes_) 237 axis.relVal_ = 0.0f; 238 238 } 239 239 }// tolua_export -
code/branches/cpp11_v3/src/libraries/core/input/KeyBinderManager.cc
r10624 r11054 56 56 57 57 KeyBinderManager::KeyBinderManager() 58 : currentBinder_( NULL)58 : currentBinder_(nullptr) 59 59 , bDefaultFileLoaded_(true) 60 60 , bBinding_(false) … … 76 76 { 77 77 // Delete all remaining KeyBinders 78 for ( std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)79 delete it->second;78 for (const auto& mapEntry : this->binders_) 79 delete mapEntry.second; 80 80 81 81 // Reset console commands 82 ModifyConsoleCommand(__CC_keybind_name ).setObject( 0);83 ModifyConsoleCommand(__CC_tkeybind_name).setObject( 0);84 ModifyConsoleCommand(__CC_unbind_name ).setObject( 0);85 ModifyConsoleCommand(__CC_tunbind_name ).setObject( 0);82 ModifyConsoleCommand(__CC_keybind_name ).setObject(nullptr); 83 ModifyConsoleCommand(__CC_tkeybind_name).setObject(nullptr); 84 ModifyConsoleCommand(__CC_unbind_name ).setObject(nullptr); 85 ModifyConsoleCommand(__CC_tunbind_name ).setObject(nullptr); 86 86 } 87 87 … … 205 205 void KeyBinderManager::registerKeybindCallback(LuaFunctor* function) 206 206 { 207 this->callbackFunction_ = function;207 this->callbackFunction_.reset(function); 208 208 } 209 209 } -
code/branches/cpp11_v3/src/libraries/core/input/KeyBinderManager.h
r9667 r11054 34 34 #include <map> 35 35 #include <string> 36 #include <memory> 36 37 37 38 #include "util/Singleton.h" … … 101 102 102 103 private: 103 KeyBinderManager(const KeyBinderManager&); 104 // non-copyable: 105 KeyBinderManager(const KeyBinderManager&) = delete; 106 KeyBinderManager& operator=(const KeyBinderManager&) = delete; 107 104 108 void keybindInternal(const std::string& command, bool bTemporary); 105 109 void keybindKeyPressed(const std::string& keyName); … … 107 111 108 112 // KeyBinder management 109 KeyBinder* currentBinder_; //! Currently selected KeyBinder (never NULL!)110 std::map<std::string, KeyBinder*> binders_; //! All loaded KeyBinders111 bool bDefaultFileLoaded_; //! Tells whether the default one is loaded112 std::string defaultFilename_; //! Name of the file with the default key bindings113 KeyBinder* currentBinder_; //! Currently selected KeyBinder (never nullptr!) 114 std::map<std::string, KeyBinder*> binders_; //! All loaded KeyBinders 115 bool bDefaultFileLoaded_; //! Tells whether the default one is loaded 116 std::string defaultFilename_; //! Name of the file with the default key bindings 113 117 114 118 // keybind command related 115 SharedPtr<LuaFunctor> callbackFunction_;//! Function to be called when key was pressed after "keybind" command116 bool bBinding_; //! Tells whether a key binding process is active117 bool bTemporary_; //! Stores tkeybind/keybind value118 std::string command_; //! Stores the command received by (t)keybind119 std::shared_ptr<LuaFunctor> callbackFunction_; //! Function to be called when key was pressed after "keybind" command 120 bool bBinding_; //! Tells whether a key binding process is active 121 bool bTemporary_; //! Stores tkeybind/keybind value 122 std::string command_; //! Stores the command received by (t)keybind 119 123 120 124 static KeyBinderManager* singletonPtr_s; -
code/branches/cpp11_v3/src/libraries/core/input/KeyDetector.cc
r10624 r11054 62 62 KeyDetector::~KeyDetector() 63 63 { 64 inputState_->setHandler( NULL);64 inputState_->setHandler(nullptr); 65 65 InputManager::getInstance().destroyState("detector"); 66 66 ModifyConsoleCommand(__CC_KeyDetector_callback_name).resetFunction(); … … 70 70 { 71 71 // Assign every button/axis the same command, but with its name as argument 72 for ( std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)73 it->second->parse(__CC_KeyDetector_callback_name + ' ' + it->second->groupName_ + "." + it->second->name_);72 for (const auto& mapEntry : allButtons_) 73 mapEntry.second->parse(__CC_KeyDetector_callback_name + ' ' + mapEntry.second->groupName_ + "." + mapEntry.second->name_); 74 74 } 75 75 -
code/branches/cpp11_v3/src/libraries/core/input/KeyDetector.h
r8729 r11054 48 48 49 49 private: 50 KeyDetector(const KeyDetector&); 50 // non-copyable: 51 KeyDetector(const KeyDetector&) = delete; 52 KeyDetector& operator=(const KeyDetector&) = delete; 51 53 52 54 void callback(const std::string& name); 53 v oid JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);55 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) override; 54 56 void assignCommands(); 55 57 -
code/branches/cpp11_v3/src/libraries/core/input/Keyboard.h
r8729 r11054 63 63 //! Only resets the keyboard modifiers. Initialising is done in the base class. 64 64 Keyboard(unsigned int id, OIS::InputManager* oisInputManager) : super(id, oisInputManager), modifiers_(0) { } 65 ~Keyboard() { }65 ~Keyboard() = default; 66 66 67 67 private: … … 75 75 } 76 76 77 bool keyPressed(const OIS::KeyEvent& arg);78 bool keyReleased(const OIS::KeyEvent& arg);77 virtual bool keyPressed(const OIS::KeyEvent& arg) override; 78 virtual bool keyReleased(const OIS::KeyEvent& arg) override; 79 79 80 80 //! Returns the class name as string -
code/branches/cpp11_v3/src/libraries/core/input/Mouse.cc
r10624 r11054 68 68 { 69 69 #ifdef ORXONOX_PLATFORM_LINUX 70 ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject( 0);71 ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject( 0);70 ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject(nullptr); 71 ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject(nullptr); 72 72 #endif 73 73 } … … 82 82 IntVector2 rel(e.state.X.rel, e.state.Y.rel); 83 83 IntVector2 clippingSize(e.state.width, e.state.height); 84 for ( unsigned int i = 0; i < inputStates_.size(); ++i)85 inputStates_[i]->mouseMoved(abs, rel, clippingSize);84 for (InputState* state : inputStates_) 85 state->mouseMoved(abs, rel, clippingSize); 86 86 } 87 87 … … 89 89 if (e.state.Z.rel != 0) 90 90 { 91 for ( unsigned int i = 0; i < inputStates_.size(); ++i)92 inputStates_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);91 for (InputState* state : inputStates_) 92 state->mouseScrolled(e.state.Z.abs, e.state.Z.rel); 93 93 } 94 94 -
code/branches/cpp11_v3/src/libraries/core/input/Mouse.h
r7809 r11054 74 74 private: 75 75 //! OIS event handler 76 bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id)76 virtual bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id) override 77 77 { 78 78 super::buttonPressed(static_cast<MouseButtonCode::ByEnum>(id)); … … 81 81 82 82 //! OIS event handler 83 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id)83 virtual bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id) override 84 84 { 85 85 super::buttonReleased(static_cast<MouseButtonCode::ByEnum>(id)); … … 87 87 } 88 88 89 bool mouseMoved(const OIS::MouseEvent &arg);89 virtual bool mouseMoved(const OIS::MouseEvent &arg) override; 90 90 91 v oid windowResized(unsigned int newWidth, unsigned int newHeight);91 virtual void windowResized(unsigned int newWidth, unsigned int newHeight) override; 92 92 93 93 // Returns the class name as string -
code/branches/cpp11_v3/src/libraries/core/module/DynLib.cc
r10540 r11054 56 56 { 57 57 mName = name; 58 m_hInst = NULL;58 m_hInst = nullptr; 59 59 } 60 60 … … 127 127 FORMAT_MESSAGE_FROM_SYSTEM | 128 128 FORMAT_MESSAGE_IGNORE_INSERTS, 129 NULL,129 nullptr, 130 130 GetLastError(), 131 131 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 132 132 (LPTSTR) &lpMsgBuf, 133 133 0, 134 NULL134 nullptr 135 135 ); 136 136 std::string ret = (char*)lpMsgBuf; -
code/branches/cpp11_v3/src/libraries/core/module/DynLib.h
r10541 r11054 45 45 #if defined(ORXONOX_PLATFORM_WINDOWS) 46 46 # define DYNLIB_HANDLE hInstance 47 # define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )47 # define DYNLIB_LOAD( a ) LoadLibraryEx( a, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH ) 48 48 # define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b ) 49 49 # define DYNLIB_UNLOAD( a ) !FreeLibrary( a ) … … 104 104 the symbol. 105 105 @par 106 If the function fails, the returned value is <b> NULL</b>.106 If the function fails, the returned value is <b>nullptr</b>. 107 107 108 108 */ -
code/branches/cpp11_v3/src/libraries/core/module/DynLibManager.cc
r10540 r11054 38 38 //----------------------------------------------------------------------- 39 39 //! Static pointer to the singleton 40 DynLibManager* DynLibManager::singletonPtr_s = 0;40 DynLibManager* DynLibManager::singletonPtr_s = nullptr; 41 41 42 42 //----------------------------------------------------------------------- … … 75 75 { 76 76 // Unload & delete resources in turn 77 for ( DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it)77 for (const auto& mapEntry : mLibList) 78 78 { 79 it->second->unload();80 delete it->second;79 mapEntry.second->unload(); 80 delete mapEntry.second; 81 81 } 82 82 -
code/branches/cpp11_v3/src/libraries/core/module/ModuleInstance.cc
r10549 r11054 33 33 namespace orxonox 34 34 { 35 ModuleInstance* ModuleInstance::currentModuleInstance_s = NULL;35 ModuleInstance* ModuleInstance::currentModuleInstance_s = nullptr; 36 36 37 37 ModuleInstance::ModuleInstance(const std::string& libraryName) 38 38 : libraryName_(libraryName) 39 , dynLib_( NULL)39 , dynLib_(nullptr) 40 40 { 41 41 } … … 59 59 { 60 60 const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type]; 61 for ( std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it)62 (*it)->load();61 for (StaticallyInitializedInstance* instance : instances) 62 instance->load(); 63 63 } 64 64 … … 73 73 void ModuleInstance::deleteAllStaticallyInitializedInstances() 74 74 { 75 std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> 75 std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*>> copy(this->staticallyInitializedInstancesByType_); 76 76 this->staticallyInitializedInstancesByType_.clear(); 77 for ( std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> >::iterator it1 = copy.begin(); it1 != copy.end(); ++it1)78 for ( std::set<StaticallyInitializedInstance*>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2)79 delete (*it2);77 for (const auto& mapEntry : copy) 78 for (StaticallyInitializedInstance* instance : mapEntry.second) 79 delete instance; 80 80 } 81 81 -
code/branches/cpp11_v3/src/libraries/core/module/ModuleInstance.h
r10549 r11054 69 69 70 70 private: 71 std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> 71 std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*>> staticallyInitializedInstancesByType_; 72 72 std::string libraryName_; 73 73 DynLib* dynLib_; -
code/branches/cpp11_v3/src/libraries/core/module/Plugin.cc
r11015 r11054 39 39 { 40 40 this->referenceCounter_ = 0; 41 this->moduleInstance_ = NULL;41 this->moduleInstance_ = nullptr; 42 42 } 43 43 … … 45 45 { 46 46 // force unloading of the module when the plugin is destroyed 47 if (this->moduleInstance_ != NULL)47 if (this->moduleInstance_ != nullptr) 48 48 this->unloadModule(); 49 49 } -
code/branches/cpp11_v3/src/libraries/core/module/PluginManager.cc
r11017 r11054 54 54 SetConsoleCommand("PluginManager", __CC_PluginManager_unload_name, &PluginManager::unloadPlugin); 55 55 56 PluginManager* PluginManager::singletonPtr_s = 0;56 PluginManager* PluginManager::singletonPtr_s = nullptr; 57 57 58 58 RegisterAbstractClass(PluginManager).inheritsFrom<Configurable>(); … … 70 70 PluginManager::~PluginManager() 71 71 { 72 ModifyConsoleCommand("PluginManager", __CC_PluginManager_load_name).setObject( NULL);73 ModifyConsoleCommand("PluginManager", __CC_PluginManager_unload_name).setObject( NULL);72 ModifyConsoleCommand("PluginManager", __CC_PluginManager_load_name).setObject(nullptr); 73 ModifyConsoleCommand("PluginManager", __CC_PluginManager_unload_name).setObject(nullptr); 74 74 75 for ( std::map<std::string, PluginReference*>::iterator it = this->references_.begin(); it != this->references_.end(); ++it)76 delete it->second;77 for ( std::map<std::string, Plugin*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)78 delete it->second;75 for (const auto& mapEntry : this->references_) 76 delete mapEntry.second; 77 for (const auto& mapEntry : this->plugins_) 78 delete mapEntry.second; 79 79 } 80 80 … … 96 96 { 97 97 const std::vector<std::string>& pluginPaths = ApplicationPaths::getInstance().getPluginPaths(); 98 for ( std::vector<std::string>::const_iterator it = pluginPaths.begin(); it != pluginPaths.end(); ++it)98 for (const std::string& libraryName : pluginPaths) 99 99 { 100 100 std::string name; 101 std::string libraryName = (*it);102 101 std::string filename = libraryName + + specialConfig::pluginExtension; 103 102 std::ifstream infile(filename.c_str()); … … 117 116 { 118 117 Plugin* plugin = this->plugins_[name]; 119 if (plugin != NULL)118 if (plugin != nullptr) 120 119 plugin->reference(); 121 120 else … … 126 125 { 127 126 Plugin* plugin = this->plugins_[name]; 128 if (plugin != NULL)127 if (plugin != nullptr) 129 128 plugin->dereference(this->bMerelyDeactivatePlugins_); 130 129 else … … 137 136 void PluginManager::loadPlugin(const std::string& name) 138 137 { 139 if (this->references_[name] == NULL)138 if (this->references_[name] == nullptr) 140 139 { 141 140 this->references_[name] = new PluginReference(name); … … 152 151 { 153 152 PluginReference* reference = this->references_[name]; 154 if (reference != NULL)153 if (reference != nullptr) 155 154 { 156 this->references_[name] = NULL;155 this->references_[name] = nullptr; 157 156 delete reference; 158 157 } -
code/branches/cpp11_v3/src/libraries/core/module/StaticInitializationHandler.h
r10532 r11054 37 37 { 38 38 public: 39 StaticInitializationHandler() {}40 virtual ~StaticInitializationHandler() {}39 StaticInitializationHandler() = default; 40 virtual ~StaticInitializationHandler() = default; 41 41 42 42 virtual void setupHandler() = 0; -
code/branches/cpp11_v3/src/libraries/core/module/StaticInitializationHandlerIncludes.h
r10535 r11054 53 53 ~StaticallyInitializedStaticInitializationHandler() { delete handler_; } 54 54 55 virtual void load() ;56 virtual void unload() ;55 virtual void load() override; 56 virtual void unload() override; 57 57 58 58 inline StaticInitializationHandler& getHandler() -
code/branches/cpp11_v3/src/libraries/core/module/StaticInitializationManager.cc
r10542 r11054 33 33 namespace orxonox 34 34 { 35 StaticInitializationManager* StaticInitializationManager::singletonPtr_s = 0;35 StaticInitializationManager* StaticInitializationManager::singletonPtr_s = nullptr; 36 36 37 37 void StaticInitializationManager::addHandler(StaticInitializationHandler* handler) … … 50 50 { 51 51 // attention: loading a module may add new handlers to the list 52 for ( std::list<StaticInitializationHandler*>::iterator it = this->handlers_.begin(); it != this->handlers_.end(); ++it)53 (*it)->loadModule(module);52 for (StaticInitializationHandler* handler : this->handlers_) 53 handler->loadModule(module); 54 54 } 55 55 -
code/branches/cpp11_v3/src/libraries/core/module/StaticInitializationManager.h
r10542 r11054 43 43 44 44 public: 45 StaticInitializationManager() {}46 virtual ~StaticInitializationManager() {}45 StaticInitializationManager() = default; 46 virtual ~StaticInitializationManager() = default; 47 47 48 48 void addHandler(StaticInitializationHandler* handler); -
code/branches/cpp11_v3/src/libraries/core/object/ClassFactory.h
r9667 r11054 53 53 { 54 54 public: 55 virtual ~Factory() {} 55 Factory() = default; 56 virtual ~Factory() = default; 56 57 virtual Identifiable* fabricate(Context* context) = 0; 57 58 }; -
code/branches/cpp11_v3/src/libraries/core/object/Context.cc
r10624 r11054 40 40 RegisterClass(Context); 41 41 42 Context* Context::rootContext_s = 0;42 Context* Context::rootContext_s = nullptr; 43 43 44 44 Context* getContextForInitializationOfOtherContexts() … … 46 46 static size_t count = 0; 47 47 // the first time this is called, ++count returns 1 and the context is created 48 // the second time this is called, ++count returns 2 and NULLis returned because we're in the constructor of the context itself48 // the second time this is called, ++count returns 2 and nullptr is returned because we're in the constructor of the context itself 49 49 // for each future call the context (now completely created) is returned 50 50 if (++count == 2) 51 return NULL;51 return nullptr; 52 52 else 53 53 { 54 static Context context( NULL);54 static Context context(nullptr); 55 55 return &context; 56 56 } … … 70 70 // unregister context from object lists before object lists are destroyed 71 71 this->unregisterObject(); 72 for ( size_t i = 0; i < this->objectLists_.size(); ++i)73 delete this->objectLists_[i];72 for (ObjectListBase* objectList : this->objectLists_) 73 delete objectList; 74 74 } 75 75 … … 82 82 { 83 83 delete Context::rootContext_s; 84 Context::rootContext_s = NULL;84 Context::rootContext_s = nullptr; 85 85 } 86 86 87 87 /*static*/ Context* Context::getRootContext() 88 88 { 89 OrxVerify(Context::rootContext_s != NULL, "Root Context is undefined");89 OrxVerify(Context::rootContext_s != nullptr, "Root Context is undefined"); 90 90 return Context::rootContext_s; 91 91 } … … 105 105 ObjectListBase* objectList = this->getObjectList(identifier); 106 106 delete objectList; 107 this->objectLists_[identifier->getClassID()] = NULL;107 this->objectLists_[identifier->getClassID()] = nullptr; 108 108 } 109 109 } -
code/branches/cpp11_v3/src/libraries/core/object/DestroyLaterManager.h
r10624 r11054 45 45 virtual ~DestroyLaterManager(); 46 46 47 virtual void preUpdate(const Clock& time) { /*no action*/ }48 virtual void postUpdate(const Clock& time) ;47 virtual void preUpdate(const Clock& time) override { /*no action*/ } 48 virtual void postUpdate(const Clock& time) override; 49 49 50 50 void retain(Destroyable* instance) … … 52 52 53 53 private: 54 std::vector<StrongPtr<Destroyable> 54 std::vector<StrongPtr<Destroyable>> retainedInstances_; 55 55 56 56 static DestroyLaterManager* singletonPtr_s; -
code/branches/cpp11_v3/src/libraries/core/object/Destroyable.cc
r11019 r11054 70 70 void Destroyable::destroy() 71 71 { 72 assert(this); // Just in case someone tries to delete a NULL pointer72 assert(this); // Just in case someone tries to delete a nullptr 73 73 this->requestedDestruction_ = true; 74 74 if (this->referenceCount_ == 0) -
code/branches/cpp11_v3/src/libraries/core/object/Iterator.h
r10624 r11054 70 70 */ 71 71 template <class T> 72 class Iterator : public IteratorBase<T, Iterator<T> 72 class Iterator : public IteratorBase<T, Iterator<T>> 73 73 { 74 74 public: … … 76 76 @brief Constructor: Sets the element, whereon the iterator points, to zero. 77 77 */ 78 inline Iterator() : IteratorBase<T, Iterator<T> >() {} 79 80 /** 81 @brief Constructor: Sets this element to a given element 82 @param element The element 83 */ 84 inline Iterator(ObjectListBaseElement* element) : IteratorBase<T, Iterator<T> >(element) {} 78 inline Iterator() : IteratorBase<T, Iterator<T>>() {} 85 79 86 80 /** … … 88 82 @param other The other Iterator 89 83 */ 90 inline Iterator(const IteratorBase<T, Iterator<T> >& other) : IteratorBase<T, Iterator<T> >(other) {} 84 template <class OT, class OI> 85 inline Iterator(const IteratorBase<OT, OI>& other) : IteratorBase<T, Iterator<T>>(other) {} 91 86 92 87 /** -
code/branches/cpp11_v3/src/libraries/core/object/IteratorBase.h
r10624 r11054 37 37 38 38 #include "core/CorePrereqs.h" 39 40 #include <boost/static_assert.hpp>41 #include <boost/type_traits/is_base_of.hpp>42 39 43 40 #include "ObjectListBase.h" … … 52 49 class IteratorBase : public ObjectListElementRemovalListener 53 50 { 54 BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));55 56 p rotected:51 static_assert(std::is_base_of<Listable, T>::value, "IteratorBase can only be used with Listables"); 52 53 public: 57 54 /** 58 55 @brief Constructor: Sets the element, whereon the iterator points, to the given element. 59 This constructor is protected and only for internal usage (don't mess with the BaseElements directly). 60 */ 61 inline IteratorBase(ObjectListBaseElement* element = NULL) 56 */ 57 inline IteratorBase(ObjectListElement<T>* element = nullptr) 62 58 { 63 59 this->element_ = element; … … 65 61 } 66 62 67 68 public:69 /**70 @brief Constructor: Sets the element, whereon the iterator points, to the given element.71 */72 inline IteratorBase(ObjectListElement<T>* element)73 {74 this->element_ = element;75 this->registerIterator();76 }77 78 63 /** 79 64 @brief Constructor: Sets the element, whereon the iterator points, to the given element of another type. 80 65 The element's type O must be a derivative of the Iterator's type T. 81 66 */ 82 template <class O> 83 inline IteratorBase(ObjectListElement<O>* element) 84 { 85 (void)static_cast<T*>((O*)NULL); // Check type: The element's type O must be a derivative of the Iterator's type T. 86 this->element_ = element; 87 this->registerIterator(); 88 } 89 90 /** 91 @brief Constructor: Sets this element to the element of another Iterator. 92 @param other The other Iterator 93 */ 94 inline IteratorBase(const IteratorBase& other) 95 { 96 this->element_ = other.element_; 67 template <class OT, class OI> 68 inline IteratorBase(const IteratorBase<OT, OI>& other) 69 { 70 this->element_ = other.getElement(); 97 71 this->registerIterator(); 98 72 } … … 172 146 @return True if the Iterator points to an existing object. 173 147 */ 174 inline operator bool() const175 { 176 return (this->element_ != NULL);148 inline explicit operator bool() const 149 { 150 return (this->element_ != nullptr); 177 151 } 178 152 … … 201 175 @param object The object to compare with 202 176 */ 203 virtual void removedElement(ObjectListBaseElement* element) 177 virtual void removedElement(ObjectListBaseElement* element) override 204 178 { 205 179 if (this->element_ == element) 206 180 this->operator++(); 181 } 182 183 inline ObjectListBaseElement* getElement() const 184 { 185 return this->element_; 207 186 } 208 187 … … 226 205 } 227 206 else 228 this->list_ = NULL;207 this->list_ = nullptr; 229 208 } 230 209 -
code/branches/cpp11_v3/src/libraries/core/object/Listable.cc
r10624 r11054 44 44 @brief Constructor: Allocates space in the element list. 45 45 */ 46 Listable::Listable() 46 Listable::Listable() : Listable(Context::getRootContext()) 47 47 { 48 this->context_ = Context::getRootContext();49 this->elements_.reserve(6);50 51 RegisterObject(Listable);52 48 } 53 49 … … 76 72 void Listable::unregisterObject() 77 73 { 78 for ( size_t i = 0; i < this->elements_.size(); ++i)79 Listable::deleteObjectListElement( this->elements_[i]);74 for (ObjectListBaseElement* element : this->elements_) 75 Listable::deleteObjectListElement(element); 80 76 this->elements_.clear(); 81 77 } … … 91 87 this->elements_.clear(); 92 88 93 for ( size_t i = 0; i < copy.size(); ++i)89 for (ObjectListBaseElement* element : copy) 94 90 { 95 copy[i]->changeContext(this->context_, context);96 Listable::deleteObjectListElement( copy[i]);91 element->changeContext(this->context_, context); 92 Listable::deleteObjectListElement(element); 97 93 } 98 94 -
code/branches/cpp11_v3/src/libraries/core/object/Listable.h
r9667 r11054 40 40 #include <vector> 41 41 42 #include "util/SmallObjectAllocator.h" 42 43 #include "core/class/Identifiable.h" 43 44 -
code/branches/cpp11_v3/src/libraries/core/object/ObjectList.h
r10624 r11054 47 47 #include "core/CorePrereqs.h" 48 48 49 #include <boost/static_assert.hpp>50 #include <boost/type_traits/is_base_of.hpp>51 52 49 #include "ObjectListBase.h" 53 50 #include "ObjectListIterator.h" … … 69 66 class ObjectList 70 67 { 71 BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));68 static_assert(std::is_base_of<Listable, T>::value, "ObjectList can only be used with Listables"); 72 69 73 70 public: 74 71 typedef ObjectListIterator<T> iterator; 75 72 76 /// Returns the size of the list (for the root context) 77 inline static size_t size() 78 { return size(Context::getRootContext()); } 73 ObjectList() : ObjectList(Context::getRootContext()) {} 74 ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {} 75 ObjectList(ObjectListBase* list) : list_(list) {} 76 79 77 /// Returns the size of the list 80 inline static size_t size(Context* context) 81 { 82 return context->getObjectList<T>()->size(); 83 } 78 inline size_t size() 79 { return this->list_->size(); } 84 80 85 /// Returns an Iterator to the first element in the list (for the root context).86 inline static ObjectListElement<T>* begin()87 { return begin(Context::getRootContext()); }88 81 /// Returns an Iterator to the first element in the list. 89 inline static ObjectListElement<T>* begin(Context* context)90 { 91 ObjectListBase* list = context->getObjectList<T>();92 return static_cast<ObjectListElement<T>*>(list->begin());93 }82 inline ObjectListIterator<T> begin() 83 { return static_cast<ObjectListElement<T>*>(this->list_->begin()); } 84 /// Returns an Iterator to the element after the last element in the list. 85 inline ObjectListIterator<T> end() 86 { return static_cast<ObjectListElement<T>*>(this->list_->end()); } 94 87 95 /// Returns an Iterator to the element after the last element in the list (for the root context). 96 inline static ObjectListElement<T>* end() 97 { return end(Context::getRootContext()); } 98 /// Returns an Iterator to the element after the last element in the list. 99 inline static ObjectListElement<T>* end(Context* context) 100 { 101 ObjectListBase* list = context->getObjectList<T>(); 102 return static_cast<ObjectListElement<T>*>(list->end()); 103 } 88 /// Returns an Iterator to the last element in the list. 89 inline ObjectListIterator<T> rbegin() 90 { return static_cast<ObjectListElement<T>*>(this->list_->rbegin()); } 91 /// Returns an Iterator to the element before the first element in the list. 92 inline ObjectListIterator<T> rend() 93 { return static_cast<ObjectListElement<T>*>(this->list_->rend()); } 104 94 105 /// Returns an Iterator to the last element in the list (for the root context). 106 inline static ObjectListElement<T>* rbegin() 107 { return rbegin(Context::getRootContext()); } 108 /// Returns an Iterator to the last element in the list. 109 inline static ObjectListElement<T>* rbegin(Context* context) 110 { 111 ObjectListBase* list = context->getObjectList<T>(); 112 return static_cast<ObjectListElement<T>*>(list->rbegin()); 113 } 114 115 /// Returns an Iterator to the element before the first element in the list (for the root context). 116 inline static ObjectListElement<T>* rend() 117 { return rend(Context::getRootContext()); } 118 /// Returns an Iterator to the element before the first element in the list. 119 inline static ObjectListElement<T>* rend(Context* context) 120 { 121 ObjectListBase* list = context->getObjectList<T>(); 122 return static_cast<ObjectListElement<T>*>(list->rend()); 123 } 95 private: 96 ObjectListBase* list_; 124 97 }; 125 98 } -
code/branches/cpp11_v3/src/libraries/core/object/ObjectListBase.cc
r9975 r11054 58 58 ObjectListBase::ObjectListBase() 59 59 { 60 this->first_ = 0;61 this->last_ = 0;60 this->first_ = nullptr; 61 this->last_ = nullptr; 62 62 this->size_ = 0; 63 63 } … … 73 73 ObjectListBaseElement* next = current->next_; 74 74 75 current->list_ = 0;76 current->next_ = 0;77 current->prev_ = 0;75 current->list_ = nullptr; 76 current->next_ = nullptr; 77 current->prev_ = nullptr; 78 78 79 79 current = next; … … 92 92 void ObjectListBase::notifyRemovalListeners(ObjectListBaseElement* element) const 93 93 { 94 for ( std::vector<ObjectListElementRemovalListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)95 (*it)->removedElement(element);94 for (ObjectListElementRemovalListener* listener : this->listeners_) 95 listener->removedElement(element); 96 96 } 97 97 … … 155 155 this->first_ = element->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list 156 156 157 element->list_ = 0;158 element->next_ = 0;159 element->prev_ = 0;157 element->list_ = nullptr; 158 element->next_ = nullptr; 159 element->prev_ = nullptr; 160 160 --this->size_; 161 161 } -
code/branches/cpp11_v3/src/libraries/core/object/ObjectListBase.h
r9667 r11054 57 57 @param objectBase The object to store 58 58 */ 59 ObjectListBaseElement(Listable* object) : next_( 0), prev_(0), objectBase_(object), list_(0) {}59 ObjectListBaseElement(Listable* object) : next_(nullptr), prev_(nullptr), objectBase_(object), list_(nullptr) {} 60 60 virtual ~ObjectListBaseElement() { this->removeFromList(); } 61 61 … … 82 82 ObjectListElement(T* object) : ObjectListBaseElement(static_cast<Listable*>(object)), object_(object) {} 83 83 84 virtual void changeContext(Context* oldContext, Context* newContext) 84 virtual void changeContext(Context* oldContext, Context* newContext) override 85 85 { 86 86 // add object to new context, but only if this element belongs exactly to the old context (and not to a sub-context to avoid re-adding objects … … 104 104 { 105 105 public: 106 virtual ~ObjectListElementRemovalListener() {} 106 ObjectListElementRemovalListener() = default; 107 virtual ~ObjectListElementRemovalListener() = default; 107 108 virtual void removedElement(ObjectListBaseElement* element) = 0; 108 109 }; … … 136 137 inline ObjectListBaseElement* begin() const { return this->first_; } 137 138 /// Returns a pointer to the element after the last element in the list. Works only with Iterator. 138 inline ObjectListBaseElement* end() const { return 0; }139 inline ObjectListBaseElement* end() const { return nullptr; } 139 140 /// Returns a pointer to the last element in the list. Works only with Iterator. 140 141 inline ObjectListBaseElement* rbegin() const { return this->last_; } 141 142 /// Returns a pointer to the element in front of the first element in the list. Works only with Iterator. 142 inline ObjectListBaseElement* rend() const { return 0; }143 inline ObjectListBaseElement* rend() const { return nullptr; } 143 144 144 145 inline void registerRemovalListener(ObjectListElementRemovalListener* listener) { this->listeners_.push_back(listener); } -
code/branches/cpp11_v3/src/libraries/core/object/ObjectListIterator.h
r10624 r11054 41 41 Usage: 42 42 @code 43 for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it) 43 ObjectList<myClass> list; 44 for (ObjectListIterator<myClass> it = list.begin(); it != list.end(); ++it) 44 45 { 45 46 it->someFunction(...); … … 68 69 */ 69 70 template <class T> 70 class ObjectListIterator : public IteratorBase<T, ObjectListIterator<T> 71 class ObjectListIterator : public IteratorBase<T, ObjectListIterator<T>> 71 72 { 72 73 public: … … 74 75 @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero. 75 76 */ 76 inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> 77 inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T>>() {} 77 78 78 79 /** … … 80 81 @param element The element to start with 81 82 */ 82 inline ObjectListIterator(ObjectListElement<T>* element) : IteratorBase<T, ObjectListIterator<T> 83 inline ObjectListIterator(ObjectListElement<T>* element) : IteratorBase<T, ObjectListIterator<T>>(element) {} 83 84 84 85 /** … … 86 87 @param other The other ObjectListIterator 87 88 */ 88 inline ObjectListIterator(const IteratorBase<T, ObjectListIterator<T> >& other) : IteratorBase<T, ObjectListIterator<T> >(other) {} 89 template <class OI> 90 inline ObjectListIterator(const IteratorBase<T, OI>& other) : IteratorBase<T, ObjectListIterator<T>>(other) {} 89 91 90 92 /** -
code/branches/cpp11_v3/src/libraries/core/object/StrongPtr.h
r10624 r11054 43 43 orxonox::StrongPtr is an implementation of a smart pointer - it wraps a pointer to an 44 44 object and keeps this object alive until no StrongPtr points to this object anymore. 45 In contrast to orxonox::SharedPtr, StrongPtr works only with classes that are derived45 In contrast to std::shared_ptr, StrongPtr works only with classes that are derived 46 46 from orxonox::Destroyable, because it's an intrusive implementation, meaning the 47 47 reference counter is stored in the object itself. … … 51 51 at any time and also convert it back to a normal pointer if you like. This is possible 52 52 because the reference counter is stored in the object itself and not in StrongPtr (in 53 contrast to SharedPtr).53 contrast to std::shared_ptr). 54 54 55 55 @b Important: If you want to delete an object, you must not use @c delete @c object but … … 138 138 public: 139 139 /// Constructor: Initializes the strong pointer with a null pointer. 140 inline StrongPtr() : pointer_( 0), base_(0)140 inline StrongPtr() : pointer_(nullptr), base_(nullptr) 141 141 { 142 142 } … … 158 158 /// Copy-constructor for strong pointers to objects of another class. 159 159 template <class O> 160 inline StrongPtr(const StrongPtr<O>& other) : pointer_(other.get()), base_(other. base_)160 inline StrongPtr(const StrongPtr<O>& other) : pointer_(other.get()), base_(other.getBase()) 161 161 { 162 162 if (this->base_) … … 172 172 } 173 173 174 /// Move-constructor 175 inline StrongPtr(StrongPtr&& other) : pointer_(other.pointer_), base_(other.base_) 176 { 177 other.pointer_ = nullptr; 178 other.base_ = nullptr; 179 } 180 174 181 /// Destructor: Decrements the reference counter. 175 182 inline ~StrongPtr() … … 187 194 188 195 /// Assigns the wrapped pointer of another StrongPtr. 189 inline StrongPtr& operator=( const StrongPtr&other)190 { 191 StrongPtr(other).swap(*this);196 inline StrongPtr& operator=(StrongPtr other) 197 { 198 other.swap(*this); 192 199 return *this; 193 200 } … … 230 237 inline T* operator->() const 231 238 { 232 assert(this->pointer_ != 0);239 assert(this->pointer_ != nullptr); 233 240 return this->pointer_; 234 241 } … … 237 244 inline T& operator*() const 238 245 { 239 assert(this->pointer_ != 0);246 assert(this->pointer_ != nullptr); 240 247 return *this->pointer_; 241 248 } 242 249 243 /// Returns true if the wrapped pointer is NULL.244 inline bool operator!() const245 { 246 return (this->pointer_ == 0);250 /// Returns true if the pointer is not nullptr. 251 inline explicit operator bool() const 252 { 253 return (this->pointer_ != nullptr); 247 254 } 248 255 … … 262 269 } 263 270 264 /// Resets the strong pointer (equivalent to assigning a NULL pointer).271 /// Resets the strong pointer (equivalent to assigning a nullptr). 265 272 inline void reset() 266 273 { -
code/branches/cpp11_v3/src/libraries/core/object/WeakPtr.h
r10624 r11054 37 37 38 38 A WeakPtr wraps a pointer to an object. If the object gets deleted, the WeakPtr becomes 39 NULL. This can be used to store pointers to objects without knowing when they will be39 nullptr. This can be used to store pointers to objects without knowing when they will be 40 40 destroyed. 41 41 … … 50 50 WeakPtr<MyClass> pointer = object; // create a WeakPtr and assign the object 51 51 52 if (pointer) // checks if pointer is not NULL(which is true)52 if (pointer) // checks if pointer is not nullptr (which is true) 53 53 pointer->someFunction(); // calls MyClass::someFunction() 54 54 55 55 object->destroy(); // calls destroy() which deletes the object 56 56 57 if (pointer) // checks if pointer is not NULL(which is now false)57 if (pointer) // checks if pointer is not nullptr (which is now false) 58 58 pointer->someFunction(); // this will not be executed 59 59 @endcode … … 91 91 { 92 92 /** 93 @brief WeakPtr wraps a pointer to an object, which becomes NULLif the object is deleted.93 @brief WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted. 94 94 95 95 @see See @ref WeakPtrExample "this description" for more information and an example. … … 100 100 public: 101 101 /// Constructor: Initializes the weak pointer with a null pointer. 102 inline WeakPtr() : pointer_( 0), base_(0), callback_(0)102 inline WeakPtr() : pointer_(nullptr), base_(nullptr), callback_(nullptr) 103 103 { 104 104 } 105 105 106 106 /// Constructor: Initializes the weak pointer with a pointer to an object. 107 inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_( 0)107 inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(nullptr) 108 108 { 109 109 this->registerAsDestructionListener(this->base_); … … 111 111 112 112 /// Copy-constructor 113 inline WeakPtr(const WeakPtr& other) : pointer_(other.pointer_), base_(other.base_), callback_( 0)113 inline WeakPtr(const WeakPtr& other) : pointer_(other.pointer_), base_(other.base_), callback_(nullptr) 114 114 { 115 115 this->registerAsDestructionListener(this->base_); … … 118 118 /// Copy-constructor for weak pointers to objects of another class. 119 119 template <class O> 120 inline WeakPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other. base_), callback_(0)120 inline WeakPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase()), callback_(nullptr) 121 121 { 122 122 this->registerAsDestructionListener(this->base_); … … 124 124 125 125 /// Destructor 126 inline virtual~WeakPtr()126 virtual inline ~WeakPtr() 127 127 { 128 128 this->unregisterAsDestructionListener(this->base_); … … 137 137 138 138 /// Assigns the wrapped pointer of another WeakPtr. 139 inline WeakPtr& operator=( const WeakPtr&other)140 { 141 WeakPtr(other).swap(*this);139 inline WeakPtr& operator=(WeakPtr other) 140 { 141 other.swap(*this); 142 142 return *this; 143 143 } … … 172 172 inline T* operator->() const 173 173 { 174 assert(this->pointer_ != 0);174 assert(this->pointer_ != nullptr); 175 175 return this->pointer_; 176 176 } … … 179 179 inline T& operator*() const 180 180 { 181 assert(this->pointer_ != 0);181 assert(this->pointer_ != nullptr); 182 182 return *this->pointer_; 183 183 } 184 184 185 /// Returns true if the wrapped pointer is NULL.186 inline bool operator!() const187 { 188 return (this->pointer_ == 0);185 /// Returns true if the pointer is not nullptr. 186 inline explicit operator bool() const 187 { 188 return (this->pointer_ != nullptr); 189 189 } 190 190 … … 210 210 } 211 211 212 /// Resets the weak pointer (equivalent to assigning a NULL pointer).212 /// Resets the weak pointer (equivalent to assigning a nullptr). 213 213 inline void reset() 214 214 { … … 230 230 private: 231 231 /// Will be called by Destroyable::~Destroyable() if the stored object is deleted. Resets the wrapped pointer and executes the callback. 232 inline void objectDeleted()233 { 234 this->base_ = 0;235 this->pointer_ = 0;232 virtual inline void objectDeleted() override 233 { 234 this->base_ = nullptr; 235 this->pointer_ = nullptr; 236 236 if (this->callback_) 237 237 (*this->callback_)(); -
code/branches/cpp11_v3/src/libraries/core/singleton/Scope.h
r10514 r11054 72 72 protected: 73 73 ScopeListener() : bActivated_(false) { } 74 virtual ~ScopeListener() { }74 virtual ~ScopeListener() = default; 75 75 76 76 //! Gets called if the scope is activated -
code/branches/cpp11_v3/src/libraries/core/singleton/ScopeManager.cc
r10542 r11054 38 38 namespace orxonox 39 39 { 40 ScopeManager* ScopeManager::singletonPtr_s = 0;40 ScopeManager* ScopeManager::singletonPtr_s = nullptr; 41 41 42 42 void ScopeManager::addScope(ScopeID::Value scope) … … 73 73 void ScopeManager::activateListenersForScope(ScopeID::Value scope) 74 74 { 75 for ( std::set<ScopeListener*>::iterator it = this->listeners_[scope].begin(); it != this->listeners_[scope].end(); ++it)76 this->activateListener( *it);75 for (ScopeListener* listener : this->listeners_[scope]) 76 this->activateListener(listener); 77 77 } 78 78 79 79 void ScopeManager::deactivateListenersForScope(ScopeID::Value scope) 80 80 { 81 for ( std::set<ScopeListener*>::iterator it = this->listeners_[scope].begin(); it != this->listeners_[scope].end(); ++it)82 this->deactivateListener( *it);81 for (ScopeListener* listener : this->listeners_[scope]) 82 this->deactivateListener(listener); 83 83 } 84 84 -
code/branches/cpp11_v3/src/libraries/core/singleton/ScopeManager.h
r11012 r11054 83 83 84 84 std::set<ScopeID::Value> activeScopes_; 85 std::map<ScopeID::Value, std::set<ScopeListener*> 85 std::map<ScopeID::Value, std::set<ScopeListener*>> listeners_; //!< Stores all listeners for a scope 86 86 87 87 static ScopeManager* singletonPtr_s; -
code/branches/cpp11_v3/src/libraries/core/singleton/ScopedSingletonIncludes.h
r11052 r11054 71 71 */ 72 72 #define ManageScopedSingleton(className, scope, allowedToFail) \ 73 className* className::singletonPtr_s = NULL; \73 className* className::singletonPtr_s = nullptr; \ 74 74 static ScopedSingletonWrapper& className##ScopedSingletonWrapper \ 75 75 = (new orxonox::SI_SSW(new ClassScopedSingletonWrapper<className, allowedToFail>(#className), scope))->getWrapper() … … 87 87 ~StaticallyInitializedScopedSingletonWrapper() { delete wrapper_; } 88 88 89 virtual void load() ;90 virtual void unload() ;89 virtual void load() override; 90 virtual void unload() override; 91 91 92 92 inline ScopedSingletonWrapper& getWrapper() -
code/branches/cpp11_v3/src/libraries/core/singleton/ScopedSingletonWrapper.h
r10528 r11054 64 64 : className_(className) 65 65 { } 66 virtual ~ScopedSingletonWrapper() { }66 virtual ~ScopedSingletonWrapper() = default; 67 67 68 68 protected: … … 91 91 ClassScopedSingletonWrapper(const std::string& className) 92 92 : ScopedSingletonWrapper(className) 93 , singletonPtr_( NULL)93 , singletonPtr_(nullptr) 94 94 { 95 95 } … … 102 102 103 103 //! Called if the Scope of the Singleton gets active (creates the instance) 104 v oid activated()104 virtual void activated() override 105 105 { 106 assert(singletonPtr_ == NULL);106 assert(singletonPtr_ == nullptr); 107 107 singletonPtr_ = new T(); 108 108 } 109 109 110 110 //! Called if the Scope of this Singleton gets deactivated (destroys the instance) 111 v oid deactivated()111 virtual void deactivated() override 112 112 { 113 assert(singletonPtr_ != NULL);113 assert(singletonPtr_ != nullptr); 114 114 this->destroy(singletonPtr_); 115 singletonPtr_ = NULL;115 singletonPtr_ = nullptr; 116 116 } 117 117 … … 146 146 ClassScopedSingletonWrapper(const std::string& className) 147 147 : ScopedSingletonWrapper(className) 148 , singletonPtr_( NULL)148 , singletonPtr_(nullptr) 149 149 { 150 150 } … … 157 157 158 158 //! Called if the Scope of the Singleton gets active (creates the instance) 159 v oid activated()159 virtual void activated() override 160 160 { 161 assert(singletonPtr_ == NULL);161 assert(singletonPtr_ == nullptr); 162 162 try 163 163 { singletonPtr_ = new T(); } … … 169 169 170 170 //! Called if the Scope of this Singleton gets deactivated (destroys the instance) 171 v oid deactivated()171 virtual void deactivated() override 172 172 { 173 if (singletonPtr_ != NULL)173 if (singletonPtr_ != nullptr) 174 174 { 175 175 this->destroy(singletonPtr_); 176 singletonPtr_ = NULL;176 singletonPtr_ = nullptr; 177 177 } 178 178 } -
code/branches/cpp11_v3/src/libraries/network/Client.cc
r10624 r11054 161 161 { 162 162 std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates(); 163 std::vector<packet::Gamestate*>::iterator it; 164 for( it = gamestates.begin(); it != gamestates.end(); ++it ) 163 for( packet::Gamestate* gamestate : gamestates ) 165 164 { 166 (*it)->send( static_cast<Host*>(this) );165 gamestate->send( static_cast<Host*>(this) ); 167 166 } 168 167 } -
code/branches/cpp11_v3/src/libraries/network/Client.h
r8858 r11054 76 76 static Client* getInstance(){ return singletonPtr_s; } // tolua_export 77 77 78 bool establishConnection();78 virtual bool establishConnection() override; 79 79 void setDestination( const std::string& serverAddress, unsigned int port ); // tolua_export 80 bool closeConnection();81 v oid queuePacket(ENetPacket* packet, int clientID, uint8_t channelID);82 virtual bool sendPacket( packet::Packet* packet ) { return packet->send( static_cast<Host*>(this) ); }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) ;85 virtual void printRTT() ;80 virtual bool closeConnection() override; 81 virtual void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID) override; 82 virtual bool sendPacket( packet::Packet* packet ) override{ return packet->send( static_cast<Host*>(this) ); } 83 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override; 84 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override; 85 virtual void printRTT() override; 86 86 87 87 void update(const Clock& time); 88 88 protected: 89 virtual void connectionClosed() ;89 virtual void connectionClosed() override; 90 90 private: 91 91 Client(const Client& copy); // not used 92 virtual bool isServer_() {return false;}93 v oid processPacket(packet::Packet* packet);92 virtual bool isServer_() override{return false;} 93 virtual void processPacket(packet::Packet* packet) override; 94 94 95 95 static Client* singletonPtr_s; -
code/branches/cpp11_v3/src/libraries/network/ClientConnection.cc
r8858 r11054 44 44 Connection(NETWORK_PEER_ID_SERVER), 45 45 established_(false), 46 server_( NULL)46 server_(nullptr) 47 47 { 48 48 this->serverAddress_ = new ENetAddress(); … … 72 72 73 73 // create host 74 this->host_ = enet_host_create( NULL, NETWORK_CLIENT_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);74 this->host_ = enet_host_create(nullptr, NETWORK_CLIENT_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0); 75 75 76 if ( this->host_ == NULL)76 if ( this->host_ == nullptr ) 77 77 { 78 orxout(internal_error, context::network) << "ClientConnection: host_ == NULL" << endl;78 orxout(internal_error, context::network) << "ClientConnection: host_ == nullptr" << endl; 79 79 // error handling 80 80 return false; … … 93 93 94 94 this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CHANNEL_COUNT, 0); 95 if ( this->server_== NULL)95 if ( this->server_==nullptr ) 96 96 { 97 orxout(internal_error, context::network) << "ClientConnection: server_ == NULL" << endl;97 orxout(internal_error, context::network) << "ClientConnection: server_ == nullptr" << endl; 98 98 // error handling 99 99 return false; -
code/branches/cpp11_v3/src/libraries/network/ClientConnection.h
r8327 r11054 57 57 uint32_t getRTT(); 58 58 private: 59 virtual void addPeer(uint32_t peerID) ;60 virtual void removePeer(uint32_t peerID) ;59 virtual void addPeer(uint32_t peerID) override; 60 virtual void removePeer(uint32_t peerID) override; 61 61 62 62 bool disconnectConnection(); -
code/branches/cpp11_v3/src/libraries/network/ClientConnectionListener.cc
r10624 r11054 44 44 void ClientConnectionListener::broadcastClientConnected(unsigned int clientID) 45 45 { 46 for ( ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)47 it->clientConnected(clientID);46 for (ClientConnectionListener* listener : ObjectList<ClientConnectionListener>()) 47 listener->clientConnected(clientID); 48 48 } 49 49 50 50 void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID) 51 51 { 52 for ( ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)53 it->clientDisconnected(clientID);52 for (ClientConnectionListener* listener : ObjectList<ClientConnectionListener>()) 53 listener->clientDisconnected(clientID); 54 54 } 55 55 -
code/branches/cpp11_v3/src/libraries/network/Connection.cc
r8858 r11054 46 46 47 47 Connection::Connection(uint32_t firstPeerID): 48 host_( 0), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID)48 host_(nullptr), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID) 49 49 { 50 50 enet_initialize(); … … 81 81 { 82 82 // this->overallMutex_->lock(); 83 outgoingEvent outEvent = { peerID, outgoingEventType::disconnectPeer, 0, 0 };83 outgoingEvent outEvent = { peerID, outgoingEventType::disconnectPeer, nullptr, 0 }; 84 84 85 85 this->outgoingEventsMutex_->lock(); … … 91 91 void Connection::disconnectPeers() 92 92 { 93 outgoingEvent outEvent = { 0, outgoingEventType::disconnectPeers, 0, 0 };93 outgoingEvent outEvent = { 0, outgoingEventType::disconnectPeers, nullptr, 0 }; 94 94 95 95 this->outgoingEventsMutex_->lock(); … … 237 237 void Connection::disconnectPeersInternal() 238 238 { 239 std::map<uint32_t, ENetPeer*>::iterator it; 240 for( it=this->peerMap_.begin(); it!=this->peerMap_.end(); ++it ) 241 { 242 enet_peer_disconnect(it->second, 0); 239 for( const auto& mapEntry : this->peerMap_ ) 240 { 241 enet_peer_disconnect(mapEntry.second, 0); 243 242 } 244 243 uint32_t iterations = NETWORK_DISCONNECT_TIMEOUT/NETWORK_WAIT_TIMEOUT; … … 323 322 324 323 // create new peerEvent and return it 325 incomingEvent inEvent = { peerID, incomingEventType::peerConnect, 0};324 incomingEvent inEvent = { peerID, incomingEventType::peerConnect, nullptr }; 326 325 return inEvent; 327 326 } … … 338 337 339 338 // create new peerEvent and return it 340 incomingEvent inEvent = { peerID, incomingEventType::peerDisconnect, 0};339 incomingEvent inEvent = { peerID, incomingEventType::peerDisconnect, nullptr }; 341 340 return inEvent; 342 341 } -
code/branches/cpp11_v3/src/libraries/network/Connection.h
r8327 r11054 46 46 #include <map> 47 47 #include <enet/enet.h> 48 #include <boost/concept_check.hpp>49 48 50 49 namespace boost -
code/branches/cpp11_v3/src/libraries/network/FunctionCall.cc
r10624 r11054 48 48 bool FunctionCall::execute(){ 49 49 NetworkFunctionBase* fct = NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ ); 50 assert( fct != NULL);50 assert( fct != nullptr ); 51 51 assert( this->nrOfArguments_==this->arguments_.size() ); 52 52 switch(this->nrOfArguments_) … … 119 119 for( unsigned int i=0; i<this->nrOfArguments_; ++i ) 120 120 { 121 this->arguments_. push_back(MultiType());121 this->arguments_.emplace_back(); 122 122 this->arguments_.back().importData(mem); 123 123 } … … 131 131 *(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_; 132 132 mem += 3*sizeof(uint32_t); 133 for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it)133 for(const MultiType& argument : this->arguments_) 134 134 { 135 it->exportData( mem );135 argument.exportData( mem ); 136 136 } 137 137 } -
code/branches/cpp11_v3/src/libraries/network/FunctionCallManager.cc
r10624 r11054 37 37 38 38 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sPeerMap_; 39 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> >> FunctionCallManager::sIncomingFunctionCallBuffer_;39 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t>>> FunctionCallManager::sIncomingFunctionCallBuffer_; 40 40 41 41 … … 54 54 void FunctionCallManager::sendCalls(orxonox::Host* host) 55 55 { 56 std::map<uint32_t, packet::FunctionCalls*>::iterator it; 57 for (it = FunctionCallManager::sPeerMap_.begin(); it != FunctionCallManager::sPeerMap_.end(); ++it ) 56 for (const auto& mapEntry : FunctionCallManager::sPeerMap_ ) 58 57 { 59 58 assert(!FunctionCallManager::sPeerMap_.empty()); 60 it->second->send(host);59 mapEntry.second->send(host); 61 60 } 62 61 FunctionCallManager::sPeerMap_.clear(); … … 65 64 void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID) 66 65 { 67 FunctionCallManager::sIncomingFunctionCallBuffer_. push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, peerID)));66 FunctionCallManager::sIncomingFunctionCallBuffer_.emplace_back(fctCall, std::make_pair(minGamestateID, peerID)); 68 67 } 69 68 70 69 void FunctionCallManager::processBufferedFunctionCalls() 71 70 { 72 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> >>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();71 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t>>>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin(); 73 72 while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() ) 74 73 { -
code/branches/cpp11_v3/src/libraries/network/FunctionCallManager.h
r10624 r11054 54 54 55 55 static std::map<uint32_t, packet::FunctionCalls*> sPeerMap_; 56 static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t> >> sIncomingFunctionCallBuffer_;56 static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t>>> sIncomingFunctionCallBuffer_; 57 57 protected: 58 58 FunctionCallManager(); -
code/branches/cpp11_v3/src/libraries/network/GamestateHandler.cc
r7801 r11054 32 32 namespace orxonox { 33 33 34 // GamestateHandler *GamestateHandler::instance_= 0;34 // GamestateHandler *GamestateHandler::instance_=nullptr; 35 35 36 36 GamestateHandler::GamestateHandler() -
code/branches/cpp11_v3/src/libraries/network/GamestateManager.cc
r8858 r11054 60 60 { 61 61 GamestateManager::GamestateManager() : 62 currentGamestate_( 0), id_(0)62 currentGamestate_(nullptr), id_(0) 63 63 { 64 64 // trafficControl_ = new TrafficControl(); … … 70 70 { 71 71 if( this->currentGamestate_ ) 72 delete this->currentGamestate_;std::map<unsigned int, packet::Gamestate*>::iterator it; 73 for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it ) 74 delete it->second; 75 std::map<uint32_t, peerInfo>::iterator peerIt; 76 std::map<uint32_t, packet::Gamestate*>::iterator gamestateIt; 77 for( peerIt = peerMap_.begin(); peerIt != peerMap_.end(); ++peerIt ) 78 { 79 for( gamestateIt = peerIt->second.gamestates.begin(); gamestateIt != peerIt->second.gamestates.end(); ++gamestateIt ) 80 delete gamestateIt->second; 72 delete this->currentGamestate_; 73 for( const auto& mapEntry : gamestateQueue ) 74 delete mapEntry.second; 75 for( const auto& mapEntryPeer : peerMap_ ) 76 { 77 for( const auto& mapEntryGamestate : mapEntryPeer.second.gamestates ) 78 delete mapEntryGamestate.second; 81 79 } 82 80 // this->trafficControl_->destroy(); … … 107 105 if( this->gamestateQueue.empty() ) 108 106 return true; 109 std::map<unsigned int, packet::Gamestate*>::iterator it;110 107 // now push only the most recent gamestates we received (ignore obsolete ones) 111 for( it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++)112 { 113 OrxVerify(processGamestate( it->second), "ERROR: could not process Gamestate");114 sendAck( it->second->getID(), it->second->getPeerID() );115 delete it->second;108 for(const auto& mapEntry : gamestateQueue) 109 { 110 OrxVerify(processGamestate(mapEntry.second), "ERROR: could not process Gamestate"); 111 sendAck( mapEntry.second->getID(), mapEntry.second->getPeerID() ); 112 delete mapEntry.second; 116 113 } 117 114 // now clear the queue … … 140 137 141 138 bool GamestateManager::getSnapshot(){ 142 if ( currentGamestate_ != 0)139 if ( currentGamestate_ != nullptr ) 143 140 delete currentGamestate_; 144 141 uint8_t gsMode; … … 165 162 { //we have no data to send 166 163 delete currentGamestate_; 167 currentGamestate_= 0;164 currentGamestate_=nullptr; 168 165 return false; 169 166 } … … 177 174 std::vector<packet::Gamestate*> peerGamestates; 178 175 179 std::map<uint32_t, peerInfo>::iterator peerIt; 180 for( peerIt=peerMap_.begin(); peerIt!=peerMap_.end(); ++peerIt ) 181 { 182 if( !peerIt->second.isSynched ) 176 for( const auto& mapEntry : peerMap_ ) 177 { 178 if( !mapEntry.second.isSynched ) 183 179 { 184 180 orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl; 185 181 continue; 186 182 } 187 orxout(verbose_more, context::network) << "client id: " << peerIt->first << endl;183 orxout(verbose_more, context::network) << "client id: " << mapEntry.first << endl; 188 184 orxout(verbose_more, context::network) << "Server: doing gamestate gamestate preparation" << endl; 189 int peerID = peerIt->first; //get client id190 191 unsigned int lastAckedGamestateID = peerIt->second.lastAckedGamestateID;192 193 packet::Gamestate* baseGamestate= 0;185 int peerID = mapEntry.first; //get client id 186 187 unsigned int lastAckedGamestateID = mapEntry.second.lastAckedGamestateID; 188 189 packet::Gamestate* baseGamestate=nullptr; 194 190 if(lastAckedGamestateID != GAMESTATEID_INITIAL) 195 191 { … … 200 196 } 201 197 202 peerGamestates.push_back( 0); // insert an empty gamestate* to be changed198 peerGamestates.push_back(nullptr); // insert an empty gamestate* to be changed 203 199 finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ ); 204 if( peerGamestates.back()== 0)200 if( peerGamestates.back()==nullptr ) 205 201 // nothing to send to remove pointer from vector 206 202 peerGamestates.pop_back(); … … 243 239 { 244 240 delete diffed1; 245 destgamestate = 0;241 destgamestate = nullptr; 246 242 return; 247 243 } … … 340 336 { 341 337 assert(peerMap_.find(peerID)!=peerMap_.end()); 342 std::map<uint32_t, packet::Gamestate*>::iterator peerIt; 343 for( peerIt = peerMap_[peerID].gamestates.begin(); peerIt!=peerMap_[peerID].gamestates.end(); ++peerIt ) 344 { 345 delete peerIt->second; 338 for( const auto& mapEntry : peerMap_[peerID].gamestates ) 339 { 340 delete mapEntry.second; 346 341 } 347 342 peerMap_.erase(peerMap_.find(peerID)); … … 351 346 // void GamestateManager::removeClient(ClientInformation* client){ 352 347 // assert(client); 353 // std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> 348 // std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>>::iterator clientMap = gamestateMap_.find(client->getID()); 354 349 // // first delete all remained gamestates 355 350 // std::map<unsigned int, packet::Gamestate*>::iterator it; -
code/branches/cpp11_v3/src/libraries/network/GamestateManager.h
r10622 r11054 47 47 #include "core/CorePrereqs.h" 48 48 #include "packet/Gamestate.h" 49 #include <boost/concept_check.hpp>50 49 51 50 namespace orxonox … … 84 83 ~GamestateManager(); 85 84 86 virtual bool addGamestate(packet::Gamestate *gs, unsigned int peerID) ;87 virtual bool ackGamestate(unsigned int gamestateID, unsigned int peerID) ;88 virtual uint32_t getLastReceivedGamestateID( unsigned int peerID ) ;89 virtual uint32_t getCurrentGamestateID() { if( currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; }85 virtual bool addGamestate(packet::Gamestate *gs, unsigned int peerID) override; 86 virtual bool ackGamestate(unsigned int gamestateID, unsigned int peerID) override; 87 virtual uint32_t getLastReceivedGamestateID( unsigned int peerID ) override; 88 virtual uint32_t getCurrentGamestateID() override{ if( currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; } 90 89 91 90 bool processGamestates(); … … 108 107 bool processGamestate(packet::Gamestate *gs); 109 108 110 // std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> 109 // std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>> gamestateMap_; 111 110 std::map<unsigned int, packet::Gamestate*> gamestateQueue; 112 111 // std::map<unsigned int, uint32_t> lastProcessedGamestateID_; -
code/branches/cpp11_v3/src/libraries/network/Host.cc
r10624 r11054 44 44 SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT); 45 45 46 // Host* Host::instance_= 0;46 // Host* Host::instance_=nullptr; 47 47 uint32_t Host::clientID_s=0; 48 48 // uint32_t Host::shipID_s=-1; … … 54 54 Host::Host() 55 55 { 56 // assert(instance_== 0);56 // assert(instance_==nullptr); 57 57 instances_s.push_back(this); 58 58 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this); … … 62 62 63 63 /** 64 * @brief Destructor: resets the instance pointer to 064 * @brief Destructor: resets the instance pointer to nullptr 65 65 */ 66 66 Host::~Host() … … 68 68 assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() ); 69 69 instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this )); 70 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject( 0);70 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(nullptr); 71 71 } 72 72 … … 80 80 void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID) 81 81 { 82 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it)82 for(Host* host : instances_s) 83 83 { 84 if( (*it)->isActive() )84 if( host->isActive() ) 85 85 { 86 (*it)->queuePacket(packet, clientID, channelID);86 host->queuePacket(packet, clientID, channelID); 87 87 } 88 88 } … … 97 97 void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 98 98 { 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);99 for(Host* host : instances_s) 100 if( host->isActive() ) 101 host->doSendChat(message, sourceID, targetID); 102 102 } 103 103 … … 107 107 void Host::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 108 108 { 109 for ( ObjectList<NetworkChatListener>::iterator it = ObjectList<NetworkChatListener>::begin(); it != ObjectList<NetworkChatListener>::end(); ++it)110 it->incomingChat(message, sourceID);109 for (NetworkChatListener* listener : ObjectList<NetworkChatListener>()) 110 listener->incomingChat(message, sourceID); 111 111 } 112 112 … … 114 114 bool Host::isServer() 115 115 { 116 for ( std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it)116 for (Host* host : instances_s) 117 117 { 118 if( (*it)->isActive() )118 if( host->isActive() ) 119 119 { 120 if( (*it)->isServer_() )120 if( host->isServer_() ) 121 121 return true; 122 122 } … … 135 135 ++it; 136 136 } 137 return 0;137 return nullptr; 138 138 } 139 139 -
code/branches/cpp11_v3/src/libraries/network/LANDiscoverable.cc
r11009 r11054 46 46 RegisterClassNoArgs(LANDiscoverable); 47 47 48 LANDiscoverable::LANDiscoverable() : bActive_(false), host_( 0)48 LANDiscoverable::LANDiscoverable() : bActive_(false), host_(nullptr) 49 49 { 50 50 /* register object in orxonox */ … … 82 82 bindAddress.host = ENET_HOST_ANY; 83 83 bindAddress.port = LAN_DISCOVERY_PORT; 84 assert( this->host_ == 0);84 assert( this->host_ == nullptr ); 85 85 this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 ); 86 if ( this->host_ == NULL)87 orxout(internal_error, context::network) << "LANDiscoverable: host_ == NULL" << endl;86 if ( this->host_ == nullptr ) 87 orxout(internal_error, context::network) << "LANDiscoverable: host_ == nullptr" << endl; 88 88 } 89 89 else 90 90 { 91 91 enet_host_destroy( this->host_ ); 92 this->host_ = 0;92 this->host_ = nullptr; 93 93 } 94 94 this->bActive_ = bActive; -
code/branches/cpp11_v3/src/libraries/network/LANDiscovery.cc
r10624 r11054 42 42 LANDiscovery::LANDiscovery() 43 43 { 44 this->host_ = enet_host_create( NULL, 10, 0, 0, 0 );45 if ( this->host_ == NULL)46 orxout(internal_error, context::network) << "LANDiscovery: host_ == NULL" << endl;44 this->host_ = enet_host_create(nullptr, 10, 0, 0, 0 ); 45 if ( this->host_ == nullptr ) 46 orxout(internal_error, context::network) << "LANDiscovery: host_ == nullptr" << endl; 47 47 } 48 48 49 49 LANDiscovery::~LANDiscovery() 50 50 { 51 if (this->host_ != NULL)51 if (this->host_ != nullptr) 52 52 enet_host_destroy(this->host_); 53 53 } … … 65 65 address.host = ENET_HOST_BROADCAST; 66 66 peer = enet_host_connect(this->host_, &address, 0, 0); 67 if (peer == NULL)67 if (peer == nullptr) 68 68 orxout(internal_error, context::network) << "Could not send LAN discovery to IPv4 Broadcast." << endl; 69 69 … … 71 71 enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group 72 72 peer = enet_host_connect(this->host_, &address, 0, 0); 73 if (peer == NULL)73 if (peer == nullptr) 74 74 orxout(internal_error, context::network) << "Could not send LAN discovery to IPv6 Multicast." << endl; 75 75 -
code/branches/cpp11_v3/src/libraries/network/MasterServer.cc
r10624 r11054 43 43 44 44 /* forward declaration so the linker doesn't complain */ 45 MasterServer *MasterServer::instance = NULL;45 MasterServer *MasterServer::instance = nullptr; 46 46 47 47 /* command: list servers */ … … 49 49 MasterServer::listServers( void ) 50 50 { 51 /* get an iterator */52 std::list<ServerListElem>::iterator i;53 54 51 /* print list header */ 55 52 orxout(user_info) << "List of connected servers" << std::endl; 56 53 57 54 /* loop through list elements */ 58 for( i = MasterServer::getInstance()->mainlist.serverlist.begin(); 59 i != MasterServer::getInstance()->mainlist.serverlist.end(); ++i ) 55 for( const ServerListElem& elem : MasterServer::getInstance()->mainlist.serverlist ) 60 56 { 61 orxout(user_info) << " " << (*i).ServerInfo.getServerIP() << std::endl;57 orxout(user_info) << " " << elem.ServerInfo.getServerIP() << std::endl; 62 58 } 63 59 … … 112 108 MasterServer::helper_sendlist( ENetEvent *event ) 113 109 { 114 /* get an iterator */115 std::list<ServerListElem>::iterator i;116 117 110 /* packet holder */ 118 111 ENetPacket *reply; 119 112 120 113 /* loop through list elements */ 121 for( i = mainlist.serverlist.begin(); i 122 != mainlist.serverlist.end(); ++i ) 114 for( const ServerListElem& elem : mainlist.serverlist ) 123 115 { 124 116 /* send this particular server */ 125 117 /* build reply string */ 126 int packetlen = MSPROTO_SERVERLIST_ITEM_LEN + 1 + (*i).ServerInfo.getServerIP().length() + 1 + (*i).ServerInfo.getServerName().length() + 1 + sizeof((*i).ServerInfo.getClientNumber()) + 1;118 int packetlen = MSPROTO_SERVERLIST_ITEM_LEN + 1 + elem.ServerInfo.getServerIP().length() + 1 + elem.ServerInfo.getServerName().length() + 1 + sizeof(elem.ServerInfo.getClientNumber()) + 1; 127 119 char *tosend = (char *)calloc(packetlen ,1 ); 128 120 if( !tosend ) … … 131 123 } 132 124 sprintf( tosend, "%s %s %s %u", MSPROTO_SERVERLIST_ITEM, 133 (*i).ServerInfo.getServerIP().c_str(), (*i).ServerInfo.getServerName().c_str(), (*i).ServerInfo.getClientNumber());125 elem.ServerInfo.getServerIP().c_str(), elem.ServerInfo.getServerName().c_str(), elem.ServerInfo.getClientNumber()); 134 126 135 127 /* create packet from it */ … … 167 159 MasterServer::helper_cleanupServers( void ) 168 160 { 169 /* get an iterator */170 std::list<ServerListElem>::iterator i;171 172 161 if( mainlist.serverlist.size() == 0 ) 173 162 return; 174 163 175 164 /* loop through list elements */ 176 for( i = mainlist.serverlist.begin(); i 177 != mainlist.serverlist.end(); ++i ) 165 for( const ServerListElem& elem : mainlist.serverlist ) 178 166 { /* see if we have a disconnected peer */ 179 if( (*i).peer &&180 ( (*i).peer->state == ENET_PEER_STATE_DISCONNECTED ||181 (*i).peer->state == ENET_PEER_STATE_ZOMBIE ))167 if( elem.peer && 168 (elem.peer->state == ENET_PEER_STATE_DISCONNECTED || 169 elem.peer->state == ENET_PEER_STATE_ZOMBIE )) 182 170 { 183 171 /* Remove it from the list */ 184 orxout(internal_warning) << (char*) (*i).peer->data << " timed out.\n";185 mainlist.delServerByName( (*i).ServerInfo.getServerName() );172 orxout(internal_warning) << (char*)elem.peer->data << " timed out.\n"; 173 mainlist.delServerByName( elem.ServerInfo.getServerName() ); 186 174 187 175 /* stop iterating, we manipulated the list */ … … 345 333 /***** ENTER MAIN LOOP *****/ 346 334 ENetEvent *event = (ENetEvent *)calloc(sizeof(ENetEvent), sizeof(char)); 347 if( event == NULL)335 if( event == nullptr ) 348 336 { 349 337 orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl; -
code/branches/cpp11_v3/src/libraries/network/MasterServerComm.cc
r8858 r11054 54 54 55 55 /* initiate the client */ 56 this->client = enet_host_create( NULL/* create a client host */,56 this->client = enet_host_create( nullptr /* create a client host */, 57 57 1, 58 58 2, /* allow up 2 channels to be used, 0 and 1 */ … … 61 61 62 62 /* see if it worked */ 63 if (this->client == NULL)63 if (this->client == nullptr) 64 64 { orxout(internal_error, context::master_server) << "An error occurred while trying to create an " 65 65 << "ENet client host." << endl; … … 85 85 this->peer = enet_host_connect(this->client, &this->address, 2, 0); 86 86 87 if( this->peer == NULL)87 if( this->peer == nullptr ) 88 88 { orxout(internal_error, context::master_server) << "No available peers for initiating an ENet" 89 89 << " connection." << endl; … … 157 157 158 158 /* address buffer */ 159 char *addrconv = NULL;159 char *addrconv = nullptr; 160 160 int retval = 0; 161 161 … … 193 193 194 194 /* call the supplied callback, if any. */ 195 if( listener != NULL)195 if( listener != nullptr ) 196 196 retval = listener->rhandler( addrconv, &(this->event) ); 197 197 -
code/branches/cpp11_v3/src/libraries/network/NetworkFunction.h
r10624 r11054 45 45 46 46 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32) 47 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8;47 static constexpr unsigned int MAX_FUNCTION_POINTER_SIZE = 8; 48 48 #else 49 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16;49 static constexpr unsigned int MAX_FUNCTION_POINTER_SIZE = 16; 50 50 #endif //ORXONOX_COMPILER_GCC 51 static const unsigned int MAX_FUNCTION_POINTER_INTS = (MAX_FUNCTION_POINTER_SIZE-1)/4+1;51 static constexpr unsigned int MAX_FUNCTION_POINTER_INTS = (MAX_FUNCTION_POINTER_SIZE-1)/4+1; 52 52 53 53 struct _NetworkExport NetworkFunctionPointer { … … 114 114 115 115 // ignore the objectID because its a static function 116 virtual bool call(uint32_t objectID) { (*this->functor_)(); return true; }117 virtual bool call(uint32_t objectID, const MultiType& mt1) { (*this->functor_)(mt1); return true; }118 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) { (*this->functor_)(mt1, mt2); return true; }119 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) { (*this->functor_)(mt1, mt2, mt3); return true; }120 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) { (*this->functor_)(mt1, mt2, mt3, mt4); return true; }121 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) { (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }116 virtual bool call(uint32_t objectID) override{ (*this->functor_)(); return true; } 117 virtual bool call(uint32_t objectID, const MultiType& mt1) override{ (*this->functor_)(mt1); return true; } 118 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) override{ (*this->functor_)(mt1, mt2); return true; } 119 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) override{ (*this->functor_)(mt1, mt2, mt3); return true; } 120 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) override{ (*this->functor_)(mt1, mt2, mt3, mt4); return true; } 121 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) override{ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; } 122 122 123 123 private: … … 142 142 { } 143 143 144 inline bool call(uint32_t objectID)145 { 146 if ( Synchronisable::getSynchronisable(objectID)!= 0)144 virtual inline bool call(uint32_t objectID) override 145 { 146 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 147 147 { 148 148 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID))); … … 152 152 return false; 153 153 } 154 inline bool call(uint32_t objectID, const MultiType& mt1)155 { 156 if ( Synchronisable::getSynchronisable(objectID)!= 0)154 virtual inline bool call(uint32_t objectID, const MultiType& mt1) override 155 { 156 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 157 157 { 158 158 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1); … … 162 162 return false; 163 163 } 164 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)165 { 166 if ( Synchronisable::getSynchronisable(objectID)!= 0)164 virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) override 165 { 166 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 167 167 { 168 168 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2); … … 172 172 return false; 173 173 } 174 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)175 { 176 if ( Synchronisable::getSynchronisable(objectID)!= 0)174 virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) override 175 { 176 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 177 177 { 178 178 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3); … … 182 182 return false; 183 183 } 184 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)185 { 186 if ( Synchronisable::getSynchronisable(objectID)!= 0)184 virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) override 185 { 186 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 187 187 { 188 188 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4); … … 192 192 return false; 193 193 } 194 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)195 { 196 if ( Synchronisable::getSynchronisable(objectID)!= 0)194 virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) override 195 { 196 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 197 197 { 198 198 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5); -
code/branches/cpp11_v3/src/libraries/network/NetworkFunctionIncludes.h
r11052 r11054 33 33 34 34 #include <boost/preprocessor/cat.hpp> 35 #include <boost/static_assert.hpp>36 35 37 36 #include "NetworkFunction.h" … … 57 56 ~StaticallyInitializedNetworkFunction() { delete function_; } 58 57 59 virtual void load() ;60 virtual void unload() ;58 virtual void load() override; 59 virtual void unload() override; 61 60 62 61 inline NetworkFunctionBase& getFunction() … … 72 71 inline NetworkFunctionBase* registerStaticNetworkFunctionFct(PT ptr, const std::string& name) 73 72 { 74 BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for static functions than defined above73 static_assert(sizeof(PT) <= sizeof(NetworkFunctionPointer), "check pointer size"); // if this fails your compiler uses bigger pointers for static functions than defined above 75 74 NetworkFunctionPointer destptr; 76 75 copyPtr(ptr, destptr); … … 81 80 inline NetworkFunctionBase* registerMemberNetworkFunctionFct(PT ptr, const std::string& name) 82 81 { 83 BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above82 static_assert(sizeof(PT) <= sizeof(NetworkFunctionPointer), "check pointer size"); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above 84 83 NetworkFunctionPointer destptr; 85 84 copyPtr(ptr, destptr); -
code/branches/cpp11_v3/src/libraries/network/NetworkFunctionManager.cc
r11052 r11054 32 32 namespace orxonox 33 33 { 34 NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = 0;34 NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = nullptr; 35 35 36 36 void NetworkFunctionManager::registerFunction(NetworkFunctionBase* function) … … 71 71 return it->second; 72 72 else 73 return NULL;73 return nullptr; 74 74 } 75 75 -
code/branches/cpp11_v3/src/libraries/network/NetworkPrereqs.h
r10624 r11054 67 67 namespace orxonox 68 68 { 69 static const unsigned int GAMESTATEID_INITIAL = static_cast<unsigned int>(-1);69 static constexpr unsigned int GAMESTATEID_INITIAL = static_cast<unsigned int>(-1); 70 70 extern const char* LAN_DISCOVERY_MESSAGE; 71 71 extern const char* LAN_DISCOVERY_ACK; 72 static const unsigned int LAN_DISCOVERY_PORT = 55558;73 static const unsigned int NETWORK_PEER_ID_SERVER = 0;74 static const unsigned int NETWORK_PEER_ID_BROADCAST = static_cast<unsigned int>(-1);75 static const unsigned int NETWORK_PEER_ID_UNKNOWN = static_cast<unsigned int>(-2);76 static const unsigned int NETWORK_CHANNEL_DEFAULT = 0;77 static const unsigned int NETWORK_CHANNEL_UNRELIABLE = 1;78 static const unsigned int NETWORK_CHANNEL_COUNT = 2;72 static constexpr unsigned int LAN_DISCOVERY_PORT = 55558; 73 static constexpr unsigned int NETWORK_PEER_ID_SERVER = 0; 74 static constexpr unsigned int NETWORK_PEER_ID_BROADCAST = static_cast<unsigned int>(-1); 75 static constexpr unsigned int NETWORK_PEER_ID_UNKNOWN = static_cast<unsigned int>(-2); 76 static constexpr unsigned int NETWORK_CHANNEL_DEFAULT = 0; 77 static constexpr unsigned int NETWORK_CHANNEL_UNRELIABLE = 1; 78 static constexpr unsigned int NETWORK_CHANNEL_COUNT = 2; 79 79 } 80 80 -
code/branches/cpp11_v3/src/libraries/network/NetworkStaticInitializationHandler.h
r10624 r11054 39 39 { 40 40 public: 41 virtual void setupHandler() ;42 virtual void shutdownHandler() ;41 virtual void setupHandler() override; 42 virtual void shutdownHandler() override; 43 43 44 virtual void loadModule(ModuleInstance* module) ;45 virtual void unloadModule(ModuleInstance* module) ;44 virtual void loadModule(ModuleInstance* module) override; 45 virtual void unloadModule(ModuleInstance* module) override; 46 46 }; 47 47 } -
code/branches/cpp11_v3/src/libraries/network/PeerList.cc
r10622 r11054 41 41 PeerList::addPeer( ENetPeer *toadd ) 42 42 { /* error correction */ 43 if( toadd == NULL)43 if( toadd == nullptr ) 44 44 { orxout(internal_error, context::master_server) << "PeerList::addPeer: empty peer given." << endl; 45 45 return -1; … … 65 65 bool 66 66 PeerList::remPeerByAddr( ENetAddress addr ) 67 { /* get an iterator */ 68 std::list<ENetPeer *>::iterator i; 69 67 { 70 68 /* loop through list elements */ 71 for( i = peerlist.begin(); i != peerlist.end(); ++i)72 if( !sub_compAddr( (*i)->address, addr ) )69 for( ENetPeer* peer : peerlist ) 70 if( !sub_compAddr(peer->address, addr ) ) 73 71 { /* found this name, remove and quit */ 74 this->peerlist.remove( *i);72 this->peerlist.remove( peer ); 75 73 return true; 76 74 } … … 82 80 ENetPeer * 83 81 PeerList::findPeerByAddr( ENetAddress addr ) 84 { /* get an iterator */ 85 std::list<ENetPeer *>::iterator i; 86 82 { 87 83 /* loop through list elements */ 88 for( i = peerlist.begin(); i != peerlist.end(); ++i)89 if( !sub_compAddr( (*i)->address, addr ) )84 for( ENetPeer* peer : peerlist ) 85 if( !sub_compAddr(peer->address, addr ) ) 90 86 /* found this name, remove and quit */ 91 return *i;87 return peer; 92 88 93 89 /* not found */ 94 return NULL;90 return nullptr; 95 91 } 96 92 -
code/branches/cpp11_v3/src/libraries/network/Server.cc
r10622 r11054 194 194 void Server::printRTT() 195 195 { 196 // for( ClientInformation* temp=ClientInformation::getBegin(); temp!= 0; temp=temp->next() )196 // for( ClientInformation* temp=ClientInformation::getBegin(); temp!=nullptr; temp=temp->next() ) 197 197 // orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl; 198 198 } … … 232 232 { 233 233 std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates(); 234 std::vector<packet::Gamestate*>::iterator it; 235 for( it = gamestates.begin(); it != gamestates.end(); ++it ) 234 for( packet::Gamestate* gamestate : gamestates ) 236 235 { 237 (*it)->send(static_cast<Host*>(this));236 gamestate->send(static_cast<Host*>(this)); 238 237 } 239 238 return true; … … 244 243 { 245 244 // ClientInformation *temp = ClientInformation::getBegin(); 246 // if( temp == NULL)245 // if( temp == nullptr ) 247 246 //no client connected 248 247 if( this->clientIDs_.size()==0 ) … … 255 254 } 256 255 // orxout(verbose, context::network) << "sending DeleteObjects" << endl; 257 // while(temp != NULL){256 // while(temp != nullptr){ 258 257 // if( !(temp->getSynched()) ) 259 258 // { … … 434 433 return true; 435 434 436 std::vector<uint32_t>::iterator it; 437 for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it ) 438 if( *it == targetID ) 435 for( uint32_t id : this->clientIDs_ ) 436 if( id == targetID ) 439 437 return true; 440 438 -
code/branches/cpp11_v3/src/libraries/network/Server.h
r10622 r11054 61 61 void open(); 62 62 void close(); 63 v oid queuePacket(ENetPacket *packet, int clientID, uint8_t channelID);64 virtual bool sendPacket( packet::Packet* packet ) { return packet->send( static_cast<Host*>(this) ); }63 virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) override; 64 virtual bool sendPacket( packet::Packet* packet ) override{ return packet->send( static_cast<Host*>(this) ); } 65 65 void update(const Clock& time); 66 66 unsigned int getRTT(unsigned int clientID); 67 virtual void printRTT() ;67 virtual void printRTT() override; 68 68 float getPacketLoss(unsigned int clientID); 69 69 int getClientCount() { return this->clientIDs_.size();} … … 73 73 void updateGamestate(); 74 74 private: 75 virtual bool isServer_() {return true;}75 virtual bool isServer_() override{return true;} 76 76 unsigned int playerID(){return 0;} 77 77 78 v oid addPeer(uint32_t peerID);79 v oid removePeer(uint32_t peerID);80 v oid processPacket(packet::Packet* packet);78 virtual void addPeer(uint32_t peerID) override; 79 virtual void removePeer(uint32_t peerID) override; 80 virtual void processPacket(packet::Packet* packet) override; 81 81 82 82 bool createClient(int clientID); … … 85 85 bool sendObjectDeletes(); 86 86 bool isValidTarget(unsigned int targetID); 87 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) ;88 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) ;87 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override; 88 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override; 89 89 void syncClassid(unsigned int clientID); 90 90 -
code/branches/cpp11_v3/src/libraries/network/ServerConnection.cc
r8858 r11054 73 73 this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0); 74 74 75 if ( this->host_ == NULL)75 if ( this->host_ == nullptr ) 76 76 { 77 orxout(internal_error, context::network) << "ServerConnection: host_ == NULL" << endl;77 orxout(internal_error, context::network) << "ServerConnection: host_ == nullptr" << endl; 78 78 return false; 79 79 } -
code/branches/cpp11_v3/src/libraries/network/TrafficControl.cc
r9667 r11054 30 30 31 31 #include <cassert> 32 #include < boost/bind.hpp>32 #include <functional> 33 33 34 34 #include "core/CoreIncludes.h" … … 38 38 namespace orxonox { 39 39 40 static const unsigned int SCHED_PRIORITY_OFFSET = static_cast<unsigned int>(-1); 40 static constexpr unsigned int SCHED_PRIORITY_OFFSET = static_cast<unsigned int>(-1); 41 namespace arg = std::placeholders; 41 42 42 43 objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched) … … 64 65 *Initializing protected members 65 66 */ 66 TrafficControl *TrafficControl::instance_= 0;67 TrafficControl *TrafficControl::instance_=nullptr; 67 68 68 69 /** … … 72 73 { 73 74 RegisterObject(TrafficControl); 74 assert(instance_== 0);75 assert(instance_==nullptr); 75 76 instance_=this; 76 77 this->setConfigValues(); … … 78 79 79 80 /** 80 * @brief Destructor: resets the instance pointer to 081 * @brief Destructor: resets the instance pointer to nullptr 81 82 */ 82 83 TrafficControl::~TrafficControl() 83 84 { 84 instance_= 0;85 instance_=nullptr; 85 86 } 86 87 … … 148 149 // shortcut for maps 149 150 std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID]; 150 std::map<unsigned int, std::list<obj> 151 std::map<unsigned int, std::list<obj>>& objectListTemp = clientListTemp_[clientID]; 151 152 152 153 for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++) … … 180 181 void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf) 181 182 { 182 std::map<unsigned int,std::map<unsigned int, objInfo> 183 std::map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm over clientIDs 183 184 unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0; 184 185 clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom); … … 258 259 259 260 //sort copied list according to priorities 260 // use boostbind here because we need to pass a memberfunction to stl sort261 // sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1,_2) );262 list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1,_2) );263 264 // list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1,_2) );261 // use std::bind here because we need to pass a memberfunction to stl sort 262 // sort( list.begin(), list.end(), std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) ); 263 list.sort( std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) ); 264 265 // list.sort(std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) ); 265 266 266 267 //now we check, that the creator of an object always exists on a client … … 275 276 cut(list, targetSize); 276 277 //now sort again after objDataOffset 277 // sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1,_2) );278 list.sort( boost::bind(&TrafficControl::dataSort, this, _1,_2) );278 // sort(list.begin(), list.end(), std::bind(&TrafficControl::dataSort, this, arg::_1, arg::_2) ); 279 list.sort( std::bind(&TrafficControl::dataSort, this, arg::_1, arg::_2) ); 279 280 280 281 //diese Funktion updateClientList muss noch gemacht werden -
code/branches/cpp11_v3/src/libraries/network/TrafficControl.h
r6746 r11054 82 82 *permanent client list: contains client ids, object ids and objectInfos (in this order) 83 83 */ 84 std::map<unsigned int, std::map<unsigned int, objInfo > 84 std::map<unsigned int, std::map<unsigned int, objInfo >> clientListPerm_; 85 85 //has to be created with constructor and then needs to be updated by evaluateList(). 86 86 … … 88 88 *temporary client list: contains client ids, gamestate ids and object ids (in this order) 89 89 */ 90 std::map<unsigned int, std::map<unsigned int, std::list<obj> >> clientListTemp_;90 std::map<unsigned int, std::map<unsigned int, std::list<obj>>> clientListTemp_; 91 91 92 92 /**updateReferenceList … … 109 109 110 110 //ClientConnectionListener functions 111 virtual void clientConnected(unsigned int clientID) {};112 virtual void clientDisconnected(unsigned int clientID) ;111 virtual void clientConnected(unsigned int clientID) override{}; 112 virtual void clientDisconnected(unsigned int clientID) override; 113 113 114 114 -
code/branches/cpp11_v3/src/libraries/network/packet/Acknowledgement.h
r7801 r11054 46 46 ~Acknowledgement(); 47 47 48 inline unsigned int getSize() const;49 virtual bool process(orxonox::Host* host) ;48 virtual inline unsigned int getSize() const override; 49 virtual bool process(orxonox::Host* host) override; 50 50 51 51 unsigned int getAckID(); -
code/branches/cpp11_v3/src/libraries/network/packet/Chat.h
r8858 r11054 49 49 50 50 /* get size of packet */ 51 inline unsigned int getSize() const;51 virtual inline unsigned int getSize() const override; 52 52 53 53 /* process chat message packet and remove it afterwards */ 54 virtual bool process(orxonox::Host* host) ;54 virtual bool process(orxonox::Host* host) override; 55 55 56 56 /* Get the length of the message (not the full size of the packet) */ -
code/branches/cpp11_v3/src/libraries/network/packet/ClassID.cc
r9667 r11054 52 52 uint32_t network_id; 53 53 flags_ = flags_ | PACKET_FLAGS_CLASSID; 54 std::queue<std::pair<uint32_t, std::string> 54 std::queue<std::pair<uint32_t, std::string>> tempQueue; 55 55 56 56 //calculate total needed size (for all strings and integers) 57 std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getInstance().getIdentifierByStringMap().begin(); 58 for(;it != IdentifierManager::getInstance().getIdentifierByStringMap().end();++it){ 59 id = it->second; 60 if(id == NULL || !id->hasFactory()) 57 for(const auto& mapEntry : IdentifierManager::getInstance().getIdentifierByStringMap()){ 58 id = mapEntry.second; 59 if(id == nullptr || !id->hasFactory()) 61 60 continue; 62 61 const std::string& classname = id->getName(); … … 144 143 id=ClassByString( std::string((const char*)classname) ); 145 144 orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl; 146 if(id== NULL){145 if(id==nullptr){ 147 146 orxout(user_error, context::packets) << "Received a bad classname" << endl; 148 147 abort(); -
code/branches/cpp11_v3/src/libraries/network/packet/ClassID.h
r7801 r11054 47 47 ~ClassID(); 48 48 49 uint32_t getSize() const;50 virtual bool process(orxonox::Host* host) ;49 virtual uint32_t getSize() const override; 50 virtual bool process(orxonox::Host* host) override; 51 51 52 52 private: -
code/branches/cpp11_v3/src/libraries/network/packet/DeleteObjects.h
r7801 r11054 48 48 bool fetchIDs(); 49 49 50 inline unsigned int getSize() const;51 virtual bool process(orxonox::Host* host) ;50 virtual inline unsigned int getSize() const override; 51 virtual bool process(orxonox::Host* host) override; 52 52 53 53 private: -
code/branches/cpp11_v3/src/libraries/network/packet/FunctionCalls.h
r10624 r11054 52 52 ~FunctionCalls(); 53 53 54 inline unsigned int getSize() const54 virtual inline unsigned int getSize() const override 55 55 { assert(!this->isDataENetAllocated()); return currentSize_; } 56 virtual bool process(orxonox::Host* host) ;56 virtual bool process(orxonox::Host* host) override; 57 57 58 58 void addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 59 virtual bool send(orxonox::Host* host) ;59 virtual bool send(orxonox::Host* host) override; 60 60 private: 61 61 std::queue<orxonox::FunctionCall> functionCalls_; -
code/branches/cpp11_v3/src/libraries/network/packet/FunctionIDs.cc
r10624 r11054 53 53 uint32_t networkID; 54 54 flags_ = flags_ | PACKET_FLAGS_FUNCTIONIDS; 55 std::queue<std::pair<uint32_t, std::string> 55 std::queue<std::pair<uint32_t, std::string>> tempQueue; 56 56 57 57 //calculate total needed size (for all strings and integers) -
code/branches/cpp11_v3/src/libraries/network/packet/FunctionIDs.h
r7801 r11054 47 47 ~FunctionIDs(); 48 48 49 virtual uint32_t getSize() const ;50 virtual bool process(orxonox::Host* host) ;49 virtual uint32_t getSize() const override; 50 virtual bool process(orxonox::Host* host) override; 51 51 52 52 private: -
code/branches/cpp11_v3/src/libraries/network/packet/Gamestate.cc
r9667 r11054 106 106 { 107 107 uint32_t tempsize=0, currentsize=0; 108 assert(data_== 0);108 assert(data_==nullptr); 109 109 uint32_t size = calcGamestateSize(id, mode); 110 110 … … 126 126 mem += GamestateHeader::getSize(); 127 127 ObjectList<Synchronisable>::iterator it; 128 for(it = ObjectList<Synchronisable> ::begin(); it; ++it)128 for(it = ObjectList<Synchronisable>().begin(); it; ++it) 129 129 { 130 130 … … 133 133 tempsize = it->getData(mem, this->sizes_, id, mode); 134 134 if ( tempsize != 0 ) 135 dataVector_. push_back( obj(it->getObjectID(), it->getContextID(), tempsize, mem-data_));135 dataVector_.emplace_back(it->getObjectID(), it->getContextID(), tempsize, mem-data_); 136 136 137 137 #ifndef NDEBUG … … 213 213 { 214 214 std::list<uint32_t> v1; 215 ObjectList<Synchronisable>::iterator it; 216 for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) 217 { 218 if (it->getObjectID() == OBJECTID_UNKNOWN) 219 { 220 if (it->objectMode_ != 0x0) 215 for (Synchronisable* synchronisable : ObjectList<Synchronisable>()) 216 { 217 if (synchronisable->getObjectID() == OBJECTID_UNKNOWN) 218 { 219 if (synchronisable->objectMode_ != 0x0) 221 220 { 222 221 orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl; 223 222 orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl; 224 orxout(user_error, context::packets) << "Objects class: " << it->getIdentifier()->getName() << endl;223 orxout(user_error, context::packets) << "Objects class: " << synchronisable->getIdentifier()->getName() << endl; 225 224 assert(false); 226 225 } … … 228 227 else 229 228 { 230 std::list<uint32_t>::iterator it2; 231 for (it2 = v1.begin(); it2 != v1.end(); ++it2) 229 for (uint32_t id : v1) 232 230 { 233 if ( it->getObjectID() == *it2)231 if (synchronisable->getObjectID() == id) 234 232 { 235 233 orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl … … 239 237 } 240 238 } 241 v1.push_back( it->getObjectID());239 v1.push_back(synchronisable->getObjectID()); 242 240 } 243 241 } … … 608 606 609 607 if(dest_length==0) 610 return NULL;608 return nullptr; 611 609 612 610 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; … … 645 643 646 644 if(dest_length==0) 647 return NULL;645 return nullptr; 648 646 649 647 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; … … 762 760 uint32_t size = 0; 763 761 uint32_t nrOfVariables = 0; 764 // get the start of the Synchronisable list765 ObjectList<Synchronisable>::iterator it;766 762 // get total size of gamestate 767 for( it = ObjectList<Synchronisable>::begin(); it; ++it){768 size+= it->getSize(id, mode); // size of the actual data of the synchronisable769 nrOfVariables += it->getNrOfVariables();763 for(Synchronisable* synchronisable : ObjectList<Synchronisable>()){ 764 size+=synchronisable->getSize(id, mode); // size of the actual data of the synchronisable 765 nrOfVariables += synchronisable->getNrOfVariables(); 770 766 } 771 767 // orxout() << "allocating " << nrOfVariables << " ints" << endl; -
code/branches/cpp11_v3/src/libraries/network/packet/Gamestate.h
r7801 r11054 48 48 { 49 49 50 static const uint8_t GAMESTATE_MODE_SERVER = 0x1;51 static const uint8_t GAMESTATE_MODE_CLIENT = 0x2;50 static constexpr uint8_t GAMESTATE_MODE_SERVER = 0x1; 51 static constexpr uint8_t GAMESTATE_MODE_CLIENT = 0x2; 52 52 53 53 class _NetworkExport GamestateHeader 54 54 { 55 55 public: 56 GamestateHeader(){ data_= 0; }56 GamestateHeader(){ data_=nullptr; } 57 57 GamestateHeader(uint8_t* data) 58 58 { assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; } … … 138 138 // void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength); 139 139 // inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 ); 140 virtual uint32_t getSize() const ;141 virtual bool process(orxonox::Host* host) ;140 virtual uint32_t getSize() const override; 141 virtual bool process(orxonox::Host* host) override; 142 142 uint32_t calcGamestateSize(uint32_t id, uint8_t mode=0x0); 143 143 // inline void diffObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes ); -
code/branches/cpp11_v3/src/libraries/network/packet/Packet.cc
r8858 r11054 34 34 #define WIN32_LEAN_AND_MEAN 35 35 #include <enet/enet.h> 36 #include <boost/static_assert.hpp>37 36 #include <boost/thread/mutex.hpp> 38 37 … … 54 53 55 54 // Make sure we assume the right values 56 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable) == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));57 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));58 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));55 static_assert(static_cast<int>(PacketFlag::Reliable) == static_cast<int>(ENET_PACKET_FLAG_RELIABLE), "check enum"); 56 static_assert(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED), "check enum"); 57 static_assert(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE), "check enum"); 59 58 60 59 #define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate … … 69 68 packetDirection_ = Direction::Outgoing; 70 69 peerID_=0; 71 data_= 0;72 enetPacket_= 0;70 data_=nullptr; 71 enetPacket_=nullptr; 73 72 bDataENetAllocated_ = false; 74 73 } … … 80 79 peerID_=peerID; 81 80 data_=data; 82 enetPacket_= 0;81 enetPacket_=nullptr; 83 82 bDataENetAllocated_ = false; 84 83 } … … 95 94 memcpy(data_, p.data_, p.getSize()); 96 95 }else 97 data_= 0;96 data_=nullptr; 98 97 bDataENetAllocated_ = p.bDataENetAllocated_; 99 98 } … … 122 121 // Destroy the ENetPacket if necessary. 123 122 // Note: For the case ENet used the callback to destroy the packet, we have already set 124 // enetPacket_ to NULLto avoid destroying it again.123 // enetPacket_ to nullptr to avoid destroying it again. 125 124 if (this->enetPacket_) 126 125 { … … 175 174 #endif 176 175 // ENetPacket *temp = enetPacket_; 177 // enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet176 // enetPacket_ = nullptr; // otherwise we have a double free because enet already handles the deallocation of the packet 178 177 if( this->flags_ & PacketFlag::Reliable ) 179 178 host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT); … … 191 190 // if( peerID==static_cast<unsigned int>(-2)) 192 191 // peerID = NETWORK_PEER_ID_SERVER; 193 Packet *p = 0;192 Packet *p = nullptr; 194 193 // orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl; 195 194 switch( *(Type::Value *)(data + _PACKETID) ) … … 251 250 assert(it != packetMap_.end()); 252 251 // Make sure we don't delete it again in the destructor 253 it->second->enetPacket_ = 0;252 it->second->enetPacket_ = nullptr; 254 253 delete it->second; 255 254 packetMap_.erase(it); -
code/branches/cpp11_v3/src/libraries/network/packet/ServerInformation.cc
r10622 r11054 87 87 } // namespace packet 88 88 89 std::ostream& operator<<(std::ostream& out, const ENetAddress& address)90 {91 char addr[64];92 if (!enet_address_get_host_ip(&address, addr, 64))93 out << addr;94 return out;95 }96 89 } // namespace orxonox 90 91 std::ostream& operator<<(std::ostream& out, const ENetAddress& address) 92 { 93 char addr[64]; 94 if (!enet_address_get_host_ip(&address, addr, 64)) 95 out << addr; 96 return out; 97 } -
code/branches/cpp11_v3/src/libraries/network/packet/ServerInformation.h
r10622 r11054 50 50 void send( ENetPeer* peer ); 51 51 void setServerName(std::string name) { this->serverName_ = name; } 52 std::string getServerName() { return this->serverName_; }52 std::string getServerName() const { return this->serverName_; } 53 53 void setServerIP( std::string IP ) { this->serverIP_ = IP; } 54 std::string getServerIP() { return this->serverIP_; }54 std::string getServerIP() const { return this->serverIP_; } 55 55 void setClientNumber( int clientNumber ) { this->clientNumber_ = clientNumber; } 56 int getClientNumber() { return this->clientNumber_; }57 uint32_t getServerRTT() { return this->serverRTT_; }56 int getClientNumber() const { return this->clientNumber_; } 57 uint32_t getServerRTT() const { return this->serverRTT_; } 58 58 59 59 private: … … 66 66 } 67 67 68 _NetworkExport std::ostream& operator<<(std::ostream& out, const ENetAddress& address);69 68 } 70 69 70 _NetworkExport std::ostream& operator<<(std::ostream& out, const ENetAddress& address); 71 71 72 #endif // SERVERINFORMATION_H -
code/branches/cpp11_v3/src/libraries/network/packet/Welcome.h
r8706 r11054 45 45 virtual ~Welcome(); 46 46 47 uint8_t *getData();48 inline unsigned int getSize() const;49 virtual bool process(orxonox::Host* host) ;47 virtual uint8_t *getData() override; 48 virtual inline unsigned int getSize() const override; 49 virtual bool process(orxonox::Host* host) override; 50 50 51 51 private: -
code/branches/cpp11_v3/src/libraries/network/synchronisable/NetworkCallback.h
r6417 r11054 53 53 NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {} 54 54 virtual ~NetworkCallback() {} 55 virtual void call() 55 virtual void call() override 56 56 { (this->object_->*function_)(); } 57 57 … … 68 68 NetworkCallbackNotify() {} 69 69 virtual ~NetworkCallbackNotify() {} 70 virtual void call() 70 virtual void call() override 71 71 { (this->object_->*function_)( this->oldValue_ ); } 72 72 void setOldValue(const U& value){ this->oldValue_ = value; } -
code/branches/cpp11_v3/src/libraries/network/synchronisable/Serialise.h
r10624 r11054 90 90 { 91 91 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 92 *const_cast<typename Loki::TypeTraits<StrongPtr<T> 92 *const_cast<typename Loki::TypeTraits<StrongPtr<T>>::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 93 93 mem += returnSize( variable ); 94 94 } … … 125 125 { 126 126 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 127 *const_cast<typename Loki::TypeTraits<WeakPtr<T> 127 *const_cast<typename Loki::TypeTraits<WeakPtr<T>>::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 128 128 mem += returnSize( variable ); 129 129 } -
code/branches/cpp11_v3/src/libraries/network/synchronisable/Synchronisable.cc
r10624 r11054 88 88 } 89 89 // delete all Synchronisable Variables from syncList_ ( which are also in stringList_ ) 90 for( std::vector<SynchronisableVariableBase*>::iterator it = syncList_.begin(); it!=syncList_.end(); it++)91 delete (*it);90 for(SynchronisableVariableBase* variable : syncList_) 91 delete variable; 92 92 syncList_.clear(); 93 93 stringList_.clear(); … … 105 105 uint32_t Synchronisable::findContextID(Context* context) 106 106 { 107 if (context == NULL)107 if (context == nullptr) 108 108 return OBJECTID_UNKNOWN; 109 109 110 110 Synchronisable* synchronisableContext = orxonox_cast<Synchronisable*>(context); 111 if (synchronisableContext != NULL)111 if (synchronisableContext != nullptr) 112 112 return synchronisableContext->getObjectID(); 113 113 else … … 140 140 { 141 141 mem += header.getDataSize() + header.getSize(); 142 return 0;142 return nullptr; 143 143 } 144 144 // assert( !header.isDiffed() ); … … 156 156 } 157 157 assert(id); 158 Context* context = 0;158 Context* context = nullptr; 159 159 if (header.getContextID() != OBJECTID_UNKNOWN) 160 160 { … … 164 164 mem += header.getDataSize()+SynchronisableHeader::getSize(); //.TODO: this suckz.... remove size from header 165 165 assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^ 166 return 0;166 return nullptr; 167 167 } 168 168 else … … 172 172 context = Context::getRootContext(); 173 173 174 assert(getSynchronisable(header.getObjectID())== 0); //make sure no object with this id exists174 assert(getSynchronisable(header.getObjectID())==nullptr); //make sure no object with this id exists 175 175 BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(context)); 176 176 assert(bo); … … 226 226 return it1->second; 227 227 // if the objects not in the map it should'nt exist at all anymore 228 return NULL;228 return nullptr; 229 229 } 230 230 … … 266 266 assert(this->classID_==this->getIdentifier()->getNetworkID()); 267 267 assert(this->objectID_!=OBJECTID_UNKNOWN); 268 std::vector<SynchronisableVariableBase*>::iterator i;269 268 270 269 // start copy header … … 276 275 // orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":"; 277 276 // copy to location 278 for( i=syncList_.begin(); i!=syncList_.end(); ++i)279 { 280 uint32_t varsize = (*i)->getData( mem, mode );277 for(SynchronisableVariableBase* variable : syncList_) 278 { 279 uint32_t varsize = variable->getData( mem, mode ); 281 280 // orxout(verbose, context::network) << " " << varsize; 282 281 tempsize += varsize; … … 348 347 assert( this->getContextID() == syncHeader2.getContextID() ); 349 348 mem += SynchronisableHeader::getSize(); 350 std::vector<SynchronisableVariableBase *>::iterator i; 351 for(i=syncList_.begin(); i!=syncList_.end(); ++i) 349 for(SynchronisableVariableBase* variable : syncList_) 352 350 { 353 351 assert( mem <= data+syncHeader2.getDataSize()+SynchronisableHeader::getSize() ); // always make sure we don't exceed the datasize in our stream 354 (*i)->putData( mem, mode, forceCallback );352 variable->putData( mem, mode, forceCallback ); 355 353 } 356 354 assert(mem == data+syncHeaderLight.getDataSize()+SynchronisableHeader::getSize() ); … … 388 386 assert( mode==state_ ); 389 387 tsize += this->dataSize_; 390 std::vector<SynchronisableVariableBase*>::iterator i; 391 for(i=stringList_.begin(); i!=stringList_.end(); ++i) 392 { 393 tsize += (*i)->getSize( mode ); 388 for(SynchronisableVariableBase* variable : stringList_) 389 { 390 tsize += variable->getSize( mode ); 394 391 } 395 392 return tsize; -
code/branches/cpp11_v3/src/libraries/network/synchronisable/Synchronisable.h
r9667 r11054 171 171 protected: 172 172 Synchronisable(Context* context); 173 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb= 0, bool bidirectional=false);174 template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb= 0, bool bidirectional=false);173 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false); 174 template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false); 175 175 template <class T> void unregisterVariable(T& var); 176 176 … … 242 242 SynchronisableVariableBase* sv; 243 243 if (bidirectional) 244 sv = new SynchronisableVariableBidirectional<std::set<T> 244 sv = new SynchronisableVariableBidirectional<std::set<T>>(variable, mode, cb); 245 245 else 246 sv = new SynchronisableVariable<std::set<T> 246 sv = new SynchronisableVariable<std::set<T>>(variable, mode, cb); 247 247 syncList_.push_back(sv); 248 248 stringList_.push_back(sv); … … 250 250 251 251 template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional); 252 // template <class T> _NetworkExport void Synchronisable::registerVariable<std::set<T> 252 // template <class T> _NetworkExport void Synchronisable::registerVariable<std::set<T>>( std::set<T>& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional); 253 253 template <> _NetworkExport void Synchronisable::unregisterVariable( std::string& variable ); 254 254 -
code/branches/cpp11_v3/src/libraries/network/synchronisable/SynchronisableVariable.h
r10624 r11054 71 71 { 72 72 public: 73 SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb= 0);73 SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=nullptr); 74 74 virtual ~SynchronisableVariable(); 75 75 76 virtual inline uint8_t getMode() { return mode_; }77 virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode) ;78 virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false) ;79 virtual inline uint32_t getSize(uint8_t mode) ;80 virtual inline void* getReference() { return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); }76 virtual inline uint8_t getMode() override{ return mode_; } 77 virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode) override; 78 virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false) override; 79 virtual inline uint32_t getSize(uint8_t mode) override; 80 virtual inline void* getReference() override{ return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); } 81 81 protected: 82 82 T& variable_; … … 89 89 { 90 90 public: 91 SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb= 0);91 SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=nullptr); 92 92 virtual ~SynchronisableVariableBidirectional(); 93 93 -
code/branches/cpp11_v3/src/libraries/tools/BillboardSet.cc
r8858 r11054 46 46 BillboardSet::BillboardSet() 47 47 { 48 this->billboardSet_ = 0;48 this->billboardSet_ = nullptr; 49 49 } 50 50 … … 81 81 { 82 82 orxout(internal_error) << "Couldn't load billboard \"" << file << '"' << endl; 83 this->billboardSet_ = 0;83 this->billboardSet_ = nullptr; 84 84 } 85 85 … … 104 104 { 105 105 orxout(internal_error) << "Couldn't load billboard \"" << file << '"' << endl; 106 this->billboardSet_ = 0;106 this->billboardSet_ = nullptr; 107 107 } 108 108 … … 114 114 if (this->billboardSet_ && this->scenemanager_) 115 115 this->scenemanager_->destroyBillboardSet(this->billboardSet_); 116 this->billboardSet_ = 0;116 this->billboardSet_ = nullptr; 117 117 } 118 118 -
code/branches/cpp11_v3/src/libraries/tools/BulletDebugDrawer.h
r10277 r11054 13 13 #include <btBulletCollisionCommon.h> 14 14 #include <OgreFrameListener.h> 15 #include <OgreVector3.h> 16 #include <OgreColourValue.h> 15 17 16 18 namespace orxonox … … 21 23 BulletDebugDrawer(Ogre::SceneManager* sceneManager); 22 24 ~BulletDebugDrawer(); 23 virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color) ;24 // virtual void drawTriangle(const btVector3& v0, const btVector3& v1, const btVector3& v2, const btVector3& color, btScalar) ;25 virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color) ;26 virtual void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color) ;27 virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color) ;28 virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color) ;29 virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color) ;30 virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform& transform, const btVector3& color) ;31 // virtual void drawPlane(const btVector3& planeNormal, btScalar planeConst, const btTransform& transform, const btVector3& color) ;25 virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color) override; 26 // virtual void drawTriangle(const btVector3& v0, const btVector3& v1, const btVector3& v2, const btVector3& color, btScalar) override; 27 virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color) override; 28 virtual void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color) override; 29 virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color) override; 30 virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color) override; 31 virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color) override; 32 virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform& transform, const btVector3& color) override; 33 // virtual void drawPlane(const btVector3& planeNormal, btScalar planeConst, const btTransform& transform, const btVector3& color) override; 32 34 33 virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color) ;35 virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color) override; 34 36 35 virtual void reportErrorWarning(const char* warningString) ;36 virtual void draw3dText(const btVector3& location, const char* textString) ;37 virtual void reportErrorWarning(const char* warningString) override; 38 virtual void draw3dText(const btVector3& location, const char* textString) override; 37 39 38 virtual void setDebugMode(int debugMode) ;39 virtual int getDebugMode() const ;40 virtual void setDebugMode(int debugMode) override; 41 virtual int getDebugMode() const override; 40 42 41 43 void configure(bool bFill, float fillAlpha); 42 44 43 45 protected: 44 bool frameStarted(const Ogre::FrameEvent& evt);45 bool frameEnded(const Ogre::FrameEvent& evt);46 virtual bool frameStarted(const Ogre::FrameEvent& evt) override; 47 virtual bool frameEnded(const Ogre::FrameEvent& evt) override; 46 48 47 49 private: -
code/branches/cpp11_v3/src/libraries/tools/DebugDrawer.cc
r10262 r11054 21 21 { 22 22 DebugDrawer::DebugDrawer(Ogre::SceneManager *_sceneManager, float _fillAlpha) : 23 sceneManager(_sceneManager), fillAlpha(_fillAlpha), manualObject( 0), isEnabled(true), linesIndex(0), trianglesIndex(0)23 sceneManager(_sceneManager), fillAlpha(_fillAlpha), manualObject(nullptr), isEnabled(true), linesIndex(0), trianglesIndex(0) 24 24 { 25 25 initialise(); … … 392 392 manualObject->estimateVertexCount(lineVertices.size()); 393 393 manualObject->estimateIndexCount(lineIndices.size()); 394 for ( std::list<VertexPair>::iterator i = lineVertices.begin(); i != lineVertices.end(); i++)394 for (const VertexPair& pair : lineVertices) 395 395 { 396 manualObject->position( i->first);397 manualObject->colour( i->second);396 manualObject->position(pair.first); 397 manualObject->colour(pair.second); 398 398 } 399 for ( std::list<int>::iterator i = lineIndices.begin(); i != lineIndices.end(); i++)400 manualObject->index( *i);399 for (int lineIndex : lineIndices) 400 manualObject->index(lineIndex); 401 401 } 402 402 else … … 409 409 manualObject->estimateVertexCount(triangleVertices.size()); 410 410 manualObject->estimateIndexCount(triangleIndices.size()); 411 for ( std::list<VertexPair>::iterator i = triangleVertices.begin(); i != triangleVertices.end(); i++)411 for (const VertexPair& pair : triangleVertices) 412 412 { 413 manualObject->position( i->first);414 manualObject->colour( i->second.r, i->second.g, i->second.b, fillAlpha);413 manualObject->position(pair.first); 414 manualObject->colour(pair.second.r, pair.second.g, pair.second.b, fillAlpha); 415 415 } 416 for ( std::list<int>::iterator i = triangleIndices.begin(); i != triangleIndices.end(); i++)417 manualObject->index( *i);416 for (int triangleIndex : triangleIndices) 417 manualObject->index(triangleIndex); 418 418 } 419 419 else … … 433 433 int DebugDrawer::addLineVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour) 434 434 { 435 lineVertices. push_back(VertexPair(vertex, colour));435 lineVertices.emplace_back(vertex, colour); 436 436 return linesIndex++; 437 437 } … … 445 445 int DebugDrawer::addTriangleVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour) 446 446 { 447 triangleVertices. push_back(VertexPair(vertex, colour));447 triangleVertices.emplace_back(vertex, colour); 448 448 return trianglesIndex++; 449 449 } -
code/branches/cpp11_v3/src/libraries/tools/DynamicLines.cc
r5781 r11054 69 69 void DynamicLines::addPoint(Real x, Real y, Real z) 70 70 { 71 mPoints. push_back(Vector3(x,y,z));71 mPoints.emplace_back(x,y,z); 72 72 mDirty = true; 73 73 } -
code/branches/cpp11_v3/src/libraries/tools/DynamicLines.h
r5781 r11054 84 84 protected: 85 85 /// Implementation DynamicRenderable, creates a simple vertex-only decl 86 virtual void createVertexDeclaration() ;86 virtual void createVertexDeclaration() override; 87 87 /// Implementation DynamicRenderable, pushes point list out to hardware memory 88 virtual void fillHardwareBuffers() ;88 virtual void fillHardwareBuffers() override; 89 89 90 90 private: -
code/branches/cpp11_v3/src/libraries/tools/DynamicRenderable.h
r5781 r11054 61 61 62 62 /// Implementation of SimpleRenderable 63 virtual Real getBoundingRadius(void) const ;63 virtual Real getBoundingRadius(void) const override; 64 64 /// Implementation of SimpleRenderable 65 virtual Real getSquaredViewDepth(const Camera* cam) const ;65 virtual Real getSquaredViewDepth(const Camera* cam) const override; 66 66 67 67 protected: -
code/branches/cpp11_v3/src/libraries/tools/IcoSphere.cc
r10262 r11054 116 116 std::list<TriangleIndices> faces2; 117 117 118 for ( std::list<TriangleIndices>::iterator j = faces.begin(); j != faces.end(); j++)118 for (const TriangleIndices& f : faces) 119 119 { 120 TriangleIndices f = *j;121 120 int a = getMiddlePoint(f.v1, f.v2); 122 121 int b = getMiddlePoint(f.v2, f.v3); … … 127 126 removeLineIndices(f.v3, f.v1); 128 127 129 faces2. push_back(TriangleIndices(f.v1, a, c));130 faces2. push_back(TriangleIndices(f.v2, b, a));131 faces2. push_back(TriangleIndices(f.v3, c, b));132 faces2. push_back(TriangleIndices(a, b, c));128 faces2.emplace_back(f.v1, a, c); 129 faces2.emplace_back(f.v2, b, a); 130 faces2.emplace_back(f.v3, c, b); 131 faces2.emplace_back(a, b, c); 133 132 134 133 addTriangleLines(f.v1, a, c); … … 143 142 void IcoSphere::addLineIndices(int index0, int index1) 144 143 { 145 lineIndices. push_back(LineIndices(index0, index1));144 lineIndices.emplace_back(index0, index1); 146 145 } 147 146 … … 164 163 { 165 164 Ogre::Real length = vertex.length(); 166 vertices. push_back(Ogre::Vector3(vertex.x / length, vertex.y / length, vertex.z / length));165 vertices.emplace_back(vertex.x / length, vertex.y / length, vertex.z / length); 167 166 return index++; 168 167 } … … 189 188 void IcoSphere::addFace(int index0, int index1, int index2) 190 189 { 191 faces. push_back(TriangleIndices(index0, index1, index2));190 faces.emplace_back(index0, index1, index2); 192 191 } 193 192 194 193 void IcoSphere::addToLineIndices(int baseIndex, std::list<int>* target) const 195 194 { 196 for ( std::list<LineIndices>::const_iterator i = lineIndices.begin(); i != lineIndices.end(); i++)195 for (const LineIndices& line : lineIndices) 197 196 { 198 target->push_back(baseIndex + (*i).v1);199 target->push_back(baseIndex + (*i).v2);197 target->push_back(baseIndex + line.v1); 198 target->push_back(baseIndex + line.v2); 200 199 } 201 200 } … … 203 202 void IcoSphere::addToTriangleIndices(int baseIndex, std::list<int>* target) const 204 203 { 205 for ( std::list<TriangleIndices>::const_iterator i = faces.begin(); i != faces.end(); i++)204 for (const TriangleIndices& triangle : faces) 206 205 { 207 target->push_back(baseIndex + (*i).v1);208 target->push_back(baseIndex + (*i).v2);209 target->push_back(baseIndex + (*i).v3);206 target->push_back(baseIndex + triangle.v1); 207 target->push_back(baseIndex + triangle.v2); 208 target->push_back(baseIndex + triangle.v3); 210 209 } 211 210 } … … 217 216 transform.setScale(Ogre::Vector3(scale, scale, scale)); 218 217 219 for ( int i = 0; i < (int) vertices.size(); i++)220 target-> push_back(VertexPair(transform * vertices[i], colour));218 for (const Ogre::Vector3& vertex : vertices) 219 target->emplace_back(transform * vertex, colour); 221 220 222 221 return vertices.size(); -
code/branches/cpp11_v3/src/libraries/tools/Mesh.cc
r8858 r11054 44 44 Mesh::Mesh() 45 45 { 46 this->entity_ = 0;46 this->entity_ = nullptr; 47 47 this->bCastShadows_ = true; 48 48 } … … 73 73 { 74 74 orxout(internal_error) << "Couldn't load mesh \"" << meshsource << '"' << endl; 75 this->entity_ = 0;75 this->entity_ = nullptr; 76 76 } 77 77 } -
code/branches/cpp11_v3/src/libraries/tools/OgreBulletUtils.h
r10262 r11054 10 10 11 11 #include "tools/ToolsPrereqs.h" 12 #include <OgreVector3.h> 13 #include <OgreQuaternion.h> 14 #include <OgreColourValue.h> 15 #include <OgreMatrix3.h> 16 #include <OgreMatrix4.h> 12 17 13 18 namespace orxonox … … 42 47 inline Ogre::Matrix3 matrix3(const btMatrix3x3& matrix) 43 48 { 44 return Matrix3(49 return Ogre::Matrix3( 45 50 matrix[0][0], matrix[0][1], matrix[0][2], 46 51 matrix[1][0], matrix[1][1], matrix[1][2], -
code/branches/cpp11_v3/src/libraries/tools/ParticleInterface.cc
r11052 r11054 59 59 60 60 this->scenemanager_ = scenemanager; 61 this->particleSystem_ = 0;61 this->particleSystem_ = nullptr; 62 62 63 63 this->bEnabled_ = true; … … 80 80 { 81 81 orxout(internal_error) << "Couldn't load particle system \"" << templateName << '"' << endl; 82 this->particleSystem_ = 0;82 this->particleSystem_ = nullptr; 83 83 } 84 84 } … … 110 110 } 111 111 else 112 return 0;112 return nullptr; 113 113 } 114 114 Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const … … 117 117 return this->particleSystem_->getEmitter(emitterNr); 118 118 else 119 return 0;119 return nullptr; 120 120 } 121 121 void ParticleInterface::removeEmitter(unsigned int emitterNr) … … 142 142 return this->particleSystem_->addAffector(name); 143 143 else 144 return 0;144 return nullptr; 145 145 } 146 146 Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) … … 149 149 return this->particleSystem_->getAffector(affectorNr); 150 150 else 151 return 0;151 return nullptr; 152 152 } 153 153 void ParticleInterface::removeAffector(unsigned int affectorNr) -
code/branches/cpp11_v3/src/libraries/tools/ParticleInterface.h
r11052 r11054 78 78 79 79 protected: 80 virtual void changedTimeFactor(float factor_new, float factor_old) ;80 virtual void changedTimeFactor(float factor_new, float factor_old) override; 81 81 82 82 private: -
code/branches/cpp11_v3/src/libraries/tools/ResourceCollection.cc
r9667 r11054 48 48 } 49 49 50 ResourceCollection::~ResourceCollection()51 {52 }53 54 50 void ResourceCollection::XMLPort(Element& xmlelement, XMLPort::Mode mode) 55 51 { … … 93 89 { 94 90 if (index >= resourceLocations_.size()) 95 return NULL;91 return nullptr; 96 92 else 97 93 return resourceLocations_[index]; -
code/branches/cpp11_v3/src/libraries/tools/ResourceCollection.h
r9667 r11054 42 42 public: 43 43 ResourceCollection(Context* context); 44 virtual ~ResourceCollection() ;44 virtual ~ResourceCollection() = default; 45 45 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 48 48 void setResourceGroup(const std::string& resourceGroup); … … 54 54 55 55 private: 56 ResourceCollection(const ResourceCollection&); 56 // non-copyable: 57 ResourceCollection(const ResourceCollection&) = delete; 58 ResourceCollection& operator=(const ResourceCollection&) = delete; 57 59 58 60 std::string resourceGroup_; -
code/branches/cpp11_v3/src/libraries/tools/ResourceLocation.cc
r10624 r11054 54 54 } 55 55 56 ResourceLocation::~ResourceLocation()57 {58 }59 60 56 void ResourceLocation::XMLPort(Element& xmlelement, XMLPort::Mode mode) 61 57 { -
code/branches/cpp11_v3/src/libraries/tools/ResourceLocation.h
r9667 r11054 44 44 public: 45 45 ResourceLocation(Context* context); 46 virtual ~ResourceLocation() ;46 virtual ~ResourceLocation() = default; 47 47 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 49 49 50 50 void setPath(const std::string& path) { path_ = path; } … … 60 60 61 61 private: 62 ResourceLocation(const ResourceLocation&); 62 // non-copyable: 63 ResourceLocation(const ResourceLocation&) = delete; 64 ResourceLocation& operator=(const ResourceLocation&) = delete; 63 65 64 66 void load(const std::string& resourceGroup); -
code/branches/cpp11_v3/src/libraries/tools/Shader.cc
r10727 r11054 44 44 @brief Initializes the values and sets the scene manager. 45 45 */ 46 Shader::Shader(Ogre::SceneManager* scenemanager) : compositorInstance_( 0)46 Shader::Shader(Ogre::SceneManager* scenemanager) : compositorInstance_(nullptr) 47 47 { 48 48 RegisterObject(Shader); … … 109 109 { 110 110 // For the moment, we get the viewport always from the graphics manager 111 // TODO: Try to support multiple viewports - note however that scenemanager_->getCurrentViewport() returns NULL111 // TODO: Try to support multiple viewports - note however that scenemanager_->getCurrentViewport() returns nullptr 112 112 // after switching to a camera in a different scene (only for the first time this scene is displayed though) 113 113 this->changedCompositorName(GraphicsManager::getInstance().getViewport()); … … 127 127 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->oldcompositorName_); 128 128 this->compositorInstance_->removeListener(this); 129 this->compositorInstance_ = 0;129 this->compositorInstance_ = nullptr; 130 130 } 131 131 if (!this->compositorName_.empty()) … … 197 197 { 198 198 // iterate through the list of parameters 199 for ( std::list<ParameterContainer>::iterator it = this->parameters_.begin(); it != this->parameters_.end(); ++it)200 { 201 Ogre::Technique* techniquePtr = materialPtr->getTechnique( it->technique_);199 for (const ParameterContainer& parameter : this->parameters_) 200 { 201 Ogre::Technique* techniquePtr = materialPtr->getTechnique(parameter.technique_); 202 202 if (techniquePtr) 203 203 { 204 Ogre::Pass* passPtr = techniquePtr->getPass( it->pass_);204 Ogre::Pass* passPtr = techniquePtr->getPass(parameter.pass_); 205 205 if (passPtr) 206 206 { 207 207 // change the value of the parameter depending on its type 208 if ( it->value_.isType<int>())209 passPtr->getFragmentProgramParameters()->setNamedConstant( it->parameter_, it->value_.get<int>());210 else if ( it->value_.isType<float>())211 passPtr->getFragmentProgramParameters()->setNamedConstant( it->parameter_, it->value_.get<float>());208 if (parameter.value_.isType<int>()) 209 passPtr->getFragmentProgramParameters()->setNamedConstant(parameter.parameter_, parameter.value_.get<int>()); 210 else if (parameter.value_.isType<float>()) 211 passPtr->getFragmentProgramParameters()->setNamedConstant(parameter.parameter_, parameter.value_.get<float>()); 212 212 } 213 213 else 214 orxout(internal_warning) << "No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << endl;214 orxout(internal_warning) << "No pass " << parameter.pass_ << " in technique " << parameter.technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << endl; 215 215 } 216 216 else 217 orxout(internal_warning) << "No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << endl;217 orxout(internal_warning) << "No technique " << parameter.technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << endl; 218 218 } 219 219 this->parameters_.clear(); … … 228 228 { 229 229 const Ogre::Root::PluginInstanceList& plugins = Ogre::Root::getSingleton().getInstalledPlugins(); 230 for ( size_t i = 0; i < plugins.size(); ++i)231 if (plugin s[i]->getName() == "Cg Program Manager")230 for (Ogre::Plugin* plugin : plugins) 231 if (plugin->getName() == "Cg Program Manager") 232 232 return true; 233 233 } -
code/branches/cpp11_v3/src/libraries/tools/Shader.h
r10727 r11054 48 48 { 49 49 public: 50 Shader(Ogre::SceneManager* scenemanager = 0);50 Shader(Ogre::SceneManager* scenemanager = nullptr); 51 51 virtual ~Shader(); 52 52 … … 87 87 { return this->scenemanager_; } 88 88 89 virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera) ;89 virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera) override; 90 90 91 91 void setParameter(unsigned short technique, unsigned short pass, const std::string& parameter, float value); 92 92 void setParameter(unsigned short technique, unsigned short pass, const std::string& parameter, int value); 93 93 94 virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr) ;94 virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr) override; 95 95 96 96 private: -
code/branches/cpp11_v3/src/libraries/tools/TextureGenerator.cc
r10546 r11054 71 71 namespace orxonox 72 72 { 73 std::map<std::string, std::map<ColourValue, std::string> 73 std::map<std::string, std::map<ColourValue, std::string>> TextureGenerator::materials_s; 74 74 unsigned int TextureGenerator::materialCount_s = 0; 75 75 -
code/branches/cpp11_v3/src/libraries/tools/TextureGenerator.h
r5781 r11054 49 49 50 50 private: 51 TextureGenerator(); 52 TextureGenerator(const TextureGenerator&); 53 ~TextureGenerator(); 51 // static class, no instances allowed: 52 TextureGenerator() = delete; 53 TextureGenerator(const TextureGenerator&) = delete; 54 TextureGenerator& operator=(const TextureGenerator&) = delete; 55 ~TextureGenerator() = delete; 54 56 55 static std::map<std::string, std::map<ColourValue, std::string> 57 static std::map<std::string, std::map<ColourValue, std::string>> materials_s; 56 58 static unsigned int materialCount_s; 57 59 }; -
code/branches/cpp11_v3/src/libraries/tools/Timer.cc
r11018 r11054 163 163 void Timer::init() 164 164 { 165 this->executor_ = 0;165 this->executor_ = nullptr; 166 166 this->interval_ = 0; 167 167 this->bLoop_ = false; -
code/branches/cpp11_v3/src/libraries/tools/Timer.h
r11018 r11054 175 175 176 176 protected: 177 virtual float getTimeFactor() ;177 virtual float getTimeFactor() override; 178 178 }; 179 179 } -
code/branches/cpp11_v3/src/libraries/tools/interfaces/TimeFactorListener.h
r9667 r11054 39 39 public: 40 40 TimeFactorListener(); 41 virtual ~TimeFactorListener() {}41 virtual ~TimeFactorListener() = default; 42 42 43 43 static void setTimeFactor(float factor); -
code/branches/cpp11_v3/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
r10624 r11054 60 60 float oldFactor = TimeFactorListener::timefactor_s; 61 61 TimeFactorListener::timefactor_s = factor; 62 for ( ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)63 it->changedTimeFactor(factor, oldFactor);62 for (TimeFactorListener* listener : ObjectList<TimeFactorListener>()) 63 listener->changedTimeFactor(factor, oldFactor); 64 64 } 65 65 -
code/branches/cpp11_v3/src/libraries/util/CMakeLists.txt
r10624 r11054 26 26 CRC32.cc 27 27 ExprParser.cc 28 SharedPtr.cc29 28 Sleep.cc 30 29 SmallObjectAllocator.cc -
code/branches/cpp11_v3/src/libraries/util/Clipboard.cc
r8858 r11054 93 93 { 94 94 HANDLE hData = GetClipboardData(CF_TEXT); 95 if (hData == NULL)95 if (hData == nullptr) 96 96 return ""; 97 97 std::string output(static_cast<char*>(GlobalLock(hData))); -
code/branches/cpp11_v3/src/libraries/util/Clock.h
r7401 r11054 102 102 103 103 private: 104 /// Undefined 105 Clock(const Clock& instance); 104 // non-copyable: 105 Clock(const Clock&) = delete; 106 Clock& operator=(const Clock&) = delete; 106 107 107 108 Ogre::Timer* timer_; ///< Ogre timer object -
code/branches/cpp11_v3/src/libraries/util/DestructionHelper.h
r8423 r11054 36 36 /** Deletes an object and resets the pointer 37 37 @param object 38 Pointer to an object. Handing over NULLis safe.38 Pointer to an object. Handing over nullptr is safe. 39 39 */ 40 40 template <class T> … … 42 42 { 43 43 delete *object; 44 *object = NULL;44 *object = nullptr; 45 45 } 46 46 … … 87 87 88 88 private: 89 DestructionHelper(const DestructionHelper&); //!< Don't use (undefined) 89 // non-copyable: 90 DestructionHelper(const DestructionHelper&) = delete; 91 DestructionHelper& operator=(const DestructionHelper&) = delete; 90 92 91 93 T* object_; -
code/branches/cpp11_v3/src/libraries/util/DisplayStringConversions.h
r6417 r11054 51 51 { 52 52 Ogre::UTFString::code_point cp; 53 for ( unsigned int i = 0; i < input.size(); ++i)53 for (const char& character : input) 54 54 { 55 cp = input[i];55 cp = character; 56 56 cp &= 0xFF; 57 57 output->append(1, cp); -
code/branches/cpp11_v3/src/libraries/util/ExprParser.cc
r8351 r11054 391 391 } 392 392 393 char*ExprParser::parse_word(char* str)393 void ExprParser::parse_word(char* str) 394 394 { 395 395 char* word = str; … … 402 402 { 403 403 this->failed_ = true; 404 return '\0';404 return; 405 405 } 406 406 }; 407 407 *word = '\0'; 408 return str;409 408 } 410 409 -
code/branches/cpp11_v3/src/libraries/util/ExprParser.h
r8858 r11054 139 139 float parse_expr_7(); 140 140 float parse_expr_8(); 141 char*parse_word(char* str);141 void parse_word(char* str); 142 142 binary_operator parse_binary_operator(); 143 143 unary_operator parse_unary_operator(); -
code/branches/cpp11_v3/src/libraries/util/ImplicitConversion.h
r8267 r11054 68 68 { 69 69 private: 70 ImplicitConversion(); ImplicitConversion(const ImplicitConversion&); ~ImplicitConversion(); 70 // static class, no instances allowed: 71 ImplicitConversion() = delete; 72 ImplicitConversion(const ImplicitConversion&) = delete; 73 ImplicitConversion& operator=(const ImplicitConversion&) = delete; 74 ~ImplicitConversion() = delete; 75 71 76 // Gets chosen only if there is an implicit conversion from FromType to ToType. 72 77 static char test(ToType); -
code/branches/cpp11_v3/src/libraries/util/Math.cc
r11052 r11054 371 371 } 372 372 373 374 namespace detail 375 { 376 std::mt19937 rngen; 377 } 378 373 379 /** 374 380 @brief Returns a unique number. This function will never return the same value twice. -
code/branches/cpp11_v3/src/libraries/util/Math.h
r11052 r11054 46 46 #include <cmath> 47 47 #include <cstdlib> 48 #include <random> 48 49 49 50 #include <OgreMath.h> … … 73 74 namespace math 74 75 { 75 const float twoPi = 6.283185482025146484375f; ///< PI * 276 const float pi = 3.1415927410125732421875f; ///< PI77 const float pi_2 = 1.57079637050628662109375f; ///< PI / 278 const float pi_4 = 0.785398185253143310546875f; ///< PI / 479 const float e = 2.718281269073486328125f; ///< e80 const float sqrt2 = 1.41421353816986083984375f; ///< sqrt(2)81 const float sqrt2_2 = 0.707106769084930419921875f; ///< sqrt(2) / 276 constexpr float twoPi = 6.283185482025146484375f; ///< PI * 2 77 constexpr float pi = 3.1415927410125732421875f; ///< PI 78 constexpr float pi_2 = 1.57079637050628662109375f; ///< PI / 2 79 constexpr float pi_4 = 0.785398185253143310546875f; ///< PI / 4 80 constexpr float e = 2.718281269073486328125f; ///< e 81 constexpr float sqrt2 = 1.41421353816986083984375f; ///< sqrt(2) 82 constexpr float sqrt2_2 = 0.707106769084930419921875f; ///< sqrt(2) / 2 82 83 } 83 84 … … 104 105 */ 105 106 template <typename T> 106 inline T sgn(T x)107 constexpr inline T sgn(T x) 107 108 { 108 109 return (x >= 0) ? (T)1 : (T)-1; … … 116 117 */ 117 118 template <typename T> 118 inline T clamp(T x, T min, T max) 119 { 120 if (x < min) 121 return min; 122 123 if (x > max) 124 return max; 125 126 return x; 119 constexpr inline T clamp(T x, T min, T max) 120 { 121 return x < min ? min : (x > max ? max : x); 127 122 } 128 123 … … 131 126 */ 132 127 template <typename T> 133 inline T square(T x)128 constexpr inline T square(T x) 134 129 { 135 130 return x*x; … … 140 135 */ 141 136 template <typename T> 142 inline T cube(T x)137 constexpr inline T cube(T x) 143 138 { 144 139 return x*x*x; … … 186 181 inline T zeroise() 187 182 { 188 // Default, raise a compiler error without including large boost header cascade. 189 T temp(); 190 *********temp; // If you reach this code, you abused zeroise()! 191 return temp; 183 // If you reach this code, you abused zeroise()! 184 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 192 185 } 193 186 … … 206 199 template <> inline long double zeroise<long double>() { return 0; } 207 200 template <> inline bool zeroise<bool>() { return 0; } 208 template <> inline void* zeroise<void*>() { return 0; }201 template <> inline void* zeroise<void*>() { return nullptr; } 209 202 template <> inline std::string zeroise<std::string>() { return std::string(); } 210 203 template <> inline orxonox::Radian zeroise<orxonox::Radian>() { return orxonox::Radian(0.0f); } … … 258 251 } 259 252 253 namespace detail 254 { 255 /** 256 Random number generator used for the functions below. Marked extern to only have one global instance. 257 */ 258 _UtilExport extern std::mt19937 rngen; 259 } 260 261 /** 262 @brief Seeds the random number generator used for the functions below. 263 */ 264 inline void rndseed(unsigned int seed) 265 { 266 detail::rngen.seed(seed); 267 } 268 269 /** 270 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 271 @param min The minimum 272 @param max The maximum 273 */ 274 inline float rnd(float min, float max) 275 { 276 std::uniform_real_distribution<float> dist(min, max); 277 return dist(detail::rngen); 278 } 279 260 280 /** 261 281 @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>. … … 263 283 inline float rnd() 264 284 { 265 return r and() / (RAND_MAX + 1.0f);285 return rnd(0, 1); 266 286 } 267 287 … … 272 292 inline float rnd(float max) 273 293 { 274 return rnd() * max; 275 } 276 277 /** 278 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 279 @param min The minimum 280 @param max The maximum 281 */ 282 inline float rnd(float min, float max) 283 { 284 return rnd(max - min) + min; 294 return rnd(0, max); 285 295 } 286 296 … … 290 300 inline float rndsgn() 291 301 { 292 return static_cast<float>((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0 302 std::uniform_int_distribution<> dist; 303 return static_cast<float>((dist(detail::rngen) & 0x2) - 1); // dist(...) & 0x2 is either 2 or 0 293 304 } 294 305 -
code/branches/cpp11_v3/src/libraries/util/MultiType.h
r10197 r11054 175 175 public: 176 176 inline MT_ValueBase(void* data, Type::Enum type) : type_(type), bLastConversionSuccessful(true), data_(data) {} 177 inline virtual~MT_ValueBase() {}177 virtual inline ~MT_ValueBase() {} 178 178 179 179 virtual MT_ValueBase* clone() const = 0; … … 266 266 267 267 /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. 268 inline MultiType() : value_( 0) { }268 inline MultiType() : value_(nullptr) { } 269 269 /// Constructor: Assigns the given value and sets the type. 270 270 template <typename V> 271 inline MultiType(const V& value) : value_( 0) { this->set(value); }271 inline MultiType(const V& value) : value_(nullptr) { this->set(value); } 272 272 /// Copyconstructor: Assigns value and type of the other MultiType. 273 inline MultiType(const MultiType& other) : value_( 0) { this->set(other); }273 inline MultiType(const MultiType& other) : value_(nullptr) { this->set(other); } 274 274 275 275 /// Destructor: Deletes the MT_Value. … … 325 325 if (this->value_) 326 326 delete this->value_; 327 this->value_ = (other.value_) ? other.value_->clone() : 0;327 this->value_ = (other.value_) ? other.value_->clone() : nullptr; 328 328 } 329 329 … … 332 332 333 333 /// Resets value and type. Type will be void afterwards and null() returns true. 334 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }334 inline void reset() { if (this->value_) delete this->value_; this->value_ = nullptr; } 335 335 /// Resets the value and changes the internal type to T. 336 336 template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } … … 428 428 } 429 429 /// Creates a new value container (works only with specialized types). 430 template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; } 430 template <typename T> inline void createNewValueContainer(const T& value) 431 { 432 // If you reach this code, you used MultiType with an unsupported type T 433 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 434 } 431 435 432 436 MT_ValueBase* value_; //!< A pointer to the value container … … 486 490 template <> inline long double MultiType::get() const { return (this->value_ ? this->value_->get<long double>() : 0); } 487 491 template <> inline bool MultiType::get() const { return (this->value_ ? this->value_->get<bool>() : 0); } 488 template <> inline void* MultiType::get() const { return (this->value_ ? this->value_->get<void*>() : 0); }492 template <> inline void* MultiType::get() const { return (this->value_ ? this->value_->get<void*>() : nullptr); } 489 493 template <> inline std::string MultiType::get() const { return (this->value_ ? this->value_->get<std::string>() : NilValue<std::string>()); } 490 494 template <> inline orxonox::Vector2 MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Vector2>() : NilValue<orxonox::Vector2>()); } -
code/branches/cpp11_v3/src/libraries/util/MultiTypeValue.h
r9550 r11054 58 58 59 59 /// Creates a copy of itself. 60 inline MT_ValueBase* clone() const{ return new MT_Value<T>(this->value_, this->type_); }60 virtual inline MT_ValueBase* clone() const override { return new MT_Value<T>(this->value_, this->type_); } 61 61 62 62 /// Resets the current value to the default. 63 inline void reset(){ this->value_ = zeroise<T>(); bLastConversionSuccessful = true; }64 65 inline bool getValue(char* value) const{ return convertValue<T, char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.66 inline bool getValue(unsigned char* value) const{ return convertValue<T, unsigned char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.67 inline bool getValue(short* value) const{ return convertValue<T, short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.68 inline bool getValue(unsigned short* value) const{ return convertValue<T, unsigned short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.69 inline bool getValue(int* value) const{ return convertValue<T, int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.70 inline bool getValue(unsigned int* value) const{ return convertValue<T, unsigned int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.71 inline bool getValue(long* value) const{ return convertValue<T, long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.72 inline bool getValue(unsigned long* value) const{ return convertValue<T, unsigned long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.73 inline bool getValue(long long* value) const{ return convertValue<T, long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.74 inline bool getValue(unsigned long long* value) const{ return convertValue<T, unsigned long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.75 inline bool getValue(float* value) const{ return convertValue<T, float >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.76 inline bool getValue(double* value) const{ return convertValue<T, double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.77 inline bool getValue(long double* value) const{ return convertValue<T, long double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.78 inline bool getValue(bool* value) const{ return convertValue<T, bool >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.79 inline bool getValue(void** value) const { return convertValue<T, void* >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.80 inline bool getValue(std::string* value) const{ return convertValue<T, std::string >(value, value_, NilValue<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.81 inline bool getValue(orxonox::Vector2* value) const{ return convertValue<T, orxonox::Vector2 >(value, value_, NilValue<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.82 inline bool getValue(orxonox::Vector3* value) const{ return convertValue<T, orxonox::Vector3 >(value, value_, NilValue<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.83 inline bool getValue(orxonox::Vector4* value) const{ return convertValue<T, orxonox::Vector4 >(value, value_, NilValue<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.84 inline bool getValue(orxonox::ColourValue* value) const{ return convertValue<T, orxonox::ColourValue>(value, value_, NilValue<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.85 inline bool getValue(orxonox::Quaternion* value) const{ return convertValue<T, orxonox::Quaternion >(value, value_, NilValue<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.86 inline bool getValue(orxonox::Radian* value) const{ return convertValue<T, orxonox::Radian >(value, value_, NilValue<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.87 inline bool getValue(orxonox::Degree* value) const{ return convertValue<T, orxonox::Degree >(value, value_, NilValue<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.63 virtual inline void reset() override { this->value_ = zeroise<T>(); bLastConversionSuccessful = true; } 64 65 virtual inline bool getValue(char* value) const override { return convertValue<T, char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 66 virtual inline bool getValue(unsigned char* value) const override { return convertValue<T, unsigned char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 67 virtual inline bool getValue(short* value) const override { return convertValue<T, short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 68 virtual inline bool getValue(unsigned short* value) const override { return convertValue<T, unsigned short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 69 virtual inline bool getValue(int* value) const override { return convertValue<T, int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 70 virtual inline bool getValue(unsigned int* value) const override { return convertValue<T, unsigned int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 71 virtual inline bool getValue(long* value) const override { return convertValue<T, long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 72 virtual inline bool getValue(unsigned long* value) const override { return convertValue<T, unsigned long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 73 virtual inline bool getValue(long long* value) const override { return convertValue<T, long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 74 virtual inline bool getValue(unsigned long long* value) const override { return convertValue<T, unsigned long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 75 virtual inline bool getValue(float* value) const override { return convertValue<T, float >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 76 virtual inline bool getValue(double* value) const override { return convertValue<T, double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 77 virtual inline bool getValue(long double* value) const override { return convertValue<T, long double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 78 virtual inline bool getValue(bool* value) const override { return convertValue<T, bool >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 79 virtual inline bool getValue(void** value) const override { return convertValue<T, void* >(value, value_, nullptr); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 80 virtual inline bool getValue(std::string* value) const override { return convertValue<T, std::string >(value, value_, NilValue<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 81 virtual inline bool getValue(orxonox::Vector2* value) const override { return convertValue<T, orxonox::Vector2 >(value, value_, NilValue<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 82 virtual inline bool getValue(orxonox::Vector3* value) const override { return convertValue<T, orxonox::Vector3 >(value, value_, NilValue<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 83 virtual inline bool getValue(orxonox::Vector4* value) const override { return convertValue<T, orxonox::Vector4 >(value, value_, NilValue<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 84 virtual inline bool getValue(orxonox::ColourValue* value) const override { return convertValue<T, orxonox::ColourValue>(value, value_, NilValue<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 85 virtual inline bool getValue(orxonox::Quaternion* value) const override { return convertValue<T, orxonox::Quaternion >(value, value_, NilValue<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 86 virtual inline bool getValue(orxonox::Radian* value) const override { return convertValue<T, orxonox::Radian >(value, value_, NilValue<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 87 virtual inline bool getValue(orxonox::Degree* value) const override { return convertValue<T, orxonox::Degree >(value, value_, NilValue<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 88 88 89 89 /** … … 91 91 @param other The other MultiType 92 92 */ 93 inline bool setValue(const MultiType& other)93 virtual inline bool setValue(const MultiType& other) override 94 94 { 95 95 if (other.value_) … … 104 104 } 105 105 106 inline bool setValue(const char& value){ return (bLastConversionSuccessful = convertValue<char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.107 inline bool setValue(const unsigned char& value){ return (bLastConversionSuccessful = convertValue<unsigned char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.108 inline bool setValue(const short& value){ return (bLastConversionSuccessful = convertValue<short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.109 inline bool setValue(const unsigned short& value){ return (bLastConversionSuccessful = convertValue<unsigned short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.110 inline bool setValue(const int& value){ return (bLastConversionSuccessful = convertValue<int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.111 inline bool setValue(const unsigned int& value){ return (bLastConversionSuccessful = convertValue<unsigned int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.112 inline bool setValue(const long& value){ return (bLastConversionSuccessful = convertValue<long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.113 inline bool setValue(const unsigned long& value){ return (bLastConversionSuccessful = convertValue<unsigned long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.114 inline bool setValue(const long long& value){ return (bLastConversionSuccessful = convertValue<long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.115 inline bool setValue(const unsigned long long& value){ return (bLastConversionSuccessful = convertValue<unsigned long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.116 inline bool setValue(const float& value){ return (bLastConversionSuccessful = convertValue<float , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.117 inline bool setValue(const double& value){ return (bLastConversionSuccessful = convertValue<double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.118 inline bool setValue(const long double& value){ return (bLastConversionSuccessful = convertValue<long double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.119 inline bool setValue(const bool& value){ return (bLastConversionSuccessful = convertValue<bool , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.120 inline bool setValue( void* const& value){ return (bLastConversionSuccessful = convertValue<void* , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.121 inline bool setValue(const std::string& value){ return (bLastConversionSuccessful = convertValue<std::string , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.122 inline bool setValue(const orxonox::Vector2& value){ return (bLastConversionSuccessful = convertValue<orxonox::Vector2 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.123 inline bool setValue(const orxonox::Vector3& value){ return (bLastConversionSuccessful = convertValue<orxonox::Vector3 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.124 inline bool setValue(const orxonox::Vector4& value){ return (bLastConversionSuccessful = convertValue<orxonox::Vector4 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.125 inline bool setValue(const orxonox::ColourValue& value){ return (bLastConversionSuccessful = convertValue<orxonox::ColourValue, T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.126 inline bool setValue(const orxonox::Quaternion& value){ return (bLastConversionSuccessful = convertValue<orxonox::Quaternion , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.127 inline bool setValue(const orxonox::Radian& value){ return (bLastConversionSuccessful = convertValue<orxonox::Radian , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.128 inline bool setValue(const orxonox::Degree& value){ return (bLastConversionSuccessful = convertValue<orxonox::Degree , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.106 virtual inline bool setValue(const char& value) override { return (bLastConversionSuccessful = convertValue<char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 107 virtual inline bool setValue(const unsigned char& value) override { return (bLastConversionSuccessful = convertValue<unsigned char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 108 virtual inline bool setValue(const short& value) override { return (bLastConversionSuccessful = convertValue<short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 109 virtual inline bool setValue(const unsigned short& value) override { return (bLastConversionSuccessful = convertValue<unsigned short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 110 virtual inline bool setValue(const int& value) override { return (bLastConversionSuccessful = convertValue<int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 111 virtual inline bool setValue(const unsigned int& value) override { return (bLastConversionSuccessful = convertValue<unsigned int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 112 virtual inline bool setValue(const long& value) override { return (bLastConversionSuccessful = convertValue<long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 113 virtual inline bool setValue(const unsigned long& value) override { return (bLastConversionSuccessful = convertValue<unsigned long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 114 virtual inline bool setValue(const long long& value) override { return (bLastConversionSuccessful = convertValue<long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 115 virtual inline bool setValue(const unsigned long long& value) override { return (bLastConversionSuccessful = convertValue<unsigned long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 116 virtual inline bool setValue(const float& value) override { return (bLastConversionSuccessful = convertValue<float , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 117 virtual inline bool setValue(const double& value) override { return (bLastConversionSuccessful = convertValue<double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 118 virtual inline bool setValue(const long double& value) override { return (bLastConversionSuccessful = convertValue<long double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 119 virtual inline bool setValue(const bool& value) override { return (bLastConversionSuccessful = convertValue<bool , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 120 virtual inline bool setValue( void* const& value) override { return (bLastConversionSuccessful = convertValue<void* , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 121 virtual inline bool setValue(const std::string& value) override { return (bLastConversionSuccessful = convertValue<std::string , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 122 virtual inline bool setValue(const orxonox::Vector2& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Vector2 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 123 virtual inline bool setValue(const orxonox::Vector3& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Vector3 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 124 virtual inline bool setValue(const orxonox::Vector4& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Vector4 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 125 virtual inline bool setValue(const orxonox::ColourValue& value) override { return (bLastConversionSuccessful = convertValue<orxonox::ColourValue, T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 126 virtual inline bool setValue(const orxonox::Quaternion& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Quaternion , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 127 virtual inline bool setValue(const orxonox::Radian& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Radian , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 128 virtual inline bool setValue(const orxonox::Degree& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Degree , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 129 129 130 130 /// Puts the current value on the stream 131 inline void toString(std::ostream& outstream) const{ outstream << this->value_; }131 virtual inline void toString(std::ostream& outstream) const override { outstream << this->value_; } 132 132 133 133 /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data 134 inline void importData( uint8_t*& mem ){ loadAndIncrease( /*(const T&)*/this->value_, mem ); }134 virtual inline void importData( uint8_t*& mem ) override { loadAndIncrease( /*(const T&)*/this->value_, mem ); } 135 135 /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data 136 inline void exportData( uint8_t*& mem ) const{ saveAndIncrease( /*(const T&)*/this->value_, mem ); }136 virtual inline void exportData( uint8_t*& mem ) const override { saveAndIncrease( /*(const T&)*/this->value_, mem ); } 137 137 /// returns the size of the data that would be saved by exportData 138 inline uint8_t getSize() const{ return returnSize( this->value_ ); }138 virtual inline uint8_t getSize() const override { return returnSize( this->value_ ); } 139 139 140 140 T value_; ///< The stored value -
code/branches/cpp11_v3/src/libraries/util/Serialise.h
r8706 r11054 672 672 { 673 673 uint32_t tempsize = sizeof(uint32_t); // for the number of entries 674 for( typename std::set<T>::iterator it=((std::set<T>*)(&variable))->begin(); it!=((std::set<T>*)(&variable))->end(); ++it)675 tempsize += returnSize( *it );674 for(const T& element : *((std::set<T>*)(&variable))) 675 tempsize += returnSize( element ); 676 676 return tempsize; 677 677 } … … 679 679 template <class T> inline void saveAndIncrease( const std::set<T>& variable, uint8_t*& mem ) 680 680 { 681 typename std::set<T>::const_iterator it = variable.begin();682 681 saveAndIncrease( (uint32_t)variable.size(), mem ); 683 for( ; it!=variable.end(); ++it)684 saveAndIncrease( *it, mem );682 for( const T& elem : variable ) 683 saveAndIncrease( elem, mem ); 685 684 } 686 685 -
code/branches/cpp11_v3/src/libraries/util/SignalHandler.cc
r9682 r11054 44 44 namespace orxonox 45 45 { 46 SignalHandler* SignalHandler::singletonPtr_s = NULL;46 SignalHandler* SignalHandler::singletonPtr_s = nullptr; 47 47 } 48 48 … … 81 81 void SignalHandler::dontCatch() 82 82 { 83 for ( SignalRecList::iterator it = sigRecList.begin(); it != sigRecList.end(); it++)84 { 85 signal( it->signal, it->handler );83 for (const SignalRec& sigRec : sigRecList) 84 { 85 signal( sigRec.signal, sigRec.handler ); 86 86 } 87 87 … … 127 127 } 128 128 // if the signalhandler has already been destroyed then don't do anything 129 if( SignalHandler::singletonPtr_s == 0)129 if( SignalHandler::singletonPtr_s == nullptr ) 130 130 { 131 131 orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl; … … 133 133 } 134 134 135 for ( SignalCallbackList::iterator it = SignalHandler::getInstance().callbackList.begin(); it != SignalHandler::getInstance().callbackList.end(); it++)136 { 137 (*( it->cb))( it->someData );135 for (const SignalCallbackRec& callback : SignalHandler::getInstance().callbackList) 136 { 137 (*(callback.cb))( callback.someData ); 138 138 } 139 139 … … 175 175 dup2( gdbErr[1], STDERR_FILENO ); 176 176 177 execlp( "sh", "sh", "-c", "gdb", static_cast<void*>( NULL));177 execlp( "sh", "sh", "-c", "gdb", static_cast<void*>(nullptr)); 178 178 } 179 179 … … 186 186 perror("pipe failed!\n"); 187 187 kill( gdbPid, SIGTERM ); 188 waitpid( gdbPid, NULL, 0 );188 waitpid( gdbPid, nullptr, 0 ); 189 189 exit(EXIT_FAILURE); 190 190 } … … 196 196 perror("fork failed!\n"); 197 197 kill( gdbPid, SIGTERM ); 198 waitpid( gdbPid, NULL, 0 );198 waitpid( gdbPid, nullptr, 0 ); 199 199 exit(EXIT_FAILURE); 200 200 } … … 297 297 298 298 299 waitpid( sigPid, NULL, 0 );300 waitpid( gdbPid, NULL, 0 );299 waitpid( sigPid, nullptr, 0 ); 300 waitpid( gdbPid, nullptr, 0 ); 301 301 302 302 int wsRemoved = 0; … … 312 312 bt.erase(0, 1); 313 313 314 time_t now = time( NULL);314 time_t now = time(nullptr); 315 315 316 316 std::string timeString = … … 388 388 SignalHandler::SignalHandler() 389 389 { 390 this->prevExceptionFilter_ = NULL;390 this->prevExceptionFilter_ = nullptr; 391 391 } 392 392 … … 394 394 SignalHandler::~SignalHandler() 395 395 { 396 if (this->prevExceptionFilter_ != NULL)396 if (this->prevExceptionFilter_ != nullptr) 397 397 { 398 398 // Remove the unhandled exception filter function 399 399 SetUnhandledExceptionFilter(this->prevExceptionFilter_); 400 this->prevExceptionFilter_ = NULL;400 this->prevExceptionFilter_ = nullptr; 401 401 } 402 402 } … … 408 408 409 409 // don't register twice 410 assert(this->prevExceptionFilter_ == NULL);411 412 if (this->prevExceptionFilter_ == NULL)410 assert(this->prevExceptionFilter_ == nullptr); 411 412 if (this->prevExceptionFilter_ == nullptr) 413 413 { 414 414 // Install the unhandled exception filter function … … 430 430 431 431 // if the signalhandler has already been destroyed then don't do anything 432 if (SignalHandler::singletonPtr_s == 0)432 if (SignalHandler::singletonPtr_s == nullptr) 433 433 { 434 434 orxout(user_error) << "Caught an unhandled exception" << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl; … … 441 441 std::ofstream crashlog(SignalHandler::getInstance().filename_.c_str()); 442 442 443 time_t now = time( NULL);443 time_t now = time(nullptr); 444 444 445 445 crashlog << "=======================================================" << endl; … … 480 480 } 481 481 482 /// Returns the stack trace for either the current function, or, if @a pExceptionInfo is not NULL, for the given exception context.482 /// Returns the stack trace for either the current function, or, if @a pExceptionInfo is not nullptr, for the given exception context. 483 483 /* static */ std::string SignalHandler::getStackTrace(PEXCEPTION_POINTERS pExceptionInfo) 484 484 { … … 625 625 #ifdef ORXONOX_COMPILER_GCC 626 626 int status; 627 char* demangled = __cxxabiv1::__cxa_demangle(symbol->Name, NULL, NULL, &status);627 char* demangled = __cxxabiv1::__cxa_demangle(symbol->Name, nullptr, nullptr, &status); 628 628 if (demangled) 629 629 { … … 684 684 HMODULE hModule; 685 685 686 std::string output = (GetModuleFileName( NULL, szModule, MAX_PATH) ? SignalHandler::getModuleName(szModule) : "Application");686 std::string output = (GetModuleFileName(nullptr, szModule, MAX_PATH) ? SignalHandler::getModuleName(szModule) : "Application"); 687 687 output += " caused "; 688 688 -
code/branches/cpp11_v3/src/libraries/util/SignalHandler.h
r9550 r11054 113 113 void doCatch(const std::string& appName, const std::string& filename); 114 114 115 static std::string getStackTrace(PEXCEPTION_POINTERS pExceptionInfo = NULL);115 static std::string getStackTrace(PEXCEPTION_POINTERS pExceptionInfo = nullptr); 116 116 static std::string getExceptionType(PEXCEPTION_POINTERS pExceptionInfo); 117 117 -
code/branches/cpp11_v3/src/libraries/util/Singleton.h
r10624 r11054 66 66 And don't forget to initialize the static singleton pointer in the source (*.cc) %file: 67 67 @code 68 TestSingleton* TestSingleton::singletonPtr_s = NULL;68 TestSingleton* TestSingleton::singletonPtr_s = nullptr; 69 69 @endcode 70 70 … … 118 118 static T& getInstance() 119 119 { 120 OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());120 OrxVerify(T::singletonPtr_s != nullptr, "T=" << typeid(T).name()); 121 121 return *T::singletonPtr_s; 122 122 } … … 125 125 static bool exists() 126 126 { 127 return (T::singletonPtr_s != NULL);127 return (T::singletonPtr_s != nullptr); 128 128 } 129 129 … … 132 132 Singleton() 133 133 { 134 OrxVerify(T::singletonPtr_s == NULL, "T=" << typeid(T).name());134 OrxVerify(T::singletonPtr_s == nullptr, "T=" << typeid(T).name()); 135 135 T::singletonPtr_s = static_cast<T*>(this); 136 136 } … … 139 139 virtual ~Singleton() 140 140 { 141 OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());142 T::singletonPtr_s = NULL;141 OrxVerify(T::singletonPtr_s != nullptr, "T=" << typeid(T).name()); 142 T::singletonPtr_s = nullptr; 143 143 } 144 144 145 145 private: 146 Singleton(const Singleton& rhs); //!< Don't use (undefined) 146 // non-copyable: 147 Singleton(const Singleton&) = delete; 148 Singleton& operator=(const Singleton&) = delete; 147 149 }; 148 150 } -
code/branches/cpp11_v3/src/libraries/util/SmallObjectAllocator.cc
r7401 r11054 45 45 this->chunkSize_ = std::max(objectSize, sizeof(Chunk)); // the chunk's size will be the maximum of the object's size and the size of a Chunk object itself 46 46 this->numChunksPerBlock_ = numObjects; 47 this->first_ = 0;47 this->first_ = nullptr; 48 48 } 49 49 … … 53 53 SmallObjectAllocator::~SmallObjectAllocator() 54 54 { 55 for ( std::vector<char*>::iterator it = this->blocks_.begin(); it != this->blocks_.end(); ++it)56 delete[] *it;55 for (char* block : this->blocks_) 56 delete[] block; 57 57 } 58 58 … … 97 97 setNext(block + i * this->chunkSize_, block + (i + 1) * this->chunkSize_); 98 98 99 // the next_ pointer of the last chunk must point to NULL100 setNext(block + (this->numChunksPerBlock_ - 1) * this->chunkSize_, 0);99 // the next_ pointer of the last chunk must point to nullptr 100 setNext(block + (this->numChunksPerBlock_ - 1) * this->chunkSize_, nullptr); 101 101 102 102 // The second chunk in the block is assigned to the first_ pointer -
code/branches/cpp11_v3/src/libraries/util/SmallObjectAllocator.h
r7401 r11054 77 77 #include "UtilPrereqs.h" 78 78 #include <vector> 79 #include <cstdio> 79 80 80 81 namespace orxonox -
code/branches/cpp11_v3/src/libraries/util/StringUtils.cc
r9550 r11054 36 36 #include <cctype> 37 37 #include <ctime> 38 #include <boost/scoped_array.hpp>39 38 #include "Convert.h" 40 39 #include "Math.h" … … 263 262 std::string output(str.size() * 2, ' '); 264 263 size_t i = 0; 265 for ( size_t pos = 0; pos < str.size(); ++pos)266 { 267 switch ( str[pos])264 for (const char& character : str) 265 { 266 switch (character) 268 267 { 269 268 case '\\': output[i] = '\\'; output[i + 1] = '\\'; break; … … 277 276 case '"': output[i] = '\\'; output[i + 1] = '"'; break; 278 277 case '\0': output[i] = '\\'; output[i + 1] = '0'; break; 279 default : output[i] = str[pos]; ++i; continue;278 default : output[i] = character; ++i; continue; 280 279 } 281 280 i += 2; … … 337 336 void lowercase(std::string* str) 338 337 { 339 for ( size_t i = 0; i < str->size(); ++i)340 { 341 (*str)[i] = static_cast<char>(tolower((*str)[i]));338 for (char& character : *str) 339 { 340 character = static_cast<char>(tolower(character)); 342 341 } 343 342 } … … 354 353 void uppercase(std::string* str) 355 354 { 356 for ( size_t i = 0; i < str->size(); ++i)357 { 358 (*str)[i] = static_cast<char>(toupper((*str)[i]));355 for (char& character : *str) 356 { 357 character = static_cast<char>(toupper(character)); 359 358 } 360 359 } … … 461 460 { 462 461 size_t j = 0; 463 for ( size_t i = 0; i < str.size(); ++i)464 { 465 if ( str[i]== target)462 for (char& character : str) 463 { 464 if (character == target) 466 465 { 467 str[i]= replacement;466 character = replacement; 468 467 ++j; 469 468 } … … 482 481 size_t cols = str1.size() + 1; 483 482 size_t rows = str2.size() + 1; 484 boost::scoped_array<int> matrix(new int[rows * cols]);483 const std::unique_ptr<int[]> matrix(new int[rows * cols]); 485 484 486 485 for (size_t r = 0; r < rows; ++r) -
code/branches/cpp11_v3/src/libraries/util/SubString.cc
r9550 r11054 112 112 for (size_t i = 0; i < argc; ++i) 113 113 { 114 this->tokens_. push_back(std::string(argv[i]));114 this->tokens_.emplace_back(argv[i]); 115 115 this->bTokenInSafemode_.push_back(false); 116 116 } -
code/branches/cpp11_v3/src/libraries/util/UtilPrereqs.h
r10624 r11054 80 80 class OutputStream; 81 81 class ScopeListener; 82 template <class T>83 class SharedPtr;84 82 class SignalHandler; 85 83 template <class T> -
code/branches/cpp11_v3/src/libraries/util/output/BaseWriter.cc
r8858 r11054 47 47 this->configurableMaxLevel_ = level::none; 48 48 this->configurableAdditionalContextsMaxLevel_ = level::verbose; 49 this->configurableAdditionalContexts_. push_back("example");49 this->configurableAdditionalContexts_.emplace_back("example"); 50 50 51 51 this->changedConfigurableLevel(); … … 116 116 117 117 // iterate over all strings in the config-vector 118 for ( size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i)118 for (const std::string& full_name : this->configurableAdditionalContexts_) 119 119 { 120 const std::string& full_name = this->configurableAdditionalContexts_[i];121 122 120 // split the name into main-name and sub-name (if given; otherwise sub-name remains empty). both names are separated by :: 123 121 std::string name = full_name; -
code/branches/cpp11_v3/src/libraries/util/output/BaseWriter.h
r8858 r11054 103 103 104 104 protected: 105 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) ;105 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) override; 106 106 107 107 private: -
code/branches/cpp11_v3/src/libraries/util/output/ConsoleWriter.h
r9550 r11054 53 53 public: 54 54 ConsoleWriter(std::ostream& outputStream); 55 ConsoleWriter(const ConsoleWriter&);56 55 virtual ~ConsoleWriter(); 57 56 … … 63 62 64 63 protected: 65 virtual void printLine(const std::string& line, OutputLevel level) ;64 virtual void printLine(const std::string& line, OutputLevel level) override; 66 65 67 66 private: 67 // non-copyable: 68 ConsoleWriter(const ConsoleWriter&) = delete; 69 ConsoleWriter& operator=(const ConsoleWriter&) = delete; 70 68 71 std::ostream& outputStream_; ///< The ostream to which the console writer writes its output 69 72 bool bEnabled_; ///< If false, the instance will not write output to the console. -
code/branches/cpp11_v3/src/libraries/util/output/LogWriter.cc
r9550 r11054 35 35 36 36 #include <ctime> 37 #include <chrono> 37 38 #include <cstdlib> 38 39 … … 43 44 namespace orxonox 44 45 { 45 static const int MAX_ARCHIVED_FILES = 9;46 static constexpr int MAX_ARCHIVED_FILES = 9; 46 47 47 48 /** … … 180 181 return; 181 182 183 // get the milliseconds 184 std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); 185 std::chrono::system_clock::duration timeSinceEpoch = now.time_since_epoch(); 186 std::chrono::milliseconds millisSinceEpoch = std::chrono::duration_cast<std::chrono::milliseconds>(timeSinceEpoch); 187 unsigned int millis = (millisSinceEpoch.count() % 1000); 188 182 189 // get the current time 183 time_t rawtime; 184 struct tm* timeinfo; 185 time(&rawtime); 186 timeinfo = localtime(&rawtime); 190 time_t rawtime = std::chrono::system_clock::to_time_t(now); 191 struct tm* timeinfo = localtime(&rawtime); 192 193 // format time: hh:mm:ss:xxx 194 char buffer[13]; 195 snprintf(buffer, sizeof(buffer), "%.2i:%.2i:%.2i:%.3i", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, millis); 187 196 188 197 // print timestamp and output line to the log file 189 this->file_ << (timeinfo->tm_hour < 10 ? "0" : "") << timeinfo->tm_hour << ':' << 190 (timeinfo->tm_min < 10 ? "0" : "") << timeinfo->tm_min << ':' << 191 (timeinfo->tm_sec < 10 ? "0" : "") << timeinfo->tm_sec << ' ' << line << std::endl; 198 this->file_ << buffer << ' ' << line << std::endl; 192 199 } 193 200 } -
code/branches/cpp11_v3/src/libraries/util/output/LogWriter.h
r9550 r11054 57 57 public: 58 58 LogWriter(); 59 LogWriter(const LogWriter&);60 59 virtual ~LogWriter(); 61 60 … … 70 69 71 70 protected: 72 virtual void printLine(const std::string& line, OutputLevel level) ;71 virtual void printLine(const std::string& line, OutputLevel level) override; 73 72 74 73 private: 74 // non-copyable: 75 LogWriter(const LogWriter&) = delete; 76 LogWriter& operator=(const LogWriter&) = delete; 77 75 78 void openFile(); 76 79 void closeFile(); -
code/branches/cpp11_v3/src/libraries/util/output/MemoryWriter.cc
r9550 r11054 57 57 void MemoryWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) 58 58 { 59 this->messages_. push_back(Message(level, context, lines));59 this->messages_.emplace_back(level, context, lines); 60 60 } 61 61 … … 65 65 void MemoryWriter::resendOutput(OutputListener* listener) const 66 66 { 67 for ( size_t i = 0; i < this->messages_.size(); ++i)67 for (const Message& message : this->messages_) 68 68 { 69 const Message& message = this->messages_[i];70 69 listener->unfilteredOutput(message.level, *message.context, message.lines); 71 70 } -
code/branches/cpp11_v3/src/libraries/util/output/MemoryWriter.h
r9550 r11054 68 68 public: 69 69 MemoryWriter(); 70 MemoryWriter(const MemoryWriter&);71 70 virtual ~MemoryWriter(); 72 71 … … 75 74 76 75 protected: 77 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) ;76 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) override; 78 77 79 78 private: 79 // non-copyable: 80 MemoryWriter(const MemoryWriter&) = delete; 81 MemoryWriter& operator=(const MemoryWriter&) = delete; 82 80 83 std::vector<Message> messages_; ///< Stores all output messages from the creation of this instance until disable() is called. 81 84 }; -
code/branches/cpp11_v3/src/libraries/util/output/OutputDefinitions.h
r10624 r11054 132 132 namespace context 133 133 { 134 static const OutputContextMask all = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1135 static const OutputContextMask none = 0x0000000000000000ull; ///< Context mask, all bits set to 0134 static constexpr OutputContextMask all = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1 135 static constexpr OutputContextMask none = 0x0000000000000000ull; ///< Context mask, all bits set to 0 136 136 137 static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts137 static constexpr OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts 138 138 139 139 namespace -
code/branches/cpp11_v3/src/libraries/util/output/OutputListener.cc
r9550 r11054 111 111 this->levelMask_ = mask; 112 112 113 for ( size_t i = 0; i < this->listeners_.size(); ++i)114 this->listeners_[i]->updatedLevelMask(this);113 for (AdditionalContextListener* listener : this->listeners_) 114 listener->updatedLevelMask(this); 115 115 } 116 116 … … 142 142 this->additionalContextsLevelMask_ = mask; 143 143 144 for ( size_t i = 0; i < this->listeners_.size(); ++i)145 this->listeners_[i]->updatedAdditionalContextsLevelMask(this);144 for (AdditionalContextListener* listener : this->listeners_) 145 listener->updatedAdditionalContextsLevelMask(this); 146 146 } 147 147 … … 153 153 this->additionalContextsMask_ = mask; 154 154 155 for ( size_t i = 0; i < this->listeners_.size(); ++i)156 this->listeners_[i]->updatedAdditionalContextsMask(this);155 for (AdditionalContextListener* listener : this->listeners_) 156 listener->updatedAdditionalContextsMask(this); 157 157 } 158 158 -
code/branches/cpp11_v3/src/libraries/util/output/OutputManager.cc
r9550 r11054 41 41 #include "util/Output.h" 42 42 #include "util/StringUtils.h" 43 #include "util/SharedPtr.h"44 43 45 44 namespace orxonox … … 57 56 58 57 this->isInitialized_ = false; 59 this->memoryWriterInstance_ = 0;60 this->consoleWriterInstance_ = 0;61 this->logWriterInstance_ = 0;58 this->memoryWriterInstance_ = nullptr; 59 this->consoleWriterInstance_ = nullptr; 60 this->logWriterInstance_ = nullptr; 62 61 63 62 // register 'undefined' context in order to give it always the first context-ID … … 81 80 } 82 81 83 /*static*/ SharedPtr<OutputManager>& OutputManager::Testing::getInstancePointer()84 { 85 static SharedPtr<OutputManager> instance(new OutputManager());82 /*static*/ std::shared_ptr<OutputManager>& OutputManager::Testing::getInstancePointer() 83 { 84 static std::shared_ptr<OutputManager> instance(new OutputManager()); 86 85 return instance; 87 86 } … … 132 131 vectorize(message, '\n', &lines); 133 132 134 for ( size_t i = 0; i < this->listeners_.size(); ++i)135 this->listeners_[i]->unfilteredOutput(level, context, lines);133 for (OutputListener* listener : this->listeners_) 134 listener->unfilteredOutput(level, context, lines); 136 135 } 137 136 … … 179 178 { 180 179 int mask = 0; 181 for ( size_t i = 0; i < this->listeners_.size(); ++i)182 mask |= this->listeners_[i]->getLevelMask();180 for (OutputListener* listener : this->listeners_) 181 mask |= listener->getLevelMask(); 183 182 this->combinedLevelMask_ = static_cast<OutputLevel>(mask); 184 183 } … … 190 189 { 191 190 int mask = 0; 192 for ( size_t i = 0; i < this->listeners_.size(); ++i)193 mask |= this->listeners_[i]->getAdditionalContextsLevelMask();191 for (OutputListener* listener : this->listeners_) 192 mask |= listener->getAdditionalContextsLevelMask(); 194 193 this->combinedAdditionalContextsLevelMask_ = static_cast<OutputLevel>(mask); 195 194 } … … 201 200 { 202 201 this->combinedAdditionalContextsMask_ = 0; 203 for ( size_t i = 0; i < this->listeners_.size(); ++i)204 this->combinedAdditionalContextsMask_ |= this->listeners_[i]->getAdditionalContextsMask();202 for (OutputListener* listener : this->listeners_) 203 this->combinedAdditionalContextsMask_ |= listener->getAdditionalContextsMask(); 205 204 } 206 205 -
code/branches/cpp11_v3/src/libraries/util/output/OutputManager.h
r9550 r11054 41 41 #include <vector> 42 42 #include <map> 43 #include <memory> 43 44 44 45 #include "OutputDefinitions.h" … … 66 67 public: 67 68 OutputManager(); 68 OutputManager(const OutputManager&);69 69 virtual ~OutputManager(); 70 70 … … 81 81 virtual void unregisterListener(OutputListener* listener); 82 82 83 virtual void updatedLevelMask(const OutputListener* listener) 83 virtual void updatedLevelMask(const OutputListener* listener) override 84 84 { this->updateCombinedLevelMask(); } 85 virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) 85 virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) override 86 86 { this->updateCombinedAdditionalContextsLevelMask(); } 87 virtual void updatedAdditionalContextsMask(const OutputListener* listener) 87 virtual void updatedAdditionalContextsMask(const OutputListener* listener) override 88 88 { this->updateCombinedAdditionalContextsMask(); } 89 89 … … 114 114 115 115 private: 116 // non-copyable: 117 OutputManager(const OutputManager&) = delete; 118 OutputManager& operator=(const OutputManager&) = delete; 119 116 120 void updateMasks(); 117 121 void updateCombinedLevelMask(); … … 137 141 struct _UtilExport Testing 138 142 { 139 static SharedPtr<OutputManager>& getInstancePointer();143 static std::shared_ptr<OutputManager>& getInstancePointer(); 140 144 }; 141 145 }; -
code/branches/cpp11_v3/src/libraries/util/output/OutputStream.cc
r8858 r11054 41 41 @brief Default constructor, initializes level and context with default values. 42 42 */ 43 OutputStream::OutputStream() 43 OutputStream::OutputStream() : OutputStream(level::debug_output, context::undefined()) 44 44 { 45 this->setOutputAttributes(level::debug_output, context::undefined());46 45 } 47 46 -
code/branches/cpp11_v3/src/libraries/util/output/SubcontextOutputListener.cc
r8858 r11054 79 79 80 80 // compose the mask of subcontexts and build the set of sub-context-IDs 81 for ( std::set<const OutputContextContainer*>::const_iterator it = subcontexts.begin(); it != subcontexts.end(); ++it)81 for (const OutputContextContainer* subcontext : subcontexts) 82 82 { 83 this->subcontextsCheckMask_ |= (*it)->mask;84 this->subcontexts_.insert( (*it)->sub_id);83 this->subcontextsCheckMask_ |= subcontext->mask; 84 this->subcontexts_.insert(subcontext->sub_id); 85 85 } 86 86 -
code/branches/cpp11_v3/src/libraries/util/output/SubcontextOutputListener.h
r9550 r11054 73 73 virtual ~SubcontextOutputListener(); 74 74 75 virtual void setAdditionalContextsMask(OutputContextMask mask) ;75 virtual void setAdditionalContextsMask(OutputContextMask mask) override; 76 76 void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts); 77 77 78 virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const ;78 virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const override; 79 79 80 80 inline const std::set<OutputContextSubID>& getSubcontexts() const
Note: See TracChangeset
for help on using the changeset viewer.