ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos::CComposableEntity Class Reference

Basic class for an entity that contains other entities. More...

#include <composable_entity.h>

+ Inheritance diagram for argos::CComposableEntity:

List of all members.

Public Member Functions

 ENABLE_VTABLE ()
 CComposableEntity (CComposableEntity *pc_parent)
 Class constructor.
 CComposableEntity (CComposableEntity *pc_parent, const std::string &str_id)
 Class constructor.
virtual ~CComposableEntity ()
 Class destructor.
virtual void Reset ()
 Resets the state of the entity to whatever it was after Init() or the standalone constructor was called.
virtual void Update ()
 Updates the status of this entity.
virtual std::string GetTypeDescription () const
 Returns a string label for this class.
virtual void SetEnabled (bool b_enabled)
 Enables or disables an entity.
virtual void UpdateComponents ()
 Calls the Update() method on all the components.
void AddComponent (CEntity &c_component)
 Adds a component to this composable entity.
CEntityRemoveComponent (const std::string &str_component)
 Removes a component from this composable entity.
CEntityGetComponent (const std::string &str_component)
 Returns the component with the passed string label.
template<class E >
E & GetComponent (const std::string &str_component)
 Returns the component with the passed string label.
bool HasComponent (const std::string &str_component)
 Returns true if this composable entity has a component with the given string label.
CEntity::TMultiMap::iterator FindComponent (const std::string &str_component)
 Searches for a component with the given string label.
CEntity::TMultiMapGetComponentMap ()
 Returns the map of all the components.
CEntity::TVectorGetComponentVector ()
 Returns the vector of all the components.

Detailed Description

Basic class for an entity that contains other entities.

Robots, as well as other complex objects, must extend this class. When you add robots, make sure to add the robot body (CEmbodiedEntity class) first, and its controllable component (CControllableEntity class) last.

See also:
CEntity

Definition at line 32 of file composable_entity.h.


Constructor & Destructor Documentation

Class constructor.

This constructor is meant to be used with the Init() method.

Parameters:
pc_parentThe parent of this entity.

Definition at line 16 of file composable_entity.cpp.

argos::CComposableEntity::CComposableEntity ( CComposableEntity pc_parent,
const std::string &  str_id 
)

Class constructor.

This constructor is meant to be standalone. You should not call Init() after using this constructor, or memory leaks are likely to happen.

Parameters:
pc_parentThe parent of this entity.
str_idThe id of this entity.

Definition at line 22 of file composable_entity.cpp.

virtual argos::CComposableEntity::~CComposableEntity ( ) [inline, virtual]

Class destructor.

Definition at line 61 of file composable_entity.h.


Member Function Documentation

Adds a component to this composable entity.

Parameters:
c_componentThe component to add.

Definition at line 72 of file composable_entity.cpp.

CEntity::TMultiMap::iterator argos::CComposableEntity::FindComponent ( const std::string &  str_component)

Searches for a component with the given string label.

The format of the label can be either label or label[label_N] to get the N+1-th component with the wanted string label.

Parameters:
str_componentThe string label of the component to find.
Returns:
An iterator to the component found.
Exceptions:
CARGoSExceptionif the component was not found.

Definition at line 181 of file composable_entity.cpp.

CEntity & argos::CComposableEntity::GetComponent ( const std::string &  str_component)

Returns the component with the passed string label.

The format of the label can be either label, label1.label2 or label1.label2[label2_N] to get the N+1-th component with the wanted string label. The dot syntax label1.label2 can be nested further, to create combinations such as label1.label2.label3[label3_N].

Parameters:
str_componentThe string label of the component to return.
See also:
GetTypeDescription()
Exceptions:
CARGoSExceptionif the component was not found.

Definition at line 109 of file composable_entity.cpp.

template<class E >
E& argos::CComposableEntity::GetComponent ( const std::string &  str_component) [inline]

Returns the component with the passed string label.

This method internally performs a dynamic_cast and returns directly the desired type instead of CEntity. The format of the label can be either label, label1.label2 or label1.label2[label2_N] to get the N+1-th component with the wanted string label. The dot syntax label1.label2 can be nested further, to create combinations such as label1.label2.label3[label3_N].

Parameters:
str_componentThe string label of the component to return.
See also:
GetTypeDescription()
Exceptions:
CARGoSExceptionif the component was not found or can't be cast to the target type.

Definition at line 136 of file composable_entity.h.

Returns the map of all the components.

Returns:
The map of all the components.

Definition at line 172 of file composable_entity.h.

Returns the vector of all the components.

The elements in this vector are stored in the same order as they were inserted.

Returns:
The vector of all the components.

Definition at line 181 of file composable_entity.h.

virtual std::string argos::CComposableEntity::GetTypeDescription ( ) const [inline, virtual]

Returns a string label for this class.

Returns:
A string label for this class.

Reimplemented from argos::CEntity.

Reimplemented in argos::CLEDEquippedEntity, argos::CFootBotEntity, argos::CEPuckEntity, argos::CCylinderEntity, and argos::CBoxEntity.

Definition at line 77 of file composable_entity.h.

bool argos::CComposableEntity::HasComponent ( const std::string &  str_component)

Returns true if this composable entity has a component with the given string label.

The format of the label can be either label, label1.label2 or label1.label2[label2_N] to get the N+1-th component with the wanted string label. The dot syntax label1.label2 can be nested further, to create combinations such as label1.label2.label3[label3_N].

Parameters:
str_componentThe string label of the component to check.
Returns:
true if this composable entity has a component with the given string label.
See also:
GetTypeDescription()

Definition at line 148 of file composable_entity.cpp.

CEntity & argos::CComposableEntity::RemoveComponent ( const std::string &  str_component)

Removes a component from this composable entity.

The format of the label can be either label or label[label_N] to get the N+1-th component with the wanted string label.

Parameters:
str_componentThe string label of the component to remove.
See also:
GetTypeDescription()
Exceptions:
CARGoSExceptionif the component was not found.

Definition at line 83 of file composable_entity.cpp.

void argos::CComposableEntity::Reset ( ) [virtual]

Resets the state of the entity to whatever it was after Init() or the standalone constructor was called.

Internally calls Reset() for all the component entities.

Reimplemented from argos::CEntity.

Reimplemented in argos::CLEDEquippedEntity, argos::CFootBotEntity, argos::CCylinderEntity, argos::CEPuckEntity, and argos::CBoxEntity.

Definition at line 29 of file composable_entity.cpp.

void argos::CComposableEntity::SetEnabled ( bool  b_enabled) [virtual]

Enables or disables an entity.

Parameters:
b_enabledtrue if the entity is enabled, false otherwise
See also:
CEntity::m_bEnabled
CEntity::m_bCanBeEnabledIfDisabled

Reimplemented from argos::CEntity.

Definition at line 47 of file composable_entity.cpp.

Updates the status of this entity.

Internally calls UpdateComponents(). If you plan to overload this method, don't forget to call CComposableEntity::Update() or UpdateComponents() in your code.

See also:
UpdateComponents()

Reimplemented from argos::CEntity.

Reimplemented in argos::CLEDEquippedEntity.

Definition at line 40 of file composable_entity.cpp.

Calls the Update() method on all the components.

See also:
Update()

Reimplemented in argos::CLEDEquippedEntity, argos::CFootBotEntity, and argos::CEPuckEntity.

Definition at line 59 of file composable_entity.cpp.


The documentation for this class was generated from the following files: