Changeset 10771 for code/branches/cpp11_v2/src/libraries
- Timestamp:
- Nov 7, 2015, 5:24:58 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/core
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/CorePrecompiledHeaders.h
r8858 r10771 50 50 #include <sstream> // 53 51 51 #include <set> // 50 52 #include <memory> 52 53 53 54 #include "util/Output.h" // 48 … … 66 67 #include <OgreColourValue.h> // 36 67 68 #include <boost/preprocessor/cat.hpp> // 27 68 #include <boost/shared_ptr.hpp> // 2169 69 70 70 #ifdef ORXONOX_COMPILER_MSVC … … 76 76 #include "util/SubString.h" // 14 77 77 78 #include <boost/scoped_ptr.hpp> // 1379 78 #include <stack> // 12 80 79 -
code/branches/cpp11_v2/src/libraries/core/GUIManager.h
r10768 r10771 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" … … 196 195 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 197 196 CEGUI::System* guiSystem_; //!< CEGUI's main system 198 s hared_ptr<ResourceInfo>rootFileInfo_; //!< Resource information about the root script197 std::shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 199 198 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 200 199 int outputLevelCeguiLog_; //!< CEGUI's log level -
code/branches/cpp11_v2/src/libraries/core/Game.cc
r10769 r10771 36 36 37 37 #include <exception> 38 #include <boost/weak_ptr.hpp>39 38 #include <loki/ScopeGuard.h> 40 39 … … 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 … … 124 123 125 124 // The empty root state is ALWAYS loaded! 126 this->rootStateNode_ = s hared_ptr<GameStateTreeNode>(new GameStateTreeNode());125 this->rootStateNode_ = std::shared_ptr<GameStateTreeNode>(new GameStateTreeNode()); 127 126 this->rootStateNode_->name_ = "emptyRootGameState"; 128 127 this->loadedTopStateNode_ = this->rootStateNode_; … … 137 136 138 137 assert(loadedStates_.size() <= 1); // Just empty root GameState 139 // Destroy all GameStates (s hared_ptrs take care of actual destruction)138 // Destroy all GameStates (std::shared_ptrs take care of actual destruction) 140 139 constructedStates_.clear(); 141 140 … … 235 234 while (this->requestedStateNodes_.size() > 0) 236 235 { 237 s hared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();236 std::shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front(); 238 237 assert(this->loadedTopStateNode_); 239 238 if (!this->loadedTopStateNode_->parent_.expired() && requestedStateNode == this->loadedTopStateNode_->parent_.lock()) … … 281 280 orxout(user_error) << "This should really never happen!" << endl; 282 281 orxout(user_error) << "Unloading all GameStates depending on the one that crashed." << endl; 283 s hared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_;282 std::shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_; 284 283 while (current->name_ != (*it)->getName() && current) 285 284 current = current->parent_.lock(); … … 372 371 } 373 372 374 s hared_ptr<GameStateTreeNode> lastRequestedNode;373 std::shared_ptr<GameStateTreeNode> lastRequestedNode; 375 374 if (this->requestedStateNodes_.empty()) 376 375 lastRequestedNode = this->loadedTopStateNode_; … … 384 383 385 384 // Check children first 386 std::vector<s hared_ptr<GameStateTreeNode>> requestedNodes;385 std::vector<std::shared_ptr<GameStateTreeNode>> requestedNodes; 387 386 for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i) 388 387 { … … 397 396 { 398 397 // Check parent and all its grand parents 399 s hared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;398 std::shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode; 400 399 while (currentNode != nullptr) 401 400 { … … 424 423 void Game::popState() 425 424 { 426 s hared_ptr<GameStateTreeNode> lastRequestedNode;425 std::shared_ptr<GameStateTreeNode> lastRequestedNode; 427 426 if (this->requestedStateNodes_.empty()) 428 427 lastRequestedNode = this->loadedTopStateNode_; … … 435 434 } 436 435 437 s hared_ptr<GameState> Game::getState(const std::string& name)436 std::shared_ptr<GameState> Game::getState(const std::string& name) 438 437 { 439 438 GameStateMap::const_iterator it = constructedStates_.find(name); … … 447 446 else 448 447 orxout(internal_error) << "Could not find GameState '" << name << "'." << endl; 449 return s hared_ptr<GameState>();448 return std::shared_ptr<GameState>(); 450 449 } 451 450 } … … 479 478 /*** Internal ***/ 480 479 481 void Game::parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, s hared_ptr<GameStateTreeNode> currentNode)480 void Game::parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, std::shared_ptr<GameStateTreeNode> currentNode) 482 481 { 483 482 SubString tokens(it->first, ","); … … 491 490 if (tokens[i] == this->rootStateNode_->name_) 492 491 ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy..."); 493 s hared_ptr<GameStateTreeNode> node(new GameStateTreeNode());492 std::shared_ptr<GameStateTreeNode> node(new GameStateTreeNode()); 494 493 node->name_ = tokens[i]; 495 494 node->parent_ = currentNode; … … 527 526 { 528 527 // Game state loading failure is serious --> don't catch 529 s hared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);528 std::shared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second); 530 529 if (!constructedStates_.insert(std::make_pair( 531 530 it->second.stateName, gameState)).second) … … 582 581 graphicsUnloader.Dismiss(); 583 582 584 s hared_ptr<GameState> state = this->getState(name);583 std::shared_ptr<GameState> state = this->getState(name); 585 584 state->activateInternal(); 586 585 if (!this->loadedStates_.empty()) … … 599 598 try 600 599 { 601 s hared_ptr<GameState> state = this->getState(name);600 std::shared_ptr<GameState> state = this->getState(name); 602 601 state->activity_.topState = false; 603 602 this->loadedStates_.pop_back(); … … 620 619 } 621 620 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;621 /*static*/ std::map<std::string, std::shared_ptr<Game::GameStateFactory>>& Game::GameStateFactory::getFactories() 622 { 623 static std::map<std::string, std::shared_ptr<GameStateFactory>> factories; 625 624 return factories; 626 625 } 627 626 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);627 /*static*/ std::shared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info) 628 { 629 std::map<std::string, std::shared_ptr<Game::GameStateFactory>>::const_iterator it = getFactories().find(info.className); 631 630 assert(it != getFactories().end()); 632 631 return it->second->fabricateInternal(info); -
code/branches/cpp11_v2/src/libraries/core/Game.h
r10769 r10771 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: … … 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(); … … 123 123 public: 124 124 virtual ~GameStateFactory() { } 125 static s hared_ptr<GameState> fabricate(const GameStateInfo& info);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 s hared_ptr<GameState> fabricateInternal(const GameStateInfo& info)138 { return s hared_ptr<GameState>(new T(info)); }137 std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) 138 { return std::shared_ptr<GameState>(new T(info)); } 139 139 }; 140 140 … … 150 150 void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); 151 151 152 void parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, s hared_ptr<GameStateTreeNode> currentNode);152 void parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, std::shared_ptr<GameStateTreeNode> currentNode); 153 153 bool checkState(const std::string& name) const; 154 154 void loadState(const std::string& name); -
code/branches/cpp11_v2/src/libraries/core/GraphicsManager.cc
r10768 r10771 34 34 #include <sstream> 35 35 #include <boost/filesystem.hpp> 36 #include <boost/shared_array.hpp>37 36 38 37 #include <OgreFrameListener.h> -
code/branches/cpp11_v2/src/libraries/core/GraphicsManager.h
r10765 r10771 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" … … 130 131 131 132 // 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 overlays133 std::shared_ptr<XMLFile> resources_; //!< XML with resource locations 134 std::shared_ptr<XMLFile> extResources_; //!< XML with resource locations in the external path (only for dev runs) 135 std::shared_ptr<XMLFile> debugOverlay_; //!< XML with various debug overlays 135 136 136 137 // config values -
code/branches/cpp11_v2/src/libraries/core/Loader.cc
r10769 r10771 73 73 std::string xmlInput; 74 74 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>>>());75 std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> lineTrace(new std::vector<std::vector<std::pair<std::string, size_t>>>()); 76 76 lineTrace->reserve(1000); //arbitrary number 77 77 … … 80 80 { 81 81 // Use the LuaState to replace the XML tags (calls our function) 82 scoped_ptr<LuaState> luaState(new LuaState());82 boost::scoped_ptr<LuaState> luaState(new LuaState()); 83 83 luaState->setTraceMap(lineTrace); 84 84 luaState->setIncludeParser(&Loader::replaceLuaTags); … … 88 88 else 89 89 { 90 s hared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename());90 std::shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename()); 91 91 if (info == nullptr) 92 92 { -
code/branches/cpp11_v2/src/libraries/core/LuaState.cc
r10769 r10771 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 86 if (sourceInfo == nullptr && !sourceFileInfo_->path.empty()) … … 91 91 bool LuaState::includeFile(const std::string& filename) 92 92 { 93 s hared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);93 std::shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename); 94 94 if (sourceInfo != nullptr) 95 95 return this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo); … … 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) … … 131 131 bool LuaState::doFile(const std::string& filename) 132 132 { 133 s hared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);133 std::shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename); 134 134 if (sourceInfo != nullptr) 135 135 return this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo); … … 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 148 if (sourceFileInfo != nullptr) … … 285 285 bool LuaState::fileExists(const std::string& filename) 286 286 { 287 s hared_ptr<ResourceInfo> info = this->getFileInfo(filename);287 std::shared_ptr<ResourceInfo> info = this->getFileInfo(filename); 288 288 if (info == nullptr) 289 289 return false; … … 300 300 if (it != this->sourceCodeMap_.end()) 301 301 return it->second; 302 s hared_ptr<ResourceInfo> info = Resource::getInfo(filename);302 std::shared_ptr<ResourceInfo> info = Resource::getInfo(filename); 303 303 if (info == nullptr) 304 304 return ""; -
code/branches/cpp11_v2/src/libraries/core/LuaState.h
r10769 r10771 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)96 void setTraceMap(std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> map) 97 97 { map->push_back(std::vector<std::pair<std::string, size_t>>()); lineTrace_ = map; } 98 98 … … 100 100 lua_State* getInternalLuaState() { return luaState_; } 101 101 102 void setDefaultResourceInfo(const s hared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }103 const s hared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }102 void setDefaultResourceInfo(const std::shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; } 103 const std::shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; } 104 104 105 105 LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export … … 115 115 116 116 private: 117 s hared_ptr<ResourceInfo> getFileInfo(const std::string& filename);118 s hared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> lineTrace_;117 std::shared_ptr<ResourceInfo> getFileInfo(const std::string& filename); 118 std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> lineTrace_; 119 119 120 120 std::stringstream output_; 121 121 lua_State* luaState_; 122 122 bool bIsRunning_; 123 s hared_ptr<ResourceInfo> sourceFileInfo_;123 std::shared_ptr<ResourceInfo> sourceFileInfo_; 124 124 std::map<std::string, std::string> sourceCodeMap_; 125 125 std::string (*includeParseFunction_)(const std::string&); -
code/branches/cpp11_v2/src/libraries/core/Resource.cc
r10765 r10771 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(new ResourceInfo()); 98 98 ptr->filename = name; 99 99 ptr->path = it->path; … … 114 114 } 115 115 } 116 return s hared_ptr<ResourceInfo>();116 return std::shared_ptr<ResourceInfo>(); 117 117 } 118 118 -
code/branches/cpp11_v2/src/libraries/core/Resource.h
r8351 r10771 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 /** -
code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc
r10768 r10771 188 188 { 189 189 while (joyStickAxes_.size() < joySticks_.size()) 190 joyStickAxes_.push_back(s hared_ptr<JoyStickAxisVector>(new JoyStickAxisVector()));190 joyStickAxes_.push_back(std::shared_ptr<JoyStickAxisVector>(new JoyStickAxisVector())); 191 191 while (joyStickButtons_.size() < joySticks_.size()) 192 joyStickButtons_.push_back(s hared_ptr<JoyStickButtonVector>(new JoyStickButtonVector()));192 joyStickButtons_.push_back(std::shared_ptr<JoyStickButtonVector>(new JoyStickButtonVector())); 193 193 // For the case the new size is smaller 194 194 this->joyStickAxes_.resize(joySticks_.size()); -
code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.h
r10769 r10771 36 36 #include <vector> 37 37 #include <map> 38 #include < boost/shared_ptr.hpp>38 #include <memory> 39 39 40 40 #include "InputHandler.h" … … 127 127 }; 128 128 //! Actual key bindings for joy stick buttons 129 std::vector<s hared_ptr<JoyStickButtonVector>> joyStickButtons_;129 std::vector<std::shared_ptr<JoyStickButtonVector>> joyStickButtons_; 130 130 //! Helper class to use something like std:vector<HalfAxis[48]> 131 131 struct JoyStickAxisVector … … 135 135 }; 136 136 //! Actual key bindings for joy stick axes (and sliders) 137 std::vector<s hared_ptr<JoyStickAxisVector>> joyStickAxes_;137 std::vector<std::shared_ptr<JoyStickAxisVector>> joyStickAxes_; 138 138 139 139 //! Pointer map with all Buttons, including half axes
Note: See TracChangeset
for help on using the changeset viewer.