blob: c362706be3c3a8d9b71870a9f5f5ff2a5379481e [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()
20 : router()
21 , 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 {
31 router=rtr;
32 mappingNumber=mn;
33 }
34
35 string getRouter()
36 {
37 return router;
38 }
39
40 int getMappingNumber()
41 {
42 return mappingNumber;
43 }
44 private:
45 string router;
46 int mappingNumber;
47 };
48
49 ostream&
50 operator<<(ostream& os, MapEntry& mpe);
51
52 class Map
53 {
54 public:
55 Map()
56 : mappingIndex(0)
57 {
58 }
akmhoqueba094742014-02-28 11:47:21 -060059
60
akmhoque5a44dd42014-03-12 18:11:32 -050061 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 }
akmhoqueba094742014-02-28 11:47:21 -060070
akmhoque5a44dd42014-03-12 18:11:32 -050071 int getMapSize()
72 {
73 return rMap.size();
74 }
akmhoqueba094742014-02-28 11:47:21 -060075
76
akmhoque5a44dd42014-03-12 18:11:32 -050077 private:
78 bool addMapElement(MapEntry& mpe);
akmhoqueba094742014-02-28 11:47:21 -060079
akmhoque5a44dd42014-03-12 18:11:32 -050080 int mappingIndex;
81 std::list< MapEntry > rMap;
82 };
akmhoqueba094742014-02-28 11:47:21 -060083
akmhoque5a44dd42014-03-12 18:11:32 -050084 ostream&
85 operator<<(ostream& os, Map& rMap);
akmhoqueba094742014-02-28 11:47:21 -060086
87} // namespace nlsr
88#endif