Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 7, 2015, 5:24:58 PM (9 years ago)
Author:
landauf
Message:

using std::shared_ptr instead of boost::shared_ptr (same for weak_ptr)

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  
    5050#include <sstream>  // 53
    5151#include <set>      // 50
     52#include <memory>
    5253
    5354#include "util/Output.h" // 48
     
    6667#include <OgreColourValue.h> // 36
    6768#include <boost/preprocessor/cat.hpp> // 27
    68 #include <boost/shared_ptr.hpp> // 21
    6969
    7070#ifdef ORXONOX_COMPILER_MSVC
     
    7676#include "util/SubString.h"  // 14
    7777
    78 #include <boost/scoped_ptr.hpp> // 13
    7978#include <stack> // 12
    8079
  • code/branches/cpp11_v2/src/libraries/core/GUIManager.h

    r10768 r10771  
    4040#include <map>
    4141#include <string>
     42#include <memory>
    4243
    4344#if CEGUI_VERSION >= 0x000800
     
    4849#   include <CEGUIVersion.h>
    4950#endif
    50 
    51 #include <boost/shared_ptr.hpp>
    5251
    5352#include "util/DestructionHelper.h"
     
    196195        CEGUI::LuaScriptModule*              scriptModule_;         //!< CEGUI's script module to use Lua
    197196        CEGUI::System*                       guiSystem_;            //!< CEGUI's main system
    198         shared_ptr<ResourceInfo>             rootFileInfo_;         //!< Resource information about the root script
     197        std::shared_ptr<ResourceInfo>        rootFileInfo_;         //!< Resource information about the root script
    199198        CEGUI::Logger*                       ceguiLogger_;          //!< CEGUI's logger to be able to log CEGUI errors in our log
    200199        int                                  outputLevelCeguiLog_;  //!< CEGUI's log level
  • code/branches/cpp11_v2/src/libraries/core/Game.cc

    r10769 r10771  
    3636
    3737#include <exception>
    38 #include <boost/weak_ptr.hpp>
    3938#include <loki/ScopeGuard.h>
    4039
     
    7271    {
    7372        std::string name_;
    74         weak_ptr<GameStateTreeNode> parent_;
    75         std::vector<shared_ptr<GameStateTreeNode>> children_;
     73        std::weak_ptr<GameStateTreeNode> parent_;
     74        std::vector<std::shared_ptr<GameStateTreeNode>> children_;
    7675    };
    7776
     
    124123
    125124        // The empty root state is ALWAYS loaded!
    126         this->rootStateNode_ = shared_ptr<GameStateTreeNode>(new GameStateTreeNode());
     125        this->rootStateNode_ = std::shared_ptr<GameStateTreeNode>(new GameStateTreeNode());
    127126        this->rootStateNode_->name_ = "emptyRootGameState";
    128127        this->loadedTopStateNode_ = this->rootStateNode_;
     
    137136
    138137        assert(loadedStates_.size() <= 1); // Just empty root GameState
    139         // Destroy all GameStates (shared_ptrs take care of actual destruction)
     138        // Destroy all GameStates (std::shared_ptrs take care of actual destruction)
    140139        constructedStates_.clear();
    141140
     
    235234        while (this->requestedStateNodes_.size() > 0)
    236235        {
    237             shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();
     236            std::shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();
    238237            assert(this->loadedTopStateNode_);
    239238            if (!this->loadedTopStateNode_->parent_.expired() && requestedStateNode == this->loadedTopStateNode_->parent_.lock())
     
    281280                orxout(user_error) << "This should really never happen!" << endl;
    282281                orxout(user_error) << "Unloading all GameStates depending on the one that crashed." << endl;
    283                 shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_;
     282                std::shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_;
    284283                while (current->name_ != (*it)->getName() && current)
    285284                    current = current->parent_.lock();
     
    372371        }
    373372
    374         shared_ptr<GameStateTreeNode> lastRequestedNode;
     373        std::shared_ptr<GameStateTreeNode> lastRequestedNode;
    375374        if (this->requestedStateNodes_.empty())
    376375            lastRequestedNode = this->loadedTopStateNode_;
     
    384383
    385384        // Check children first
    386         std::vector<shared_ptr<GameStateTreeNode>> requestedNodes;
     385        std::vector<std::shared_ptr<GameStateTreeNode>> requestedNodes;
    387386        for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
    388387        {
     
    397396        {
    398397            // Check parent and all its grand parents
    399             shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
     398            std::shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
    400399            while (currentNode != nullptr)
    401400            {
     
    424423    void Game::popState()
    425424    {
    426         shared_ptr<GameStateTreeNode> lastRequestedNode;
     425        std::shared_ptr<GameStateTreeNode> lastRequestedNode;
    427426        if (this->requestedStateNodes_.empty())
    428427            lastRequestedNode = this->loadedTopStateNode_;
     
    435434    }
    436435
    437     shared_ptr<GameState> Game::getState(const std::string& name)
     436    std::shared_ptr<GameState> Game::getState(const std::string& name)
    438437    {
    439438        GameStateMap::const_iterator it = constructedStates_.find(name);
     
    447446            else
    448447                orxout(internal_error) << "Could not find GameState '" << name << "'." << endl;
    449             return shared_ptr<GameState>();
     448            return std::shared_ptr<GameState>();
    450449        }
    451450    }
     
    479478    /*** Internal ***/
    480479
    481     void Game::parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode)
     480    void Game::parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, std::shared_ptr<GameStateTreeNode> currentNode)
    482481    {
    483482        SubString tokens(it->first, ",");
     
    491490            if (tokens[i] == this->rootStateNode_->name_)
    492491                ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy...");
    493             shared_ptr<GameStateTreeNode> node(new GameStateTreeNode());
     492            std::shared_ptr<GameStateTreeNode> node(new GameStateTreeNode());
    494493            node->name_ = tokens[i];
    495494            node->parent_ = currentNode;
     
    527526                {
    528527                    // Game state loading failure is serious --> don't catch
    529                     shared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);
     528                    std::shared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);
    530529                    if (!constructedStates_.insert(std::make_pair(
    531530                        it->second.stateName, gameState)).second)
     
    582581            graphicsUnloader.Dismiss();
    583582
    584         shared_ptr<GameState> state = this->getState(name);
     583        std::shared_ptr<GameState> state = this->getState(name);
    585584        state->activateInternal();
    586585        if (!this->loadedStates_.empty())
     
    599598        try
    600599        {
    601             shared_ptr<GameState> state = this->getState(name);
     600            std::shared_ptr<GameState> state = this->getState(name);
    602601            state->activity_.topState = false;
    603602            this->loadedStates_.pop_back();
     
    620619    }
    621620
    622     /*static*/ std::map<std::string, shared_ptr<Game::GameStateFactory>>& Game::GameStateFactory::getFactories()
    623     {
    624         static std::map<std::string, shared_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;
    625624        return factories;
    626625    }
    627626
    628     /*static*/ shared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info)
    629     {
    630         std::map<std::string, shared_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);
    631630        assert(it != getFactories().end());
    632631        return it->second->fabricateInternal(info);
  • code/branches/cpp11_v2/src/libraries/core/Game.h

    r10769 r10771  
    4444#include <string>
    4545#include <vector>
    46 #include <boost/shared_ptr.hpp>
     46#include <memory>
    4747#include <boost/preprocessor/cat.hpp>
    4848
     
    8484    { // tolua_export
    8585        friend class Singleton<Game>;
    86         typedef std::vector<shared_ptr<GameState>> GameStateVector;
    87         typedef std::map<std::string, shared_ptr<GameState>> GameStateMap;
    88         typedef shared_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;
    8989
    9090    public:
     
    9797
    9898        void setStateHierarchy(const std::string& str);
    99         shared_ptr<GameState> getState(const std::string& name);
     99        std::shared_ptr<GameState> getState(const std::string& name);
    100100
    101101        void run();
     
    123123        public:
    124124            virtual ~GameStateFactory() { }
    125             static shared_ptr<GameState> fabricate(const GameStateInfo& info);
     125            static std::shared_ptr<GameState> fabricate(const GameStateInfo& info);
    126126            template <class T>
    127127            static void createFactory(const std::string& className)
    128128                { getFactories()[className].reset(new TemplateGameStateFactory<T>()); }
    129129
    130             virtual shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0;
    131             static std::map<std::string, shared_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();
    132132        };
    133133        template <class T>
     
    135135        {
    136136        public:
    137             shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)
    138                 { return shared_ptr<GameState>(new T(info)); }
     137            std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)
     138                { return std::shared_ptr<GameState>(new T(info)); }
    139139        };
    140140
     
    150150        void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true);
    151151
    152         void parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode);
     152        void parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, std::shared_ptr<GameStateTreeNode> currentNode);
    153153        bool checkState(const std::string& name) const;
    154154        void loadState(const std::string& name);
  • code/branches/cpp11_v2/src/libraries/core/GraphicsManager.cc

    r10768 r10771  
    3434#include <sstream>
    3535#include <boost/filesystem.hpp>
    36 #include <boost/shared_array.hpp>
    3736
    3837#include <OgreFrameListener.h>
  • code/branches/cpp11_v2/src/libraries/core/GraphicsManager.h

    r10765 r10771  
    4747#include <cassert>
    4848#include <string>
     49#include <memory>
     50
    4951#include <OgreLog.h>
    50 #include <boost/shared_ptr.hpp>
    5152
    5253#include "util/DestructionHelper.h"
     
    130131
    131132        // XML files for the resources and the debug overlay
    132         shared_ptr<XMLFile> resources_;                //!< XML with resource locations
    133         shared_ptr<XMLFile> extResources_;             //!< XML with resource locations in the external path (only for dev runs)
    134         shared_ptr<XMLFile> debugOverlay_;             //!< XML with various debug overlays
     133        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
    135136
    136137        // config values
  • code/branches/cpp11_v2/src/libraries/core/Loader.cc

    r10769 r10771  
    7373        std::string xmlInput;
    7474
    75         shared_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>>>());
    7676        lineTrace->reserve(1000); //arbitrary number
    7777
     
    8080        {
    8181            // 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());
    8383            luaState->setTraceMap(lineTrace);
    8484            luaState->setIncludeParser(&Loader::replaceLuaTags);
     
    8888        else
    8989        {
    90             shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename());
     90            std::shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename());
    9191            if (info == nullptr)
    9292            {
  • code/branches/cpp11_v2/src/libraries/core/LuaState.cc

    r10769 r10771  
    7979    }
    8080
    81     shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename)
     81    std::shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename)
    8282    {
    8383        // Look in the current directory first
    84         shared_ptr<ResourceInfo> sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename);
     84        std::shared_ptr<ResourceInfo> sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename);
    8585        // Continue search in root directories
    8686        if (sourceInfo == nullptr && !sourceFileInfo_->path.empty())
     
    9191    bool LuaState::includeFile(const std::string& filename)
    9292    {
    93         shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
     93        std::shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
    9494        if (sourceInfo != nullptr)
    9595            return this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
     
    101101    }
    102102
    103     bool LuaState::includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
     103    bool LuaState::includeString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo)
    104104    {
    105105        // Parse string with provided include parser (otherwise don't preparse at all)
     
    131131    bool LuaState::doFile(const std::string& filename)
    132132    {
    133         shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
     133        std::shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
    134134        if (sourceInfo != nullptr)
    135135            return this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
     
    141141    }
    142142
    143     bool LuaState::doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
     143    bool LuaState::doString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo)
    144144    {
    145145        // Save the old source file info
    146         shared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_;
     146        std::shared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_;
    147147        // Only override if sourceFileInfo provides useful information
    148148        if (sourceFileInfo != nullptr)
     
    285285    bool LuaState::fileExists(const std::string& filename)
    286286    {
    287         shared_ptr<ResourceInfo> info = this->getFileInfo(filename);
     287        std::shared_ptr<ResourceInfo> info = this->getFileInfo(filename);
    288288        if (info == nullptr)
    289289            return false;
     
    300300        if (it != this->sourceCodeMap_.end())
    301301            return it->second;
    302         shared_ptr<ResourceInfo> info = Resource::getInfo(filename);
     302        std::shared_ptr<ResourceInfo> info = Resource::getInfo(filename);
    303303        if (info == nullptr)
    304304            return "";
  • code/branches/cpp11_v2/src/libraries/core/LuaState.h

    r10769 r10771  
    4747#include <string>
    4848#include <vector>
    49 #include <boost/shared_ptr.hpp>
     49#include <memory>
    5050
    5151#include "util/Output.h"
     
    7979
    8080        bool doFile(const std::string& filename); // tolua_export
    81         bool doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
     81        bool doString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo = std::shared_ptr<ResourceInfo>());
    8282
    8383        bool includeFile(const std::string& filename); // tolua_export
    84         bool includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
     84        bool includeString(const std::string& code, const std::shared_ptr<ResourceInfo>& sourceFileInfo = std::shared_ptr<ResourceInfo>());
    8585
    8686        void luaPrint(const std::string& str); // tolua_export
     
    9494        void clearOutput() { output_.clear(); } // tolua_export
    9595
    96         void setTraceMap(shared_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)
    9797            { map->push_back(std::vector<std::pair<std::string, size_t>>()); lineTrace_ = map; }
    9898
     
    100100        lua_State* getInternalLuaState() { return luaState_; }
    101101
    102         void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
    103         const shared_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_; }
    104104
    105105        LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
     
    115115
    116116    private:
    117         shared_ptr<ResourceInfo> getFileInfo(const std::string& filename);
    118         shared_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_;
    119119       
    120120        std::stringstream output_;
    121121        lua_State* luaState_;
    122122        bool bIsRunning_;
    123         shared_ptr<ResourceInfo> sourceFileInfo_;
     123        std::shared_ptr<ResourceInfo> sourceFileInfo_;
    124124        std::map<std::string, std::string> sourceCodeMap_;
    125125        std::string (*includeParseFunction_)(const std::string&);
  • code/branches/cpp11_v2/src/libraries/core/Resource.cc

    r10765 r10771  
    7979    }
    8080
    81     shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name)
     81    std::shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name)
    8282    {
    8383        std::string group;
     
    8888        catch (const Ogre::Exception&)
    8989        {
    90             return shared_ptr<ResourceInfo>();
     90            return std::shared_ptr<ResourceInfo>();
    9191        }
    9292        Ogre::FileInfoListPtr infos = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(group, name);
     
    9595            if (it->filename == name)
    9696            {
    97                 shared_ptr<ResourceInfo> ptr(new ResourceInfo());
     97                std::shared_ptr<ResourceInfo> ptr(new ResourceInfo());
    9898                ptr->filename = name;
    9999                ptr->path = it->path;
     
    114114            }
    115115        }
    116         return shared_ptr<ResourceInfo>();
     116        return std::shared_ptr<ResourceInfo>();
    117117    }
    118118
  • code/branches/cpp11_v2/src/libraries/core/Resource.h

    r8351 r10771  
    4242#include "CorePrereqs.h"
    4343
    44 #include <boost/shared_ptr.hpp>
     44#include <memory>
     45
    4546#include <OgreDataStream.h>
    4647#include <OgreStringVector.h>
     
    9394
    9495        //! Similar to open(string, string, bool), but with a fileInfo struct
    95         static DataStreamPtr open(shared_ptr<ResourceInfo> fileInfo)
     96        static DataStreamPtr open(std::shared_ptr<ResourceInfo> fileInfo)
    9697        {
    9798            return open(fileInfo->filename);
     
    125126            Fully qualified name of the file to test for
    126127        */
    127         static shared_ptr<ResourceInfo> getInfo(const std::string& name);
     128        static std::shared_ptr<ResourceInfo> getInfo(const std::string& name);
    128129
    129130        /**
  • code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc

    r10768 r10771  
    188188    {
    189189        while (joyStickAxes_.size() < joySticks_.size())
    190             joyStickAxes_.push_back(shared_ptr<JoyStickAxisVector>(new JoyStickAxisVector()));
     190            joyStickAxes_.push_back(std::shared_ptr<JoyStickAxisVector>(new JoyStickAxisVector()));
    191191        while (joyStickButtons_.size() < joySticks_.size())
    192             joyStickButtons_.push_back(shared_ptr<JoyStickButtonVector>(new JoyStickButtonVector()));
     192            joyStickButtons_.push_back(std::shared_ptr<JoyStickButtonVector>(new JoyStickButtonVector()));
    193193        // For the case the new size is smaller
    194194        this->joyStickAxes_.resize(joySticks_.size());
  • code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.h

    r10769 r10771  
    3636#include <vector>
    3737#include <map>
    38 #include <boost/shared_ptr.hpp>
     38#include <memory>
    3939
    4040#include "InputHandler.h"
     
    127127        };
    128128        //! Actual key bindings for joy stick buttons
    129         std::vector<shared_ptr<JoyStickButtonVector>> joyStickButtons_;
     129        std::vector<std::shared_ptr<JoyStickButtonVector>> joyStickButtons_;
    130130        //! Helper class to use something like std:vector<HalfAxis[48]>
    131131        struct JoyStickAxisVector
     
    135135        };
    136136        //! Actual key bindings for joy stick axes (and sliders)
    137         std::vector<shared_ptr<JoyStickAxisVector>> joyStickAxes_;
     137        std::vector<std::shared_ptr<JoyStickAxisVector>> joyStickAxes_;
    138138
    139139        //! Pointer map with all Buttons, including half axes
Note: See TracChangeset for help on using the changeset viewer.