blob: 8f7d0f42115d5d871d8ea184d9f29783363382a7 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
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
akmhoque31d1d4b2014-05-05 22:08:14 -050053 const ndn::Name
akmhoquefdbddb12014-05-02 18:35:19 -050054 getRouterNameByMappingNo(int32_t mn);
akmhoque53353462014-04-22 08:43:45 -050055
akmhoquefdbddb12014-05-02 18:35:19 -050056 int32_t
akmhoque31d1d4b2014-05-05 22:08:14 -050057 getMappingNoByRouterName(const ndn::Name& rName);
akmhoque53353462014-04-22 08:43:45 -050058
59 void
60 reset();
61
62 std::list<MapEntry>&
63 getMapList()
64 {
65 return m_table;
66 }
67
akmhoque31d1d4b2014-05-05 22:08:14 -050068 size_t
akmhoque53353462014-04-22 08:43:45 -050069 getMapSize() const
70 {
71 return m_table.size();
72 }
73
akmhoque2f423352014-06-03 11:49:35 -050074 void
75 writeLog();
akmhoque53353462014-04-22 08:43:45 -050076
77private:
78 bool
akmhoquefdbddb12014-05-02 18:35:19 -050079 addEntry(MapEntry& mpe);
akmhoque53353462014-04-22 08:43:45 -050080
akmhoquefdbddb12014-05-02 18:35:19 -050081 int32_t m_mappingIndex;
akmhoque53353462014-04-22 08:43:45 -050082 std::list<MapEntry> m_table;
83};
84
akmhoque53353462014-04-22 08:43:45 -050085} // namespace nlsr
86#endif //NLSR_MAP_HPP