// // 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 &)
// Returns true if the parameterized neighbor // is in this neighborhood, false otherwise. bool Neighborhood::isNbr(const Neighbor n) { return isNbr(n.ID); }