akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | #ifndef NLSR_SM_HPP |
2 | #define NLSR_SM_HPP | ||||
3 | |||||
4 | #include<list> | ||||
5 | #include<string> | ||||
6 | #include <ndn-cpp-dev/face.hpp> | ||||
7 | |||||
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 8 | namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 9 | { |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 10 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 11 | using namespace std; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 12 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 13 | class SequencingManager |
14 | { | ||||
15 | public: | ||||
16 | SequencingManager() | ||||
17 | : nameLsaSeq(0) | ||||
18 | , adjLsaSeq(0) | ||||
19 | , corLsaSeq(0) | ||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 20 | , combinedSeqNo(0) |
21 | , seqFileNameWithPath() | ||||
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 22 | { |
23 | } | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 24 | |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 25 | SequencingManager(uint64_t seqNo) |
26 | { | ||||
27 | splittSequenceNo(seqNo); | ||||
28 | } | ||||
29 | |||||
30 | SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn) | ||||
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 31 | { |
32 | nameLsaSeq=nlsn; | ||||
33 | adjLsaSeq=alsn; | ||||
34 | corLsaSeq=clsn; | ||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 35 | combineSequenceNo(); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 36 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 37 | |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 38 | uint64_t getNameLsaSeq() const |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 39 | { |
40 | return nameLsaSeq; | ||||
41 | } | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 42 | |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 43 | void setNameLsaSeq(uint64_t nlsn) |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 44 | { |
45 | nameLsaSeq=nlsn; | ||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 46 | combineSequenceNo(); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 47 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 48 | |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 49 | uint64_t getAdjLsaSeq() const |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 50 | { |
51 | return adjLsaSeq; | ||||
52 | } | ||||
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 53 | |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 54 | void setAdjLsaSeq(uint64_t alsn) |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 55 | { |
56 | adjLsaSeq=alsn; | ||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 57 | combineSequenceNo(); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 58 | } |
59 | |||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 60 | uint64_t getCorLsaSeq() const |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 61 | { |
62 | return corLsaSeq; | ||||
63 | } | ||||
64 | |||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 65 | void setCorLsaSeq(uint64_t clsn) |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 66 | { |
67 | corLsaSeq=clsn; | ||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 68 | combineSequenceNo(); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 69 | } |
70 | |||||
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 71 | 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 | |||||
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 81 | private: |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 82 | 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; | ||||
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 92 | }; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 93 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 94 | |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 95 | ostream& operator <<(ostream& os, const SequencingManager& sm); |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 96 | }//namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 97 | #endif |