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