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 MetaModel;
00047 class IPather;
00048 class Object;
00049
00053 class Model: public FifeClass {
00054 public:
00055
00059 Model(RenderBackend* renderbackend, const std::vector<RendererBase*>& renderers);
00060
00064 ~Model();
00065
00069 Map* createMap(const std::string& identifier);
00070
00073 void deleteMap(Map*);
00074
00077 const std::list<Map*>& getMaps() const { return m_maps; }
00078
00083 Map* getMap(const std::string& identifier) const;
00084
00087 uint32_t getMapCount() const;
00088
00091 void deleteMaps();
00092
00095 std::list<std::string> getNamespaces() const;
00096
00103 Object* createObject(const std::string& identifier, const std::string& name_space, Object* parent=0);
00104
00108 bool deleteObject(Object*);
00109
00113 bool deleteObjects();
00114
00117 Object* getObject(const std::string& id, const std::string& name_space);
00118
00121 std::list<Object*> getObjects(const std::string& name_space) const;
00122
00125 void adoptPather(IPather* pather);
00126
00129 IPather* getPather(const std::string& pathername);
00130
00133 void adoptCellGrid(CellGrid* grid);
00134
00137 CellGrid* getCellGrid(const std::string& gridtype);
00138
00141 void update();
00142
00147 void setTimeMultiplier(float multip) { m_timeprovider.setMultiplier(multip); }
00148
00151 double getTimeMultiplier() const { return m_timeprovider.getMultiplier(); }
00152
00153 private:
00154
00155 std::list<Map*> m_maps;
00156
00157 typedef std::map<std::string,Object*> objectmap_t;
00158 typedef std::pair<std::string,objectmap_t> namespace_t;
00159 std::list<namespace_t> m_namespaces;
00160
00162 namespace_t* m_last_namespace;
00163
00165 namespace_t* selectNamespace(const std::string& name_space);
00166
00168 const namespace_t* selectNamespace(const std::string& name_space) const;
00169
00170 std::vector<IPather*> m_pathers;
00171 std::vector<CellGrid*> m_created_grids;
00172 std::vector<CellGrid*> m_adopted_grids;
00173
00174 TimeProvider m_timeprovider;
00175
00176 RenderBackend* m_renderbackend;
00177
00178 std::vector<RendererBase*> m_renderers;
00179 };
00180
00181 };
00182 #endif