FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
model.h
1 /***************************************************************************
2  * Copyright (C) 2006-2011 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_MODEL_H
23 #define FIFE_MODEL_H
24 
25 // Standard C++ library includes
26 #include <list>
27 #include <map>
28 #include <vector>
29 #include <utility>
30 
31 // 3rd party library includes
32 
33 // FIFE includes
34 // These includes are split up in two parts, separated by one empty line
35 // First block: files included from the FIFE root src directory
36 // Second block: files included from the same folder
37 #include "util/base/fifeclass.h"
38 
39 #include "model/structures/map.h"
40 #include "model/metamodel/timeprovider.h"
41 
42 namespace FIFE {
43 
44  class RenderBackend;
45  class RendererBase;
46  class MetaModel;
47  class IPather;
48  class Object;
49 
53  class Model: public FifeClass {
54  public:
55 
59  Model(RenderBackend* renderbackend, const std::vector<RendererBase*>& renderers);
60 
64  ~Model();
65 
69  Map* createMap(const std::string& identifier);
70 
73  void deleteMap(Map*);
74 
77  const std::list<Map*>& getMaps() const { return m_maps; }
78 
83  Map* getMap(const std::string& identifier) const;
84 
87  uint32_t getMapCount() const;
88 
91  void deleteMaps();
92 
95  std::list<std::string> getNamespaces() const;
96 
103  Object* createObject(const std::string& identifier, const std::string& name_space, Object* parent=0);
104 
108  bool deleteObject(Object*);
109 
113  bool deleteObjects();
114 
117  Object* getObject(const std::string& id, const std::string& name_space);
118 
121  std::list<Object*> getObjects(const std::string& name_space) const;
122 
125  void adoptPather(IPather* pather);
126 
129  IPather* getPather(const std::string& pathername);
130 
133  void adoptCellGrid(CellGrid* grid);
134 
137  CellGrid* getCellGrid(const std::string& gridtype);
138 
141  void update();
142 
147  void setTimeMultiplier(float multip) { m_timeprovider.setMultiplier(multip); }
148 
151  double getTimeMultiplier() const { return m_timeprovider.getMultiplier(); }
152 
153  private:
154 
155  std::list<Map*> m_maps;
156 
157  typedef std::map<std::string,Object*> objectmap_t;
158  typedef std::pair<std::string,objectmap_t> namespace_t;
159  std::list<namespace_t> m_namespaces;
160 
162  namespace_t* m_last_namespace;
163 
165  namespace_t* selectNamespace(const std::string& name_space);
166 
168  const namespace_t* selectNamespace(const std::string& name_space) const;
169 
170  std::vector<IPather*> m_pathers;
171  std::vector<CellGrid*> m_created_grids;
172  std::vector<CellGrid*> m_adopted_grids;
173  //std::vector<CellGrid*> m_created_grids;
174  TimeProvider m_timeprovider;
175 
176  RenderBackend* m_renderbackend;
177 
178  std::vector<RendererBase*> m_renderers;
179  };
180 
181 }; //FIFE
182 #endif
std::list< std::string > getNamespaces() const
Definition: model.cpp:140
Map * getMap(const std::string &identifier) const
Definition: model.cpp:110
double getTimeMultiplier() const
Definition: model.h:151
void adoptCellGrid(CellGrid *grid)
Definition: model.cpp:92
void setMultiplier(float multiplier)
bool deleteObjects()
Definition: model.cpp:201
const std::list< Map * > & getMaps() const
Definition: model.h:77
Object * createObject(const std::string &identifier, const std::string &name_space, Object *parent=0)
Definition: model.cpp:149
void update()
Definition: model.cpp:271
void setTimeMultiplier(float multip)
Definition: model.h:147
float getMultiplier() const
void deleteMaps()
Definition: model.cpp:135
uint32_t getMapCount() const
Definition: model.cpp:131
CellGrid * getCellGrid(const std::string &gridtype)
Definition: model.cpp:96
Model(RenderBackend *renderbackend, const std::vector< RendererBase * > &renderers)
Definition: model.cpp:47
void deleteMap(Map *)
Definition: model.cpp:120
IPather * getPather(const std::string &pathername)
Definition: model.cpp:81
void adoptPather(IPather *pather)
Definition: model.cpp:77
Object * getObject(const std::string &id, const std::string &name_space)
Definition: model.cpp:224
bool deleteObject(Object *)
Definition: model.cpp:169
Definition: map.h:86
std::list< Object * > getObjects(const std::string &name_space) const
Definition: model.cpp:234
Map * createMap(const std::string &identifier)
Definition: model.cpp:64