akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 1 | #ifndef NLSR_SM_HPP |
| 2 | #define NLSR_SM_HPP |
| 3 | |
| 4 | #include <list> |
| 5 | #include <string> |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame^] | 6 | #include <ndn-cxx/face.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 7 | |
| 8 | namespace nlsr { |
| 9 | class SequencingManager |
| 10 | { |
| 11 | public: |
| 12 | SequencingManager() |
| 13 | : m_nameLsaSeq(0) |
| 14 | , m_adjLsaSeq(0) |
| 15 | , m_corLsaSeq(0) |
| 16 | , m_combinedSeqNo(0) |
| 17 | , m_seqFileNameWithPath() |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | SequencingManager(uint64_t seqNo) |
| 22 | { |
| 23 | splittSequenceNo(seqNo); |
| 24 | } |
| 25 | |
| 26 | SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn) |
| 27 | { |
| 28 | m_nameLsaSeq = nlsn; |
| 29 | m_adjLsaSeq = alsn; |
| 30 | m_corLsaSeq = clsn; |
| 31 | combineSequenceNo(); |
| 32 | } |
| 33 | |
| 34 | uint64_t |
| 35 | getNameLsaSeq() const |
| 36 | { |
| 37 | return m_nameLsaSeq; |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | setNameLsaSeq(uint64_t nlsn) |
| 42 | { |
| 43 | m_nameLsaSeq = nlsn; |
| 44 | combineSequenceNo(); |
| 45 | } |
| 46 | |
| 47 | uint64_t |
| 48 | getAdjLsaSeq() const |
| 49 | { |
| 50 | return m_adjLsaSeq; |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | setAdjLsaSeq(uint64_t alsn) |
| 55 | { |
| 56 | m_adjLsaSeq = alsn; |
| 57 | combineSequenceNo(); |
| 58 | } |
| 59 | |
| 60 | uint64_t |
| 61 | getCorLsaSeq() const |
| 62 | { |
| 63 | return m_corLsaSeq; |
| 64 | } |
| 65 | |
| 66 | void |
| 67 | setCorLsaSeq(uint64_t clsn) |
| 68 | { |
| 69 | m_corLsaSeq = clsn; |
| 70 | combineSequenceNo(); |
| 71 | } |
| 72 | |
| 73 | uint64_t |
| 74 | getCombinedSeqNo() const |
| 75 | { |
| 76 | return m_combinedSeqNo; |
| 77 | } |
| 78 | |
| 79 | void |
| 80 | writeSeqNoToFile(); |
| 81 | |
| 82 | void |
| 83 | initiateSeqNoFromFile(); |
| 84 | |
| 85 | void |
| 86 | setSeqFileName(std::string filePath); |
| 87 | |
| 88 | std::string |
| 89 | getUserHomeDirectory(); |
| 90 | |
| 91 | private: |
| 92 | void |
| 93 | splittSequenceNo(uint64_t seqNo); |
| 94 | |
| 95 | void |
| 96 | combineSequenceNo(); |
| 97 | |
| 98 | |
| 99 | private: |
| 100 | uint64_t m_nameLsaSeq; |
| 101 | uint64_t m_adjLsaSeq; |
| 102 | uint64_t m_corLsaSeq; |
| 103 | uint64_t m_combinedSeqNo; |
| 104 | std::string m_seqFileNameWithPath; |
| 105 | }; |
| 106 | |
| 107 | |
| 108 | std::ostream& |
| 109 | operator<<(std::ostream& os, const SequencingManager& sm); |
| 110 | |
| 111 | }//namespace nlsr |
| 112 | #endif //NLSR_SM_HPP |