annotate engine/core/model/model.cpp @ 422:9d94f4676d17

Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
author vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 12 Feb 2010 06:34:50 +0000
parents e7a431577c95
children ea80b41c9bd7
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
8 * License as published by the Free Software Foundation; either *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
11 * This library is distributed in the hope that it will be useful, *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
14 * Lesser General Public License for more details. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
17 * License along with this library; if not, write to the *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 35
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 // 3rd party library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 // FIFE includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // These includes are split up in two parts, separated by one empty line
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // First block: files included from the FIFE root src directory
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // Second block: files included from the same folder
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 #include "util/structures/purge.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 #include "model/metamodel/abstractpather.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 #include "model/metamodel/object.h"
33
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
33 #include "model/metamodel/grids/cellgrid.h"
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 #include "structures/map.h"
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
35 #include "structures/layer.h"
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
36 #include "structures/instance.h"
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 #include "util/base/exception.h"
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
38 #include "view/rendererbase.h"
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
39 #include "video/renderbackend.h"
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
40 #include "video/imagepool.h"
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
41 #include "video/animationpool.h"
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 #include "model.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 namespace FIFE {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
47 Model::Model(RenderBackend* renderbackend, const std::vector<RendererBase*>& renderers,
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
48 ImagePool* imagepool, AnimationPool* animpool):
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 FifeClass(),
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
50 m_last_namespace(NULL),
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
51 m_renderbackend(renderbackend),
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
52 m_renderers(renderers),
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
53 m_imagepool(imagepool),
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
54 m_animpool(animpool),
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 m_timeprovider(NULL) {
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
56
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
57 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 Model::~Model() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 purge(m_maps);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 for(std::list<namespace_t>::iterator nspace = m_namespaces.begin(); nspace != m_namespaces.end(); ++nspace)
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
62 purge_map(nspace->second);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 purge(m_pathers);
33
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
64 purge(m_created_grids);
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
65 purge(m_adopted_grids);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 Map* Model::createMap(const std::string& identifier) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 std::list<Map*>::const_iterator it = m_maps.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 for(; it != m_maps.end(); ++it) {
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
71 if(identifier == (*it)->getId()) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 throw NameClash(identifier);
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
73 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
76 Map* map = new Map(identifier, m_renderbackend, m_renderers, m_imagepool, m_animpool, &m_timeprovider);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 m_maps.push_back(map);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 return map;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 void Model::adoptPather(AbstractPather* pather) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 m_pathers.push_back(pather);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 AbstractPather* Model::getPather(const std::string& pathername) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 std::vector<AbstractPather*>::const_iterator it = m_pathers.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 for(; it != m_pathers.end(); ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 if ((*it)->getName() == pathername) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 return *it;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 return NULL;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 }
33
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
94
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
95 void Model::adoptCellGrid(CellGrid* grid) {
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
96 m_adopted_grids.push_back(grid);
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
97 }
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
98
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
99 CellGrid* Model::getCellGrid(const std::string& gridtype) {
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
100 std::vector<CellGrid*>::const_iterator it = m_adopted_grids.begin();
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
101 for(; it != m_adopted_grids.end(); ++it) {
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
102 if ((*it)->getType() == gridtype) {
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
103 CellGrid* newcg = (*it)->clone();
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
104 m_created_grids.push_back(newcg);
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
105 return newcg;
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
106 }
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
107 }
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
108 return NULL;
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
109 }
112fc4af772d moved grid ownership to model in similar way as with pathers
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
110
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 Map* Model::getMap(const std::string& identifier) const {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 std::list<Map*>::const_iterator it = m_maps.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 for(; it != m_maps.end(); ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 if((*it)->getId() == identifier)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 return *it;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118
422
9d94f4676d17 Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 145
diff changeset
119 throw NotFound(std::string("Tried to get non-existent map: ") + identifier + ".");
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 void Model::deleteMap(Map* map) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 std::list<Map*>::iterator it = m_maps.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 for(; it != m_maps.end(); ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 if(*it == map) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 delete *it;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127 m_maps.erase(it);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 return ;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 size_t Model::getNumMaps() const {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 return m_maps.size();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 void Model::deleteMaps() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 purge(m_maps);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 m_maps.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 std::list<std::string> Model::getNamespaces() const {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
143 std::list<std::string> namespace_list;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 std::list<namespace_t>::const_iterator nspace = m_namespaces.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 for(; nspace != m_namespaces.end(); ++nspace) {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
146 namespace_list.push_back(nspace->first);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 }
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
148 return namespace_list;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 Object* Model::createObject(const std::string& identifier, const std::string& name_space, Object* parent) {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
152 // Find or create namespace
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
153 namespace_t* nspace = selectNamespace(name_space);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
154 if(!nspace) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
155 m_namespaces.push_back(namespace_t(name_space,objectmap_t()));
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
156 nspace = selectNamespace(name_space);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
159 // Check for nameclashes
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
160 objectmap_t::const_iterator it = nspace->second.find(identifier);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
161 if( it != nspace->second.end() ) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
162 throw NameClash(identifier);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
165 // Finally insert & create
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 Object* object = new Object(identifier, name_space, parent);
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
167 nspace->second[identifier] = object;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 return object;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
171 bool Model::deleteObject(Object* object) {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
172 // WARNING: This code has obviously not been tested (thoroughly).
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
173
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
174 // Check if any instances exist. If yes - bail out.
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
175 std::list<Layer*>::const_iterator jt;
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
176 std::vector<Instance*>::const_iterator kt;
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
177 for(std::list<Map*>::iterator it = m_maps.begin(); it != m_maps.end(); ++it) {
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
178 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
179 for(kt = (*jt)->getInstances().begin(); kt != (*jt)->getInstances().end(); ++kt) {
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
180 Object* o = (*kt)->getObject();
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
181 if(o == object) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
182 return false;
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
183 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
184 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
185 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
186 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
187
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
188 // Check if the namespace exists
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
189 namespace_t* nspace = selectNamespace(object->getNamespace());
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
190 if(!nspace)
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
191 return true;
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
192
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
193 // If yes - delete+erase object.
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
194 objectmap_t::iterator it = nspace->second.find(object->getId());
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
195 if( it != nspace->second.end()) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
196 delete it->second;
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
197 nspace->second.erase(it);
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
198 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
199
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
200 return true;
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
201 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
202
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
203 bool Model::deleteObjects() {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
204 // If we have layers with instances - bail out.
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
205 std::list<Layer*>::const_iterator jt;
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
206 for(std::list<Map*>::iterator it = m_maps.begin(); it != m_maps.end(); ++it) {
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
207 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
208 if((*jt)->hasInstances())
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
209 return false;
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
210 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
211 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
212
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
213 // Otherwise delete every object in every namespace
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
214 std::list<namespace_t>::iterator nspace = m_namespaces.begin();
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
215 while(nspace != m_namespaces.end()) {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
216 objectmap_t::iterator it = nspace->second.begin();
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
217 for(; it != nspace->second.end(); ++it) {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
218 delete it->second;
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
219 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
220 nspace = m_namespaces.erase(nspace);
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
221 }
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
222 m_last_namespace = 0;
35
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
223 return true;
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
224 }
bf7f838e6684 Added methods for removing Objects from the Model.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 33
diff changeset
225
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 Object* Model::getObject(const std::string& id, const std::string& name_space) {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
227 namespace_t* nspace = selectNamespace(name_space);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
228 if(nspace) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
229 objectmap_t::iterator it = nspace->second.find(id);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
230 if( it != nspace->second.end() )
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
231 return it->second;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233 return 0;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
236 std::list<Object*> Model::getObjects(const std::string& name_space) const {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
237 std::list<Object*> object_list;
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
238 const namespace_t* nspace = selectNamespace(name_space);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
239 if(nspace) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
240 objectmap_t::const_iterator it = nspace->second.begin();
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
241 for(; it != nspace->second.end(); ++it )
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
242 object_list.push_back(it->second);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
243 return object_list;
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
244 }
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
245 throw NotFound(name_space);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
246 }
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
247
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
248 const Model::namespace_t* Model::selectNamespace(const std::string& name_space) const {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 std::list<namespace_t>::const_iterator nspace = m_namespaces.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 for(; nspace != m_namespaces.end(); ++nspace) {
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
251 if( nspace->first == name_space ) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
252 return &(*nspace);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
253 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 }
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
255 return 0;
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
256 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257
145
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
258 Model::namespace_t* Model::selectNamespace(const std::string& name_space) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
259 if( m_last_namespace && m_last_namespace->first == name_space )
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
260 return m_last_namespace;
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
261 std::list<namespace_t>::iterator nspace = m_namespaces.begin();
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
262 for(; nspace != m_namespaces.end(); ++nspace) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
263 if( nspace->first == name_space ) {
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
264 m_last_namespace = &(*nspace);
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
265 return m_last_namespace;
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
266 }
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
267 }
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
268 m_last_namespace = 0;
e7a431577c95 Cleaned the basic model up. Code is cleaner now and a bit faster.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
269 return 0;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 void Model::update() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 std::list<Map*>::iterator it = m_maps.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 for(; it != m_maps.end(); ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 (*it)->update();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 std::vector<AbstractPather*>::iterator jt = m_pathers.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 for(; jt != m_pathers.end(); ++jt) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 (*jt)->update();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 } //FIFE
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284