akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 1 | #ifndef NLSR_SEQUENCING_MANAGER_HPP |
| 2 | #define NLSR_SEQUENCING_MANAGER_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 3 | |
| 4 | #include <list> |
| 5 | #include <string> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 6 | #include <boost/cstdint.hpp> |
| 7 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 8 | #include <ndn-cxx/face.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 9 | |
| 10 | namespace nlsr { |
| 11 | class SequencingManager |
| 12 | { |
| 13 | public: |
| 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 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 75 | 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 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 96 | 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 | |
| 114 | private: |
| 115 | void |
| 116 | splittSequenceNo(uint64_t seqNo); |
| 117 | |
| 118 | void |
| 119 | combineSequenceNo(); |
| 120 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 121 | private: |
| 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 | |
| 130 | std::ostream& |
| 131 | operator<<(std::ostream& os, const SequencingManager& sm); |
| 132 | |
| 133 | }//namespace nlsr |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 134 | #endif //NLSR_SEQUENCING_MANAGER_HPP |