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 | |
| 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 | |
| 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 | |
| 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 | } |