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