blob: bf50aacd16de312018d3619bcc1914689b814872 [file] [log] [blame]
akmhoqueba094742014-02-28 11:47:21 -06001#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
9namespace nlsr
10{
11
akmhoque5a44dd42014-03-12 18:11:32 -050012 class Nlsr;
akmhoqueba094742014-02-28 11:47:21 -060013
akmhoque5a44dd42014-03-12 18:11:32 -050014 using namespace std;
akmhoqueba094742014-02-28 11:47:21 -060015
akmhoque5a44dd42014-03-12 18:11:32 -050016 class MapEntry
17 {
18 public:
19 MapEntry()
akmhoque05d5fcf2014-04-15 14:58:45 -050020 : m_router()
21 , m_mappingNumber(-1)
akmhoqueba094742014-02-28 11:47:21 -060022 {
akmhoque5a44dd42014-03-12 18:11:32 -050023 }
akmhoqueba094742014-02-28 11:47:21 -060024
akmhoque5a44dd42014-03-12 18:11:32 -050025 ~MapEntry()
akmhoqueba094742014-02-28 11:47:21 -060026 {
akmhoque5a44dd42014-03-12 18:11:32 -050027 }
28
29 MapEntry(string rtr, int mn)
30 {
akmhoque05d5fcf2014-04-15 14:58:45 -050031 m_router=rtr;
32 m_mappingNumber=mn;
akmhoque5a44dd42014-03-12 18:11:32 -050033 }
34
35 string getRouter()
36 {
akmhoque05d5fcf2014-04-15 14:58:45 -050037 return m_router;
akmhoque5a44dd42014-03-12 18:11:32 -050038 }
39
40 int getMappingNumber()
41 {
akmhoque05d5fcf2014-04-15 14:58:45 -050042 return m_mappingNumber;
akmhoque5a44dd42014-03-12 18:11:32 -050043 }
44 private:
akmhoque05d5fcf2014-04-15 14:58:45 -050045 string m_router;
46 int m_mappingNumber;
akmhoque5a44dd42014-03-12 18:11:32 -050047 };
48
49 ostream&
50 operator<<(ostream& os, MapEntry& mpe);
51
52 class Map
53 {
54 public:
55 Map()
akmhoque05d5fcf2014-04-15 14:58:45 -050056 : m_mappingIndex(0)
akmhoque5a44dd42014-03-12 18:11:32 -050057 {
58 }
akmhoqueba094742014-02-28 11:47:21 -060059
60
akmhoque05d5fcf2014-04-15 14:58:45 -050061 void addElement(string& rtrName);
62 void createFromAdjLsdb(Nlsr& pnlsr);
akmhoque5a44dd42014-03-12 18:11:32 -050063 string getRouterNameByMappingNo(int mn);
64 int getMappingNoByRouterName(string& rName);
akmhoque05d5fcf2014-04-15 14:58:45 -050065 void reset();
akmhoque5a44dd42014-03-12 18:11:32 -050066 std::list< MapEntry >& getMapList()
67 {
akmhoque05d5fcf2014-04-15 14:58:45 -050068 return m_table;
akmhoque5a44dd42014-03-12 18:11:32 -050069 }
akmhoqueba094742014-02-28 11:47:21 -060070
akmhoque5a44dd42014-03-12 18:11:32 -050071 int getMapSize()
72 {
akmhoque05d5fcf2014-04-15 14:58:45 -050073 return m_table.size();
akmhoque5a44dd42014-03-12 18:11:32 -050074 }
akmhoqueba094742014-02-28 11:47:21 -060075
76
akmhoque5a44dd42014-03-12 18:11:32 -050077 private:
akmhoque05d5fcf2014-04-15 14:58:45 -050078 bool addElement(MapEntry& mpe);
akmhoqueba094742014-02-28 11:47:21 -060079
akmhoque05d5fcf2014-04-15 14:58:45 -050080 int m_mappingIndex;
81 std::list< MapEntry > m_table;
akmhoque5a44dd42014-03-12 18:11:32 -050082 };
akmhoqueba094742014-02-28 11:47:21 -060083
akmhoque5a44dd42014-03-12 18:11:32 -050084 ostream&
akmhoque05d5fcf2014-04-15 14:58:45 -050085 operator<<(ostream& os, Map& map);
akmhoqueba094742014-02-28 11:47:21 -060086
87} // namespace nlsr
88#endif