FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
A model is a facade for everything in the model. More...
#include <model.h>
Public Member Functions | |
Model (RenderBackend *renderbackend, const std::vector< RendererBase *> &renderers) | |
Constructor. More... | |
~Model () | |
Destructor. More... | |
Map * | createMap (const std::string &identifier) |
Add a map this model, and get a pointer to it. More... | |
void | deleteMap (Map *) |
Remove a map from this model. More... | |
const std::list< Map * > & | getMaps () const |
Get all the maps in the model. More... | |
Map * | getMap (const std::string &identifier) const |
Get a map. More... | |
uint32_t | getMapCount () const |
Return the number of maps in this model. More... | |
void | deleteMaps () |
Removes all maps from this model. More... | |
uint32_t | getActiveCameraCount () const |
Return the number of enabled cameras in this model. More... | |
std::list< std::string > | getNamespaces () const |
Get a list of namespaces currently referenced by objects in the metamodel. More... | |
Object * | createObject (const std::string &identifier, const std::string &name_space, Object *parent=0) |
Add an object to the metamodel. More... | |
bool | deleteObject (Object *) |
Attempt to remove an object from the model Fails and returns false if the object is referenced by an instance. More... | |
bool | deleteObjects () |
Attempt to remove all objects from the model Fails and returns false if any maps with instances are present. More... | |
Object * | getObject (const std::string &id, const std::string &name_space) |
Get an object by its id. More... | |
std::list< Object * > | getObjects (const std::string &name_space) const |
Get all the objects in the given namespace. More... | |
void | adoptPather (IPather *pather) |
Adds pather to model. More... | |
IPather * | getPather (const std::string &pathername) |
Returns pather corresponding given name. More... | |
void | adoptCellGrid (CellGrid *grid) |
Adds cellgrid to model. More... | |
CellGrid * | getCellGrid (const std::string &gridtype) |
Returns new copy of cellgrid corresponding given name. More... | |
void | removeCellGrid (CellGrid *grid) |
Removes cellgrid from model. More... | |
void | update () |
Called periodically to update events on model. More... | |
void | setTimeMultiplier (float multip) |
Sets speed for the model. More... | |
double | getTimeMultiplier () const |
Gets model speed. More... | |
Public Member Functions inherited from FIFE::FifeClass | |
FifeClass () | |
virtual | ~FifeClass () |
fifeid_t | getFifeId () |
Gets unique id of this instance inside the engine. More... | |
Private Types | |
typedef std::map< std::string, Object * > | objectmap_t |
typedef std::pair< std::string, objectmap_t > | namespace_t |
Private Member Functions | |
namespace_t * | selectNamespace (const std::string &name_space) |
Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist. More... | |
const namespace_t * | selectNamespace (const std::string &name_space) const |
Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist. More... | |
Private Attributes | |
ModelMapObserver * | m_mapObserver |
std::list< Map * > | m_maps |
std::list< namespace_t > | m_namespaces |
namespace_t * | m_lastNamespace |
Used to remember last 'selected' namespace. More... | |
std::vector< IPather * > | m_pathers |
std::vector< CellGrid * > | m_createdGrids |
std::vector< CellGrid * > | m_adoptedGrids |
TimeProvider | m_timeprovider |
RenderBackend * | m_renderbackend |
std::vector< RendererBase * > | m_renderers |
|
private |
|
private |
FIFE::Model::Model | ( | RenderBackend * | renderbackend, |
const std::vector< RendererBase *> & | renderers | ||
) |
FIFE::Model::~Model | ( | ) |
Destructor.
Definition at line 78 of file model.cpp.
References m_adoptedGrids, m_createdGrids, m_mapObserver, m_maps, m_namespaces, m_pathers, purge(), and purge_map().
void FIFE::Model::adoptCellGrid | ( | CellGrid * | grid | ) |
Adds cellgrid to model.
Moves ownership to model
Definition at line 122 of file model.cpp.
References m_adoptedGrids.
Referenced by getMaps(), and FIFE::Engine::init().
void FIFE::Model::adoptPather | ( | IPather * | pather | ) |
Adds pather to model.
Moves ownership to model
Definition at line 107 of file model.cpp.
References m_pathers.
Referenced by getMaps(), and FIFE::Engine::init().
Map * FIFE::Model::createMap | ( | const std::string & | identifier | ) |
Add a map this model, and get a pointer to it.
The returned pointer is owned by the Model, so don't delete it!
Definition at line 93 of file model.cpp.
References FIFE::Map::addChangeListener(), m_mapObserver, m_maps, m_renderbackend, m_renderers, and m_timeprovider.
Referenced by FIFE::MapLoader::load().
Object * FIFE::Model::createObject | ( | const std::string & | identifier, |
const std::string & | name_space, | ||
Object * | parent = 0 |
||
) |
Add an object to the metamodel.
identifier | A string for identifying this object; must be unique for its namespace. |
name_space | A string identifying the namespace this object resides in. |
parent | Objects may optionally inherit values from a parent object. |
Definition at line 205 of file model.cpp.
References m_namespaces, and selectNamespace().
Referenced by getMaps(), and FIFE::ObjectLoader::load().
void FIFE::Model::deleteMap | ( | Map * | map | ) |
void FIFE::Model::deleteMaps | ( | ) |
Removes all maps from this model.
Definition at line 176 of file model.cpp.
References m_createdGrids, m_mapObserver, m_maps, and purge().
Referenced by getMaps().
bool FIFE::Model::deleteObject | ( | Object * | object | ) |
Attempt to remove an object from the model Fails and returns false if the object is referenced by an instance.
Definition at line 225 of file model.cpp.
References FIFE::Object::getId(), FIFE::Object::getNamespace(), m_maps, and selectNamespace().
Referenced by getMaps().
bool FIFE::Model::deleteObjects | ( | ) |
Attempt to remove all objects from the model Fails and returns false if any maps with instances are present.
Definition at line 257 of file model.cpp.
References m_lastNamespace, m_maps, and m_namespaces.
Referenced by getMaps().
uint32_t FIFE::Model::getActiveCameraCount | ( | ) | const |
Return the number of enabled cameras in this model.
Definition at line 187 of file model.cpp.
References m_maps.
Referenced by getMaps(), and FIFE::Engine::pump().
CellGrid * FIFE::Model::getCellGrid | ( | const std::string & | gridtype | ) |
Returns new copy of cellgrid corresponding given name.
If none found, returns NULL
Definition at line 126 of file model.cpp.
References FIFE::_log, FIFE::CellGrid::clone(), FL_WARN, m_adoptedGrids, and m_createdGrids.
Referenced by getMaps(), and FIFE::MapLoader::load().
Map * FIFE::Model::getMap | ( | const std::string & | identifier | ) | const |
uint32_t FIFE::Model::getMapCount | ( | ) | const |
|
inline |
Get all the maps in the model.
Definition at line 78 of file model.h.
References adoptCellGrid(), adoptPather(), createObject(), deleteMaps(), deleteObject(), deleteObjects(), getActiveCameraCount(), getCellGrid(), getMap(), getMapCount(), getNamespaces(), getObject(), getObjects(), getPather(), m_maps, removeCellGrid(), and update().
std::list< std::string > FIFE::Model::getNamespaces | ( | ) | const |
Get a list of namespaces currently referenced by objects in the metamodel.
Definition at line 196 of file model.cpp.
References m_namespaces.
Referenced by getMaps(), and FIFE::MapLoader::load().
Object * FIFE::Model::getObject | ( | const std::string & | id, |
const std::string & | name_space | ||
) |
Get an object by its id.
Returns 0 if object is not found.
Definition at line 280 of file model.cpp.
References selectNamespace().
Referenced by getMaps(), FIFE::ObjectLoader::load(), and FIFE::MapLoader::load().
std::list< Object * > FIFE::Model::getObjects | ( | const std::string & | name_space | ) | const |
Get all the objects in the given namespace.
Definition at line 290 of file model.cpp.
References selectNamespace().
Referenced by getMaps(), and FIFE::MapLoader::load().
IPather * FIFE::Model::getPather | ( | const std::string & | pathername | ) |
Returns pather corresponding given name.
If none found, returns NULL
Definition at line 111 of file model.cpp.
References FIFE::_log, FL_WARN, and m_pathers.
Referenced by getMaps(), and FIFE::ObjectLoader::load().
|
inline |
Gets model speed.
Definition at line 161 of file model.h.
References FIFE::TimeProvider::getMultiplier(), and m_timeprovider.
void FIFE::Model::removeCellGrid | ( | CellGrid * | grid | ) |
Removes cellgrid from model.
Definition at line 139 of file model.cpp.
References m_createdGrids.
Referenced by getMaps(), and FIFE::ModelMapObserver::onLayerDelete().
|
private |
Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist.
Definition at line 313 of file model.cpp.
References m_lastNamespace, and m_namespaces.
Referenced by createObject(), deleteObject(), getObject(), and getObjects().
|
private |
Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist.
Definition at line 302 of file model.cpp.
References m_namespaces.
|
inline |
Sets speed for the model.
With speed 1.0, everything runs with normal speed. With speed 2.0, clock is ticking twice as fast. With 0, everything gets paused. Negavtive values are not supported (throws NotSupported exception).
Definition at line 157 of file model.h.
References m_timeprovider, and FIFE::TimeProvider::setMultiplier().
void FIFE::Model::update | ( | ) |
|
private |
Definition at line 184 of file model.h.
Referenced by adoptCellGrid(), getCellGrid(), and ~Model().
|
private |
Definition at line 183 of file model.h.
Referenced by deleteMaps(), getCellGrid(), removeCellGrid(), and ~Model().
|
private |
Used to remember last 'selected' namespace.
Definition at line 174 of file model.h.
Referenced by deleteObjects(), and selectNamespace().
|
private |
Definition at line 165 of file model.h.
Referenced by createMap(), deleteMaps(), Model(), and ~Model().
|
private |
Definition at line 167 of file model.h.
Referenced by createMap(), deleteMap(), deleteMaps(), deleteObject(), deleteObjects(), getActiveCameraCount(), getMap(), getMapCount(), getMaps(), update(), and ~Model().
|
private |
Definition at line 171 of file model.h.
Referenced by createObject(), deleteObjects(), getNamespaces(), selectNamespace(), and ~Model().
|
private |
Definition at line 182 of file model.h.
Referenced by adoptPather(), getPather(), update(), and ~Model().
|
private |
Definition at line 188 of file model.h.
Referenced by createMap().
|
private |
Definition at line 190 of file model.h.
Referenced by createMap().
|
private |
Definition at line 186 of file model.h.
Referenced by createMap(), getTimeMultiplier(), and setTimeMultiplier().