blob: 8bc009a6f2d168fb692d78ba76d85dfcf68e03da [file] [log] [blame]
akmhoquefdbddb12014-05-02 18:35:19 -05001#ifndef NLSR_SEQUENCING_MANAGER_HPP
2#define NLSR_SEQUENCING_MANAGER_HPP
akmhoque53353462014-04-22 08:43:45 -05003
4#include <list>
5#include <string>
akmhoquefdbddb12014-05-02 18:35:19 -05006#include <boost/cstdint.hpp>
7
akmhoquec8a10f72014-04-25 18:42:55 -05008#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -05009
10namespace nlsr {
11class SequencingManager
12{
13public:
14 SequencingManager()
15 : m_nameLsaSeq(0)
16 , m_adjLsaSeq(0)
17 , m_corLsaSeq(0)
18 , m_combinedSeqNo(0)
19 , m_seqFileNameWithPath()
20 {
21 }
22
23 SequencingManager(uint64_t seqNo)
24 {
25 splittSequenceNo(seqNo);
26 }
27
28 SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn)
29 {
30 m_nameLsaSeq = nlsn;
31 m_adjLsaSeq = alsn;
32 m_corLsaSeq = clsn;
33 combineSequenceNo();
34 }
35
36 uint64_t
37 getNameLsaSeq() const
38 {
39 return m_nameLsaSeq;
40 }
41
42 void
43 setNameLsaSeq(uint64_t nlsn)
44 {
45 m_nameLsaSeq = nlsn;
46 combineSequenceNo();
47 }
48
49 uint64_t
50 getAdjLsaSeq() const
51 {
52 return m_adjLsaSeq;
53 }
54
55 void
56 setAdjLsaSeq(uint64_t alsn)
57 {
58 m_adjLsaSeq = alsn;
59 combineSequenceNo();
60 }
61
62 uint64_t
63 getCorLsaSeq() const
64 {
65 return m_corLsaSeq;
66 }
67
68 void
69 setCorLsaSeq(uint64_t clsn)
70 {
71 m_corLsaSeq = clsn;
72 combineSequenceNo();
73 }
74
akmhoquefdbddb12014-05-02 18:35:19 -050075 void
76 increaseNameLsaSeq()
77 {
78 m_nameLsaSeq++;
79 combineSequenceNo();
80 }
81
82 void
83 increaseAdjLsaSeq()
84 {
85 m_adjLsaSeq++;
86 combineSequenceNo();
87 }
88
89 void
90 increaseCorLsaSeq()
91 {
92 m_corLsaSeq++;
93 combineSequenceNo();
94 }
95
akmhoque53353462014-04-22 08:43:45 -050096 uint64_t
97 getCombinedSeqNo() const
98 {
99 return m_combinedSeqNo;
100 }
101
102 void
103 writeSeqNoToFile();
104
105 void
106 initiateSeqNoFromFile();
107
108 void
109 setSeqFileName(std::string filePath);
110
111 std::string
112 getUserHomeDirectory();
113
114private:
115 void
116 splittSequenceNo(uint64_t seqNo);
117
118 void
119 combineSequenceNo();
120
akmhoque53353462014-04-22 08:43:45 -0500121private:
122 uint64_t m_nameLsaSeq;
123 uint64_t m_adjLsaSeq;
124 uint64_t m_corLsaSeq;
125 uint64_t m_combinedSeqNo;
126 std::string m_seqFileNameWithPath;
127};
128
129
130std::ostream&
131operator<<(std::ostream& os, const SequencingManager& sm);
132
133}//namespace nlsr
akmhoquefdbddb12014-05-02 18:35:19 -0500134#endif //NLSR_SEQUENCING_MANAGER_HPP