Changeset 11071 for code/trunk/src/libraries/core
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 155 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/ApplicationPaths.cc
r10624 r11071 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/trunk/src/libraries/core/ApplicationPaths.h
r10624 r11071 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/trunk/src/libraries/core/BaseObject.cc
r10624 r11071 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/trunk/src/libraries/core/BaseObject.h
r10624 r11071 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/trunk/src/libraries/core/ClassTreeMask.cc
r10624 r11071 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/trunk/src/libraries/core/ClassTreeMask.h
r10693 r11071 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/trunk/src/libraries/core/ConfigurablePaths.cc
r10624 r11071 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/trunk/src/libraries/core/ConfigurablePaths.h
r10624 r11071 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/trunk/src/libraries/core/Core.cc
r11011 r11071 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/trunk/src/libraries/core/Core.h
r11012 r11071 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/trunk/src/libraries/core/CoreConfig.cc
r11052 r11071 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/trunk/src/libraries/core/CoreConfig.h
r11052 r11071 76 76 public: 77 77 DevModeListener(); 78 virtual ~DevModeListener() {}78 virtual ~DevModeListener() = default; 79 79 virtual void devModeChanged(bool value) = 0; 80 80 }; -
code/trunk/src/libraries/core/CoreIncludes.h
r11020 r11071 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/trunk/src/libraries/core/CorePrecompiledHeaders.h
r8858 r11071 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/trunk/src/libraries/core/CorePrereqs.h
r10624 r11071 38 38 #include "OrxonoxConfig.h" 39 39 #include <boost/version.hpp> 40 #include <string> 40 41 41 42 //----------------------------------------------------------------------- … … 68 69 namespace orxonox 69 70 { 70 static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);71 static constexpr uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1); 71 72 } 72 73 … … 82 83 83 84 //!A list of available scopes for the Scope template. 84 static const Value ROOT = 1;85 static const Value GRAPHICS = 2;85 static constexpr Value ROOT = 1; 86 static constexpr Value GRAPHICS = 2; 86 87 } 87 88 … … 90 91 typedef int Type; 91 92 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;93 static constexpr Type STATIC_INITIALIZATION_HANDLER = 1; 94 static constexpr Type IDENTIFIER = 2; 95 static constexpr Type SCOPED_SINGLETON_WRAPPER = 3; 96 static constexpr Type COMMAND_LINE_ARGUMENT = 4; 97 static constexpr Type CONSOLE_COMMAND = 5; 97 98 } 98 99 -
code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc
r10624 r11071 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/trunk/src/libraries/core/CoreStaticInitializationHandler.h
r10624 r11071 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/trunk/src/libraries/core/EventIncludes.h
r8729 r11071 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/trunk/src/libraries/core/GUIManager.cc
r11052 r11071 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 … … 265 267 ArgumentCompletionList names; 266 268 const std::vector<std::string> guis = GUIManager::getInstance().getLoadedGUIs(); 267 for ( size_t i = 0; i < guis.size(); ++i)268 names.push_back(ArgumentCompletionListElement(gui s[i], getLowercase(guis[i])));269 for (const std::string gui : guis) 270 names.push_back(ArgumentCompletionListElement(gui, getLowercase(gui))); 269 271 return names; 270 272 } … … 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/trunk/src/libraries/core/GUIManager.h
r11052 r11071 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/trunk/src/libraries/core/Game.cc
r10624 r11071 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/trunk/src/libraries/core/Game.h
r10624 r11071 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/trunk/src/libraries/core/GameMode.h
r7401 r11071 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/trunk/src/libraries/core/GraphicsManager.cc
r10624 r11071 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/trunk/src/libraries/core/GraphicsManager.h
r10624 r11071 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/trunk/src/libraries/core/Language.cc
r10624 r11071 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/trunk/src/libraries/core/Language.h
r10624 r11071 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/trunk/src/libraries/core/Loader.cc
r10624 r11071 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/trunk/src/libraries/core/Loader.h
r10624 r11071 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/trunk/src/libraries/core/LuaState.cc
r10265 r11071 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/trunk/src/libraries/core/LuaState.h
r10265 r11071 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/trunk/src/libraries/core/Namespace.cc
r10624 r11071 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/trunk/src/libraries/core/Namespace.h
r9667 r11071 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/trunk/src/libraries/core/NamespaceNode.cc
r8858 r11071 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/trunk/src/libraries/core/NamespaceNode.h
r7401 r11071 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/trunk/src/libraries/core/Resource.cc
r9675 r11071 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/trunk/src/libraries/core/Resource.h
r8351 r11071 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/trunk/src/libraries/core/Template.cc
r9667 r11071 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/trunk/src/libraries/core/Template.h
r9667 r11071 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/trunk/src/libraries/core/Thread.cc
r8399 r11071 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/trunk/src/libraries/core/ThreadPool.cc
r8394 r11071 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/trunk/src/libraries/core/ThreadWin.cc
r8706 r11071 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/trunk/src/libraries/core/ViewportEventListener.h
r9667 r11071 44 44 protected: 45 45 ViewportEventListener(); 46 virtual ~ViewportEventListener() {}46 virtual ~ViewportEventListener() = default; 47 47 }; 48 48 } -
code/trunk/src/libraries/core/WindowEventListener.cc
r10624 r11071 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/trunk/src/libraries/core/WindowEventListener.h
r9667 r11071 47 47 protected: 48 48 WindowEventListener(); 49 virtual ~WindowEventListener() { }49 virtual ~WindowEventListener() = default; 50 50 51 51 //! Returns the current render window width -
code/trunk/src/libraries/core/XMLNameListener.h
r9667 r11071 44 44 public: 45 45 XMLNameListener(); 46 virtual ~XMLNameListener() {}46 virtual ~XMLNameListener() = default; 47 47 48 48 virtual void loadedNewXMLName(BaseObject* object) = 0; -
code/trunk/src/libraries/core/XMLPort.h
r9667 r11071 245 245 return my_added_objects[index]; 246 246 else 247 return 0;247 return nullptr; 248 248 } 249 249 @endcode … … 324 324 { 325 325 public: 326 enum ParseResult326 enum class ParseResult 327 327 { 328 PR_not_started,329 PR_finished,330 PR_waiting_for_default_values328 not_started, 329 finished, 330 waiting_for_default_values 331 331 }; 332 332 333 333 public: 334 334 XMLPortParamContainer() 335 { this->parseResult_ = P R_not_started; }336 virtual ~XMLPortParamContainer() {}335 { this->parseResult_ = ParseResult::not_started; } 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(); … … 419 415 this->loadexecutor_->parse(object, attributeValue, &error, ","); 420 416 if (!error || (mode == XMLPort::ExpandObject)) 421 this->parseResult_ = P R_finished;417 this->parseResult_ = ParseResult::finished; 422 418 else 423 this->parseResult_ = P R_waiting_for_default_values;419 this->parseResult_ = ParseResult::waiting_for_default_values; 424 420 } 425 421 else if (mode == XMLPort::ExpandObject) 426 this->parseResult_ = P R_finished;422 this->parseResult_ = ParseResult::finished; 427 423 else 428 this->parseResult_ = P R_waiting_for_default_values;424 this->parseResult_ = ParseResult::waiting_for_default_values; 429 425 } 430 426 catch (ticpp::Exception& ex) … … 453 449 XMLPortParamContainer& portIfWaitingForDefaultValues(const ParseResult& result, const ParseParams& params) 454 450 { 455 if (result == P R_waiting_for_default_values)451 if (result == ParseResult::waiting_for_default_values) 456 452 return this->port(this->owner_, params); 457 453 else … … 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/trunk/src/libraries/core/class/Identifiable.cc
r10624 r11071 48 48 Identifiable::Identifiable() 49 49 { 50 this->identifier_ = 0;50 this->identifier_ = nullptr; 51 51 this->objectPointers_.reserve(6); // Optimisation 52 52 -
code/trunk/src/libraries/core/class/Identifiable.h
r9667 r11071 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/trunk/src/libraries/core/class/Identifier.cc
r10624 r11071 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/trunk/src/libraries/core/class/Identifier.h
r10624 r11071 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); … … 203 204 /// Returns the map that stores all XMLPort params. 204 205 inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; } 205 /// Returns a const_iterator to the beginning of the map that stores all XMLPort params.206 inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapBegin() const { return this->xmlportParamContainers_.begin(); }207 /// Returns a const_iterator to the end of the map that stores all XMLPort params.208 inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapEnd() const { return this->xmlportParamContainers_.end(); }209 206 210 207 /// Returns the map that stores all XMLPort objects. 211 208 inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortObjectMap() const { return this->xmlportObjectContainers_; } 212 /// Returns a const_iterator to the beginning of the map that stores all XMLPort objects.213 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapBegin() const { return this->xmlportObjectContainers_.begin(); }214 /// Returns a const_iterator to the end of the map that stores all XMLPort objects.215 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); }216 209 217 210 void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container); … … 269 262 class ClassIdentifier : public Identifier 270 263 { 271 BOOST_STATIC_ASSERT((boost::is_base_of<Identifiable, T>::value));264 static_assert(std::is_base_of<Identifiable, T>::value, "ClassIdentifier can only be used with Identifiables"); 272 265 273 266 #ifndef DOXYGEN_SHOULD_SKIP_THIS … … 279 272 ClassIdentifier(const std::string& name, Factory* factory, bool bLoadable) : Identifier(name, factory, bLoadable) 280 273 { 281 OrxVerify(ClassIdentifier<T>::classIdentifier_s == NULL, "Assertion failed in ClassIdentifier of type " << typeid(T).name());274 OrxVerify(ClassIdentifier<T>::classIdentifier_s == nullptr, "Assertion failed in ClassIdentifier of type " << typeid(T).name()); 282 275 ClassIdentifier<T>::classIdentifier_s = this; 283 276 … … 291 284 bool initializeObject(T* object); 292 285 293 virtual void updateConfigValues(bool updateChildren = true) const ;294 295 virtual const std::type_info& getTypeInfo() 286 virtual void updateConfigValues(bool updateChildren = true) const override; 287 288 virtual const std::type_info& getTypeInfo() override 296 289 { return typeid(T); } 297 290 298 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const 299 { return dynamic_cast<T*>(object) != 0; }300 301 virtual void destroyObjects() ;291 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const override 292 { return dynamic_cast<T*>(object) != nullptr; } 293 294 virtual void destroyObjects() override; 302 295 303 296 static ClassIdentifier<T>* getIdentifier(); 304 297 305 298 private: 306 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 299 // non-copyable: 300 ClassIdentifier(const ClassIdentifier<T>&) = delete; 301 ClassIdentifier& operator=(const ClassIdentifier<T>&) = delete; 307 302 308 303 void setConfigValues(T* object, Configurable*) const; … … 321 316 void updateConfigValues(bool updateChildren, Identifiable*) const; 322 317 323 static WeakPtr<ClassIdentifier<T> 318 static WeakPtr<ClassIdentifier<T>> classIdentifier_s; 324 319 }; 325 320 326 321 template <class T> 327 WeakPtr<ClassIdentifier<T> 322 WeakPtr<ClassIdentifier<T>> ClassIdentifier<T>::classIdentifier_s; 328 323 329 324 /** … … 334 329 /*static*/ inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 335 330 { 336 if (ClassIdentifier<T>::classIdentifier_s == NULL)331 if (ClassIdentifier<T>::classIdentifier_s == nullptr) 337 332 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*) IdentifierManager::getInstance().getIdentifierByTypeInfo(typeid(T)); 338 333 339 OrxVerify(ClassIdentifier<T>::classIdentifier_s != NULL, "Did you forget to register the class of type " << typeid(T).name() << "?");334 OrxVerify(ClassIdentifier<T>::classIdentifier_s != nullptr, "Did you forget to register the class of type " << typeid(T).name() << "?"); 340 335 return ClassIdentifier<T>::classIdentifier_s; 341 336 } … … 365 360 366 361 // 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)));362 object->objectPointers_.emplace_back(this->getClassID(), static_cast<void*>(object)); 368 363 return false; 369 364 } … … 408 403 void ClassIdentifier<T>::destroyObjects() 409 404 { 410 this->destroyObjects((T*) 0);405 this->destroyObjects((T*)nullptr); 411 406 } 412 407 … … 417 412 void ClassIdentifier<T>::destroyObjects(Listable*) 418 413 { 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; ) 414 ObjectList<T> list(Context::getRootContext()->getObjectList(this)); 415 for (typename ObjectList<T>::iterator it = list.begin(); it != list.end(); ) 423 416 this->destroyObject(*(it++)); 424 417 } … … 451 444 void ClassIdentifier<T>::updateConfigValues(bool updateChildren) const 452 445 { 453 this->updateConfigValues(updateChildren, static_cast<T*>( NULL));446 this->updateConfigValues(updateChildren, static_cast<T*>(nullptr)); 454 447 } 455 448 … … 460 453 return; 461 454 462 for ( ObjectListIterator<T> it = ObjectList<T>::begin(); it; ++it)463 this->setConfigValues( *it, *it);455 for (T* object : ObjectList<T>()) 456 this->setConfigValues(object, object); 464 457 465 458 if (updateChildren) 466 for ( std::set<const Identifier*>::const_iterator it = this->getChildren().begin(); it != this->getChildren().end(); ++it)467 (*it)->updateConfigValues(false);459 for (const Identifier* child : this->getChildren()) 460 child->updateConfigValues(false); 468 461 } 469 462 … … 483 476 registered in the class hierarchy. 484 477 @return 485 Returns NULLif the cast is not possible478 Returns nullptr if the cast is not possible 486 479 @note 487 In case of NULLreturn (and using MSVC), a dynamic_cast might still be possible if480 In case of nullptr return (and using MSVC), a dynamic_cast might still be possible if 488 481 a class forgot to register its objects. 489 482 Also note that the function is implemented differently for GCC/MSVC. … … 494 487 #ifdef ORXONOX_COMPILER_MSVC 495 488 typedef Loki::TypeTraits<typename Loki::TypeTraits<T>::PointeeType>::NonConstType ClassType; 496 if (source != NULL)489 if (source != nullptr) 497 490 return source->template getDerivedPointer<ClassType>(ClassIdentifier<ClassType>::getIdentifier()->getClassID()); 498 491 else 499 return NULL;492 return nullptr; 500 493 #else 501 494 return dynamic_cast<T>(source); -
code/trunk/src/libraries/core/class/IdentifierManager.cc
r10624 r11071 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/trunk/src/libraries/core/class/IdentifierManager.h
r10624 r11071 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/trunk/src/libraries/core/class/SubclassIdentifier.h
r9667 r11071 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/trunk/src/libraries/core/class/Super.h
r10624 r11071 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/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
r10624 r11071 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/trunk/src/libraries/core/command/ArgumentCompletionFunctions.h
r11052 r11071 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/trunk/src/libraries/core/command/CommandEvaluation.cc
r10624 r11071 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/trunk/src/libraries/core/command/CommandEvaluation.h
r8079 r11071 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/trunk/src/libraries/core/command/CommandExecutor.cc
r10624 r11071 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/trunk/src/libraries/core/command/CommandExecutor.h
r8858 r11071 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/trunk/src/libraries/core/command/ConsoleCommand.cc
r10624 r11071 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/trunk/src/libraries/core/command/ConsoleCommand.h
r10624 r11071 60 60 } 61 61 62 namespace AccessLevel 62 /** 63 @brief Possible access levels: A command can only be executed if the program is in the state which is requested by the access level. 64 */ 65 enum class AccessLevel 63 66 { 64 /** 65 @brief Possible access levels: A command can only be executed if the program is in the state which is requested by the access level. 66 */ 67 enum Enum 68 { 69 All, 70 Standalone, 71 Master, 72 Server, 73 Client, 74 Online, 75 Offline, 76 None 77 }; 78 } 67 All, 68 Standalone, 69 Master, 70 Server, 71 Client, 72 Online, 73 Offline, 74 None 75 }; 79 76 80 77 /** … … 195 192 { if (this->command_) { this->command_->popFunction(); } return *this; } 196 193 197 /// Sets the current function-pointer to NULL, which also deactivates the command.194 /// Sets the current function-pointer to nullptr, which also deactivates the command. 198 195 inline ConsoleCommandManipulator& resetFunction() 199 196 { if (this->command_) { this->command_->resetFunction(); } return *this; } … … 205 202 inline ConsoleCommandManipulator& pushObject(void* object) 206 203 { 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).204 /// 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 205 inline ConsoleCommandManipulator& popObject() 209 206 { if (this->command_) { this->command_->popObject(); } return *this; } … … 249 246 250 247 /// Changes the access level of the command. 251 inline ConsoleCommandManipulator& accessLevel(AccessLevel ::Enumlevel)248 inline ConsoleCommandManipulator& accessLevel(AccessLevel level) 252 249 { if (this->command_) { this->command_->accessLevel(level); } return *this; } 253 250 … … 332 329 333 330 /// Changes the access level of the command. 334 inline ConsoleCommand& accessLevel(AccessLevel ::Enumlevel)331 inline ConsoleCommand& accessLevel(AccessLevel level) 335 332 { this->accessLevel_ = level; return *this; } 336 333 /// Returns the access level of the command. 337 inline AccessLevel ::EnumgetAccessLevel() const334 inline AccessLevel getAccessLevel() const 338 335 { return this->accessLevel_; } 339 336 … … 394 391 bool bActive_; ///< True if the command should be active (it can still be inactive, for example if the function is missing) 395 392 bool bHidden_; ///< True if the command is hidden (it is still executable, but not visible in the list of available commands) 396 AccessLevel ::Enum accessLevel_;///< The access level (the state of the game in which you can access the command)393 AccessLevel accessLevel_; ///< The access level (the state of the game in which you can access the command) 397 394 std::string baseName_; ///< The name that was first assigned to the command 398 395 std::vector<CommandName> names_; ///< All names and aliases of this command -
code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h
r10624 r11071 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/trunk/src/libraries/core/command/ConsoleCommandManager.cc
r11052 r11071 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/trunk/src/libraries/core/command/ConsoleCommandManager.h
r10624 r11071 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/trunk/src/libraries/core/command/Executor.cc
r9550 r11071 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/trunk/src/libraries/core/command/Executor.h
r9550 r11071 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. … … 147 147 { return this->functor_->hasReturnvalue(); } 148 148 /// Returns the type of the wrapped function (static or member). 149 inline Functor::Type ::EnumgetType() const149 inline Functor::Type getType() const 150 150 { return this->functor_->getType(); } 151 151 /// Returns the name of the type of a parameter with given index (the first parameter has index 0). … … 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/trunk/src/libraries/core/command/ExecutorPtr.h
r7401 r11071 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/trunk/src/libraries/core/command/Functor.h
r9667 r11071 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: … … 176 176 { 177 177 public: 178 struct Type 179 { 180 /// Defines the type of a function (static or member) 181 enum Enum 182 { 183 Static, 184 Member 185 }; 178 /// Defines the type of a function (static or member) 179 enum class Type 180 { 181 Static, 182 Member 186 183 }; 187 184 188 185 public: 189 virtual ~Functor() {}186 virtual ~Functor() = default; 190 187 191 188 /// 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) … … 196 193 197 194 /// Returns the type of the function: static or member. 198 virtual Type ::EnumgetType() const = 0;195 virtual Type getType() const = 0; 199 196 /// Returns the number of parameters of the function. 200 197 virtual unsigned int getParamCount() const = 0; … … 215 212 virtual void* getRawObjectPointer() const = 0; 216 213 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).214 /// 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 215 virtual void setSafeMode(bool bSafeMode) = 0; 219 216 … … 242 239 public: 243 240 /// Constructor: Stores the object-pointer. 244 FunctorMember(O* object = 0) : object_(object), bSafeMode_(false) {}241 FunctorMember(O* object = nullptr) : object_(object), bSafeMode_(false) {} 245 242 virtual ~FunctorMember() { if (this->bSafeMode_) { this->unregisterObject(this->object_); } } 246 243 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)244 /// 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 245 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 246 250 247 // 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)248 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 249 { 253 250 // call the function if an object was assigned … … 262 259 263 260 // see Functor::getType() 264 inline Functor::Type::Enum getType() const261 virtual inline Functor::Type getType() const override 265 262 { return Functor::Type::Member; } 266 263 … … 280 277 281 278 // see Functor::setRawObjectPointer() 282 inline void setRawObjectPointer(void* object)279 virtual inline void setRawObjectPointer(void* object) override 283 280 { this->setObject((O*)object); } 284 281 // see Functor::getRawObjectPointer() 285 inline void* getRawObjectPointer() const282 virtual inline void* getRawObjectPointer() const override 286 283 { return this->object_; } 287 284 288 285 // see Functor::setSafeMode() 289 inline void setSafeMode(bool bSafeMode)286 virtual inline void setSafeMode(bool bSafeMode) override 290 287 { 291 288 if (bSafeMode == this->bSafeMode_) … … 301 298 302 299 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 300 /// Casts the object and registers as destruction listener if the object is a Destroyable. 301 inline void registerObject(Destroyable* object) 302 { this->registerAsDestructionListener(object); } 303 304 inline void registerObject(void* object) {} 305 306 /// Casts the object and unregisters as destruction listener if the object is a Destroyable. 307 inline void unregisterObject(Destroyable* object) 308 { this->unregisterAsDestructionListener(object); } 309 310 inline void unregisterObject(void* object) {} 311 312 /// Will be called by Destroyable::~Destroyable() if the stored object is a Destroyable and deleted and the Functor is in safe mode. 313 virtual inline void objectDeleted() override 314 { this->object_ = nullptr; } 315 316 O* object_; ///< The stored object-pointer, used to execute a member-function (or nullptr for static functions) 317 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 318 }; 317 319 … … 322 324 public: 323 325 /// 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)326 FunctorMember(void* object = nullptr) {} 327 328 /// 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 329 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 330 329 331 // 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);332 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 333 { 334 return (*this)((void*)nullptr, param1, param2, param3, param4, param5); 333 335 } 334 336 335 337 // see Functor::getType() 336 inline Functor::Type::Enum getType() const338 virtual inline Functor::Type getType() const override 337 339 { return Functor::Type::Static; } 338 340 339 341 // see Functor::setRawObjectPointer() 340 inline void setRawObjectPointer(void*)342 virtual inline void setRawObjectPointer(void*) override 341 343 { orxout(internal_warning) << "Can't assign an object pointer to a static functor" << endl; } 342 344 // see Functor::getRawObjectPointer() 343 inline void* getRawObjectPointer() const344 { return 0; }345 virtual inline void* getRawObjectPointer() const override 346 { return nullptr; } 345 347 346 348 // see Functor::setSafeMode() 347 inline void setSafeMode(bool){}349 virtual inline void setSafeMode(bool) override {} 348 350 }; 349 351 … … 352 354 353 355 /** 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 )356 @brief FunctorPointer is a child class of FunctorMember and extends it with a function-pointer (or a function-object). 357 @param F The type of the function-pointer (or the function-object) 358 @param O The type of the function's class (or void if it's a static function or a function-object) 357 359 358 360 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.361 of the function-pointer (or the function-object). This can be handy if you want to get 362 or set the function-pointer (or the function-object). You can then use a static_cast 363 to cast a Functor to FunctorPointer if you know the type of the function. 362 364 363 365 However FunctorPointer is not aware of the types of the different parameters or the … … 369 371 public: 370 372 /// Constructor: Initializes the base class and stores the function-pointer. 371 FunctorPointer(F functionPointer, O* object = 0) : FunctorMember<O>(object), functionPointer_(functionPointer) {}373 FunctorPointer(F functionPointer, O* object = nullptr) : FunctorMember<O>(object), functionPointer_(functionPointer) {} 372 374 373 375 /// Changes the function-pointer. … … 378 380 { return this->functionPointer_; } 379 381 380 // see Functor::getFullIdentifier()381 const std::type_info& getFullIdentifier() const382 { return typeid(F); }383 384 382 protected: 385 383 F functionPointer_; ///< The stored function-pointer … … 388 386 namespace detail 389 387 { 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 {}; 388 // Helper class to get the type of the function-pointer (or the function-object) with the given class, parameters, return-value, and constness 389 template <class F, class R, class O, bool isconst, class... Params> struct FunctionType /* generic type is undefined */; 390 template < class R, class O, class... Params> struct FunctionType<void, R, O, false, Params...> { typedef R (O::*Type)(Params...); }; // spezialization: non-const member function 391 template < class R, class O, class... Params> struct FunctionType<void, R, O, true, Params...> { typedef R (O::*Type)(Params...) const; }; // spezialization: const member function 392 template < class R, class... Params> struct FunctionType<void, R, void, false, Params...> { typedef R (*Type)(Params...); }; // spezialization: static function 393 template <class F, class R, class... Params> struct FunctionType<F, R, void, false, Params...> { typedef F Type; }; // spezialization: function object 394 395 // Helper class, used to call a function with a given object and parameters and to return its return-value (if available) 396 template <class F, class R, class O, bool isconst, class... Params> struct FunctorCaller /* generic type is undefined */; 397 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 398 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 399 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 400 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 401 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 402 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 403 442 404 // Helper class to determine if a function has a returnvalue … … 448 410 { enum { result = false }; }; 449 411 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 }; }; 412 // Helper class to determine the N-th parameter of a variadic template (with 0 being the index of the first parameter) 413 template <int n, typename T = void, typename... Other> 414 struct GetNthParamType 415 { typedef typename GetNthParamType<n - 1, Other...>::Type Type; }; 416 template <typename T, typename... Other> 417 struct GetNthParamType<0, T, Other...> 418 { typedef T Type; }; 419 420 // Helper structs to deduce the first N types of a parameter pack 421 template<class... Types> struct type_list {}; 422 423 template <class T1, class... AllTypes> 424 struct make_type_list_helper 425 { 426 template <std::size_t N, class... Types> 427 struct make_type_list_impl : make_type_list_helper<AllTypes...>::template make_type_list_impl<N - 1, Types..., T1> {}; 428 429 template <class... Types> 430 struct make_type_list_impl<1u, Types...> : type_list<Types..., T1> {}; 431 }; 432 433 template <class T1> 434 struct make_type_list_helper<T1> 435 { 436 template <std::size_t N, class... Types> 437 struct make_type_list_impl : type_list<Types..., T1> {}; 438 }; 439 440 template <std::size_t N, class... Types> 441 struct make_type_list : make_type_list_helper<Types...>::template make_type_list_impl<N> {}; 442 443 template <class... Types> 444 struct make_type_list<0u, Types...> : type_list<> {}; 445 446 template <std::size_t N> 447 struct make_type_list<N> : type_list<> {}; 448 466 449 template <> 467 struct FunctorParamCount<void, void, void, void, void> 468 { enum { result = 0 }; }; 450 struct make_type_list<0u> : type_list<> {}; 469 451 } 470 452 … … 473 455 that need to know the exact types of the parameters, return-value, and class. 474 456 457 @param F the type of the function-object (or void if a function-pointer is used). 475 458 @param R The type of the return-value of the function 476 459 @param O The class of the function 477 460 @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 461 @param Params The types of the parameters 483 462 484 463 This template has many parameters and is usually not used directly. It is created by … … 489 468 All template arguments can be void. 490 469 */ 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 { 470 template <class F, class R, class O, bool isconst, class... Params> 471 class FunctorTemplate : public FunctorPointer<typename detail::FunctionType<F, R, O, isconst, Params...>::Type, O> 472 { 473 static_assert(sizeof...(Params) <= 5, "Only up to 5 parameters are supported"); 474 494 475 public: 495 476 /// 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) {}477 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 478 498 479 // 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);480 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 481 { 482 return detail::FunctorCaller<F, R, O, isconst, Params...>::call(this->functionPointer_, object, param1, param2, param3, param4, param5); 502 483 } 503 484 504 485 // see Functor::clone() 505 FunctorPtr clone()506 { 507 return new FunctorTemplate(*this);486 virtual FunctorPtr clone() override 487 { 488 return std::make_shared<FunctorTemplate>(*this); 508 489 } 509 490 510 491 // see Functor::evaluateArgument() 511 v oid evaluateArgument(unsigned int index, MultiType& argument) const492 virtual void evaluateArgument(unsigned int index, MultiType& argument) const override 512 493 { 513 494 switch (index) 514 495 { 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;496 case 0: argument.convert<typename detail::GetNthParamType<0, Params...>::Type>(); break; 497 case 1: argument.convert<typename detail::GetNthParamType<1, Params...>::Type>(); break; 498 case 2: argument.convert<typename detail::GetNthParamType<2, Params...>::Type>(); break; 499 case 3: argument.convert<typename detail::GetNthParamType<3, Params...>::Type>(); break; 500 case 4: argument.convert<typename detail::GetNthParamType<4, Params...>::Type>(); break; 520 501 } 521 502 } 522 503 523 504 // see Functor::getParamCount() 524 unsigned int getParamCount() const525 { 526 return detail::FunctorParamCount<P1, P2, P3, P4, P5>::result;505 virtual unsigned int getParamCount() const override 506 { 507 return sizeof...(Params); 527 508 } 528 509 529 510 // see Functor::hasReturnvalue() 530 bool hasReturnvalue() const511 virtual bool hasReturnvalue() const override 531 512 { 532 513 return detail::FunctorHasReturnvalue<R>::result; … … 534 515 535 516 // see Functor::getTypenameParam() 536 std::string getTypenameParam(unsigned int index) const517 virtual std::string getTypenameParam(unsigned int index) const override 537 518 { 538 519 switch (index) 539 520 { 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>();521 case 0: return typeToString<typename detail::GetNthParamType<0, Params...>::Type>(); 522 case 1: return typeToString<typename detail::GetNthParamType<1, Params...>::Type>(); 523 case 2: return typeToString<typename detail::GetNthParamType<2, Params...>::Type>(); 524 case 3: return typeToString<typename detail::GetNthParamType<3, Params...>::Type>(); 525 case 4: return typeToString<typename detail::GetNthParamType<4, Params...>::Type>(); 545 526 default: return ""; 546 527 } … … 548 529 549 530 // see Functor::getTypenameReturnvalue() 550 std::string getTypenameReturnvalue() const531 virtual std::string getTypenameReturnvalue() const override 551 532 { 552 533 return typeToString<R>(); 553 534 } 554 535 536 // see Functor::getFullIdentifier() 537 virtual const std::type_info& getFullIdentifier() const override 538 { 539 return typeid(typename detail::FunctionType<void, R, O, isconst, Params...>::Type); 540 } 541 555 542 // see Functor::getHeaderIdentifier() 556 const std::type_info& getHeaderIdentifier() const557 { 558 return typeid( detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);543 virtual const std::type_info& getHeaderIdentifier() const override 544 { 545 return typeid(typename detail::FunctionType<void, R, void, false, Params...>::Type); 559 546 } 560 547 561 548 // see Functor::getHeaderIdentifier(unsigned int) 562 const std::type_info& getHeaderIdentifier(unsigned int params) const549 virtual const std::type_info& getHeaderIdentifier(unsigned int params) const override 563 550 { 564 551 switch (params) 565 552 { 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>);553 case 0: return this->getTypelistIdentifier(detail::make_type_list<0, Params...>{}); 554 case 1: return this->getTypelistIdentifier(detail::make_type_list<1, Params...>{}); 555 case 2: return this->getTypelistIdentifier(detail::make_type_list<2, Params...>{}); 556 case 3: return this->getTypelistIdentifier(detail::make_type_list<3, Params...>{}); 557 case 4: return this->getTypelistIdentifier(detail::make_type_list<4, Params...>{}); 558 default: return this->getTypelistIdentifier(detail::make_type_list<5, Params...>{}); 572 559 } 573 560 } 561 562 private: 563 /// Helper function that deduces a parameter pack of types and returns the corresponding identifier 564 template<class... Types> 565 const std::type_info& getTypelistIdentifier(detail::type_list<Types...>) const 566 { 567 return typeid(typename detail::FunctionType<void, R, void, false, Types...>::Type); 568 } 574 569 }; 575 570 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 571 572 namespace detail 573 { 574 // Helper functions to deduce types and constness of operator() and return the correct FunctorTemplate 575 template <class F> 576 struct CallableHelper 577 { 578 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); } 579 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. 580 }; 581 } 582 583 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 584 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 585 586 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 587 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 588 589 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 590 591 /** Take care that this functor does not outlive objects that have been captured by reference in a lambda. */ 592 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 593 } 609 594 -
code/trunk/src/libraries/core/command/FunctorPtr.h
r7401 r11071 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/trunk/src/libraries/core/command/IOConsolePOSIX.cc
r9667 r11071 44 44 namespace orxonox 45 45 { 46 IOConsole* IOConsole::singletonPtr_s = NULL; 47 48 namespace EscapeMode 49 { 50 enum Value 51 { 52 None, 53 First, 54 Second 55 }; 56 } 46 IOConsole* IOConsole::singletonPtr_s = nullptr; 47 48 enum class EscapeMode 49 { 50 None, 51 First, 52 Second 53 }; 57 54 58 55 IOConsole::IOConsole() … … 62 59 , promptString_("orxonox # ") 63 60 , bStatusPrinted_(false) 64 , originalTerminalSettings_( 0)61 , originalTerminalSettings_(nullptr) 65 62 { 66 63 this->setTerminalMode(); … … 90 87 std::cout.flush(); 91 88 if (!this->origCout_.str().empty()) 92 this->shell_->addOutput(this->origCout_.str(), Shell:: Cout);89 this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout); 93 90 // Erase input and status lines 94 91 this->cout_ << "\033[1G\033[J"; … … 111 108 unsigned char c; 112 109 std::string escapeSequence; 113 EscapeMode ::ValueescapeMode = EscapeMode::None;110 EscapeMode escapeMode = EscapeMode::None; 114 111 while (std::cin.good()) 115 112 { … … 231 228 if (!this->origCout_.str().empty()) 232 229 { 233 this->shell_->addOutput(this->origCout_.str(), Shell:: Cout);230 this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout); 234 231 this->origCout_.str(""); 235 232 } … … 241 238 switch (type) 242 239 { 243 case Shell:: Message:244 case Shell:: DebugOutput: this->cout_ << "\033[0m"; break;245 246 case Shell:: UserError: this->cout_ << "\033[91m"; break;247 case Shell:: UserWarning: this->cout_ << "\033[93m"; break;248 case Shell:: UserStatus: this->cout_ << "\033[92m"; break;249 case Shell:: UserInfo: this->cout_ << "\033[96m"; break;250 251 case Shell:: InternalError: this->cout_ << "\033[31m"; break;252 case Shell:: InternalWarning: this->cout_ << "\033[33m"; break;253 case Shell:: InternalStatus: this->cout_ << "\033[32m"; break;254 case Shell:: InternalInfo: this->cout_ << "\033[36m"; break;255 256 case Shell:: Verbose: this->cout_ << "\033[94m"; break;257 case Shell:: VerboseMore: this->cout_ << "\033[34m"; break;258 case Shell:: VerboseUltra: this->cout_ << "\033[34m"; break;259 260 case Shell:: Command: this->cout_ << "\033[95m"; break;261 case Shell:: Hint: this->cout_ << "\033[35m"; break;262 263 default: this->cout_ << "\033[37m"; break;240 case Shell::LineType::Message: 241 case Shell::LineType::DebugOutput: this->cout_ << "\033[0m"; break; 242 243 case Shell::LineType::UserError: this->cout_ << "\033[91m"; break; 244 case Shell::LineType::UserWarning: this->cout_ << "\033[93m"; break; 245 case Shell::LineType::UserStatus: this->cout_ << "\033[92m"; break; 246 case Shell::LineType::UserInfo: this->cout_ << "\033[96m"; break; 247 248 case Shell::LineType::InternalError: this->cout_ << "\033[31m"; break; 249 case Shell::LineType::InternalWarning: this->cout_ << "\033[33m"; break; 250 case Shell::LineType::InternalStatus: this->cout_ << "\033[32m"; break; 251 case Shell::LineType::InternalInfo: this->cout_ << "\033[36m"; break; 252 253 case Shell::LineType::Verbose: this->cout_ << "\033[94m"; break; 254 case Shell::LineType::VerboseMore: this->cout_ << "\033[34m"; break; 255 case Shell::LineType::VerboseUltra: this->cout_ << "\033[34m"; break; 256 257 case Shell::LineType::Command: this->cout_ << "\033[95m"; break; 258 case Shell::LineType::Hint: this->cout_ << "\033[35m"; break; 259 260 default: this->cout_ << "\033[37m"; break; 264 261 } 265 262 … … 326 323 tcsetattr(0, TCSANOW, IOConsole::singletonPtr_s->originalTerminalSettings_); 327 324 delete IOConsole::singletonPtr_s->originalTerminalSettings_; 328 IOConsole::singletonPtr_s->originalTerminalSettings_ = 0;325 IOConsole::singletonPtr_s->originalTerminalSettings_ = nullptr; 329 326 } 330 327 } … … 353 350 const char* s; 354 351 if (!this->terminalWidth_ && (s = getenv("COLUMNS"))) 355 this->terminalWidth_ = strtol(s, NULL, 10);352 this->terminalWidth_ = strtol(s, nullptr, 10); 356 353 if (!this->terminalWidth_) 357 354 this->terminalWidth_ = 80; 358 355 if (!this->terminalHeight_ && (s = getenv("LINES"))) 359 this->terminalHeight_ = strtol(s, NULL, 10);356 this->terminalHeight_ = strtol(s, nullptr, 10); 360 357 if (!this->terminalHeight_) 361 358 this->terminalHeight_ = 24; … … 384 381 void IOConsole::executed() 385 382 { 386 this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell:: Command);383 this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::LineType::Command); 387 384 } 388 385 -
code/trunk/src/libraries/core/command/IOConsolePOSIX.h
r8858 r11071 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/trunk/src/libraries/core/command/IOConsoleWindows.cc
r9676 r11071 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 … … 97 97 std::cout.flush(); 98 98 if (!this->origCout_.str().empty()) 99 this->shell_->addOutput(this->origCout_.str(), Shell:: Cout);99 this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout); 100 100 101 101 this->shell_->unregisterListener(this); … … 190 190 if (!this->origCout_.str().empty()) 191 191 { 192 this->shell_->addOutput(this->origCout_.str(), Shell:: Cout);192 this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout); 193 193 this->origCout_.str(""); 194 194 } … … 202 202 switch (type) 203 203 { 204 case Shell:: Message:205 case Shell:: DebugOutput: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;206 207 case Shell:: UserError: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | 0 ; break;208 case Shell:: UserWarning: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break;209 case Shell:: UserStatus: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | 0 ; break;210 case Shell:: UserInfo: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break;211 212 case Shell:: InternalError: colour = 0 | FOREGROUND_RED | 0 | 0 ; break;213 case Shell:: InternalWarning: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break;214 case Shell:: InternalStatus: colour = 0 | 0 | FOREGROUND_GREEN | 0 ; break;215 case Shell:: InternalInfo: colour = 0 | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break;216 217 case Shell:: Verbose: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break;218 case Shell:: VerboseMore: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break;219 case Shell:: VerboseUltra: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break;220 221 case Shell:: Command: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break;222 case Shell:: Hint: colour = 0 | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break;223 224 default: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;204 case Shell::LineType::Message: 205 case Shell::LineType::DebugOutput: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 206 207 case Shell::LineType::UserError: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | 0 ; break; 208 case Shell::LineType::UserWarning: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break; 209 case Shell::LineType::UserStatus: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | 0 ; break; 210 case Shell::LineType::UserInfo: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 211 212 case Shell::LineType::InternalError: colour = 0 | FOREGROUND_RED | 0 | 0 ; break; 213 case Shell::LineType::InternalWarning: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break; 214 case Shell::LineType::InternalStatus: colour = 0 | 0 | FOREGROUND_GREEN | 0 ; break; 215 case Shell::LineType::InternalInfo: colour = 0 | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 216 217 case Shell::LineType::Verbose: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break; 218 case Shell::LineType::VerboseMore: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break; 219 case Shell::LineType::VerboseUltra: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break; 220 221 case Shell::LineType::Command: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break; 222 case Shell::LineType::Hint: colour = 0 | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break; 223 224 default: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break; 225 225 } 226 226 … … 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 } … … 331 331 void IOConsole::executed() 332 332 { 333 this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell:: Command);333 this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::LineType::Command); 334 334 } 335 335 … … 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/trunk/src/libraries/core/command/IOConsoleWindows.h
r9676 r11071 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/trunk/src/libraries/core/command/IRC.cc
r10624 r11071 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/trunk/src/libraries/core/command/IRC.h
r7401 r11071 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/trunk/src/libraries/core/command/Shell.cc
r10624 r11071 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 … … 268 268 { 269 269 // yes it was - push the new line to the list 270 this->outputLines_.push_front(std::make_pair(line, static_cast<LineType>(type)));270 this->outputLines_.push_front(std::make_pair(line, type)); 271 271 272 272 // adjust the scroll position if needed … … 381 381 const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &error); 382 382 if (error) 383 this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", " + CommandExecutor::getErrorDescription(error) + ". (Shell)", UserError);383 this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", " + CommandExecutor::getErrorDescription(error) + ". (Shell)", LineType::UserError); 384 384 else if (result != "") 385 this->addOutput(result, Result);385 this->addOutput(result, LineType::Result); 386 386 387 387 this->clearInput(); … … 392 392 { 393 393 this->inputBuffer_->set(CommandExecutor::evaluate(this->inputBuffer_->get()).complete()); 394 this->addOutput(CommandExecutor::evaluate(this->inputBuffer_->get()).hint(), Hint);394 this->addOutput(CommandExecutor::evaluate(this->inputBuffer_->get()).hint(), LineType::Hint); 395 395 396 396 this->inputChanged(); -
code/trunk/src/libraries/core/command/Shell.h
r10624 r11071 61 61 62 62 public: 63 virtual ~ShellListener() {} 63 ShellListener() = default; 64 virtual ~ShellListener() = default; 64 65 65 66 private: … … 87 88 public: 88 89 /// Defines the type of a line of text in the Shell - some types depend on the output level, others are of internal use. 89 enum LineType90 enum class LineType 90 91 { 91 92 DebugOutput = debug_output, … … 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; 133 134 134 void addOutput(const std::string& text, LineType type = DebugOutput);135 void addLine(const std::string& line, LineType type = DebugOutput);135 void addOutput(const std::string& text, LineType type = LineType::DebugOutput); 136 void addLine(const std::string& line, LineType type = LineType::DebugOutput); 136 137 void clearOutput(); 137 138 … … 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/trunk/src/libraries/core/command/TclBind.cc
r10624 r11071 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/trunk/src/libraries/core/command/TclBind.h
r8079 r11071 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/trunk/src/libraries/core/command/TclThreadList.h
r7401 r11071 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/trunk/src/libraries/core/command/TclThreadManager.cc
r10624 r11071 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/trunk/src/libraries/core/commandline/CommandLineIncludes.h
r10535 r11071 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/trunk/src/libraries/core/commandline/CommandLineParser.cc
r10542 r11071 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/trunk/src/libraries/core/commandline/CommandLineParser.h
r10542 r11071 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/trunk/src/libraries/core/config/ConfigFile.cc
r10624 r11071 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)235 file << (*it_entries)->getFileEntry() << endl;236 for (ConfigFileSection* section : this->sections_) 237 { 238 file << section->getFileEntry() << endl; 239 240 for (ConfigFileEntry* entry : section->getEntries()) 241 file << entry->getFileEntry() << endl; 236 242 237 243 file << endl; … … 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/trunk/src/libraries/core/config/ConfigFileEntry.h
r9559 r11071 51 51 public: 52 52 /// Destructor 53 virtual ~ConfigFileEntry() {};53 virtual ~ConfigFileEntry() = default; 54 54 55 55 /// Changes the value of the entry. -
code/trunk/src/libraries/core/config/ConfigFileEntryComment.h
r9559 r11071 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/trunk/src/libraries/core/config/ConfigFileEntryValue.h
r9684 r11071 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/trunk/src/libraries/core/config/ConfigFileEntryVectorValue.h
r9559 r11071 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/trunk/src/libraries/core/config/ConfigFileManager.cc
r9559 r11071 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/trunk/src/libraries/core/config/ConfigFileManager.h
r9559 r11071 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/trunk/src/libraries/core/config/ConfigFileSection.cc
r9559 r11071 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/trunk/src/libraries/core/config/ConfigFileSection.h
r9684 r11071 39 39 #include <string> 40 40 #include <list> 41 #include "util/StringUtils.h" 41 42 #include "ConfigFileEntry.h" 42 43 … … 160 161 std::list<ConfigFileEntry*>& getEntries() 161 162 { return this->entries_; } 162 /// Returns the begin-iterator of the list of entries in this section. 163 std::list<ConfigFileEntry*>::const_iterator getEntriesBegin() const 164 { return this->entries_.begin(); } 165 /// Returns the end-iterator of the list of entries in this section. 166 std::list<ConfigFileEntry*>::const_iterator getEntriesEnd() const 167 { return this->entries_.end(); } 163 const std::list<ConfigFileEntry*>& getEntries() const 164 { return this->entries_; } 168 165 169 166 std::list<ConfigFileEntry*>::iterator getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString); -
code/trunk/src/libraries/core/config/ConfigValueContainer.cc
r9559 r11071 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/trunk/src/libraries/core/config/ConfigValueContainer.h
r9667 r11071 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/trunk/src/libraries/core/config/SettingsConfigFile.cc
r10624 r11071 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/trunk/src/libraries/core/config/SettingsConfigFile.h
r9684 r11071 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/trunk/src/libraries/core/input/Button.cc
r9983 r11071 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/trunk/src/libraries/core/input/HalfAxis.h
r7859 r11071 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/trunk/src/libraries/core/input/InputBuffer.cc
r9667 r11071 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/trunk/src/libraries/core/input/InputBuffer.h
r9667 r11071 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/trunk/src/libraries/core/input/InputCommands.h
r9978 r11071 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/trunk/src/libraries/core/input/InputDevice.h
r8858 r11071 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/trunk/src/libraries/core/input/InputHandler.h
r8729 r11071 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/trunk/src/libraries/core/input/InputManager.cc
r10624 r11071 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/trunk/src/libraries/core/input/InputManager.h
r8729 r11071 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/trunk/src/libraries/core/input/InputPrereqs.h
r8729 r11071 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/trunk/src/libraries/core/input/InputState.cc
r8729 r11071 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/trunk/src/libraries/core/input/InputState.h
r8729 r11071 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/trunk/src/libraries/core/input/JoyStick.cc
r10624 r11071 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/trunk/src/libraries/core/input/JoyStick.h
r9667 r11071 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/trunk/src/libraries/core/input/JoyStickQuantityListener.cc
r10624 r11071 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/trunk/src/libraries/core/input/JoyStickQuantityListener.h
r9667 r11071 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/trunk/src/libraries/core/input/KeyBinder.cc
r11052 r11071 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/trunk/src/libraries/core/input/KeyBinder.h
r11052 r11071 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/trunk/src/libraries/core/input/KeyBinderManager.cc
r10624 r11071 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/trunk/src/libraries/core/input/KeyBinderManager.h
r9667 r11071 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/trunk/src/libraries/core/input/KeyDetector.cc
r10624 r11071 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/trunk/src/libraries/core/input/KeyDetector.h
r8729 r11071 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/trunk/src/libraries/core/input/Keyboard.h
r8729 r11071 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/trunk/src/libraries/core/input/Mouse.cc
r10624 r11071 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/trunk/src/libraries/core/input/Mouse.h
r7809 r11071 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/trunk/src/libraries/core/module/DynLib.cc
r10540 r11071 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/trunk/src/libraries/core/module/DynLib.h
r10541 r11071 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/trunk/src/libraries/core/module/DynLibManager.cc
r10540 r11071 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/trunk/src/libraries/core/module/ModuleInstance.cc
r10549 r11071 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/trunk/src/libraries/core/module/ModuleInstance.h
r10549 r11071 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/trunk/src/libraries/core/module/Plugin.cc
r11015 r11071 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 } … … 79 79 { 80 80 // only load module if it isn't already loaded. otherwise merely activate it. 81 if (this->moduleInstance_ == NULL)81 if (this->moduleInstance_ == nullptr) 82 82 this->loadModule(); 83 83 else … … 112 112 Core::getInstance().unloadModule(this->moduleInstance_); 113 113 delete this->moduleInstance_; 114 this->moduleInstance_ = NULL;114 this->moduleInstance_ = nullptr; 115 115 } 116 116 void Plugin::deactivateModule() -
code/trunk/src/libraries/core/module/PluginManager.cc
r11017 r11071 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/trunk/src/libraries/core/module/StaticInitializationHandler.h
r10532 r11071 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/trunk/src/libraries/core/module/StaticInitializationHandlerIncludes.h
r10535 r11071 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/trunk/src/libraries/core/module/StaticInitializationManager.cc
r10542 r11071 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/trunk/src/libraries/core/module/StaticInitializationManager.h
r10542 r11071 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/trunk/src/libraries/core/object/ClassFactory.h
r9667 r11071 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/trunk/src/libraries/core/object/Context.cc
r10624 r11071 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/trunk/src/libraries/core/object/DestroyLaterManager.h
r10624 r11071 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/trunk/src/libraries/core/object/Destroyable.cc
r11019 r11071 54 54 Destroyable::~Destroyable() 55 55 { 56 if (!this->requestedDestruction_ && !IdentifierManager::getInstance().isCreatingHierarchy())56 if (!this->requestedDestruction_ && IdentifierManager::exists() && !IdentifierManager::getInstance().isCreatingHierarchy()) 57 57 orxout(internal_warning) << "Deleted destroyable object without destroy()" << endl; 58 58 … … 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/trunk/src/libraries/core/object/Iterator.h
r10624 r11071 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/trunk/src/libraries/core/object/IteratorBase.h
r10624 r11071 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/trunk/src/libraries/core/object/Listable.cc
r10624 r11071 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/trunk/src/libraries/core/object/Listable.h
r9667 r11071 40 40 #include <vector> 41 41 42 #include "util/SmallObjectAllocator.h" 42 43 #include "core/class/Identifiable.h" 43 44 -
code/trunk/src/libraries/core/object/ObjectList.h
r10624 r11071 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/trunk/src/libraries/core/object/ObjectListBase.cc
r9975 r11071 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/trunk/src/libraries/core/object/ObjectListBase.h
r9667 r11071 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/trunk/src/libraries/core/object/ObjectListIterator.h
r10624 r11071 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/trunk/src/libraries/core/object/StrongPtr.h
r10624 r11071 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/trunk/src/libraries/core/object/WeakPtr.h
r10624 r11071 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/trunk/src/libraries/core/singleton/Scope.h
r10514 r11071 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/trunk/src/libraries/core/singleton/ScopeManager.cc
r10542 r11071 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/trunk/src/libraries/core/singleton/ScopeManager.h
r11012 r11071 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/trunk/src/libraries/core/singleton/ScopedSingletonIncludes.h
r11052 r11071 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/trunk/src/libraries/core/singleton/ScopedSingletonWrapper.h
r10528 r11071 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 }
Note: See TracChangeset
for help on using the changeset viewer.