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