diff engine/core/model/model.h @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children 112fc4af772d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/engine/core/model/model.h	Sun Jun 29 18:44:17 2008 +0000
@@ -0,0 +1,143 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2008 by the FIFE team                              *
+ *   http://www.fifengine.de                                               *
+ *   This file is part of FIFE.                                            *
+ *                                                                         *
+ *   FIFE is free software; you can redistribute it and/or modify          *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
+ ***************************************************************************/
+
+#ifndef FIFE_MODEL_H
+#define FIFE_MODEL_H
+
+// Standard C++ library includes
+#include <list>
+
+// 3rd party library includes
+
+// FIFE includes
+// These includes are split up in two parts, separated by one empty line
+// First block: files included from the FIFE root src directory
+// Second block: files included from the same folder
+#include "util/base/fifeclass.h"
+
+#include "model/structures/map.h"
+#include "model/metamodel/timeprovider.h"
+
+namespace FIFE {
+
+	class MetaModel;
+	class AbstractPather;
+	class Object;
+
+	/**
+	 * A model is a facade for everything in the model.
+	 */
+	class Model: public FifeClass {
+	public:
+
+		/** Constructor
+		 *
+		 */
+		Model();
+
+		/** Destructor
+		 *
+		 */
+		~Model();
+		
+		/** Add a map this model, and get a pointer to it.
+		 * The returned pointer is owned by the Model, so don't delete it!
+		 */
+		Map* createMap(const std::string& identifier);
+
+		/** Remove a map from this model
+		 */
+		void deleteMap(Map*);
+
+		/** Get all the maps in the model.
+		 */
+		const std::list<Map*>& getMaps() const { return m_maps; }
+
+		/** Get a map.
+		 *
+		 * @param identifier the id of the map to be found.
+		 */
+		Map* getMap(const std::string& identifier) const;
+
+		/** Return the number of maps in this model
+		 */
+		size_t getNumMaps() const;
+
+		/** Remove all elevations from a map
+		 */
+		void deleteMaps();
+
+		/** Get a list of namespaces currently referenced by objects in the metamodel.
+		 */
+		std::list<std::string> getNamespaces() const;
+
+		/** Add an object to the metamodel.
+		 * 
+		 * @param identifier A string for identifying this object; must be unique for its namespace.
+		 * @param parent Objects may optionally inherit values from a parent object.
+		 * @note This object belongs to the model, so don't delete the returned pointer
+		 */
+		Object* createObject(const std::string& identifier, const std::string& name_space, Object* parent=0);
+
+		/** 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.
+		 */
+		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;
+
+		/** Adds pather to model. Moves ownership to model
+		 */
+		void adoptPather(AbstractPather* pather);
+		
+		/** Returns pather corresponding given name. If none found, returns NULL
+		 */
+		AbstractPather* getPather(const std::string& pathername);
+		
+		/** Called periodically to update events on model
+		 */
+		void update();
+		
+		/** Sets speed for the model. With speed 1.0, everything runs with normal speed.
+		 * With speed 2.0, clock is ticking twice as fast. With 0, everything gets paused.
+		 * Negavtive values are not supported (throws NotSupported exception).
+		 */
+		void setTimeMultiplier(float multip) { m_timeprovider.setMultiplier(multip); }
+		
+		/** Gets model speed. @see setTimeMultiplier.
+		 */
+		double getTimeMultiplier() const { return m_timeprovider.getMultiplier(); }
+
+	private:
+
+		std::list<Map*> m_maps;
+
+		typedef std::pair<std::string, std::list<Object*> > namespace_t;
+		std::list<namespace_t> m_namespaces;
+
+		std::vector<AbstractPather*> m_pathers;
+		TimeProvider m_timeprovider;
+	};
+
+}; //FIFE
+#endif