Пример #1
0
/* BEGIN FUNCTION DEFINITION */
void Router::disconnectFrom( Router &r) {
  if ( is_neighbour( &r ) )  //check that they are neighbours!!
    {
      delete_routes_starting( r.getAddress() );
      r.delete_routes_starting( address );
      //delete each other from neighbours list
      delete_neighbour( &r );
      r.delete_neighbour( this );
      // tell neighbours about lost connection
      tell_neighbours_to_remove( address, r.getAddress() );
      r.tell_neighbours_to_remove( address, r.getAddress() );
    }
  else
    cout << "Router " << address << " and Router " << r.getAddress()
	 << " are not directly connected so this disconnection is forbidden!\n" << endl;
}
Пример #2
0
/* BEGIN FUNCTION DEFINITION */
void Router::connectTo( Router& r ) {
  //check they aren't already connected
  if ( ! is_neighbour(  &r ) && &r != this )
    {
      neighbours.push_back( &r );
      r.neighbours.push_back( this );
      pass_all_routes_to( &r );
      r.pass_all_routes_to( this );
    }
  else
    cout << "Router with address: " << r.getAddress()
	 << " is already connected to Router: " << this->address 
	 << endl << endl;
      
}