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() | ||||
20 | : router() | ||||
21 | , 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 | { | ||||
31 | router=rtr; | ||||
32 | mappingNumber=mn; | ||||
33 | } | ||||
34 | |||||
35 | string getRouter() | ||||
36 | { | ||||
37 | return router; | ||||
38 | } | ||||
39 | |||||
40 | int getMappingNumber() | ||||
41 | { | ||||
42 | return mappingNumber; | ||||
43 | } | ||||
44 | private: | ||||
45 | string router; | ||||
46 | int mappingNumber; | ||||
47 | }; | ||||
48 | |||||
49 | ostream& | ||||
50 | operator<<(ostream& os, MapEntry& mpe); | ||||
51 | |||||
52 | class Map | ||||
53 | { | ||||
54 | public: | ||||
55 | Map() | ||||
56 | : mappingIndex(0) | ||||
57 | { | ||||
58 | } | ||||
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 59 | |
60 | |||||
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 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 | } | ||||
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 | { | ||||
73 | return rMap.size(); | ||||
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: |
78 | bool addMapElement(MapEntry& mpe); | ||||
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 79 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 80 | int mappingIndex; |
81 | std::list< MapEntry > rMap; | ||||
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& |
85 | operator<<(ostream& os, Map& rMap); | ||||
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 86 | |
87 | } // namespace nlsr | ||||
88 | #endif |