Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/Game.h

    r10624 r11071  
    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:
     
    9292
    9393        //! Leave empty and use cleanup() instead
    94         ~Game() {}
     94        ~Game() = default;
    9595        /// Destructor that also executes when object fails to construct
    9696        void destroy();
    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();
     
    122122        {
    123123        public:
    124             virtual ~GameStateFactory() { }
    125             static shared_ptr<GameState> fabricate(const GameStateInfo& info);
     124            virtual ~GameStateFactory() = default;
     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            virtual std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) override
     138                { return std::shared_ptr<GameState>(std::make_shared<T>(info)); }
    139139        };
    140140
     
    145145        };
    146146
    147         Game(Game&); // don't mess with singletons
     147        // non-copyable:
     148        Game(const Game&) = delete;
     149        Game& operator=(const Game&) = delete;
    148150
    149151        void loadGraphics();
    150152        void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true);
    151153
    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);
    153155        bool checkState(const std::string& name) const;
    154156        void loadState(const std::string& name);
Note: See TracChangeset for help on using the changeset viewer.