blob: f5a2c8e34f9de9a75a22577d84e7c01e77fe4eb9 [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
akmhoquefdbddb12014-05-02 18:35:19 -050013Adjacent::Adjacent(const string& an, uint32_t cf, double lc, uint32_t s, uint32_t iton)
akmhoque53353462014-04-22 08:43:45 -050014{
15 m_name = an;
16 m_connectingFace = cf;
17 m_linkCost = lc;
18 m_status = s;
19 m_interestTimedOutNo = iton;
20}
21
22bool
akmhoquefdbddb12014-05-02 18:35:19 -050023Adjacent::operator==(const Adjacent& adjacent) const
akmhoque53353462014-04-22 08:43:45 -050024{
akmhoquefdbddb12014-05-02 18:35:19 -050025 return (m_name == adjacent.getName()) &&
26 (m_connectingFace == adjacent.getConnectingFace()) &&
27 (std::abs(m_linkCost - adjacent.getLinkCost()) <
akmhoque53353462014-04-22 08:43:45 -050028 std::numeric_limits<double>::epsilon()) ;
29}
30
akmhoquefdbddb12014-05-02 18:35:19 -050031bool
32Adjacent::compareName(const Adjacent& adjacent)
akmhoque53353462014-04-22 08:43:45 -050033{
akmhoquefdbddb12014-05-02 18:35:19 -050034 return m_name == adjacent.getName();
35}
36
37std::ostream&
38operator<<(std::ostream& os, const Adjacent& adj)
39{
40 os << "Adjacent : " << adj.getName() << endl;
akmhoque53353462014-04-22 08:43:45 -050041 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