blob: c023b382d414257d3a481462813a33def0266f0f [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Vince Lehmanc2e51f62015-01-20 15:03:11 -06003 * Copyright (c) 2014-2015, The University of Memphis,
4 * Regents of the University of California,
5 * Arizona Board of Regents.
akmhoque3d06e792014-05-27 16:23:20 -05006 *
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/>.
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
Vince Lehmanc2e51f62015-01-20 15:03:11 -060021
akmhoquefdbddb12014-05-02 18:35:19 -050022#ifndef NLSR_SEQUENCING_MANAGER_HPP
23#define NLSR_SEQUENCING_MANAGER_HPP
akmhoque53353462014-04-22 08:43:45 -050024
25#include <list>
26#include <string>
akmhoquefdbddb12014-05-02 18:35:19 -050027#include <boost/cstdint.hpp>
28
akmhoquec8a10f72014-04-25 18:42:55 -050029#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -050030
31namespace nlsr {
32class SequencingManager
33{
34public:
35 SequencingManager()
36 : m_nameLsaSeq(0)
37 , m_adjLsaSeq(0)
38 , m_corLsaSeq(0)
39 , m_combinedSeqNo(0)
40 , m_seqFileNameWithPath()
41 {
42 }
43
44 SequencingManager(uint64_t seqNo)
45 {
Vince Lehman6151e952015-02-16 12:36:00 -060046 splitSequenceNo(seqNo);
akmhoque53353462014-04-22 08:43:45 -050047 }
48
49 SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn)
50 {
51 m_nameLsaSeq = nlsn;
52 m_adjLsaSeq = alsn;
53 m_corLsaSeq = clsn;
54 combineSequenceNo();
55 }
56
57 uint64_t
58 getNameLsaSeq() const
59 {
60 return m_nameLsaSeq;
61 }
62
63 void
64 setNameLsaSeq(uint64_t nlsn)
65 {
66 m_nameLsaSeq = nlsn;
67 combineSequenceNo();
68 }
69
70 uint64_t
71 getAdjLsaSeq() const
72 {
73 return m_adjLsaSeq;
74 }
75
76 void
77 setAdjLsaSeq(uint64_t alsn)
78 {
79 m_adjLsaSeq = alsn;
80 combineSequenceNo();
81 }
82
83 uint64_t
84 getCorLsaSeq() const
85 {
86 return m_corLsaSeq;
87 }
88
89 void
90 setCorLsaSeq(uint64_t clsn)
91 {
92 m_corLsaSeq = clsn;
93 combineSequenceNo();
94 }
95
akmhoquefdbddb12014-05-02 18:35:19 -050096 void
97 increaseNameLsaSeq()
98 {
99 m_nameLsaSeq++;
100 combineSequenceNo();
101 }
102
103 void
104 increaseAdjLsaSeq()
105 {
106 m_adjLsaSeq++;
107 combineSequenceNo();
108 }
109
110 void
111 increaseCorLsaSeq()
112 {
113 m_corLsaSeq++;
114 combineSequenceNo();
115 }
116
akmhoque53353462014-04-22 08:43:45 -0500117 uint64_t
118 getCombinedSeqNo() const
119 {
120 return m_combinedSeqNo;
121 }
122
123 void
Vince Lehman0bcf9a32014-12-10 11:24:45 -0600124 writeSeqNoToFile() const;
akmhoque53353462014-04-22 08:43:45 -0500125
126 void
127 initiateSeqNoFromFile();
128
129 void
130 setSeqFileName(std::string filePath);
131
132 std::string
133 getUserHomeDirectory();
134
akmhoque2f423352014-06-03 11:49:35 -0500135 void
Vince Lehman904c2412014-09-23 19:36:11 -0500136 writeLog() const;
akmhoque2f423352014-06-03 11:49:35 -0500137
akmhoque53353462014-04-22 08:43:45 -0500138private:
139 void
Vince Lehman6151e952015-02-16 12:36:00 -0600140 splitSequenceNo(uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500141
142 void
143 combineSequenceNo();
144
akmhoque53353462014-04-22 08:43:45 -0500145private:
146 uint64_t m_nameLsaSeq;
147 uint64_t m_adjLsaSeq;
148 uint64_t m_corLsaSeq;
149 uint64_t m_combinedSeqNo;
150 std::string m_seqFileNameWithPath;
151};
152
akmhoque53353462014-04-22 08:43:45 -0500153}//namespace nlsr
akmhoquefdbddb12014-05-02 18:35:19 -0500154#endif //NLSR_SEQUENCING_MANAGER_HPP