49 m_last_namespace(NULL),
51 m_renderbackend(renderbackend),
52 m_renderers(renderers){
65 std::list<Map*>::const_iterator it =
m_maps.begin();
66 for(; it !=
m_maps.end(); ++it) {
67 if(identifier == (*it)->getId()) {
68 throw NameClash(identifier);
82 std::vector<IPather*>::const_iterator it =
m_pathers.begin();
84 if ((*it)->getName() == pathername) {
88 FL_WARN(
_log,
"No pather of requested type \"" + pathername +
"\" found.");
99 if ((*it)->getType() == gridtype) {
105 FL_WARN(
_log,
"No cellgrid of requested type \"" + gridtype +
"\" found.");
111 std::list<Map*>::const_iterator it =
m_maps.begin();
112 for(; it !=
m_maps.end(); ++it) {
113 if((*it)->getId() == identifier)
117 throw NotFound(std::string(
"Tried to get non-existent map: ") + identifier +
".");
121 std::list<Map*>::iterator it =
m_maps.begin();
122 for(; it !=
m_maps.end(); ++it) {
141 std::list<std::string> namespace_list;
142 std::list<namespace_t>::const_iterator nspace =
m_namespaces.begin();
144 namespace_list.push_back(nspace->first);
146 return namespace_list;
158 objectmap_t::const_iterator it = nspace->second.find(identifier);
159 if( it != nspace->second.end() ) {
160 throw NameClash(identifier);
164 Object*
object =
new Object(identifier, name_space, parent);
165 nspace->second[identifier] = object;
173 std::list<Layer*>::const_iterator jt;
174 std::vector<Instance*>::const_iterator kt;
175 for(std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
176 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
177 for(kt = (*jt)->getInstances().begin(); kt != (*jt)->getInstances().end(); ++kt) {
178 Object* o = (*kt)->getObject();
192 objectmap_t::iterator it = nspace->second.find(object->
getId());
193 if( it != nspace->second.end()) {
195 nspace->second.erase(it);
203 std::list<Layer*>::const_iterator jt;
204 for(std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
205 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
206 if((*jt)->hasInstances())
212 std::list<namespace_t>::iterator nspace =
m_namespaces.begin();
214 objectmap_t::iterator it = nspace->second.begin();
215 for(; it != nspace->second.end(); ++it) {
227 objectmap_t::iterator it = nspace->second.find(
id);
228 if( it != nspace->second.end() )
235 std::list<Object*> object_list;
238 objectmap_t::const_iterator it = nspace->second.begin();
239 for(; it != nspace->second.end(); ++it )
240 object_list.push_back(it->second);
247 std::list<namespace_t>::const_iterator nspace =
m_namespaces.begin();
249 if( nspace->first == name_space ) {
260 std::list<namespace_t>::iterator nspace =
m_namespaces.begin();
262 if( nspace->first == name_space ) {
272 std::list<Map*>::iterator it =
m_maps.begin();
273 for(; it !=
m_maps.end(); ++it) {
276 std::vector<IPather*>::iterator jt =
m_pathers.begin();
std::list< std::string > getNamespaces() const
Get a list of namespaces currently referenced by objects in the metamodel.
#define FL_WARN(logger, msg)
Abstract interface for all the renderbackends.
Map * getMap(const std::string &identifier) const
Get a map.
void adoptCellGrid(CellGrid *grid)
Adds cellgrid to model.
std::vector< CellGrid * > m_adopted_grids
RenderBackend * m_renderbackend
bool deleteObjects()
Attempt to remove all objects from the model Fails and returns false if any maps with instances are p...
namespace_t * m_last_namespace
Used to remember last 'selected' namespace.
const std::string & getNamespace() const
const std::string & getId() const
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.
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
std::list< namespace_t > m_namespaces
void deleteMaps()
Removes all maps from this model.
uint32_t getMapCount() const
Return the number of maps in this model.
std::list< Map * > m_maps
CellGrid * getCellGrid(const std::string &gridtype)
Returns new copy of cellgrid corresponding given name.
Model(RenderBackend *renderbackend, const std::vector< RendererBase * > &renderers)
Constructor.
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 ...
std::vector< CellGrid * > m_created_grids
std::map< std::string, Object * > objectmap_t
std::list< Object * > getObjects(const std::string &name_space) const
Get all the objects in the given namespace.
Map * createMap(const std::string &identifier)
Add a map this model, and get a pointer to it.