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