akmhoque | 298385a | 2014-02-13 14:13:09 -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 | |||||
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 9 | namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 10 | { |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 11 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 12 | class Nlsr; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 13 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 14 | using namespace std; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 15 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 16 | class MapEntry |
17 | { | ||||
18 | public: | ||||
19 | MapEntry() | ||||
20 | : router() | ||||
21 | , mappingNumber(-1) | ||||
22 | { | ||||
23 | } | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 24 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 25 | ~MapEntry() |
26 | { | ||||
27 | } | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 28 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 29 | MapEntry(string rtr, int mn) |
30 | { | ||||
31 | router=rtr; | ||||
32 | mappingNumber=mn; | ||||
33 | } | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 34 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 35 | string getRouter() |
36 | { | ||||
37 | return router; | ||||
38 | } | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 39 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 40 | int getMappingNumber() |
41 | { | ||||
42 | return mappingNumber; | ||||
43 | } | ||||
44 | private: | ||||
45 | string router; | ||||
46 | int mappingNumber; | ||||
47 | }; | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 48 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 49 | ostream& |
50 | operator<<(ostream& os, MapEntry& mpe); | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 51 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame^] | 52 | 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); | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 86 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 87 | } // namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 88 | #endif |