Changeset 11054 for code/branches/cpp11_v3/src/libraries/core/Game.h
- Timestamp:
- Jan 10, 2016, 1:54:11 PM (9 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/src/libraries/core/Game.h
r10624 r11054 44 44 #include <string> 45 45 #include <vector> 46 #include < boost/shared_ptr.hpp>46 #include <memory> 47 47 #include <boost/preprocessor/cat.hpp> 48 48 … … 84 84 { // tolua_export 85 85 friend class Singleton<Game>; 86 typedef std::vector<s hared_ptr<GameState>> GameStateVector;87 typedef std::map<std::string, s hared_ptr<GameState>> GameStateMap;88 typedef s hared_ptr<GameStateTreeNode> GameStateTreeNodePtr;86 typedef std::vector<std::shared_ptr<GameState>> GameStateVector; 87 typedef std::map<std::string, std::shared_ptr<GameState>> GameStateMap; 88 typedef std::shared_ptr<GameStateTreeNode> GameStateTreeNodePtr; 89 89 90 90 public: … … 92 92 93 93 //! Leave empty and use cleanup() instead 94 ~Game() {}94 ~Game() = default; 95 95 /// Destructor that also executes when object fails to construct 96 96 void destroy(); 97 97 98 98 void setStateHierarchy(const std::string& str); 99 s hared_ptr<GameState> getState(const std::string& name);99 std::shared_ptr<GameState> getState(const std::string& name); 100 100 101 101 void run(); … … 122 122 { 123 123 public: 124 virtual ~GameStateFactory() { }125 static s hared_ptr<GameState> fabricate(const GameStateInfo& info);124 virtual ~GameStateFactory() = default; 125 static std::shared_ptr<GameState> fabricate(const GameStateInfo& info); 126 126 template <class T> 127 127 static void createFactory(const std::string& className) 128 128 { getFactories()[className].reset(new TemplateGameStateFactory<T>()); } 129 129 130 virtual s hared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0;131 static std::map<std::string, s hared_ptr<GameStateFactory>>& getFactories();130 virtual std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0; 131 static std::map<std::string, std::shared_ptr<GameStateFactory>>& getFactories(); 132 132 }; 133 133 template <class T> … … 135 135 { 136 136 public: 137 shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)138 { return s hared_ptr<GameState>(new T(info)); }137 virtual std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) override 138 { return std::shared_ptr<GameState>(std::make_shared<T>(info)); } 139 139 }; 140 140 … … 145 145 }; 146 146 147 Game(Game&); // don't mess with singletons 147 // non-copyable: 148 Game(const Game&) = delete; 149 Game& operator=(const Game&) = delete; 148 150 149 151 void loadGraphics(); 150 152 void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); 151 153 152 void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it,shared_ptr<GameStateTreeNode> currentNode);154 void parseStates(std::vector<std::pair<std::string, int>>::const_iterator& it, std::shared_ptr<GameStateTreeNode> currentNode); 153 155 bool checkState(const std::string& name) const; 154 156 void loadState(const std::string& name);
Note: See TracChangeset
for help on using the changeset viewer.