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