FIFE
|
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... | |
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 | 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... | |
![]() | |
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 | |
std::list< Map * > | m_maps |
std::list< namespace_t > | m_namespaces |
namespace_t * | m_last_namespace |
Used to remember last 'selected' namespace. More... | |
std::vector< IPather * > | m_pathers |
std::vector< CellGrid * > | m_created_grids |
std::vector< CellGrid * > | m_adopted_grids |
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 55 of file model.cpp.
References m_adopted_grids, m_created_grids, 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 92 of file model.cpp.
References m_adopted_grids.
Referenced by FIFE::Engine::init().
void FIFE::Model::adoptPather | ( | IPather * | pather | ) |
Adds pather to model.
Moves ownership to model
Definition at line 77 of file model.cpp.
References m_pathers.
Referenced by 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 64 of file model.cpp.
References 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 149 of file model.cpp.
References m_namespaces, and selectNamespace().
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Model::deleteMap | ( | Map * | map | ) |
void FIFE::Model::deleteMaps | ( | ) |
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 169 of file model.cpp.
References FIFE::Object::getId(), FIFE::Object::getNamespace(), m_maps, and selectNamespace().
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 201 of file model.cpp.
References m_last_namespace, m_maps, and m_namespaces.
CellGrid * FIFE::Model::getCellGrid | ( | const std::string & | gridtype | ) |
Returns new copy of cellgrid corresponding given name.
If none found, returns NULL
Definition at line 96 of file model.cpp.
References FIFE::_log, FIFE::CellGrid::clone(), FL_WARN, m_adopted_grids, and m_created_grids.
Referenced by FIFE::MapLoader::load().
Map * FIFE::Model::getMap | ( | const std::string & | identifier | ) | const |
uint32_t FIFE::Model::getMapCount | ( | ) | const |
Return the number of maps in this model.
Definition at line 131 of file model.cpp.
References m_maps.
Referenced by FIFE::Engine::pump().
|
inline |
std::list< std::string > FIFE::Model::getNamespaces | ( | ) | const |
Get a list of namespaces currently referenced by objects in the metamodel.
Definition at line 140 of file model.cpp.
References m_namespaces.
Referenced by 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 224 of file model.cpp.
References selectNamespace().
Referenced by FIFE::ObjectLoader::load(), FIFE::MapLoader::load(), and FIFE::AtlasLoader::parseObject().
std::list< Object * > FIFE::Model::getObjects | ( | const std::string & | name_space | ) | const |
Get all the objects in the given namespace.
Definition at line 234 of file model.cpp.
References selectNamespace().
Referenced by FIFE::MapLoader::load().
IPather * FIFE::Model::getPather | ( | const std::string & | pathername | ) |
Returns pather corresponding given name.
If none found, returns NULL
Definition at line 81 of file model.cpp.
References FIFE::_log, FL_WARN, and m_pathers.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
inline |
Gets model speed.
Definition at line 152 of file model.h.
References FIFE::TimeProvider::getMultiplier(), and m_timeprovider.
|
private |
Convenience function to retrieve a pointer to a namespace or NULL if it doesn't exist.
Definition at line 257 of file model.cpp.
References m_last_namespace, 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 246 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 148 of file model.h.
References m_timeprovider, and FIFE::TimeProvider::setMultiplier().
void FIFE::Model::update | ( | ) |
Called periodically to update events on model.
Definition at line 271 of file model.cpp.
References m_maps, and m_pathers.
Referenced by FIFE::Engine::pump().
|
private |
Definition at line 173 of file model.h.
Referenced by adoptCellGrid(), getCellGrid(), and ~Model().
|
private |
Definition at line 172 of file model.h.
Referenced by getCellGrid(), and ~Model().
|
private |
Used to remember last 'selected' namespace.
Definition at line 163 of file model.h.
Referenced by deleteObjects(), and selectNamespace().
|
private |
Definition at line 156 of file model.h.
Referenced by createMap(), deleteMap(), deleteMaps(), deleteObject(), deleteObjects(), getMap(), getMapCount(), getMaps(), update(), and ~Model().
|
private |
Definition at line 160 of file model.h.
Referenced by createObject(), deleteObjects(), getNamespaces(), selectNamespace(), and ~Model().
|
private |
Definition at line 171 of file model.h.
Referenced by adoptPather(), getPather(), update(), and ~Model().
|
private |
Definition at line 177 of file model.h.
Referenced by createMap().
|
private |
Definition at line 179 of file model.h.
Referenced by createMap().
|
private |
Definition at line 175 of file model.h.
Referenced by createMap(), getTimeMultiplier(), and setTimeMultiplier().