blob: 9c9e6e8d2172783a289f20fdb66699985d9cef6f [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#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
9namespace nlsr {
10
11class Nlsr;
12
13class MapEntry
14{
15public:
16 MapEntry()
17 : m_router()
18 , m_mappingNumber(-1)
19 {
20 }
21
22 ~MapEntry()
23 {
24 }
25
26 MapEntry(std::string rtr, int mn)
27 {
28 m_router = rtr;
29 m_mappingNumber = mn;
30 }
31
32 std::string
33 getRouter() const
34 {
35 return m_router;
36 }
37
38 int
39 getMappingNumber() const
40 {
41 return m_mappingNumber;
42 }
43
44private:
45 std::string m_router;
46 int m_mappingNumber;
47};
48
49std::ostream&
50operator<<(std::ostream& os, MapEntry& mpe);
51
52class Map
53{
54public:
55 Map()
56 : m_mappingIndex(0)
57 {
58 }
59
60
61 void
62 addElement(std::string& rtrName);
63
64 void
65 createFromAdjLsdb(Nlsr& pnlsr);
66
67 std::string
68 getRouterNameByMappingNo(int mn);
69
70 int
71 getMappingNoByRouterName(std::string& rName);
72
73 void
74 reset();
75
76 std::list<MapEntry>&
77 getMapList()
78 {
79 return m_table;
80 }
81
82 int
83 getMapSize() const
84 {
85 return m_table.size();
86 }
87
88
89private:
90 bool
91 addElement(MapEntry& mpe);
92
93 int m_mappingIndex;
94 std::list<MapEntry> m_table;
95};
96
97std::ostream&
98operator<<(std::ostream& os, Map& map);
99
100} // namespace nlsr
101#endif //NLSR_MAP_HPP