blob: 0c8504f88d712be5f32c13ed8cc784331fea702c [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Ashlesh Gawande0db4d4d2020-02-05 20:30:02 -08003 * Copyright (c) 2014-2020, The University of Memphis,
Vince Lehmanc2e51f62015-01-20 15:03:11 -06004 * 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
Ashlesh Gawande85998a12017-12-07 22:22:13 -060025#include "conf-parameter.hpp"
26#include "test-access-control.hpp"
akmhoquefdbddb12014-05-02 18:35:19 -050027
akmhoquec8a10f72014-04-25 18:42:55 -050028#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -050029
Ashlesh Gawande85998a12017-12-07 22:22:13 -060030#include <list>
31#include <string>
32#include <boost/cstdint.hpp>
Nick Gordon5c467f02016-07-13 13:40:10 -050033
akmhoque53353462014-04-22 08:43:45 -050034namespace nlsr {
Nick Gordon5c467f02016-07-13 13:40:10 -050035
akmhoque53353462014-04-22 08:43:45 -050036class SequencingManager
37{
38public:
Ashlesh Gawande55d1b5c2019-12-19 16:21:58 -060039 SequencingManager(const std::string& filePath, int hypState);
akmhoque53353462014-04-22 08:43:45 -050040
akmhoque53353462014-04-22 08:43:45 -050041 uint64_t
42 getNameLsaSeq() const
43 {
44 return m_nameLsaSeq;
45 }
46
47 void
48 setNameLsaSeq(uint64_t nlsn)
49 {
50 m_nameLsaSeq = nlsn;
akmhoque53353462014-04-22 08:43:45 -050051 }
52
53 uint64_t
54 getAdjLsaSeq() const
55 {
56 return m_adjLsaSeq;
57 }
58
59 void
60 setAdjLsaSeq(uint64_t alsn)
61 {
62 m_adjLsaSeq = alsn;
akmhoque53353462014-04-22 08:43:45 -050063 }
64
65 uint64_t
66 getCorLsaSeq() const
67 {
68 return m_corLsaSeq;
69 }
70
71 void
72 setCorLsaSeq(uint64_t clsn)
73 {
74 m_corLsaSeq = clsn;
akmhoque53353462014-04-22 08:43:45 -050075 }
76
akmhoquefdbddb12014-05-02 18:35:19 -050077 void
78 increaseNameLsaSeq()
79 {
80 m_nameLsaSeq++;
akmhoquefdbddb12014-05-02 18:35:19 -050081 }
82
83 void
84 increaseAdjLsaSeq()
85 {
86 m_adjLsaSeq++;
akmhoquefdbddb12014-05-02 18:35:19 -050087 }
88
89 void
90 increaseCorLsaSeq()
91 {
92 m_corLsaSeq++;
akmhoque53353462014-04-22 08:43:45 -050093 }
94
95 void
Vince Lehman0bcf9a32014-12-10 11:24:45 -060096 writeSeqNoToFile() const;
akmhoque53353462014-04-22 08:43:45 -050097
Ashlesh Gawande85998a12017-12-07 22:22:13 -060098PUBLIC_WITH_TESTS_ELSE_PRIVATE:
akmhoque53353462014-04-22 08:43:45 -050099 void
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600100 initiateSeqNoFromFile();
akmhoque53353462014-04-22 08:43:45 -0500101
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600102private:
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500103 /*! \brief Set the sequence file directory
akmhoque53353462014-04-22 08:43:45 -0500104
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500105 If the string is empty, home directory is set as sequence file directory
106
107 \param filePath The directory where sequence file will be stored
108 */
109 void
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600110 setSeqFileDirectory(const std::string& filePath);
akmhoque53353462014-04-22 08:43:45 -0500111
akmhoque2f423352014-06-03 11:49:35 -0500112 void
Vince Lehman904c2412014-09-23 19:36:11 -0500113 writeLog() const;
akmhoque2f423352014-06-03 11:49:35 -0500114
akmhoque53353462014-04-22 08:43:45 -0500115private:
Ashlesh Gawande55d1b5c2019-12-19 16:21:58 -0600116 uint64_t m_nameLsaSeq = 0;
117 uint64_t m_adjLsaSeq = 0;
118 uint64_t m_corLsaSeq = 0;
akmhoque53353462014-04-22 08:43:45 -0500119 std::string m_seqFileNameWithPath;
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600120
121PUBLIC_WITH_TESTS_ELSE_PRIVATE:
122 int m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500123};
124
Nick Gordonfad8e252016-08-11 14:21:38 -0500125} // namespace nlsr
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500126#endif // NLSR_SEQUENCING_MANAGER_HPP