model.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_MODEL_H
00023 #define FIFE_MODEL_H
00024
00025
00026 #include <list>
00027 #include <map>
00028 #include <vector>
00029 #include <utility>
00030
00031
00032
00033
00034
00035
00036
00037 #include "util/base/fifeclass.h"
00038
00039 #include "model/structures/map.h"
00040 #include "model/metamodel/timeprovider.h"
00041
00042 namespace FIFE {
00043
00044 class RenderBackend;
00045 class RendererBase;
00046 class ImagePool;
00047 class AnimationPool;
00048 class MetaModel;
00049 class AbstractPather;
00050 class Object;
00051
00055 class Model: public FifeClass {
00056 public:
00057
00061 Model(RenderBackend* renderbackend, const std::vector<RendererBase*>& renderers,
00062 ImagePool* imagepool, AnimationPool* animpool);
00063
00067 ~Model();
00068
00072 Map* createMap(const std::string& identifier);
00073
00076 void deleteMap(Map*);
00077
00080 const std::list<Map*>& getMaps() const { return m_maps; }
00081
00086 Map* getMap(const std::string& identifier) const;
00087
00090 uint32_t getNumMaps() const;
00091
00094 void deleteMaps();
00095
00098 std::list<std::string> getNamespaces() const;
00099
00106 Object* createObject(const std::string& identifier, const std::string& name_space, Object* parent=0);
00107
00111 bool deleteObject(Object*);
00112
00116 bool deleteObjects();
00117
00120 Object* getObject(const std::string& id, const std::string& name_space);
00121
00124 std::list<Object*> getObjects(const std::string& name_space) const;
00125
00128 void adoptPather(AbstractPather* pather);
00129
00132 AbstractPather* getPather(const std::string& pathername);
00133
00136 void adoptCellGrid(CellGrid* grid);
00137
00140 CellGrid* getCellGrid(const std::string& gridtype);
00141
00144 void update();
00145
00150 void setTimeMultiplier(float multip) { m_timeprovider.setMultiplier(multip); }
00151
00154 double getTimeMultiplier() const { return m_timeprovider.getMultiplier(); }
00155
00156 private:
00157
00158 std::list<Map*> m_maps;
00159
00160 typedef std::map<std::string,Object*> objectmap_t;
00161 typedef std::pair<std::string,objectmap_t> namespace_t;
00162 std::list<namespace_t> m_namespaces;
00163
00165 namespace_t* m_last_namespace;
00166
00168 namespace_t* selectNamespace(const std::string& name_space);
00169
00171 const namespace_t* selectNamespace(const std::string& name_space) const;
00172
00173 std::vector<AbstractPather*> m_pathers;
00174 std::vector<CellGrid*> m_adopted_grids;
00175 std::vector<CellGrid*> m_created_grids;
00176 TimeProvider m_timeprovider;
00177
00178 RenderBackend* m_renderbackend;
00179 ImagePool* m_imagepool;
00180 AnimationPool* m_animpool;
00181
00182 std::vector<RendererBase*> m_renderers;
00183 };
00184
00185 };
00186 #endif