Ejemplo n.º 1
0
/* Purpose:  To remove a component according to user input
 *     Pre:  Current layer exists,
 *           stringstream with x position and y position
 *    Post:  Removes component at given position
 *  Author:  Matthew James Harrison
 ******************************************************************************/
void removeComponent(Layer &layer, StartingList &startingList, stringstream &ss)
{
    string    data         = "";
    int       xPos         = -1;
    int       yPos         = -1;

    /* Get command data */
    xPos = readNumber(ss);
    yPos = readNumber(ss);

    /* If no junk data */
    if (!hasJunk(ss))
    {
        /* If type and position are valid */
        if (isPosition(layer, xPos, yPos))
        {
            removeComponent(layer, startingList, xPos, yPos);
        }
        else
        {
            displayMessage(MSG_INV_REMOVE);
        }
    }
    else
    {
        displayMessage(MSG_INV_REMOVE);
    }
}
Ejemplo n.º 2
0
/* Purpose:  To add a component according to user input
 *     Pre:  Current layer exists,
 *           stringstream with component type, x position, and y position
 *    Post:  Adds component of given type at given position
 *  Author:  Matthew James Harrison
 ******************************************************************************/
void addComponent(Layer &layer, StartingList &startingList, stringstream &ss)
{
    string        data         = "";
    ComponentType type         = EMPTY;
    int           xPos         = -1;
    int           yPos         = -1;

    /* Get command data */
    type = readComponentType(ss);
    xPos = readNumber(ss);
    yPos = readNumber(ss);

    /* If no junk data */
    if (!hasJunk(ss))
    {
        /* If type and position are valid */
        if (isPosition(layer, xPos, yPos) && type != EMPTY)
        {
            addComponent(layer, startingList, type, xPos, yPos);
        }
        else
        {
            displayMessage(MSG_INV_ADD);
        }
    }
}
Ejemplo n.º 3
0
JointState::MODE JointState::getMode() const
{
    if (isPosition())    return POSITION;
    else if (isSpeed())  return SPEED;
    else if (isEffort()) return EFFORT;
    else if (isRaw())    return RAW;
    else if (isAcceleration())    return ACCELERATION;
    else if (hasPosition() || hasSpeed() || hasEffort() || hasRaw() || hasAcceleration())
        throw std::runtime_error("getMode() called on a JointState that has more than one field set");
    else
        return UNSET;
}