blob: 6ef9c0b00f51e284c4caae69602e5ff0986ebfbb [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#include<iostream>
2#include<string>
3#include<cmath>
4#include<limits>
akmhoque298385a2014-02-13 14:13:09 -06005#include "nlsr_adjacent.hpp"
akmhoque05d5fcf2014-04-15 14:58:45 -05006#include "utility/nlsr_logger.hpp"
7
8#define THIS_FILE "nlsr_adjacent.cpp"
akmhoque298385a2014-02-13 14:13:09 -06009
akmhoque1fd8c1e2014-02-19 19:41:49 -060010namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -060011{
akmhoque298385a2014-02-13 14:13:09 -060012
akmhoque5a44dd42014-03-12 18:11:32 -050013 using namespace std;
akmhoque1fd8c1e2014-02-19 19:41:49 -060014
akmhoque5a44dd42014-03-12 18:11:32 -050015 Adjacent::Adjacent(const string& an, int cf, double lc, int s, int iton)
16 {
akmhoque05d5fcf2014-04-15 14:58:45 -050017 m_name=an;
18 m_connectingFace=cf;
19 m_linkCost=lc;
20 m_status=s;
21 m_interestTimedOutNo=iton;
akmhoque5a44dd42014-03-12 18:11:32 -050022 }
akmhoque1fd8c1e2014-02-19 19:41:49 -060023
akmhoque5a44dd42014-03-12 18:11:32 -050024 bool
akmhoque05d5fcf2014-04-15 14:58:45 -050025 Adjacent::isEqual(Adjacent& adj)
akmhoque5a44dd42014-03-12 18:11:32 -050026 {
akmhoque05d5fcf2014-04-15 14:58:45 -050027 return ( m_name == adj.getName() ) &&
28 ( m_connectingFace == adj.getConnectingFace() ) &&
29 (std::abs(m_linkCost - adj.getLinkCost()) <
akmhoque5a44dd42014-03-12 18:11:32 -050030 std::numeric_limits<double>::epsilon()) ;
31 }
akmhoque1fd8c1e2014-02-19 19:41:49 -060032
akmhoque5a44dd42014-03-12 18:11:32 -050033 std::ostream&
34 operator << (std::ostream &os, Adjacent &adj)
35 {
akmhoque05d5fcf2014-04-15 14:58:45 -050036 cout<<"Adjacent : "<< adj.getName() << endl;
akmhoque5a44dd42014-03-12 18:11:32 -050037 cout<<"Connecting Face: "<<adj.getConnectingFace()<<endl;
38 cout<<"Link Cost: "<<adj.getLinkCost()<<endl;
39 cout<<"Status: "<<adj.getStatus()<<endl;
40 cout<<"Interest Timed out: "<<adj.getInterestTimedOutNo()<<endl;
41 return os;
42 }
akmhoqueb1710aa2014-02-19 17:13:36 -060043
44} //namespace nlsr