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