#include <iostream>

#include "nlsr_nhl.hpp"
#include "nlsr_nexthop.hpp"

using namespace std;

static bool
nexthopCompare(NextHop& nh1, NextHop& nh2){
	return nh1.getConnectingFace()==nh2.getConnectingFace();
}

/** 
Add next hop to the Next Hop list
If next hop is new it is added
If next hop already exists in next
hop list then updates the route
cost with new next hop's route cost
*/

void
Nhl::addNextHop(NextHop& nh)
{
	std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(), 
									nexthopList.end(),	
   								bind(&nexthopCompare, _1, nh));
	if ( it == nexthopList.end() ){
		nexthopList.push_back(nh);
	}

	(*it).setRouteCost(nh.getRouteCost());
}


ostream&
operator<<(ostream& os, Nhl& nhl)
{
	std::list< NextHop > nexthopList = nhl.getNextHopList();
	int i=1;
	for( std::list<NextHop>::iterator it=nexthopList.begin(); 
	                                            it!= nexthopList.end() ; it++,i++)
	{
		os << "Nexthop "<<i<<": "<<(*it)<<endl;
	}
	return os;
}
