diff 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
line wrap: on
line diff
--- a/engine/core/model/model.h	Thu Oct 09 06:18:36 2008 +0000
+++ b/engine/core/model/model.h	Thu Oct 09 08:23:13 2008 +0000
@@ -107,14 +107,13 @@
 		 */
 		bool deleteObjects();
 
-		/** Get an object by its id. If no namespace is specified, the namespaces are searched in order
-		 * and the first matching object is returned. Returns 0 if object is not found.
+		/** Get an object by its id. Returns 0 if object is not found.
 		 */
 		Object* getObject(const std::string& id, const std::string& name_space);
 
 		/** Get all the objects in the given namespace.
 		 */
-		const std::list<Object*>& getObjects(const std::string& name_space) const;
+		std::list<Object*> getObjects(const std::string& name_space) const;
 
 		/** Adds pather to model. Moves ownership to model
 		 */
@@ -150,9 +149,19 @@
 
 		std::list<Map*> m_maps;
 
-		typedef std::pair<std::string, std::list<Object*> > namespace_t;
+		typedef std::map<std::string,Object*> objectmap_t;
+		typedef std::pair<std::string,objectmap_t> namespace_t;
 		std::list<namespace_t> m_namespaces;
 
+		/// Used to remember last 'selected' namespace.
+		namespace_t* m_last_namespace;
+
+		/// Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist
+		namespace_t* selectNamespace(const std::string& name_space);
+
+		/// Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist
+		const namespace_t* selectNamespace(const std::string& name_space) const;
+
 		std::vector<AbstractPather*> m_pathers;
 		std::vector<CellGrid*> m_adopted_grids;
 		std::vector<CellGrid*> m_created_grids;