akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014 University of Memphis, |
| 4 | * Regents of the University of California |
| 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * \author A K M Mahmudul Hoque <ahoque1@memphis.edu> |
| 21 | * |
| 22 | **/ |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 23 | #ifndef NLSR_SEQUENCING_MANAGER_HPP |
| 24 | #define NLSR_SEQUENCING_MANAGER_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 25 | |
| 26 | #include <list> |
| 27 | #include <string> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 28 | #include <boost/cstdint.hpp> |
| 29 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 30 | #include <ndn-cxx/face.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 31 | |
| 32 | namespace nlsr { |
| 33 | class SequencingManager |
| 34 | { |
| 35 | public: |
| 36 | SequencingManager() |
| 37 | : m_nameLsaSeq(0) |
| 38 | , m_adjLsaSeq(0) |
| 39 | , m_corLsaSeq(0) |
| 40 | , m_combinedSeqNo(0) |
| 41 | , m_seqFileNameWithPath() |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | SequencingManager(uint64_t seqNo) |
| 46 | { |
| 47 | splittSequenceNo(seqNo); |
| 48 | } |
| 49 | |
| 50 | SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn) |
| 51 | { |
| 52 | m_nameLsaSeq = nlsn; |
| 53 | m_adjLsaSeq = alsn; |
| 54 | m_corLsaSeq = clsn; |
| 55 | combineSequenceNo(); |
| 56 | } |
| 57 | |
| 58 | uint64_t |
| 59 | getNameLsaSeq() const |
| 60 | { |
| 61 | return m_nameLsaSeq; |
| 62 | } |
| 63 | |
| 64 | void |
| 65 | setNameLsaSeq(uint64_t nlsn) |
| 66 | { |
| 67 | m_nameLsaSeq = nlsn; |
| 68 | combineSequenceNo(); |
| 69 | } |
| 70 | |
| 71 | uint64_t |
| 72 | getAdjLsaSeq() const |
| 73 | { |
| 74 | return m_adjLsaSeq; |
| 75 | } |
| 76 | |
| 77 | void |
| 78 | setAdjLsaSeq(uint64_t alsn) |
| 79 | { |
| 80 | m_adjLsaSeq = alsn; |
| 81 | combineSequenceNo(); |
| 82 | } |
| 83 | |
| 84 | uint64_t |
| 85 | getCorLsaSeq() const |
| 86 | { |
| 87 | return m_corLsaSeq; |
| 88 | } |
| 89 | |
| 90 | void |
| 91 | setCorLsaSeq(uint64_t clsn) |
| 92 | { |
| 93 | m_corLsaSeq = clsn; |
| 94 | combineSequenceNo(); |
| 95 | } |
| 96 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 97 | void |
| 98 | increaseNameLsaSeq() |
| 99 | { |
| 100 | m_nameLsaSeq++; |
| 101 | combineSequenceNo(); |
| 102 | } |
| 103 | |
| 104 | void |
| 105 | increaseAdjLsaSeq() |
| 106 | { |
| 107 | m_adjLsaSeq++; |
| 108 | combineSequenceNo(); |
| 109 | } |
| 110 | |
| 111 | void |
| 112 | increaseCorLsaSeq() |
| 113 | { |
| 114 | m_corLsaSeq++; |
| 115 | combineSequenceNo(); |
| 116 | } |
| 117 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 118 | uint64_t |
| 119 | getCombinedSeqNo() const |
| 120 | { |
| 121 | return m_combinedSeqNo; |
| 122 | } |
| 123 | |
| 124 | void |
| 125 | writeSeqNoToFile(); |
| 126 | |
| 127 | void |
| 128 | initiateSeqNoFromFile(); |
| 129 | |
| 130 | void |
| 131 | setSeqFileName(std::string filePath); |
| 132 | |
| 133 | std::string |
| 134 | getUserHomeDirectory(); |
| 135 | |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame^] | 136 | void |
| 137 | writeLog(); |
| 138 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 139 | private: |
| 140 | void |
| 141 | splittSequenceNo(uint64_t seqNo); |
| 142 | |
| 143 | void |
| 144 | combineSequenceNo(); |
| 145 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 146 | private: |
| 147 | uint64_t m_nameLsaSeq; |
| 148 | uint64_t m_adjLsaSeq; |
| 149 | uint64_t m_corLsaSeq; |
| 150 | uint64_t m_combinedSeqNo; |
| 151 | std::string m_seqFileNameWithPath; |
| 152 | }; |
| 153 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 154 | }//namespace nlsr |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 155 | #endif //NLSR_SEQUENCING_MANAGER_HPP |