blob: b9729fc5e8af2d7748ab27688a88e895d04e669b [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
Nick G97e34942016-07-11 14:46:27 -050046 /*! \brief Add a map entry to this map.
47 \param rtrName The name of the router.
akmhoque53353462014-04-22 08:43:45 -050048
Nick G97e34942016-07-11 14:46:27 -050049 Adds a router to this map. Each entry is also given an arbitrary,
50 ascending mappingNo (mapping number).
51 */
akmhoque53353462014-04-22 08:43:45 -050052 void
akmhoque31d1d4b2014-05-05 22:08:14 -050053 addEntry(const ndn::Name& rtrName);
akmhoque53353462014-04-22 08:43:45 -050054
55 void
56 createFromAdjLsdb(Nlsr& pnlsr);
57
Nick Gordone8e03ac2016-07-07 14:24:38 -050058 void
59 createFromCoordinateLsdb(Nlsr& nlsr);
60
akmhoque31d1d4b2014-05-05 22:08:14 -050061 const ndn::Name
akmhoquefdbddb12014-05-02 18:35:19 -050062 getRouterNameByMappingNo(int32_t mn);
akmhoque53353462014-04-22 08:43:45 -050063
akmhoquefdbddb12014-05-02 18:35:19 -050064 int32_t
akmhoque31d1d4b2014-05-05 22:08:14 -050065 getMappingNoByRouterName(const ndn::Name& rName);
akmhoque53353462014-04-22 08:43:45 -050066
67 void
68 reset();
69
70 std::list<MapEntry>&
71 getMapList()
72 {
73 return m_table;
74 }
75
akmhoque31d1d4b2014-05-05 22:08:14 -050076 size_t
akmhoque53353462014-04-22 08:43:45 -050077 getMapSize() const
78 {
79 return m_table.size();
80 }
81
akmhoque2f423352014-06-03 11:49:35 -050082 void
83 writeLog();
akmhoque53353462014-04-22 08:43:45 -050084
85private:
86 bool
akmhoquefdbddb12014-05-02 18:35:19 -050087 addEntry(MapEntry& mpe);
akmhoque53353462014-04-22 08:43:45 -050088
akmhoquefdbddb12014-05-02 18:35:19 -050089 int32_t m_mappingIndex;
akmhoque53353462014-04-22 08:43:45 -050090 std::list<MapEntry> m_table;
91};
92
akmhoque53353462014-04-22 08:43:45 -050093} // namespace nlsr
94#endif //NLSR_MAP_HPP