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