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) {
142 std::list<Map*>::const_iterator it =
m_maps.begin();
143 for(; it !=
m_maps.end(); ++it) {
144 count += (*it)->getActiveCameraCount();
150 std::list<std::string> namespace_list;
151 std::list<namespace_t>::const_iterator nspace =
m_namespaces.begin();
153 namespace_list.push_back(nspace->first);
155 return namespace_list;
167 objectmap_t::const_iterator it = nspace->second.find(identifier);
168 if( it != nspace->second.end() ) {
169 throw NameClash(identifier);
173 Object*
object =
new Object(identifier, name_space, parent);
174 nspace->second[identifier] = object;
182 std::list<Layer*>::const_iterator jt;
183 std::vector<Instance*>::const_iterator kt;
184 for(std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
185 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
186 for(kt = (*jt)->getInstances().begin(); kt != (*jt)->getInstances().end(); ++kt) {
187 Object* o = (*kt)->getObject();
201 objectmap_t::iterator it = nspace->second.find(object->
getId());
202 if( it != nspace->second.end()) {
204 nspace->second.erase(it);
212 std::list<Layer*>::const_iterator jt;
213 for(std::list<Map*>::iterator it =
m_maps.begin(); it !=
m_maps.end(); ++it) {
214 for(jt = (*it)->getLayers().begin(); jt != (*it)->getLayers().end(); ++jt) {
215 if((*jt)->hasInstances())
221 std::list<namespace_t>::iterator nspace =
m_namespaces.begin();
223 objectmap_t::iterator it = nspace->second.begin();
224 for(; it != nspace->second.end(); ++it) {
236 objectmap_t::iterator it = nspace->second.find(
id);
237 if( it != nspace->second.end() )
244 std::list<Object*> object_list;
247 objectmap_t::const_iterator it = nspace->second.begin();
248 for(; it != nspace->second.end(); ++it )
249 object_list.push_back(it->second);
256 std::list<namespace_t>::const_iterator nspace =
m_namespaces.begin();
258 if( nspace->first == name_space ) {
269 std::list<namespace_t>::iterator nspace =
m_namespaces.begin();
271 if( nspace->first == name_space ) {
281 std::list<Map*>::iterator it =
m_maps.begin();
282 for(; it !=
m_maps.end(); ++it) {
285 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.
uint32_t getActiveCameraCount() const
Return the number of enabled cameras in this model.
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.