CTagEntity& CTagEquippedEntity::GetTag(UInt32 un_index) { ARGOS_ASSERT(un_index < m_vecInstances.size(), "CTagEquippedEntity::GetTag(), id=\"" << GetContext() << GetId() << "\": index out of bounds: un_index = " << un_index << ", m_vecInstances.size() = " << m_vecInstances.size()); return m_vecInstances[un_index].Tag; }
const CDirectionalLEDEntity& CDirectionalLEDEquippedEntity::GetLED(UInt32 un_index) const { ARGOS_ASSERT(un_index < m_vecInstances.size(), "CLEDEquippedEntity::GetLED(), id=\"" << GetContext() + GetId() << "\": index out of bounds: un_index = " << un_index << ", m_vecInstances.size() = " << m_vecInstances.size()); return m_vecInstances[un_index].LED; }
void CTagEquippedEntity::SetTagPayload(UInt32 un_index, const std::string& str_payload) { ARGOS_ASSERT(un_index < m_vecInstances.size(), "CTagEquippedEntity::SetTagPayload(), id=\"" << GetContext() << GetId() << "\": index out of bounds: un_index = " << un_index << ", m_vecInstances.size() = " << m_vecInstances.size()); m_vecInstances[un_index].Tag.SetPayload(str_payload); }
void CDirectionalLEDEquippedEntity::SetLEDColor(UInt32 un_index, const CColor& c_color) { ARGOS_ASSERT(un_index < m_vecInstances.size(), "CLEDEquippedEntity::SetLEDColor(), id=\"" << GetContext() + GetId() << "\": index out of bounds: un_index = " << un_index << ", m_vecInstances.size() = " << m_vecInstances.size()); m_vecInstances[un_index].LED.SetColor(c_color); }
template <class T> void AssignController(T& c_entity) { /* Get a reference to the controllable entity */ CControllableEntity& cControllableEntity = c_entity.GetControllableEntity(); /* Look for the controller with the right id in the XML */ TConfigurationNode tControllersTree; tControllersTree = GetNode(CSimulator::GetInstance().GetConfigurationRoot(), "controllers"); bool found = false; TConfigurationNodeIterator itControllers; std::string strControllerId; itControllers = itControllers.begin(&tControllersTree); while(!found && itControllers != itControllers.end()) { GetNodeAttribute(*itControllers, "id", strControllerId); if(strControllerId == cControllableEntity.GetControllerId()) { found = true; } else { ++itControllers; } } /* Did we find the controller? */ ARGOS_ASSERT(found, "[FATAL] The entity \"" << c_entity.GetId() << "\" has been associated with a controller with id \"" << cControllableEntity.GetControllerId() << "\", but a controller with this id wasn't found in the <controllers> section of the XML file."); /* Now itControllers points to the right controller subtree */ /* Get the parameters subtree */ TConfigurationNode tControllerParameters; tControllerParameters = GetNode(*itControllers, "parameters"); /* Create the controller */ CCI_Controller* pcController = CSimulator::GetInstance(). GetDynamicLinkingManager(). NewController(c_entity, cControllableEntity.GetControllerId(), tControllerParameters); /* Set the controller to the entity */ cControllableEntity.SetController(*pcController); }