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