blob: 94dceee9a866789840558f17ca598e547e9fbb2d [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#include <iostream>
2#include <string>
3#include <cmath>
4#include <limits>
akmhoquec8a10f72014-04-25 18:42:55 -05005
akmhoquefdbddb12014-05-02 18:35:19 -05006
akmhoque53353462014-04-22 08:43:45 -05007#include "adjacent.hpp"
8
9namespace nlsr {
10
11using namespace std;
12
akmhoque31d1d4b2014-05-05 22:08:14 -050013Adjacent::Adjacent(const ndn::Name& an, uint32_t cf, double lc, uint32_t s,
14 uint32_t iton)
akmhoque53353462014-04-22 08:43:45 -050015{
16 m_name = an;
17 m_connectingFace = cf;
18 m_linkCost = lc;
19 m_status = s;
20 m_interestTimedOutNo = iton;
21}
22
23bool
akmhoquefdbddb12014-05-02 18:35:19 -050024Adjacent::operator==(const Adjacent& adjacent) const
akmhoque53353462014-04-22 08:43:45 -050025{
akmhoquefdbddb12014-05-02 18:35:19 -050026 return (m_name == adjacent.getName()) &&
27 (m_connectingFace == adjacent.getConnectingFace()) &&
28 (std::abs(m_linkCost - adjacent.getLinkCost()) <
akmhoque53353462014-04-22 08:43:45 -050029 std::numeric_limits<double>::epsilon()) ;
30}
31
akmhoquefdbddb12014-05-02 18:35:19 -050032bool
akmhoque31d1d4b2014-05-05 22:08:14 -050033Adjacent::compare(const ndn::Name& adjacencyName)
akmhoque53353462014-04-22 08:43:45 -050034{
akmhoque31d1d4b2014-05-05 22:08:14 -050035 return m_name == adjacencyName;
akmhoquefdbddb12014-05-02 18:35:19 -050036}
37
38std::ostream&
39operator<<(std::ostream& os, const Adjacent& adj)
40{
41 os << "Adjacent : " << adj.getName() << endl;
akmhoque53353462014-04-22 08:43:45 -050042 os << "Connecting Face: " << adj.getConnectingFace() << endl;
43 os << "Link Cost: " << adj.getLinkCost() << endl;
44 os << "Status: " << adj.getStatus() << endl;
45 os << "Interest Timed out: " << adj.getInterestTimedOutNo() << endl;
46 return os;
47}
48
49} //namespace nlsr