#include <space.h>
Public Types | |
typedef std::map< std::string, CAny, std::less< std::string > > | TMapPerType |
A map of entities indexed by type description. More... | |
typedef std::map< std::string, TMapPerType, std::less< std::string > > | TMapPerTypePerId |
A map of entities indexed by type description and by id. More... | |
Public Member Functions | |
CSpace () | |
Class constructor. More... | |
virtual | ~CSpace () |
Class destructor. More... | |
virtual void | Init (TConfigurationNode &t_tree) |
Initializes the space using the <arena> section of the XML configuration file. More... | |
virtual void | Reset () |
Reset the space and all its entities. More... | |
virtual void | Destroy () |
Destroys the space and all its entities. More... | |
UInt32 | GetNumberEntities () const |
Returns the number of entities contained in the space. More... | |
CEntity::TVector & | GetEntityVector () |
Returns a vector of all the entities in the space. More... | |
CEntity::TVector & | GetRootEntityVector () |
Returns a vector of all the root entities in the space. More... | |
CEntity & | GetEntity (const std::string &str_id) |
Returns the entity with the given id. More... | |
void | GetEntitiesMatching (CEntity::TVector &t_buffer, const std::string &str_pattern) |
Returns the entities matching a given pattern. More... | |
CEntity::TMap & | GetEntityMapPerId () |
Returns a map of all entities ordered by id. More... | |
TMapPerTypePerId & | GetEntityMapPerTypePerId () |
Returns a nested map of entities, ordered by type and by id. More... | |
TMapPerType & | GetEntitiesByType (const std::string &str_type) |
Returns a map containing all the objects of a given type. More... | |
CFloorEntity & | GetFloorEntity () |
Returns the floor entity. More... | |
void | SetFloorEntity (CFloorEntity &c_floor_entity) |
Sets the floor entity. More... | |
virtual void | Update () |
Updates the space. More... | |
template<typename ENTITY > | |
void | AddEntity (ENTITY &c_entity) |
Adds an entity of the given type. More... | |
template<typename ENTITY > | |
void | RemoveEntity (ENTITY &c_entity) |
Removes an entity of the given type. More... | |
UInt32 | GetSimulationClock () const |
Returns the current value of the simulation clock. More... | |
void | SetSimulationClock (UInt32 un_simulation_clock) |
Sets a new value for the simulation clock. More... | |
void | IncreaseSimulationClock (UInt32 un_increase=1) |
Increases the simulation clock by the wanted value. More... | |
const CVector3 & | GetArenaSize () const |
Returns the arena size. More... | |
void | SetArenaSize (const CVector3 &c_size) |
Sets the arena size. More... | |
const CVector3 & | GetArenaCenter () const |
Returns the arena center. More... | |
void | SetArenaCenter (const CVector3 &c_center) |
Sets the arena center. More... | |
const CRange< CVector3 > & | GetArenaLimits () const |
virtual void | AddControllableEntity (CControllableEntity &c_entity) |
virtual void | RemoveControllableEntity (CControllableEntity &c_entity) |
virtual void | AddEntityToPhysicsEngine (CEmbodiedEntity &c_entity) |
Public Member Functions inherited from argos::CBaseConfigurableResource | |
virtual | ~CBaseConfigurableResource () |
Class destructor. More... | |
Protected Member Functions | |
virtual void | UpdateControllableEntitiesAct ()=0 |
virtual void | UpdatePhysics ()=0 |
virtual void | UpdateMedia ()=0 |
virtual void | UpdateControllableEntitiesSenseStep ()=0 |
void | Distribute (TConfigurationNode &t_tree) |
void | AddBoxStrip (TConfigurationNode &t_tree) |
Protected Attributes | |
CSimulator & | m_cSimulator |
UInt32 | m_unSimulationClock |
The current simulation clock. More... | |
CVector3 | m_cArenaCenter |
Arena center. More... | |
CVector3 | m_cArenaSize |
Arena size. More... | |
CRange< CVector3 > | m_cArenaLimits |
Arena limits. More... | |
CEntity::TVector | m_vecEntities |
A vector of entities. More... | |
CEntity::TVector | m_vecRootEntities |
A vector of all the entities without a parent. More... | |
CEntity::TMap | m_mapEntitiesPerId |
A map of entities. More... | |
TMapPerTypePerId | m_mapEntitiesPerTypePerId |
A map of maps of all the simulated entities. More... | |
CControllableEntity::TVector | m_vecControllableEntities |
A vector of controllable entities. More... | |
CFloorEntity * | m_pcFloorEntity |
The floor entity. More... | |
CPhysicsEngine::TVector * | m_ptPhysicsEngines |
A pointer to the list of physics engines. More... | |
CMedium::TVector * | m_ptMedia |
A pointer to the list of media. More... | |
typedef std::map<std::string, CAny, std::less <std::string> > argos::CSpace::TMapPerType |
A map of entities indexed by type description.
This map type is particularly useful when one wants to execute operations on a specific entity type. For instance, one could want to get the list of all robots of a specific type, and execute operations for that robot.
The elements in this map are indexed by type description (the string returned by CEntity::GetTypeDescription()). The elements themselves are stored as objects of the CAny class. This is because any_cast() is faster than dynamic_cast
, and equally type-safe.
typedef std::map<std::string, TMapPerType, std::less <std::string> > argos::CSpace::TMapPerTypePerId |
A map of entities indexed by type description and by id.
This map type is particularly useful when one wants to execute operations on a specific entity type with a specific id. For instance, one could want to operate on a list of robots with a specific type and id, and execute operations for each robot.
The elements in this map are indexed by type description (the string returned by CEntity::GetTypeDescription()), and by id (the string returned by CEntity::GetId()). The elements themselves are stored as objects of the CAny class. This is because any_cast() is faster than dynamic_cast
, and equally type-safe.
|
inlinevirtual |
|
protected |
|
virtual |
Reimplemented in argos::CSpaceMultiThreadBalanceQuantity.
|
inline |
Adds an entity of the given type.
This method is used internally, don't use it in your code. throws CARGoSException if the entity id already exists in the space indexes.
|
virtual |
|
virtual |
Destroys the space and all its entities.
Implements argos::CBaseConfigurableResource.
Reimplemented in argos::CSpaceMultiThreadBalanceQuantity, and argos::CSpaceMultiThreadBalanceLength.
|
protected |
|
inline |
|
inline |
CSpace::TMapPerType & argos::CSpace::GetEntitiesByType | ( | const std::string & | str_type | ) |
Returns a map containing all the objects of a given type.
The 'type' here refers to the string returned by CEntity::GetTypeDescription(). Take this example: CSpace::TMapPerType& theMap = space.GetEntitiesByType("box"); CBoxEntity* box = any_cast<CBoxEntity*>(theMap["my_box"]); // do stuff with the box ...
str_type | The wanted type to search for. |
CARGoSException | if the given type is not valid. |
void argos::CSpace::GetEntitiesMatching | ( | CEntity::TVector & | t_buffer, |
const std::string & | str_pattern | ||
) |
Returns the entities matching a given pattern.
The pattern must be a valid regexp.
t_buffer | A vector filled with all the entities that match the given pattern. |
str_pattern | The pattern to match. |
CARGoSException | if the regexp is not valid. |
|
inline |
Returns the entity with the given id.
str_id | The id of the wanted entity |
CARGoSException | if an entity with the wanted id does not exist |
|
inline |
|
inline |
Returns a nested map of entities, ordered by type and by id.
The 'type' here refers to the string returned by CEntity::GetTypeDescription(). Take this example: CSpace::TMapPerTypePerId& theMap = space.GetEntityMapPerTypePerId(); // theMap["box"] is a CSpace::TMapPerType containing all the box entities, ordered by id // theMap["led"] is a CSpace::TMapPerType containing all the led entities, ordered by id // etc. CBoxEntity* box = any_cast<CBoxEntity*>(theMap["box"]["my_box_22"]); // do stuff with the box ...
|
inline |
Returns a vector of all the entities in the space.
All entities are returned, i.e., all the components of a robot.
|
inline |
Returns the floor entity.
CARGoSException | if the floor entity has not been added to the arena. |
|
inline |
|
inline |
Returns a vector of all the root entities in the space.
A root entity is an entity that has no parent. This method differs from GetEntityVector() in that the latter returns all entities including the components of a composable entity, while this method does not return any component, but only the parentless composables.
|
inline |
|
inline |
|
virtual |
Initializes the space using the <arena>
section of the XML configuration file.
t_tree | the <arena> section of the XML configuration file. |
Implements argos::CBaseConfigurableResource.
Reimplemented in argos::CSpaceMultiThreadBalanceQuantity, and argos::CSpaceMultiThreadBalanceLength.
|
virtual |
Reimplemented in argos::CSpaceMultiThreadBalanceQuantity.
|
inline |
Removes an entity of the given type.
This method is used internally, don't use it in your code. throws CARGoSException if the entity id does not exist in the space indexes.
|
virtual |
Reset the space and all its entities.
Implements argos::CBaseConfigurableResource.
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Updates the space.
The operations are performed in the following order:
Reimplemented in argos::CSpaceMultiThreadBalanceLength.
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protected |
|
protected |
|
protected |
|
protected |
A map of maps of all the simulated entities.
The top-level map is indexed by type, as returned by CEntity::GetTypeDescription(). The second-level maps are indexed by entity id
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |