prototype_joint_equipped_entity.cpp
Go to the documentation of this file.
1 
8 
9 namespace argos {
10 
11  /****************************************/
12  /****************************************/
13 
15  CComposableEntity(pc_parent) {}
16 
17  /****************************************/
18  /****************************************/
19 
21  try {
22  /* Init parent */
24  /* Go through the joints */
25  TConfigurationNodeIterator itJoint("joint");
26  for(itJoint = itJoint.begin(&t_tree);
27  itJoint != itJoint.end();
28  ++itJoint) {
29  /* for each <joint/> node */
30  CPrototypeJointEntity* pcJointEntity = new CPrototypeJointEntity(this);
31  pcJointEntity->Init(*itJoint);
32  AddComponent(*pcJointEntity);
33  m_vecJoints.push_back(pcJointEntity);
34  }
35  }
36  catch(CARGoSException& ex) {
37  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize joint equipped entity \"" << GetId() << "\".", ex);
38  }
39  }
40 
41  /****************************************/
42  /****************************************/
43 
46  std::find_if(std::begin(m_vecJoints),
47  std::end(m_vecJoints),
48  [str_id] (const CPrototypeJointEntity* pc_joint) {
49  return (pc_joint->GetId() == str_id);
50  });
51  ARGOS_ASSERT(itJoint != std::end(m_vecJoints),
52  "CPrototypeJointEquippedEntity::GetJoint(), id=\"" <<
53  GetId() <<
54  "\": joint not found: str_id = " <<
55  str_id);
56  return **itJoint;
57  }
58 
59  /****************************************/
60  /****************************************/
61 
63  ARGOS_ASSERT(un_index < m_vecJoints.size(),
64  "CPrototypeJointEquippedEntity::GetJoint(), id=\"" <<
65  GetId() <<
66  "\": index out of bounds: un_index = " <<
67  un_index <<
68  ", m_vecJoints.size() = " <<
69  m_vecJoints.size());
70  return *m_vecJoints[un_index];
71  }
72 
73  /****************************************/
74  /****************************************/
75 
77 
78  /****************************************/
79  /****************************************/
80 
81 }
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
CPrototypeJointEquippedEntity(CComposableEntity *pc_parent)
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
Basic class for an entity that contains other entities.
void AddComponent(CEntity &c_component)
Adds a component to this composable entity.
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
The exception that wraps all errors in ARGoS.
std::vector< CPrototypeJointEntity * >::iterator TVectorIterator
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: entity.cpp:40
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
REGISTER_STANDARD_SPACE_OPERATIONS_ON_COMPOSABLE(CComposableEntity)
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
CPrototypeJointEntity & GetJoint(UInt32 un_index)