blob: 0352d1da7d327bfab4c7c8d7385ec400bfc2a858 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#ifndef NLSR_MAP_HPP
2#define NLSR_MAP_HPP
3
4#include <iostream>
5#include <list>
6
7#include <ndn-cpp-dev/face.hpp>
8
akmhoque1fd8c1e2014-02-19 19:41:49 -06009namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -060010{
akmhoque298385a2014-02-13 14:13:09 -060011
akmhoque1fd8c1e2014-02-19 19:41:49 -060012 class Nlsr;
akmhoque298385a2014-02-13 14:13:09 -060013
akmhoque1fd8c1e2014-02-19 19:41:49 -060014 using namespace std;
akmhoque298385a2014-02-13 14:13:09 -060015
akmhoque1fd8c1e2014-02-19 19:41:49 -060016 class MapEntry
17 {
18 public:
19 MapEntry()
20 : router()
21 , mappingNumber(-1)
22 {
23 }
akmhoque298385a2014-02-13 14:13:09 -060024
akmhoque1fd8c1e2014-02-19 19:41:49 -060025 ~MapEntry()
26 {
27 }
akmhoque298385a2014-02-13 14:13:09 -060028
akmhoque1fd8c1e2014-02-19 19:41:49 -060029 MapEntry(string rtr, int mn)
30 {
31 router=rtr;
32 mappingNumber=mn;
33 }
akmhoque298385a2014-02-13 14:13:09 -060034
akmhoque1fd8c1e2014-02-19 19:41:49 -060035 string getRouter()
36 {
37 return router;
38 }
akmhoque298385a2014-02-13 14:13:09 -060039
akmhoque1fd8c1e2014-02-19 19:41:49 -060040 int getMappingNumber()
41 {
42 return mappingNumber;
43 }
44 private:
45 string router;
46 int mappingNumber;
47 };
akmhoque298385a2014-02-13 14:13:09 -060048
akmhoque1fd8c1e2014-02-19 19:41:49 -060049 ostream&
50 operator<<(ostream& os, MapEntry& mpe);
akmhoque298385a2014-02-13 14:13:09 -060051
akmhoque1fd8c1e2014-02-19 19:41:49 -060052 class Map
53 {
54 public:
55 Map()
56 : mappingIndex(0)
57 {
58 }
59
60
61 void addMapElement(string& rtrName);
62 void createMapFromAdjLsdb(Nlsr& pnlsr);
63 string getRouterNameByMappingNo(int mn);
64 int getMappingNoByRouterName(string& rName);
65 void resetMap();
66 std::list< MapEntry >& getMapList()
67 {
68 return rMap;
69 }
70
71 int getMapSize()
72 {
73 return rMap.size();
74 }
75
76
77 private:
78 bool addMapElement(MapEntry& mpe);
79
80 int mappingIndex;
81 std::list< MapEntry > rMap;
82 };
83
84 ostream&
85 operator<<(ostream& os, Map& rMap);
akmhoque298385a2014-02-13 14:13:09 -060086
akmhoqueb1710aa2014-02-19 17:13:36 -060087} // namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -060088#endif