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