blob: a3671225c8cd42e7a4760525319ef1fe2217c168 [file] [log] [blame]
akmhoquefdbddb12014-05-02 18:35:19 -05001#ifndef NLSR_ADJACENCY_LIST_HPP
2#define NLSR_ADJACENCY_LIST_HPP
akmhoque53353462014-04-22 08:43:45 -05003
akmhoque53353462014-04-22 08:43:45 -05004#include <list>
akmhoquefdbddb12014-05-02 18:35:19 -05005#include <boost/cstdint.hpp>
6#include <ndn-cxx/common.hpp>
akmhoque53353462014-04-22 08:43:45 -05007
akmhoquec8a10f72014-04-25 18:42:55 -05008#include "adjacent.hpp"
9
akmhoque53353462014-04-22 08:43:45 -050010namespace nlsr {
11class Nlsr;
12
akmhoquec8a10f72014-04-25 18:42:55 -050013class AdjacencyList
akmhoque53353462014-04-22 08:43:45 -050014{
15
16public:
akmhoquec8a10f72014-04-25 18:42:55 -050017 AdjacencyList();
18 ~AdjacencyList();
akmhoque53353462014-04-22 08:43:45 -050019
akmhoquefdbddb12014-05-02 18:35:19 -050020 int32_t
21 insert(Adjacent& adjacent);
akmhoque53353462014-04-22 08:43:45 -050022
akmhoquefdbddb12014-05-02 18:35:19 -050023 int32_t
akmhoque31d1d4b2014-05-05 22:08:14 -050024 updateAdjacentStatus(const ndn::Name& adjName, int32_t s);
akmhoque53353462014-04-22 08:43:45 -050025
akmhoquefdbddb12014-05-02 18:35:19 -050026 int32_t
akmhoque31d1d4b2014-05-05 22:08:14 -050027 updateAdjacentLinkCost(const ndn::Name& adjName, double lc);
akmhoque53353462014-04-22 08:43:45 -050028
29 std::list<Adjacent>&
30 getAdjList();
31
32 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050033 isNeighbor(const ndn::Name& adjName);
akmhoque53353462014-04-22 08:43:45 -050034
35 void
akmhoque31d1d4b2014-05-05 22:08:14 -050036 incrementTimedOutInterestCount(const ndn::Name& neighbor);
akmhoque53353462014-04-22 08:43:45 -050037
akmhoquefdbddb12014-05-02 18:35:19 -050038 int32_t
akmhoque31d1d4b2014-05-05 22:08:14 -050039 getTimedOutInterestCount(const ndn::Name& neighbor);
akmhoque53353462014-04-22 08:43:45 -050040
akmhoquefdbddb12014-05-02 18:35:19 -050041 uint32_t
akmhoque31d1d4b2014-05-05 22:08:14 -050042 getStatusOfNeighbor(const ndn::Name& neighbor);
akmhoque53353462014-04-22 08:43:45 -050043
44 void
akmhoque31d1d4b2014-05-05 22:08:14 -050045 setStatusOfNeighbor(const ndn::Name& neighbor, int32_t status);
akmhoque53353462014-04-22 08:43:45 -050046
47 void
akmhoque31d1d4b2014-05-05 22:08:14 -050048 setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
akmhoque53353462014-04-22 08:43:45 -050049
50 void
akmhoquefdbddb12014-05-02 18:35:19 -050051 addAdjacents(AdjacencyList& adl);
akmhoque53353462014-04-22 08:43:45 -050052
53 bool
54 isAdjLsaBuildable(Nlsr& pnlsr);
55
akmhoquefdbddb12014-05-02 18:35:19 -050056 int32_t
akmhoque53353462014-04-22 08:43:45 -050057 getNumOfActiveNeighbor();
58
59 Adjacent
akmhoque31d1d4b2014-05-05 22:08:14 -050060 getAdjacent(const ndn::Name& adjName);
akmhoque53353462014-04-22 08:43:45 -050061
62 bool
akmhoquefdbddb12014-05-02 18:35:19 -050063 operator==(AdjacencyList& adl);
akmhoque53353462014-04-22 08:43:45 -050064
akmhoquefdbddb12014-05-02 18:35:19 -050065 size_t
akmhoque53353462014-04-22 08:43:45 -050066 getSize()
67 {
68 return m_adjList.size();
69 }
70
71 void
72 reset()
73 {
akmhoque157b0a42014-05-13 00:26:37 -050074 if (m_adjList.size() > 0) {
akmhoque53353462014-04-22 08:43:45 -050075 m_adjList.clear();
76 }
77 }
78
79 void
akmhoquec8a10f72014-04-25 18:42:55 -050080 print();
akmhoque53353462014-04-22 08:43:45 -050081
akmhoque674b0b12014-05-20 14:33:28 -050082 void
83 writeLog();
84
akmhoque53353462014-04-22 08:43:45 -050085private:
86 std::list<Adjacent>::iterator
akmhoque31d1d4b2014-05-05 22:08:14 -050087 find(const ndn::Name& adjName);
akmhoque53353462014-04-22 08:43:45 -050088
89private:
90 std::list<Adjacent> m_adjList;
91};
92
93} //namespace nlsr
akmhoquefdbddb12014-05-02 18:35:19 -050094#endif //NLSR_ADJACENCY_LIST_HPP