akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 1 | #include<iostream> |
| 2 | #include<string> |
akmhoque | 4768f89 | 2014-02-08 23:58:07 -0600 | [diff] [blame^] | 3 | #include<cmath> |
| 4 | #include<limits> |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 5 | |
akmhoque | 204e754 | 2014-01-31 16:08:25 -0600 | [diff] [blame] | 6 | #include "nlsr_adjacent.hpp" |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 7 | |
| 8 | using namespace std; |
| 9 | |
| 10 | Adjacent::Adjacent(const string& an, int cf, double lc, int s, int iton){ |
| 11 | adjacentName=an; |
| 12 | connectingFace=cf; |
| 13 | linkCost=lc; |
| 14 | status=s; |
| 15 | interestTimedOutNo=iton; |
| 16 | } |
| 17 | |
akmhoque | 4768f89 | 2014-02-08 23:58:07 -0600 | [diff] [blame^] | 18 | bool |
| 19 | Adjacent::isAdjacentEqual(Adjacent& adj) |
| 20 | { |
| 21 | return ( adjacentName == adj.getAdjacentName() ) && |
| 22 | ( connectingFace == adj.getConnectingFace() ) && |
| 23 | (std::abs(linkCost - adj.getLinkCost()) < |
| 24 | std::numeric_limits<double>::epsilon()) ; |
| 25 | } |
| 26 | |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 27 | std::ostream& |
| 28 | operator << (std::ostream &os, Adjacent &adj){ |
| 29 | cout<<"Adjacent : "<< adj.getAdjacentName() << endl; |
| 30 | cout<<"Connecting Face: "<<adj.getConnectingFace()<<endl; |
| 31 | cout<<"Link Cost: "<<adj.getLinkCost()<<endl; |
| 32 | cout<<"Status: "<<adj.getStatus()<<endl; |
| 33 | cout<<"Interest Timed out: "<<adj.getInterestTimedOutNo()<<endl; |
| 34 | return os; |
| 35 | } |