// Updates the state of the neighbor with the parameterized ID,
// returning true if successful, false otherwise.
bool Neighborhood::updateNbr(const int id, const State &s)
{
    Neighbor *nbr = nbrWithID(id);
    if (nbr == NULL)
        return false;
    return updateNbr(*nbr, s);
}
Exemple #2
0
//
// bool processPacket(p)
// Last modified: 22Dec2006
//
// Attempts to process the parameterized packet,
// returning true if successful, false otherwise.
//
// Returns:     true if successful, false otherwise
// Parameters:
//      p       in/out      the packet to be processed
//
bool Cell::processPacket(Packet &p)
{
    bool success = false;
    if ((p.fromOperator()) && (p.type == CHANGE_FORMATION))
        success  = changeFormation(*((Formation *)p.msg));
    else if ((isNbr(p.fromID)) || (p.fromBroadcast()))
        switch(p.type)
        {
            case STATE:
                success = (p.msg == NULL) ?
                    false : updateNbr(p.fromID, *((State *)p.msg));
                delete (State *)p.msg;
                p.msg   = NULL;
                break;
            default: break;
        }
    return success;
}   // processPacket(Packet &)