blob: a37f1ace2215260d37039629a4253ae03fa5c6a7 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonf8b5bcd2016-08-11 15:06:50 -05003 * Copyright (c) 2014-2016, The University of Memphis,
4 * Regents of the University of California
akmhoque3d06e792014-05-27 16:23:20 -05005 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoque53353462014-04-22 08:43:45 -050023#ifndef NLSR_MAP_HPP
24#define NLSR_MAP_HPP
25
26#include <iostream>
27#include <list>
akmhoquefdbddb12014-05-02 18:35:19 -050028#include <boost/cstdint.hpp>
akmhoque53353462014-04-22 08:43:45 -050029
akmhoquefdbddb12014-05-02 18:35:19 -050030#include <ndn-cxx/common.hpp>
31
32#include "map-entry.hpp"
akmhoque53353462014-04-22 08:43:45 -050033
34namespace nlsr {
35
36class Nlsr;
37
akmhoque53353462014-04-22 08:43:45 -050038class Map
39{
40public:
41 Map()
42 : m_mappingIndex(0)
43 {
44 }
45
46
47 void
akmhoque31d1d4b2014-05-05 22:08:14 -050048 addEntry(const ndn::Name& rtrName);
akmhoque53353462014-04-22 08:43:45 -050049
50 void
51 createFromAdjLsdb(Nlsr& pnlsr);
52
Nick Gordone8e03ac2016-07-07 14:24:38 -050053 void
54 createFromCoordinateLsdb(Nlsr& nlsr);
55
akmhoque31d1d4b2014-05-05 22:08:14 -050056 const ndn::Name
akmhoquefdbddb12014-05-02 18:35:19 -050057 getRouterNameByMappingNo(int32_t mn);
akmhoque53353462014-04-22 08:43:45 -050058
akmhoquefdbddb12014-05-02 18:35:19 -050059 int32_t
akmhoque31d1d4b2014-05-05 22:08:14 -050060 getMappingNoByRouterName(const ndn::Name& rName);
akmhoque53353462014-04-22 08:43:45 -050061
62 void
63 reset();
64
65 std::list<MapEntry>&
66 getMapList()
67 {
68 return m_table;
69 }
70
akmhoque31d1d4b2014-05-05 22:08:14 -050071 size_t
akmhoque53353462014-04-22 08:43:45 -050072 getMapSize() const
73 {
74 return m_table.size();
75 }
76
akmhoque2f423352014-06-03 11:49:35 -050077 void
78 writeLog();
akmhoque53353462014-04-22 08:43:45 -050079
80private:
81 bool
akmhoquefdbddb12014-05-02 18:35:19 -050082 addEntry(MapEntry& mpe);
akmhoque53353462014-04-22 08:43:45 -050083
akmhoquefdbddb12014-05-02 18:35:19 -050084 int32_t m_mappingIndex;
akmhoque53353462014-04-22 08:43:45 -050085 std::list<MapEntry> m_table;
86};
87
akmhoque53353462014-04-22 08:43:45 -050088} // namespace nlsr
89#endif //NLSR_MAP_HPP