comparison engine/core/model/model.h @ 145:e7a431577c95

Cleaned the basic model up. Code is cleaner now and a bit faster. Some code path were never tested in depth :-( Added a 'time_to_load' attribute to XMLMapLoader, which records the seconds it took to load a map. Down from 6s to 5.6s for reio de hola. Yay!
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 09 Oct 2008 08:23:13 +0000
parents 90005975cdbb
children e496e3681855
comparison
equal deleted inserted replaced
144:d2f1e81fbe2c 145:e7a431577c95
105 /** Attempt to remove all objects from the model 105 /** Attempt to remove all objects from the model
106 * Fails and returns false if any maps with instances are present. 106 * Fails and returns false if any maps with instances are present.
107 */ 107 */
108 bool deleteObjects(); 108 bool deleteObjects();
109 109
110 /** Get an object by its id. If no namespace is specified, the namespaces are searched in order 110 /** Get an object by its id. Returns 0 if object is not found.
111 * and the first matching object is returned. Returns 0 if object is not found.
112 */ 111 */
113 Object* getObject(const std::string& id, const std::string& name_space); 112 Object* getObject(const std::string& id, const std::string& name_space);
114 113
115 /** Get all the objects in the given namespace. 114 /** Get all the objects in the given namespace.
116 */ 115 */
117 const std::list<Object*>& getObjects(const std::string& name_space) const; 116 std::list<Object*> getObjects(const std::string& name_space) const;
118 117
119 /** Adds pather to model. Moves ownership to model 118 /** Adds pather to model. Moves ownership to model
120 */ 119 */
121 void adoptPather(AbstractPather* pather); 120 void adoptPather(AbstractPather* pather);
122 121
148 147
149 private: 148 private:
150 149
151 std::list<Map*> m_maps; 150 std::list<Map*> m_maps;
152 151
153 typedef std::pair<std::string, std::list<Object*> > namespace_t; 152 typedef std::map<std::string,Object*> objectmap_t;
153 typedef std::pair<std::string,objectmap_t> namespace_t;
154 std::list<namespace_t> m_namespaces; 154 std::list<namespace_t> m_namespaces;
155
156 /// Used to remember last 'selected' namespace.
157 namespace_t* m_last_namespace;
158
159 /// Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist
160 namespace_t* selectNamespace(const std::string& name_space);
161
162 /// Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist
163 const namespace_t* selectNamespace(const std::string& name_space) const;
155 164
156 std::vector<AbstractPather*> m_pathers; 165 std::vector<AbstractPather*> m_pathers;
157 std::vector<CellGrid*> m_adopted_grids; 166 std::vector<CellGrid*> m_adopted_grids;
158 std::vector<CellGrid*> m_created_grids; 167 std::vector<CellGrid*> m_created_grids;
159 TimeProvider m_timeprovider; 168 TimeProvider m_timeprovider;