70 m_lastNamespace(NULL),
72 m_renderbackend(renderbackend),
73 m_renderers(renderers){
80 for (std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
94 std::list<Map*>::const_iterator it =
m_maps.begin();
95 for(; it !=
m_maps.end(); ++it) {
96 if(identifier == (*it)->getId()) {
97 throw NameClash(identifier);
112 std::vector<IPather*>::const_iterator it =
m_pathers.begin();
114 if ((*it)->getName() == pathername) {
118 FL_WARN(
_log,
"No pather of requested type \"" + pathername +
"\" found.");
127 std::vector<CellGrid*>::const_iterator it =
m_adoptedGrids.begin();
129 if ((*it)->getType() == gridtype) {
135 FL_WARN(
_log,
"No cellgrid of requested type \"" + gridtype +
"\" found.");
152 std::list<Map*>::const_iterator it =
m_maps.begin();
153 for(; it !=
m_maps.end(); ++it) {
154 if((*it)->getId() == identifier)
158 throw NotFound(std::string(
"Tried to get non-existent map: ") + identifier +
".");
162 std::list<Map*>::iterator it =
m_maps.begin();
163 for(; it !=
m_maps.end(); ++it) {
178 for (std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
189 std::list<Map*>::const_iterator it =
m_maps.begin();
190 for(; it !=
m_maps.end(); ++it) {
191 count += (*it)->getActiveCameraCount();
197 std::list<std::string> namespace_list;
198 std::list<namespace_t>::const_iterator nspace =
m_namespaces.begin();
200 namespace_list.push_back(nspace->first);
202 return namespace_list;
214 objectmap_t::const_iterator it = nspace->second.find(identifier);
215 if( it != nspace->second.end() ) {
216 throw NameClash(identifier);
220 Object*
object =
new Object(identifier, name_space, parent);
221 nspace->second[identifier] = object;
229 std::list<Layer*>::const_iterator jt;
230 std::vector<Instance*>::const_iterator kt;
231 for(std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
232 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
233 for(kt = (*jt)->getInstances().begin(); kt != (*jt)->getInstances().end(); ++kt) {
234 Object* o = (*kt)->getObject();
248 objectmap_t::iterator it = nspace->second.find(object->
getId());
249 if( it != nspace->second.end()) {
251 nspace->second.erase(it);
259 std::list<Layer*>::const_iterator jt;
260 for(std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
261 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
262 if((*jt)->hasInstances())
268 std::list<namespace_t>::iterator nspace =
m_namespaces.begin();
270 objectmap_t::iterator it = nspace->second.begin();
271 for(; it != nspace->second.end(); ++it) {
283 objectmap_t::iterator it = nspace->second.find(
id);
284 if( it != nspace->second.end() )
291 std::list<Object*> object_list;
294 objectmap_t::const_iterator it = nspace->second.begin();
295 for(; it != nspace->second.end(); ++it )
296 object_list.push_back(it->second);
303 std::list<namespace_t>::const_iterator nspace =
m_namespaces.begin();
305 if( nspace->first == name_space ) {
316 std::list<namespace_t>::iterator nspace =
m_namespaces.begin();
318 if( nspace->first == name_space ) {
328 std::list<Map*>::iterator it =
m_maps.begin();
329 for(; it !=
m_maps.end(); ++it) {
332 std::vector<IPather*>::iterator jt =
m_pathers.begin();
#define FL_WARN(logger, msg)
Abstract interface for all the renderbackends.
uint32_t getMapCount() const
Return the number of maps in this model.
void adoptCellGrid(CellGrid *grid)
Adds cellgrid to model.
RenderBackend * m_renderbackend
bool deleteObjects()
Attempt to remove all objects from the model Fails and returns false if any maps with instances are p...
uint32_t getActiveCameraCount() const
Return the number of enabled cameras in this model.
std::list< Object * > getObjects(const std::string &name_space) const
Get all the objects in the given namespace.
ModelMapObserver(Model *model)
namespace_t * m_lastNamespace
Used to remember last 'selected' namespace.
virtual ~ModelMapObserver()
std::vector< IPather * > m_pathers
Object * createObject(const std::string &identifier, const std::string &name_space, Object *parent=0)
Add an object to the metamodel.
void addChangeListener(MapChangeListener *listener)
Adds new change listener.
Base class for all fife classes Used e.g.
void update()
Called periodically to update events on model.
static Logger _log(LM_AUDIO)
std::vector< RendererBase * > m_renderers
virtual void onLayerDelete(Map *map, Layer *layer)
Called when some layer gets deleted on map.
const std::string & getId() const
virtual void onLayerCreate(Map *map, Layer *layer)
Called when some layer gets created on the map.
std::vector< CellGrid * > m_createdGrids
std::vector< CellGrid * > m_adoptedGrids
std::list< namespace_t > m_namespaces
void deleteMaps()
Removes all maps from this model.
const std::string & getNamespace() const
void removeCellGrid(CellGrid *grid)
Removes cellgrid from model.
A model is a facade for everything in the model.
ModelMapObserver * m_mapObserver
std::list< std::string > getNamespaces() const
Get a list of namespaces currently referenced by objects in the metamodel.
Model(RenderBackend *renderbackend, const std::vector< RendererBase *> &renderers)
Constructor.
CellGrid * getCellGrid() const
Get the Cellgrid.
std::list< Map * > m_maps
CellGrid * getCellGrid(const std::string &gridtype)
Returns new copy of cellgrid corresponding given name.
virtual CellGrid * clone()=0
Returns clone of this cellgrid.
namespace_t * selectNamespace(const std::string &name_space)
Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist.
TimeProvider m_timeprovider
void deleteMap(Map *)
Remove a map from this model.
IPather * getPather(const std::string &pathername)
Returns pather corresponding given name.
void adoptPather(IPather *pather)
Adds pather to model.
std::pair< std::string, objectmap_t > namespace_t
Object * getObject(const std::string &id, const std::string &name_space)
Get an object by its id.
bool deleteObject(Object *)
Attempt to remove an object from the model Fails and returns false if the object is referenced by an ...
virtual void onMapChanged(Map *map, std::vector< Layer *> &changedLayers)
Called when some layer is changed on map.
std::map< std::string, Object * > objectmap_t
Map * getMap(const std::string &identifier) const
Get a map.
Map * createMap(const std::string &identifier)
Add a map this model, and get a pointer to it.
Listener interface for changes happening on map.