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