blob: b1b1b39c6800d8b161d893dc3015c4974fe663f7 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#ifndef NLSR_SM_HPP
2#define NLSR_SM_HPP
3
4#include<list>
5#include<string>
6#include <ndn-cpp-dev/face.hpp>
7
akmhoque1fd8c1e2014-02-19 19:41:49 -06008namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -06009{
akmhoque298385a2014-02-13 14:13:09 -060010
akmhoque1fd8c1e2014-02-19 19:41:49 -060011 using namespace std;
akmhoque298385a2014-02-13 14:13:09 -060012
akmhoque1fd8c1e2014-02-19 19:41:49 -060013 class SequencingManager
14 {
15 public:
16 SequencingManager()
17 : nameLsaSeq(0)
18 , adjLsaSeq(0)
19 , corLsaSeq(0)
akmhoque2bb198e2014-02-28 11:46:27 -060020 , combinedSeqNo(0)
21 , seqFileNameWithPath()
akmhoque1fd8c1e2014-02-19 19:41:49 -060022 {
23 }
akmhoque298385a2014-02-13 14:13:09 -060024
akmhoque2bb198e2014-02-28 11:46:27 -060025 SequencingManager(uint64_t seqNo)
26 {
27 splittSequenceNo(seqNo);
28 }
29
30 SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn)
akmhoque1fd8c1e2014-02-19 19:41:49 -060031 {
32 nameLsaSeq=nlsn;
33 adjLsaSeq=alsn;
34 corLsaSeq=clsn;
akmhoque2bb198e2014-02-28 11:46:27 -060035 combineSequenceNo();
akmhoque1fd8c1e2014-02-19 19:41:49 -060036 }
akmhoque298385a2014-02-13 14:13:09 -060037
akmhoque2bb198e2014-02-28 11:46:27 -060038 uint64_t getNameLsaSeq() const
akmhoque1fd8c1e2014-02-19 19:41:49 -060039 {
40 return nameLsaSeq;
41 }
akmhoque298385a2014-02-13 14:13:09 -060042
akmhoque2bb198e2014-02-28 11:46:27 -060043 void setNameLsaSeq(uint64_t nlsn)
akmhoque1fd8c1e2014-02-19 19:41:49 -060044 {
45 nameLsaSeq=nlsn;
akmhoque2bb198e2014-02-28 11:46:27 -060046 combineSequenceNo();
akmhoque1fd8c1e2014-02-19 19:41:49 -060047 }
akmhoque298385a2014-02-13 14:13:09 -060048
akmhoque2bb198e2014-02-28 11:46:27 -060049 uint64_t getAdjLsaSeq() const
akmhoque1fd8c1e2014-02-19 19:41:49 -060050 {
51 return adjLsaSeq;
52 }
akmhoque298385a2014-02-13 14:13:09 -060053
akmhoque2bb198e2014-02-28 11:46:27 -060054 void setAdjLsaSeq(uint64_t alsn)
akmhoque1fd8c1e2014-02-19 19:41:49 -060055 {
56 adjLsaSeq=alsn;
akmhoque2bb198e2014-02-28 11:46:27 -060057 combineSequenceNo();
akmhoque1fd8c1e2014-02-19 19:41:49 -060058 }
59
akmhoque2bb198e2014-02-28 11:46:27 -060060 uint64_t getCorLsaSeq() const
akmhoque1fd8c1e2014-02-19 19:41:49 -060061 {
62 return corLsaSeq;
63 }
64
akmhoque2bb198e2014-02-28 11:46:27 -060065 void setCorLsaSeq(uint64_t clsn)
akmhoque1fd8c1e2014-02-19 19:41:49 -060066 {
67 corLsaSeq=clsn;
akmhoque2bb198e2014-02-28 11:46:27 -060068 combineSequenceNo();
akmhoque1fd8c1e2014-02-19 19:41:49 -060069 }
70
akmhoque2bb198e2014-02-28 11:46:27 -060071 uint64_t getCombinedSeqNo() const
72 {
73 return combinedSeqNo;
74 }
75
76 void writeSeqNoToFile();
77 void initiateSeqNoFromFile();
78 void setSeqFileName(string filePath);
79 string getUserHomeDirectory();
80
akmhoque1fd8c1e2014-02-19 19:41:49 -060081 private:
akmhoque2bb198e2014-02-28 11:46:27 -060082 void splittSequenceNo(uint64_t seqNo);
83 void combineSequenceNo();
84
85
86 private:
87 uint64_t nameLsaSeq;
88 uint64_t adjLsaSeq;
89 uint64_t corLsaSeq;
90 uint64_t combinedSeqNo;
91 string seqFileNameWithPath;
akmhoque1fd8c1e2014-02-19 19:41:49 -060092 };
akmhoque298385a2014-02-13 14:13:09 -060093
akmhoqueb1710aa2014-02-19 17:13:36 -060094
akmhoque2bb198e2014-02-28 11:46:27 -060095 ostream& operator <<(ostream& os, const SequencingManager& sm);
akmhoqueb1710aa2014-02-19 17:13:36 -060096}//namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -060097#endif